@pagopa/io-app-design-system 7.0.2 → 7.1.0

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 (182) hide show
  1. package/lib/commonjs/components/alert/Alert.js +6 -5
  2. package/lib/commonjs/components/alert/Alert.js.map +1 -1
  3. package/lib/commonjs/components/banner/Banner.js +7 -6
  4. package/lib/commonjs/components/banner/Banner.js.map +1 -1
  5. package/lib/commonjs/components/buttons/IOButton/IOButton.js +10 -8
  6. package/lib/commonjs/components/buttons/IOButton/IOButton.js.map +1 -1
  7. package/lib/commonjs/components/layout/ContentWrapper.js +5 -4
  8. package/lib/commonjs/components/layout/ContentWrapper.js.map +1 -1
  9. package/lib/commonjs/components/otpInput/OTPInput.js +6 -4
  10. package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
  11. package/lib/commonjs/components/searchInput/SearchInput.js +8 -6
  12. package/lib/commonjs/components/searchInput/SearchInput.js.map +1 -1
  13. package/lib/commonjs/components/tabs/TabItem.js +6 -4
  14. package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
  15. package/lib/commonjs/components/textInput/TextInputValidation.js +5 -3
  16. package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
  17. package/lib/commonjs/components/typography/Body.js +8 -5
  18. package/lib/commonjs/components/typography/Body.js.map +1 -1
  19. package/lib/commonjs/components/typography/BodyMonospace.js +4 -5
  20. package/lib/commonjs/components/typography/BodyMonospace.js.map +1 -1
  21. package/lib/commonjs/components/typography/BodySmall.js +8 -5
  22. package/lib/commonjs/components/typography/BodySmall.js.map +1 -1
  23. package/lib/commonjs/components/typography/ButtonText.js +4 -5
  24. package/lib/commonjs/components/typography/ButtonText.js.map +1 -1
  25. package/lib/commonjs/components/typography/Caption.js +4 -5
  26. package/lib/commonjs/components/typography/Caption.js.map +1 -1
  27. package/lib/commonjs/components/typography/H1.js +4 -5
  28. package/lib/commonjs/components/typography/H1.js.map +1 -1
  29. package/lib/commonjs/components/typography/H2.js +4 -5
  30. package/lib/commonjs/components/typography/H2.js.map +1 -1
  31. package/lib/commonjs/components/typography/H3.js +4 -5
  32. package/lib/commonjs/components/typography/H3.js.map +1 -1
  33. package/lib/commonjs/components/typography/H4.js +4 -5
  34. package/lib/commonjs/components/typography/H4.js.map +1 -1
  35. package/lib/commonjs/components/typography/H5.js +4 -5
  36. package/lib/commonjs/components/typography/H5.js.map +1 -1
  37. package/lib/commonjs/components/typography/H6.js +4 -5
  38. package/lib/commonjs/components/typography/H6.js.map +1 -1
  39. package/lib/commonjs/components/typography/Hero.js +4 -5
  40. package/lib/commonjs/components/typography/Hero.js.map +1 -1
  41. package/lib/commonjs/components/typography/IOText.js +16 -14
  42. package/lib/commonjs/components/typography/IOText.js.map +1 -1
  43. package/lib/commonjs/components/typography/LabelMini.js +8 -5
  44. package/lib/commonjs/components/typography/LabelMini.js.map +1 -1
  45. package/lib/commonjs/components/typography/markdown/MdH1.js +4 -5
  46. package/lib/commonjs/components/typography/markdown/MdH1.js.map +1 -1
  47. package/lib/commonjs/components/typography/markdown/MdH2.js +4 -5
  48. package/lib/commonjs/components/typography/markdown/MdH2.js.map +1 -1
  49. package/lib/commonjs/components/typography/markdown/MdH3.js +4 -5
  50. package/lib/commonjs/components/typography/markdown/MdH3.js.map +1 -1
  51. package/lib/commonjs/context/IOThemeContextProvider.js +3 -4
  52. package/lib/commonjs/context/IOThemeContextProvider.js.map +1 -1
  53. package/lib/module/components/alert/Alert.js +5 -5
  54. package/lib/module/components/alert/Alert.js.map +1 -1
  55. package/lib/module/components/banner/Banner.js +6 -6
  56. package/lib/module/components/banner/Banner.js.map +1 -1
  57. package/lib/module/components/buttons/IOButton/IOButton.js +10 -9
  58. package/lib/module/components/buttons/IOButton/IOButton.js.map +1 -1
  59. package/lib/module/components/layout/ContentWrapper.js +4 -4
  60. package/lib/module/components/layout/ContentWrapper.js.map +1 -1
  61. package/lib/module/components/otpInput/OTPInput.js +6 -5
  62. package/lib/module/components/otpInput/OTPInput.js.map +1 -1
  63. package/lib/module/components/searchInput/SearchInput.js +8 -7
  64. package/lib/module/components/searchInput/SearchInput.js.map +1 -1
  65. package/lib/module/components/tabs/TabItem.js +6 -5
  66. package/lib/module/components/tabs/TabItem.js.map +1 -1
  67. package/lib/module/components/textInput/TextInputValidation.js +5 -4
  68. package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
  69. package/lib/module/components/typography/Body.js +7 -5
  70. package/lib/module/components/typography/Body.js.map +1 -1
  71. package/lib/module/components/typography/BodyMonospace.js +3 -5
  72. package/lib/module/components/typography/BodyMonospace.js.map +1 -1
  73. package/lib/module/components/typography/BodySmall.js +7 -5
  74. package/lib/module/components/typography/BodySmall.js.map +1 -1
  75. package/lib/module/components/typography/ButtonText.js +3 -5
  76. package/lib/module/components/typography/ButtonText.js.map +1 -1
  77. package/lib/module/components/typography/Caption.js +3 -5
  78. package/lib/module/components/typography/Caption.js.map +1 -1
  79. package/lib/module/components/typography/H1.js +3 -5
  80. package/lib/module/components/typography/H1.js.map +1 -1
  81. package/lib/module/components/typography/H2.js +3 -5
  82. package/lib/module/components/typography/H2.js.map +1 -1
  83. package/lib/module/components/typography/H3.js +3 -5
  84. package/lib/module/components/typography/H3.js.map +1 -1
  85. package/lib/module/components/typography/H4.js +3 -5
  86. package/lib/module/components/typography/H4.js.map +1 -1
  87. package/lib/module/components/typography/H5.js +3 -5
  88. package/lib/module/components/typography/H5.js.map +1 -1
  89. package/lib/module/components/typography/H6.js +3 -5
  90. package/lib/module/components/typography/H6.js.map +1 -1
  91. package/lib/module/components/typography/Hero.js +3 -5
  92. package/lib/module/components/typography/Hero.js.map +1 -1
  93. package/lib/module/components/typography/IOText.js +16 -15
  94. package/lib/module/components/typography/IOText.js.map +1 -1
  95. package/lib/module/components/typography/LabelMini.js +7 -5
  96. package/lib/module/components/typography/LabelMini.js.map +1 -1
  97. package/lib/module/components/typography/markdown/MdH1.js +3 -5
  98. package/lib/module/components/typography/markdown/MdH1.js.map +1 -1
  99. package/lib/module/components/typography/markdown/MdH2.js +3 -5
  100. package/lib/module/components/typography/markdown/MdH2.js.map +1 -1
  101. package/lib/module/components/typography/markdown/MdH3.js +3 -5
  102. package/lib/module/components/typography/markdown/MdH3.js.map +1 -1
  103. package/lib/module/context/IOThemeContextProvider.js +3 -4
  104. package/lib/module/context/IOThemeContextProvider.js.map +1 -1
  105. package/lib/typescript/components/alert/Alert.d.ts +3 -1
  106. package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
  107. package/lib/typescript/components/banner/Banner.d.ts +3 -1
  108. package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
  109. package/lib/typescript/components/buttons/IOButton/IOButton.d.ts +3 -2
  110. package/lib/typescript/components/buttons/IOButton/IOButton.d.ts.map +1 -1
  111. package/lib/typescript/components/layout/ContentWrapper.d.ts +10 -6
  112. package/lib/typescript/components/layout/ContentWrapper.d.ts.map +1 -1
  113. package/lib/typescript/components/otpInput/OTPInput.d.ts +3 -1
  114. package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
  115. package/lib/typescript/components/searchInput/SearchInput.d.ts +3 -1
  116. package/lib/typescript/components/searchInput/SearchInput.d.ts.map +1 -1
  117. package/lib/typescript/components/tabs/TabItem.d.ts +3 -11
  118. package/lib/typescript/components/tabs/TabItem.d.ts.map +1 -1
  119. package/lib/typescript/components/textInput/TextInputValidation.d.ts +7 -24
  120. package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
  121. package/lib/typescript/components/typography/Body.d.ts +4 -2
  122. package/lib/typescript/components/typography/Body.d.ts.map +1 -1
  123. package/lib/typescript/components/typography/BodyMonospace.d.ts +2 -8
  124. package/lib/typescript/components/typography/BodyMonospace.d.ts.map +1 -1
  125. package/lib/typescript/components/typography/BodySmall.d.ts +4 -2
  126. package/lib/typescript/components/typography/BodySmall.d.ts.map +1 -1
  127. package/lib/typescript/components/typography/ButtonText.d.ts +2 -8
  128. package/lib/typescript/components/typography/ButtonText.d.ts.map +1 -1
  129. package/lib/typescript/components/typography/Caption.d.ts +2 -8
  130. package/lib/typescript/components/typography/Caption.d.ts.map +1 -1
  131. package/lib/typescript/components/typography/H1.d.ts +2 -8
  132. package/lib/typescript/components/typography/H1.d.ts.map +1 -1
  133. package/lib/typescript/components/typography/H2.d.ts +6 -10
  134. package/lib/typescript/components/typography/H2.d.ts.map +1 -1
  135. package/lib/typescript/components/typography/H3.d.ts +2 -8
  136. package/lib/typescript/components/typography/H3.d.ts.map +1 -1
  137. package/lib/typescript/components/typography/H4.d.ts +2 -8
  138. package/lib/typescript/components/typography/H4.d.ts.map +1 -1
  139. package/lib/typescript/components/typography/H5.d.ts +2 -8
  140. package/lib/typescript/components/typography/H5.d.ts.map +1 -1
  141. package/lib/typescript/components/typography/H6.d.ts +2 -8
  142. package/lib/typescript/components/typography/H6.d.ts.map +1 -1
  143. package/lib/typescript/components/typography/Hero.d.ts +2 -8
  144. package/lib/typescript/components/typography/Hero.d.ts.map +1 -1
  145. package/lib/typescript/components/typography/IOText.d.ts +5 -5
  146. package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
  147. package/lib/typescript/components/typography/LabelMini.d.ts +4 -2
  148. package/lib/typescript/components/typography/LabelMini.d.ts.map +1 -1
  149. package/lib/typescript/components/typography/markdown/MdH1.d.ts +2 -8
  150. package/lib/typescript/components/typography/markdown/MdH1.d.ts.map +1 -1
  151. package/lib/typescript/components/typography/markdown/MdH2.d.ts +2 -8
  152. package/lib/typescript/components/typography/markdown/MdH2.d.ts.map +1 -1
  153. package/lib/typescript/components/typography/markdown/MdH3.d.ts +2 -8
  154. package/lib/typescript/components/typography/markdown/MdH3.d.ts.map +1 -1
  155. package/lib/typescript/context/IOThemeContextProvider.d.ts.map +1 -1
  156. package/package.json +6 -7
  157. package/src/components/alert/Alert.tsx +108 -112
  158. package/src/components/banner/Banner.tsx +121 -125
  159. package/src/components/buttons/IOButton/IOButton.tsx +204 -216
  160. package/src/components/layout/ContentWrapper.tsx +21 -24
  161. package/src/components/otpInput/OTPInput.tsx +156 -167
  162. package/src/components/searchInput/SearchInput.tsx +208 -217
  163. package/src/components/tabs/TabItem.tsx +143 -146
  164. package/src/components/textInput/TextInputValidation.tsx +116 -122
  165. package/src/components/typography/Body.tsx +51 -52
  166. package/src/components/typography/BodyMonospace.tsx +19 -24
  167. package/src/components/typography/BodySmall.tsx +51 -52
  168. package/src/components/typography/ButtonText.tsx +14 -20
  169. package/src/components/typography/Caption.tsx +18 -23
  170. package/src/components/typography/H1.tsx +12 -20
  171. package/src/components/typography/H2.tsx +16 -23
  172. package/src/components/typography/H3.tsx +12 -20
  173. package/src/components/typography/H4.tsx +12 -20
  174. package/src/components/typography/H5.tsx +16 -24
  175. package/src/components/typography/H6.tsx +13 -21
  176. package/src/components/typography/Hero.tsx +14 -19
  177. package/src/components/typography/IOText.tsx +54 -59
  178. package/src/components/typography/LabelMini.tsx +45 -49
  179. package/src/components/typography/markdown/MdH1.tsx +14 -19
  180. package/src/components/typography/markdown/MdH2.tsx +14 -19
  181. package/src/components/typography/markdown/MdH3.tsx +14 -19
  182. package/src/context/IOThemeContextProvider.tsx +4 -12
@@ -1,10 +1,4 @@
1
- import {
2
- ComponentProps,
3
- forwardRef,
4
- useCallback,
5
- useEffect,
6
- useRef
7
- } from "react";
1
+ import { ComponentProps, Ref, useCallback, useEffect, useRef } from "react";
8
2
  import {
9
3
  AccessibilityRole,
10
4
  ColorValue,
@@ -74,6 +68,7 @@ type IOButtonSpecificProps =
74
68
 
75
69
  export type IOButtonProps = WithTestID<
76
70
  IOButtonSpecificProps & {
71
+ ref?: Ref<View>;
77
72
  /**
78
73
  * @default primary
79
74
  */
@@ -111,244 +106,237 @@ export type IOButtonProps = WithTestID<
111
106
  >
112
107
  >;
113
108
 
114
- export const IOButton = forwardRef<View, IOButtonProps>(
115
- (
116
- {
117
- variant = "solid",
118
- color = "primary",
119
- label,
120
- fullWidth = false,
121
- disabled = false,
122
- loading = false,
123
- numberOfLines = 1,
124
- textAlign = "auto",
125
- icon,
126
- iconPosition = "start",
127
- onPress,
128
- accessibilityLabel,
129
- accessibilityHint,
130
- accessibilityRole = "button",
131
- testID
132
- },
133
- ref
134
- ) => {
135
- const mapColorStates = useButtonColorMap(variant);
136
- const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
137
- useScaleAnimation();
138
- const { buttonAnimatedStyle, labelAnimatedStyle, iconColorAnimatedStyle } =
139
- useButtonAnimatedStyles(variant, color, progress);
140
- const reducedMotion = useReducedMotion();
109
+ export const IOButton = ({
110
+ variant = "solid",
111
+ color = "primary",
112
+ label,
113
+ fullWidth = false,
114
+ disabled = false,
115
+ loading = false,
116
+ numberOfLines = 1,
117
+ textAlign = "auto",
118
+ icon,
119
+ iconPosition = "start",
120
+ onPress,
121
+ accessibilityLabel,
122
+ accessibilityHint,
123
+ accessibilityRole = "button",
124
+ ref,
125
+ testID
126
+ }: IOButtonProps) => {
127
+ const mapColorStates = useButtonColorMap(variant);
128
+ const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
129
+ useScaleAnimation();
130
+ const { buttonAnimatedStyle, labelAnimatedStyle, iconColorAnimatedStyle } =
131
+ useButtonAnimatedStyles(variant, color, progress);
132
+ const reducedMotion = useReducedMotion();
141
133
 
142
- const isLinkButton = variant === "link";
134
+ const isLinkButton = variant === "link";
143
135
 
144
- // ---------------------------------------
145
- // VISUAL ATTRIBUTES
146
- // ---------------------------------------
147
- const btnIconSizeMap: Record<IOButtonVariant, IOIconSizeScale> = {
148
- solid: 20,
149
- outline: 20,
150
- link: 24
151
- };
136
+ // ---------------------------------------
137
+ // VISUAL ATTRIBUTES
138
+ // ---------------------------------------
139
+ const btnIconSizeMap: Record<IOButtonVariant, IOIconSizeScale> = {
140
+ solid: 20,
141
+ outline: 20,
142
+ link: 24
143
+ };
152
144
 
153
- const btnBorderWidthMap: Record<IOButtonVariant, ViewStyle["borderWidth"]> =
154
- {
155
- solid: 0,
156
- outline: 2,
157
- link: 0
158
- };
145
+ const btnBorderWidthMap: Record<IOButtonVariant, ViewStyle["borderWidth"]> = {
146
+ solid: 0,
147
+ outline: 2,
148
+ link: 0
149
+ };
159
150
 
160
- const btnPaddingHorizontalMap: Record<
161
- string,
162
- ViewStyle["paddingHorizontal"]
163
- > = {
164
- default: 24,
165
- fullWidth: 16,
166
- link: 0
167
- };
151
+ const btnPaddingHorizontalMap: Record<
152
+ string,
153
+ ViewStyle["paddingHorizontal"]
154
+ > = {
155
+ default: 24,
156
+ fullWidth: 16,
157
+ link: 0
158
+ };
168
159
 
169
- const btnLinkHitSlop: PressableProps["hitSlop"] = {
170
- top: 14,
171
- right: 24,
172
- bottom: 14,
173
- left: 24
174
- };
160
+ const btnLinkHitSlop: PressableProps["hitSlop"] = {
161
+ top: 14,
162
+ right: 24,
163
+ bottom: 14,
164
+ left: 24
165
+ };
175
166
 
176
- const btnIconSize = btnIconSizeMap[variant];
177
- const btnBorderWidth = btnBorderWidthMap[variant];
178
- const btnBorderRadius = 8;
179
- const btnSizeDefault = 48;
167
+ const btnIconSize = btnIconSizeMap[variant];
168
+ const btnBorderWidth = btnBorderWidthMap[variant];
169
+ const btnBorderRadius = 8;
170
+ const btnSizeDefault = 48;
180
171
 
181
- const ICON_MARGIN = 8;
182
- const DISABLED_OPACITY = 0.5;
172
+ const ICON_MARGIN = 8;
173
+ const DISABLED_OPACITY = 0.5;
183
174
 
184
- // Background color
185
- const backgroundColor: ColorValue = disabled
186
- ? mapColorStates[color].background.disabled
187
- : mapColorStates[color].background.default;
175
+ // Background color
176
+ const backgroundColor: ColorValue = disabled
177
+ ? mapColorStates[color].background.disabled
178
+ : mapColorStates[color].background.default;
188
179
 
189
- // Label & Icons colors
190
- const foregroundColor: ColorValue = disabled
191
- ? mapColorStates[color]?.foreground?.disabled
192
- : mapColorStates[color]?.foreground?.default;
180
+ // Label & Icons colors
181
+ const foregroundColor: ColorValue = disabled
182
+ ? mapColorStates[color]?.foreground?.disabled
183
+ : mapColorStates[color]?.foreground?.default;
193
184
 
194
- // ---------------------------------------
195
- // BUTTON INNER LOGIC
196
- // ---------------------------------------
185
+ // ---------------------------------------
186
+ // BUTTON INNER LOGIC
187
+ // ---------------------------------------
197
188
 
198
- /* Prevent the component from triggering the `isEntering' transition
189
+ /* Prevent the component from triggering the `isEntering' transition
199
190
  on the on the first render. Solution from this discussion:
200
191
  https://github.com/software-mansion/react-native-reanimated/discussions/2513
201
192
  */
202
- const isMounted = useRef<boolean>(false);
193
+ const isMounted = useRef<boolean>(false);
203
194
 
204
- useEffect(() => {
205
- // eslint-disable-next-line functional/immutable-data
206
- isMounted.current = true;
207
- }, []);
195
+ useEffect(() => {
196
+ // eslint-disable-next-line functional/immutable-data
197
+ isMounted.current = true;
198
+ }, []);
208
199
 
209
- const handleOnPress = useCallback(
210
- (event: GestureResponderEvent) => {
211
- /* Don't call `onPress` if the button is
200
+ const handleOnPress = useCallback(
201
+ (event: GestureResponderEvent) => {
202
+ /* Don't call `onPress` if the button is
212
203
  in loading state */
213
- if (loading) {
214
- return;
215
- }
216
- ReactNativeHapticFeedback.trigger("impactLight");
217
- onPress(event);
218
- },
219
- [loading, onPress]
220
- );
221
-
222
- // ---------------------------------------
223
- // BUTTON INNER CONTENT
224
- // ---------------------------------------
225
- const renderButtonContent = () => (
226
- <>
227
- {loading && (
228
- <LayoutAnimationConfig skipExiting>
229
- <Animated.View
230
- style={styles.buttonInner}
231
- entering={
232
- isMounted.current ? enterTransitionInnerContentSmall : undefined
233
- }
234
- exiting={exitTransitionInnerContent}
235
- >
236
- <LoadingSpinner color={foregroundColor} />
237
- </Animated.View>
238
- </LayoutAnimationConfig>
239
- )}
204
+ if (loading) {
205
+ return;
206
+ }
207
+ ReactNativeHapticFeedback.trigger("impactLight");
208
+ onPress(event);
209
+ },
210
+ [loading, onPress]
211
+ );
240
212
 
241
- {!loading && (
213
+ // ---------------------------------------
214
+ // BUTTON INNER CONTENT
215
+ // ---------------------------------------
216
+ const renderButtonContent = () => (
217
+ <>
218
+ {loading && (
219
+ <LayoutAnimationConfig skipExiting>
242
220
  <Animated.View
243
- style={[
244
- styles.buttonInner,
245
- { columnGap: ICON_MARGIN },
246
- iconPosition === "end" && { flexDirection: "row-reverse" }
247
- ]}
221
+ style={styles.buttonInner}
248
222
  entering={
249
- isMounted.current ? enterTransitionInnerContent : undefined
223
+ isMounted.current ? enterTransitionInnerContentSmall : undefined
250
224
  }
225
+ exiting={exitTransitionInnerContent}
251
226
  >
252
- {icon &&
253
- (!disabled ? (
254
- <AnimatedIconWithColorTransition
255
- allowFontScaling
256
- name={icon}
257
- animatedProps={iconColorAnimatedStyle}
258
- size={btnIconSize}
259
- />
260
- ) : (
261
- <AnimatedIcon
262
- allowFontScaling
263
- name={icon}
264
- color={mapColorStates[color]?.foreground?.disabled}
265
- size={btnIconSize}
266
- />
267
- ))}
268
- <AnimatedIOText
269
- weight={"Semibold"}
270
- size={buttonTextFontSize}
271
- lineHeight={isLinkButton ? buttonTextLineHeight : undefined}
272
- accessible={false}
273
- accessibilityElementsHidden
274
- importantForAccessibility="no-hide-descendants"
275
- numberOfLines={numberOfLines}
276
- ellipsizeMode="tail"
277
- style={[
278
- { textAlign },
279
- disabled
280
- ? { color: mapColorStates[color]?.foreground?.disabled }
281
- : { color: mapColorStates[color]?.foreground?.default },
282
- !disabled && labelAnimatedStyle
283
- ]}
284
- >
285
- {label}
286
- </AnimatedIOText>
227
+ <LoadingSpinner color={foregroundColor} />
287
228
  </Animated.View>
288
- )}
289
- </>
290
- );
229
+ </LayoutAnimationConfig>
230
+ )}
291
231
 
292
- return (
293
- <Pressable
294
- ref={ref}
295
- accessible={true}
296
- // Using || operator because empty string is not an accepted value
297
- accessibilityLabel={accessibilityLabel || label}
298
- accessibilityHint={accessibilityHint}
299
- accessibilityRole={accessibilityRole}
300
- accessibilityState={{
301
- busy: loading,
302
- disabled: disabled || false
303
- }}
304
- onPress={handleOnPress}
305
- onPressIn={onPressIn}
306
- onPressOut={onPressOut}
307
- disabled={disabled}
308
- hitSlop={isLinkButton ? btnLinkHitSlop : undefined}
309
- style={
310
- isLinkButton
311
- ? { alignSelf: "flex-start" }
312
- : fullWidth
313
- ? { flexShrink: 0, alignSelf: "stretch" }
314
- : { flexShrink: 1, alignSelf: "auto" }
315
- }
316
- testID={testID}
317
- >
232
+ {!loading && (
318
233
  <Animated.View
319
234
  style={[
320
- styles.button,
321
- /* Prevent Reanimated from overriding background colors
322
- if button is disabled */
323
- !disabled && !reducedMotion && scaleAnimatedStyle,
324
- !disabled && buttonAnimatedStyle,
325
- {
326
- paddingHorizontal: isLinkButton
327
- ? btnPaddingHorizontalMap.link
328
- : fullWidth
329
- ? btnPaddingHorizontalMap.fullWidth
330
- : btnPaddingHorizontalMap.default
331
- },
332
- {
333
- height: isLinkButton ? undefined : btnSizeDefault,
334
- backgroundColor,
335
- borderWidth: btnBorderWidth,
336
- borderRadius: btnBorderRadius,
337
- borderColor: foregroundColor
338
- },
339
- disabled
340
- ? {
341
- opacity: DISABLED_OPACITY
342
- }
343
- : {}
235
+ styles.buttonInner,
236
+ { columnGap: ICON_MARGIN },
237
+ iconPosition === "end" && { flexDirection: "row-reverse" }
344
238
  ]}
239
+ entering={isMounted.current ? enterTransitionInnerContent : undefined}
345
240
  >
346
- {renderButtonContent()}
241
+ {icon &&
242
+ (!disabled ? (
243
+ <AnimatedIconWithColorTransition
244
+ allowFontScaling
245
+ name={icon}
246
+ animatedProps={iconColorAnimatedStyle}
247
+ size={btnIconSize}
248
+ />
249
+ ) : (
250
+ <AnimatedIcon
251
+ allowFontScaling
252
+ name={icon}
253
+ color={mapColorStates[color]?.foreground?.disabled}
254
+ size={btnIconSize}
255
+ />
256
+ ))}
257
+ <AnimatedIOText
258
+ weight={"Semibold"}
259
+ size={buttonTextFontSize}
260
+ lineHeight={isLinkButton ? buttonTextLineHeight : undefined}
261
+ accessible={false}
262
+ accessibilityElementsHidden
263
+ importantForAccessibility="no-hide-descendants"
264
+ numberOfLines={numberOfLines}
265
+ ellipsizeMode="tail"
266
+ style={[
267
+ { textAlign },
268
+ disabled
269
+ ? { color: mapColorStates[color]?.foreground?.disabled }
270
+ : { color: mapColorStates[color]?.foreground?.default },
271
+ !disabled && labelAnimatedStyle
272
+ ]}
273
+ >
274
+ {label}
275
+ </AnimatedIOText>
347
276
  </Animated.View>
348
- </Pressable>
349
- );
350
- }
351
- );
277
+ )}
278
+ </>
279
+ );
280
+
281
+ return (
282
+ <Pressable
283
+ ref={ref}
284
+ accessible={true}
285
+ // Using || operator because empty string is not an accepted value
286
+ accessibilityLabel={accessibilityLabel || label}
287
+ accessibilityHint={accessibilityHint}
288
+ accessibilityRole={accessibilityRole}
289
+ accessibilityState={{
290
+ busy: loading,
291
+ disabled: disabled || false
292
+ }}
293
+ onPress={handleOnPress}
294
+ onPressIn={onPressIn}
295
+ onPressOut={onPressOut}
296
+ disabled={disabled}
297
+ hitSlop={isLinkButton ? btnLinkHitSlop : undefined}
298
+ style={
299
+ isLinkButton
300
+ ? { alignSelf: "flex-start" }
301
+ : fullWidth
302
+ ? { flexShrink: 0, alignSelf: "stretch" }
303
+ : { flexShrink: 1, alignSelf: "auto" }
304
+ }
305
+ testID={testID}
306
+ >
307
+ <Animated.View
308
+ style={[
309
+ styles.button,
310
+ /* Prevent Reanimated from overriding background colors
311
+ if button is disabled */
312
+ !disabled && !reducedMotion && scaleAnimatedStyle,
313
+ !disabled && buttonAnimatedStyle,
314
+ {
315
+ paddingHorizontal: isLinkButton
316
+ ? btnPaddingHorizontalMap.link
317
+ : fullWidth
318
+ ? btnPaddingHorizontalMap.fullWidth
319
+ : btnPaddingHorizontalMap.default
320
+ },
321
+ {
322
+ height: isLinkButton ? undefined : btnSizeDefault,
323
+ backgroundColor,
324
+ borderWidth: btnBorderWidth,
325
+ borderRadius: btnBorderRadius,
326
+ borderColor: foregroundColor
327
+ },
328
+ disabled
329
+ ? {
330
+ opacity: DISABLED_OPACITY
331
+ }
332
+ : {}
333
+ ]}
334
+ >
335
+ {renderButtonContent()}
336
+ </Animated.View>
337
+ </Pressable>
338
+ );
339
+ };
352
340
 
353
341
  const styles = StyleSheet.create({
354
342
  button: {
@@ -1,4 +1,4 @@
1
- import { forwardRef, ReactNode } from "react";
1
+ import { Ref, ReactNode } from "react";
2
2
  import { View, ViewProps, ViewStyle } from "react-native";
3
3
  import { WithTestID } from "src/utils/types";
4
4
  import type { IOAppMargin } from "../../core";
@@ -6,6 +6,7 @@ import { IOVisualCostants } from "../../core/IOStyles";
6
6
 
7
7
  type IOContentWrapperProps = WithTestID<
8
8
  Omit<ViewProps, "style"> & {
9
+ ref?: Ref<View>;
9
10
  margin?: IOAppMargin;
10
11
  children: ReactNode;
11
12
  style?: Omit<
@@ -20,27 +21,23 @@ type IOContentWrapperProps = WithTestID<
20
21
  depending on the size value
21
22
  @param {IOContentWrapper} margin
22
23
  */
23
- export const ContentWrapper = forwardRef<View, IOContentWrapperProps>(
24
- (
25
- {
26
- margin = IOVisualCostants.appMarginDefault,
27
- style,
28
- children,
29
- testID,
30
- ...rest
31
- }: IOContentWrapperProps,
32
- ref
33
- ) => (
34
- <View
35
- testID={testID}
36
- style={{
37
- paddingHorizontal: margin,
38
- ...style
39
- }}
40
- ref={ref}
41
- {...rest}
42
- >
43
- {children}
44
- </View>
45
- )
24
+ export const ContentWrapper = ({
25
+ margin = IOVisualCostants.appMarginDefault,
26
+ style,
27
+ children,
28
+ testID,
29
+ ref,
30
+ ...rest
31
+ }: IOContentWrapperProps) => (
32
+ <View
33
+ testID={testID}
34
+ style={{
35
+ paddingHorizontal: margin,
36
+ ...style
37
+ }}
38
+ ref={ref}
39
+ {...rest}
40
+ >
41
+ {children}
42
+ </View>
46
43
  );