@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.
- package/lib/commonjs/components/alert/Alert.js +6 -5
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/banner/Banner.js +7 -6
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/buttons/IOButton/IOButton.js +10 -8
- package/lib/commonjs/components/buttons/IOButton/IOButton.js.map +1 -1
- package/lib/commonjs/components/layout/ContentWrapper.js +5 -4
- package/lib/commonjs/components/layout/ContentWrapper.js.map +1 -1
- package/lib/commonjs/components/otpInput/OTPInput.js +6 -4
- package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
- package/lib/commonjs/components/searchInput/SearchInput.js +8 -6
- package/lib/commonjs/components/searchInput/SearchInput.js.map +1 -1
- package/lib/commonjs/components/tabs/TabItem.js +6 -4
- package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputValidation.js +5 -3
- package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/commonjs/components/typography/Body.js +8 -5
- package/lib/commonjs/components/typography/Body.js.map +1 -1
- package/lib/commonjs/components/typography/BodyMonospace.js +4 -5
- package/lib/commonjs/components/typography/BodyMonospace.js.map +1 -1
- package/lib/commonjs/components/typography/BodySmall.js +8 -5
- package/lib/commonjs/components/typography/BodySmall.js.map +1 -1
- package/lib/commonjs/components/typography/ButtonText.js +4 -5
- package/lib/commonjs/components/typography/ButtonText.js.map +1 -1
- package/lib/commonjs/components/typography/Caption.js +4 -5
- package/lib/commonjs/components/typography/Caption.js.map +1 -1
- package/lib/commonjs/components/typography/H1.js +4 -5
- package/lib/commonjs/components/typography/H1.js.map +1 -1
- package/lib/commonjs/components/typography/H2.js +4 -5
- package/lib/commonjs/components/typography/H2.js.map +1 -1
- package/lib/commonjs/components/typography/H3.js +4 -5
- package/lib/commonjs/components/typography/H3.js.map +1 -1
- package/lib/commonjs/components/typography/H4.js +4 -5
- package/lib/commonjs/components/typography/H4.js.map +1 -1
- package/lib/commonjs/components/typography/H5.js +4 -5
- package/lib/commonjs/components/typography/H5.js.map +1 -1
- package/lib/commonjs/components/typography/H6.js +4 -5
- package/lib/commonjs/components/typography/H6.js.map +1 -1
- package/lib/commonjs/components/typography/Hero.js +4 -5
- package/lib/commonjs/components/typography/Hero.js.map +1 -1
- package/lib/commonjs/components/typography/IOText.js +16 -14
- package/lib/commonjs/components/typography/IOText.js.map +1 -1
- package/lib/commonjs/components/typography/LabelMini.js +8 -5
- package/lib/commonjs/components/typography/LabelMini.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH1.js +4 -5
- package/lib/commonjs/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH2.js +4 -5
- package/lib/commonjs/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/commonjs/components/typography/markdown/MdH3.js +4 -5
- package/lib/commonjs/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/commonjs/context/IOThemeContextProvider.js +3 -4
- package/lib/commonjs/context/IOThemeContextProvider.js.map +1 -1
- package/lib/module/components/alert/Alert.js +5 -5
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/banner/Banner.js +6 -6
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/buttons/IOButton/IOButton.js +10 -9
- package/lib/module/components/buttons/IOButton/IOButton.js.map +1 -1
- package/lib/module/components/layout/ContentWrapper.js +4 -4
- package/lib/module/components/layout/ContentWrapper.js.map +1 -1
- package/lib/module/components/otpInput/OTPInput.js +6 -5
- package/lib/module/components/otpInput/OTPInput.js.map +1 -1
- package/lib/module/components/searchInput/SearchInput.js +8 -7
- package/lib/module/components/searchInput/SearchInput.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +6 -5
- package/lib/module/components/tabs/TabItem.js.map +1 -1
- package/lib/module/components/textInput/TextInputValidation.js +5 -4
- package/lib/module/components/textInput/TextInputValidation.js.map +1 -1
- package/lib/module/components/typography/Body.js +7 -5
- package/lib/module/components/typography/Body.js.map +1 -1
- package/lib/module/components/typography/BodyMonospace.js +3 -5
- package/lib/module/components/typography/BodyMonospace.js.map +1 -1
- package/lib/module/components/typography/BodySmall.js +7 -5
- package/lib/module/components/typography/BodySmall.js.map +1 -1
- package/lib/module/components/typography/ButtonText.js +3 -5
- package/lib/module/components/typography/ButtonText.js.map +1 -1
- package/lib/module/components/typography/Caption.js +3 -5
- package/lib/module/components/typography/Caption.js.map +1 -1
- package/lib/module/components/typography/H1.js +3 -5
- package/lib/module/components/typography/H1.js.map +1 -1
- package/lib/module/components/typography/H2.js +3 -5
- package/lib/module/components/typography/H2.js.map +1 -1
- package/lib/module/components/typography/H3.js +3 -5
- package/lib/module/components/typography/H3.js.map +1 -1
- package/lib/module/components/typography/H4.js +3 -5
- package/lib/module/components/typography/H4.js.map +1 -1
- package/lib/module/components/typography/H5.js +3 -5
- package/lib/module/components/typography/H5.js.map +1 -1
- package/lib/module/components/typography/H6.js +3 -5
- package/lib/module/components/typography/H6.js.map +1 -1
- package/lib/module/components/typography/Hero.js +3 -5
- package/lib/module/components/typography/Hero.js.map +1 -1
- package/lib/module/components/typography/IOText.js +16 -15
- package/lib/module/components/typography/IOText.js.map +1 -1
- package/lib/module/components/typography/LabelMini.js +7 -5
- package/lib/module/components/typography/LabelMini.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH1.js +3 -5
- package/lib/module/components/typography/markdown/MdH1.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH2.js +3 -5
- package/lib/module/components/typography/markdown/MdH2.js.map +1 -1
- package/lib/module/components/typography/markdown/MdH3.js +3 -5
- package/lib/module/components/typography/markdown/MdH3.js.map +1 -1
- package/lib/module/context/IOThemeContextProvider.js +3 -4
- package/lib/module/context/IOThemeContextProvider.js.map +1 -1
- package/lib/typescript/components/alert/Alert.d.ts +3 -1
- package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts +3 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IOButton/IOButton.d.ts +3 -2
- package/lib/typescript/components/buttons/IOButton/IOButton.d.ts.map +1 -1
- package/lib/typescript/components/layout/ContentWrapper.d.ts +10 -6
- package/lib/typescript/components/layout/ContentWrapper.d.ts.map +1 -1
- package/lib/typescript/components/otpInput/OTPInput.d.ts +3 -1
- package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
- package/lib/typescript/components/searchInput/SearchInput.d.ts +3 -1
- package/lib/typescript/components/searchInput/SearchInput.d.ts.map +1 -1
- package/lib/typescript/components/tabs/TabItem.d.ts +3 -11
- package/lib/typescript/components/tabs/TabItem.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInputValidation.d.ts +7 -24
- package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -1
- package/lib/typescript/components/typography/Body.d.ts +4 -2
- package/lib/typescript/components/typography/Body.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodyMonospace.d.ts +2 -8
- package/lib/typescript/components/typography/BodyMonospace.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodySmall.d.ts +4 -2
- package/lib/typescript/components/typography/BodySmall.d.ts.map +1 -1
- package/lib/typescript/components/typography/ButtonText.d.ts +2 -8
- package/lib/typescript/components/typography/ButtonText.d.ts.map +1 -1
- package/lib/typescript/components/typography/Caption.d.ts +2 -8
- package/lib/typescript/components/typography/Caption.d.ts.map +1 -1
- package/lib/typescript/components/typography/H1.d.ts +2 -8
- package/lib/typescript/components/typography/H1.d.ts.map +1 -1
- package/lib/typescript/components/typography/H2.d.ts +6 -10
- package/lib/typescript/components/typography/H2.d.ts.map +1 -1
- package/lib/typescript/components/typography/H3.d.ts +2 -8
- package/lib/typescript/components/typography/H3.d.ts.map +1 -1
- package/lib/typescript/components/typography/H4.d.ts +2 -8
- package/lib/typescript/components/typography/H4.d.ts.map +1 -1
- package/lib/typescript/components/typography/H5.d.ts +2 -8
- package/lib/typescript/components/typography/H5.d.ts.map +1 -1
- package/lib/typescript/components/typography/H6.d.ts +2 -8
- package/lib/typescript/components/typography/H6.d.ts.map +1 -1
- package/lib/typescript/components/typography/Hero.d.ts +2 -8
- package/lib/typescript/components/typography/Hero.d.ts.map +1 -1
- package/lib/typescript/components/typography/IOText.d.ts +5 -5
- package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
- package/lib/typescript/components/typography/LabelMini.d.ts +4 -2
- package/lib/typescript/components/typography/LabelMini.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH1.d.ts +2 -8
- package/lib/typescript/components/typography/markdown/MdH1.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH2.d.ts +2 -8
- package/lib/typescript/components/typography/markdown/MdH2.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH3.d.ts +2 -8
- package/lib/typescript/components/typography/markdown/MdH3.d.ts.map +1 -1
- package/lib/typescript/context/IOThemeContextProvider.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/components/alert/Alert.tsx +108 -112
- package/src/components/banner/Banner.tsx +121 -125
- package/src/components/buttons/IOButton/IOButton.tsx +204 -216
- package/src/components/layout/ContentWrapper.tsx +21 -24
- package/src/components/otpInput/OTPInput.tsx +156 -167
- package/src/components/searchInput/SearchInput.tsx +208 -217
- package/src/components/tabs/TabItem.tsx +143 -146
- package/src/components/textInput/TextInputValidation.tsx +116 -122
- package/src/components/typography/Body.tsx +51 -52
- package/src/components/typography/BodyMonospace.tsx +19 -24
- package/src/components/typography/BodySmall.tsx +51 -52
- package/src/components/typography/ButtonText.tsx +14 -20
- package/src/components/typography/Caption.tsx +18 -23
- package/src/components/typography/H1.tsx +12 -20
- package/src/components/typography/H2.tsx +16 -23
- package/src/components/typography/H3.tsx +12 -20
- package/src/components/typography/H4.tsx +12 -20
- package/src/components/typography/H5.tsx +16 -24
- package/src/components/typography/H6.tsx +13 -21
- package/src/components/typography/Hero.tsx +14 -19
- package/src/components/typography/IOText.tsx +54 -59
- package/src/components/typography/LabelMini.tsx +45 -49
- package/src/components/typography/markdown/MdH1.tsx +14 -19
- package/src/components/typography/markdown/MdH2.tsx +14 -19
- package/src/components/typography/markdown/MdH3.tsx +14 -19
- 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 =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
134
|
+
const isLinkButton = variant === "link";
|
|
143
135
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
};
|
|
145
|
+
const btnBorderWidthMap: Record<IOButtonVariant, ViewStyle["borderWidth"]> = {
|
|
146
|
+
solid: 0,
|
|
147
|
+
outline: 2,
|
|
148
|
+
link: 0
|
|
149
|
+
};
|
|
159
150
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
151
|
+
const btnPaddingHorizontalMap: Record<
|
|
152
|
+
string,
|
|
153
|
+
ViewStyle["paddingHorizontal"]
|
|
154
|
+
> = {
|
|
155
|
+
default: 24,
|
|
156
|
+
fullWidth: 16,
|
|
157
|
+
link: 0
|
|
158
|
+
};
|
|
168
159
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
160
|
+
const btnLinkHitSlop: PressableProps["hitSlop"] = {
|
|
161
|
+
top: 14,
|
|
162
|
+
right: 24,
|
|
163
|
+
bottom: 14,
|
|
164
|
+
left: 24
|
|
165
|
+
};
|
|
175
166
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
167
|
+
const btnIconSize = btnIconSizeMap[variant];
|
|
168
|
+
const btnBorderWidth = btnBorderWidthMap[variant];
|
|
169
|
+
const btnBorderRadius = 8;
|
|
170
|
+
const btnSizeDefault = 48;
|
|
180
171
|
|
|
181
|
-
|
|
182
|
-
|
|
172
|
+
const ICON_MARGIN = 8;
|
|
173
|
+
const DISABLED_OPACITY = 0.5;
|
|
183
174
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
// Background color
|
|
176
|
+
const backgroundColor: ColorValue = disabled
|
|
177
|
+
? mapColorStates[color].background.disabled
|
|
178
|
+
: mapColorStates[color].background.default;
|
|
188
179
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
180
|
+
// Label & Icons colors
|
|
181
|
+
const foregroundColor: ColorValue = disabled
|
|
182
|
+
? mapColorStates[color]?.foreground?.disabled
|
|
183
|
+
: mapColorStates[color]?.foreground?.default;
|
|
193
184
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
185
|
+
// ---------------------------------------
|
|
186
|
+
// BUTTON INNER LOGIC
|
|
187
|
+
// ---------------------------------------
|
|
197
188
|
|
|
198
|
-
|
|
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
|
-
|
|
193
|
+
const isMounted = useRef<boolean>(false);
|
|
203
194
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
// eslint-disable-next-line functional/immutable-data
|
|
197
|
+
isMounted.current = true;
|
|
198
|
+
}, []);
|
|
208
199
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
200
|
+
const handleOnPress = useCallback(
|
|
201
|
+
(event: GestureResponderEvent) => {
|
|
202
|
+
/* Don't call `onPress` if the button is
|
|
212
203
|
in loading state */
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
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 ?
|
|
223
|
+
isMounted.current ? enterTransitionInnerContentSmall : undefined
|
|
250
224
|
}
|
|
225
|
+
exiting={exitTransitionInnerContent}
|
|
251
226
|
>
|
|
252
|
-
{
|
|
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
|
-
|
|
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.
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
{
|
|
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
|
-
|
|
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 {
|
|
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 =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
);
|