@pagopa/io-app-design-system 5.0.2 → 5.0.3

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 (84) hide show
  1. package/lib/commonjs/components/accordion/AccordionItem.js +3 -1
  2. package/lib/commonjs/components/accordion/AccordionItem.js.map +1 -1
  3. package/lib/commonjs/components/buttons/ButtonLink.js +3 -1
  4. package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
  5. package/lib/commonjs/components/buttons/ButtonOutline.js +7 -1
  6. package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
  7. package/lib/commonjs/components/buttons/ButtonSolid.js +7 -1
  8. package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
  9. package/lib/commonjs/components/buttons/IconButtonContained.js +3 -1
  10. package/lib/commonjs/components/buttons/IconButtonContained.js.map +1 -1
  11. package/lib/commonjs/components/buttons/IconButtonSolid.js +3 -1
  12. package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -1
  13. package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +8 -4
  14. package/lib/commonjs/components/layout/HeaderFirstLevel.js +3 -2
  15. package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -1
  16. package/lib/commonjs/components/layout/HeaderSecondLevel.js +12 -1
  17. package/lib/commonjs/components/layout/HeaderSecondLevel.js.map +1 -1
  18. package/lib/commonjs/components/searchInput/SearchInput.js +7 -5
  19. package/lib/commonjs/components/searchInput/SearchInput.js.map +1 -1
  20. package/lib/commonjs/components/tabs/TabNavigation.js +7 -6
  21. package/lib/commonjs/components/tabs/TabNavigation.js.map +1 -1
  22. package/lib/commonjs/components/typography/H2.js +2 -1
  23. package/lib/commonjs/components/typography/H2.js.map +1 -1
  24. package/lib/commonjs/components/typography/H3.js +1 -2
  25. package/lib/commonjs/components/typography/H3.js.map +1 -1
  26. package/lib/commonjs/core/IOStyles.js +0 -4
  27. package/lib/commonjs/core/IOStyles.js.map +1 -1
  28. package/lib/module/components/accordion/AccordionItem.js +3 -1
  29. package/lib/module/components/accordion/AccordionItem.js.map +1 -1
  30. package/lib/module/components/buttons/ButtonLink.js +3 -1
  31. package/lib/module/components/buttons/ButtonLink.js.map +1 -1
  32. package/lib/module/components/buttons/ButtonOutline.js +7 -1
  33. package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
  34. package/lib/module/components/buttons/ButtonSolid.js +7 -1
  35. package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
  36. package/lib/module/components/buttons/IconButtonContained.js +4 -2
  37. package/lib/module/components/buttons/IconButtonContained.js.map +1 -1
  38. package/lib/module/components/buttons/IconButtonSolid.js +4 -2
  39. package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
  40. package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +8 -4
  41. package/lib/module/components/layout/HeaderFirstLevel.js +4 -3
  42. package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -1
  43. package/lib/module/components/layout/HeaderSecondLevel.js +13 -2
  44. package/lib/module/components/layout/HeaderSecondLevel.js.map +1 -1
  45. package/lib/module/components/searchInput/SearchInput.js +7 -5
  46. package/lib/module/components/searchInput/SearchInput.js.map +1 -1
  47. package/lib/module/components/tabs/TabNavigation.js +7 -6
  48. package/lib/module/components/tabs/TabNavigation.js.map +1 -1
  49. package/lib/module/components/typography/H2.js +2 -1
  50. package/lib/module/components/typography/H2.js.map +1 -1
  51. package/lib/module/components/typography/H3.js +2 -2
  52. package/lib/module/components/typography/H3.js.map +1 -1
  53. package/lib/module/core/IOStyles.js +0 -4
  54. package/lib/module/core/IOStyles.js.map +1 -1
  55. package/lib/typescript/components/accordion/AccordionItem.d.ts.map +1 -1
  56. package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +1 -1
  57. package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +1 -1
  58. package/lib/typescript/components/buttons/IconButtonContained.d.ts.map +1 -1
  59. package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -1
  60. package/lib/typescript/components/layout/HeaderSecondLevel.d.ts.map +1 -1
  61. package/lib/typescript/components/searchInput/SearchInput.d.ts.map +1 -1
  62. package/lib/typescript/components/tabs/TabNavigation.d.ts +2 -1
  63. package/lib/typescript/components/tabs/TabNavigation.d.ts.map +1 -1
  64. package/lib/typescript/components/typography/H2.d.ts +2 -0
  65. package/lib/typescript/components/typography/H2.d.ts.map +1 -1
  66. package/lib/typescript/components/typography/H3.d.ts +0 -2
  67. package/lib/typescript/components/typography/H3.d.ts.map +1 -1
  68. package/lib/typescript/core/IOStyles.d.ts +0 -3
  69. package/lib/typescript/core/IOStyles.d.ts.map +1 -1
  70. package/package.json +1 -1
  71. package/src/components/accordion/AccordionItem.tsx +5 -1
  72. package/src/components/buttons/ButtonLink.tsx +1 -1
  73. package/src/components/buttons/ButtonOutline.tsx +5 -1
  74. package/src/components/buttons/ButtonSolid.tsx +5 -1
  75. package/src/components/buttons/IconButtonContained.tsx +2 -7
  76. package/src/components/buttons/IconButtonSolid.tsx +2 -2
  77. package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +8 -4
  78. package/src/components/layout/HeaderFirstLevel.tsx +4 -3
  79. package/src/components/layout/HeaderSecondLevel.tsx +28 -5
  80. package/src/components/searchInput/SearchInput.tsx +10 -6
  81. package/src/components/tabs/TabNavigation.tsx +8 -6
  82. package/src/components/typography/H2.tsx +11 -4
  83. package/src/components/typography/H3.tsx +4 -11
  84. package/src/core/IOStyles.ts +0 -4
@@ -161,7 +161,7 @@ export const ButtonLink = forwardRef<View, ButtonLinkProps>(
161
161
  accessible={true}
162
162
  disabled={disabled}
163
163
  hitSlop={{ top: 14, right: 24, bottom: 14, left: 24 }}
164
- style={IOButtonStyles.dimensionsDefault}
164
+ style={{ alignSelf: "flex-start" }}
165
165
  >
166
166
  <Animated.View
167
167
  style={[
@@ -192,7 +192,11 @@ export const ButtonOutline = forwardRef<View, ButtonOutline>(
192
192
  onPressOut={onPressOut}
193
193
  accessible={true}
194
194
  disabled={disabled}
195
- style={!fullWidth ? IOButtonStyles.dimensionsDefault : {}}
195
+ style={
196
+ fullWidth
197
+ ? { flexShrink: 0, alignSelf: "stretch" }
198
+ : { flexShrink: 1, alignSelf: "auto" }
199
+ }
196
200
  >
197
201
  <Animated.View
198
202
  style={[
@@ -208,7 +208,11 @@ export const ButtonSolid = forwardRef<View, ButtonSolidProps>(
208
208
  onPressIn={onPressIn}
209
209
  onPressOut={onPressOut}
210
210
  disabled={disabled}
211
- style={!fullWidth ? IOButtonStyles.dimensionsDefault : {}}
211
+ style={
212
+ fullWidth
213
+ ? { flexShrink: 0, alignSelf: "stretch" }
214
+ : { flexShrink: 1, alignSelf: "auto" }
215
+ }
212
216
  >
213
217
  <Animated.View
214
218
  style={[
@@ -11,12 +11,7 @@ import {
11
11
  IOIcons,
12
12
  IconClassComponent
13
13
  } from "../../components/icons";
14
- import {
15
- IOButtonStyles,
16
- IOColors,
17
- IOIconButtonStyles,
18
- hexToRgba
19
- } from "../../core";
14
+ import { IOColors, IOIconButtonStyles, hexToRgba } from "../../core";
20
15
  import { useScaleAnimation } from "../../hooks";
21
16
  import { WithTestID } from "../../utils/types";
22
17
 
@@ -135,7 +130,7 @@ export const IconButtonContained = ({
135
130
  onPressOut={onPressOut}
136
131
  accessible={true}
137
132
  disabled={disabled}
138
- style={IOButtonStyles.dimensionsDefault}
133
+ style={{ alignSelf: "flex-start" }}
139
134
  >
140
135
  <Animated.View
141
136
  style={[
@@ -5,7 +5,7 @@ import Animated, {
5
5
  useAnimatedStyle,
6
6
  useReducedMotion
7
7
  } from "react-native-reanimated";
8
- import { IOButtonStyles, IOIconButtonStyles, useIOTheme } from "../../core";
8
+ import { IOIconButtonStyles, useIOTheme } from "../../core";
9
9
  import { IOColors, hexToRgba } from "../../core/IOColors";
10
10
  import { useScaleAnimation } from "../../hooks";
11
11
  import { WithTestID } from "../../utils/types";
@@ -98,7 +98,7 @@ export const IconButtonSolid = ({
98
98
  onPressOut={onPressOut}
99
99
  accessible={true}
100
100
  disabled={disabled}
101
- style={IOButtonStyles.dimensionsDefault}
101
+ style={{ alignSelf: "flex-start" }}
102
102
  >
103
103
  <Animated.View
104
104
  style={[
@@ -147,7 +147,8 @@ exports[`Test Buttons Components - Experimental Enabled ButtonOutline Snapshot 1
147
147
  onStartShouldSetResponder={[Function]}
148
148
  style={
149
149
  {
150
- "alignSelf": "flex-start",
150
+ "alignSelf": "auto",
151
+ "flexShrink": 1,
151
152
  }
152
153
  }
153
154
  >
@@ -264,7 +265,8 @@ exports[`Test Buttons Components - Experimental Enabled ButtonSolid Snapshot 1`]
264
265
  onStartShouldSetResponder={[Function]}
265
266
  style={
266
267
  {
267
- "alignSelf": "flex-start",
268
+ "alignSelf": "auto",
269
+ "flexShrink": 1,
268
270
  }
269
271
  }
270
272
  >
@@ -890,7 +892,8 @@ exports[`Test Buttons Components ButtonOutline Snapshot 1`] = `
890
892
  onStartShouldSetResponder={[Function]}
891
893
  style={
892
894
  {
893
- "alignSelf": "flex-start",
895
+ "alignSelf": "auto",
896
+ "flexShrink": 1,
894
897
  }
895
898
  }
896
899
  >
@@ -1007,7 +1010,8 @@ exports[`Test Buttons Components ButtonSolid Snapshot 1`] = `
1007
1010
  onStartShouldSetResponder={[Function]}
1008
1011
  style={
1009
1012
  {
1010
- "alignSelf": "flex-start",
1013
+ "alignSelf": "auto",
1014
+ "flexShrink": 1,
1011
1015
  }
1012
1016
  }
1013
1017
  >
@@ -23,7 +23,7 @@ import {
23
23
  import { WithTestID } from "../../utils/types";
24
24
  import { IconButton } from "../buttons";
25
25
  import { HStack } from "../stack";
26
- import { H3 } from "../typography";
26
+ import { H2 } from "../typography";
27
27
  import { HeaderActionProps } from "./common";
28
28
 
29
29
  type HeaderActionsProp =
@@ -125,14 +125,15 @@ export const HeaderFirstLevel = ({
125
125
 
126
126
  <View style={styles.headerInner}>
127
127
  <View ref={titleRef} accessible accessibilityRole="header">
128
- <H3
128
+ <H2
129
129
  weight="Bold"
130
130
  style={{ flexShrink: 1 }}
131
131
  numberOfLines={1}
132
132
  color={theme["textHeading-default"]}
133
+ maxFontSizeMultiplier={1.25}
133
134
  >
134
135
  {title}
135
- </H3>
136
+ </H2>
136
137
  </View>
137
138
  <HStack space={16} style={{ flexShrink: 0 }}>
138
139
  {actions.map((action, index) => (
@@ -13,6 +13,8 @@ import Animated, {
13
13
  SharedValue,
14
14
  interpolate,
15
15
  interpolateColor,
16
+ runOnJS,
17
+ useAnimatedReaction,
16
18
  useAnimatedStyle,
17
19
  useDerivedValue,
18
20
  useScrollViewOffset,
@@ -269,6 +271,31 @@ export const HeaderSecondLevel = ({
269
271
  : 1
270
272
  }));
271
273
 
274
+ const [importantForAccessibility, setImportantForAccessibility] =
275
+ React.useState<"yes" | "no-hide-descendants">("yes");
276
+
277
+ // Updates accessibility state based on scroll position.
278
+ useAnimatedReaction(
279
+ () =>
280
+ enableDiscreteTransition
281
+ ? scrollOffset.value
282
+ : scrollValues?.contentOffsetY.value,
283
+ (currentOffset, previousOffset) => {
284
+ if (currentOffset !== previousOffset) {
285
+ const offsetToCompare = enableDiscreteTransition
286
+ ? 0
287
+ : scrollValues?.triggerOffset ?? 0;
288
+ // Sets accessibility to "yes" when scrolled past the threshold, else hides it from screen readers.
289
+ const newValue =
290
+ (currentOffset ?? 0) > offsetToCompare && !ignoreAccessibilityCheck
291
+ ? "yes"
292
+ : "no-hide-descendants";
293
+ runOnJS(setImportantForAccessibility)(newValue);
294
+ }
295
+ },
296
+ [scrollValues, enableDiscreteTransition]
297
+ );
298
+
272
299
  return (
273
300
  <Animated.View
274
301
  accessibilityRole="header"
@@ -303,11 +330,7 @@ export const HeaderSecondLevel = ({
303
330
  <View
304
331
  ref={titleRef}
305
332
  accessibilityElementsHidden={!isTitleAccessible}
306
- importantForAccessibility={
307
- isTitleAccessible && !ignoreAccessibilityCheck
308
- ? "yes"
309
- : "no-hide-descendants"
310
- }
333
+ importantForAccessibility={importantForAccessibility}
311
334
  accessible={isTitleAccessible}
312
335
  accessibilityLabel={title}
313
336
  accessibilityRole="header"
@@ -214,7 +214,7 @@ export const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
214
214
  : inputWidth;
215
215
  };
216
216
 
217
- const cancel = useCallback(
217
+ const handleCancel = useCallback(
218
218
  (event: GestureResponderEvent) => {
219
219
  onChangeText?.("");
220
220
  onCancel?.(event);
@@ -222,7 +222,7 @@ export const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
222
222
  [onCancel, onChangeText]
223
223
  );
224
224
 
225
- const clear = useCallback(() => {
225
+ const handleClear = useCallback(() => {
226
226
  onChangeText?.("");
227
227
  searchInputRef.current?.clear();
228
228
  }, [onChangeText]);
@@ -233,7 +233,10 @@ export const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
233
233
  );
234
234
 
235
235
  const renderSearchBar = () => (
236
- <Animated.View style={styles.searchBar}>
236
+ <Animated.View
237
+ importantForAccessibility={pressable ? "no-hide-descendants" : "auto"}
238
+ style={styles.searchBar}
239
+ >
237
240
  <Animated.View
238
241
  style={[styles.searchInput, animatedStyle]}
239
242
  pointerEvents={pressable ? "none" : "auto"}
@@ -279,7 +282,7 @@ export const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
279
282
  />
280
283
  <AnimatedPressable
281
284
  style={[styles.clearButton, clearButtonAnimatedStyle]}
282
- onPress={clear}
285
+ onPress={handleClear}
283
286
  accessibilityLabel={clearAccessibilityLabel}
284
287
  accessibilityRole="button"
285
288
  hitSlop={16}
@@ -294,7 +297,7 @@ export const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
294
297
  <Pressable
295
298
  accessibilityRole="button"
296
299
  accessibilityLabel={cancelButtonLabel}
297
- onPress={cancel}
300
+ onPress={handleCancel}
298
301
  >
299
302
  <IOText
300
303
  color={theme["interactiveElem-default"]}
@@ -316,9 +319,10 @@ export const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
316
319
 
317
320
  return pressable ? (
318
321
  <Pressable
322
+ accessible={true}
319
323
  accessibilityRole="button"
320
324
  accessibilityLabel={placeholder}
321
- onPress={pressable?.onPress}
325
+ onPress={pressable.onPress}
322
326
  >
323
327
  {renderSearchBar()}
324
328
  </Pressable>
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { FlexStyle, LayoutChangeEvent, StyleSheet, View } from "react-native";
3
3
  import { ScrollView } from "react-native-gesture-handler";
4
+ import { IOVisualCostants } from "../../core";
4
5
  import { TabItem } from "./TabItem";
5
6
 
6
7
  export type TabNavigationItem = Omit<
@@ -23,6 +24,7 @@ type TabNavigation = {
23
24
  onItemPress?: (index: number) => void;
24
25
  // Tabs
25
26
  children: TabNavigationChildren;
27
+ includeContentMargins?: boolean;
26
28
  };
27
29
 
28
30
  const itemsJustify: Record<TabAlignment, FlexStyle["justifyContent"]> = {
@@ -37,7 +39,8 @@ const TabNavigation = ({
37
39
  selectedIndex,
38
40
  tabAlignment = "center",
39
41
  onItemPress,
40
- children
42
+ children,
43
+ includeContentMargins = true
41
44
  }: TabNavigation) => {
42
45
  const [itemMinWidth, setItemMinWidth] = React.useState<number>(0);
43
46
 
@@ -79,8 +82,11 @@ const TabNavigation = ({
79
82
  centerContent={true}
80
83
  showsHorizontalScrollIndicator={false}
81
84
  contentContainerStyle={[
82
- styles.container,
85
+ includeContentMargins
86
+ ? { paddingHorizontal: IOVisualCostants.appMarginDefault }
87
+ : {},
83
88
  {
89
+ flexGrow: 1,
84
90
  justifyContent: itemsJustify[tabAlignment]
85
91
  }
86
92
  ]}
@@ -91,10 +97,6 @@ const TabNavigation = ({
91
97
  };
92
98
 
93
99
  const styles = StyleSheet.create({
94
- container: {
95
- flexGrow: 1,
96
- paddingHorizontal: 24
97
- },
98
100
  item: {
99
101
  flexGrow: 0,
100
102
  flexShrink: 1,
@@ -1,17 +1,24 @@
1
1
  import React, { ForwardedRef, forwardRef } from "react";
2
2
  import { View } from "react-native";
3
3
  import { useIONewTypeface, useIOTheme } from "../../core";
4
- import { IOFontSize } from "../../utils/fonts";
4
+ import { IOFontSize, IOFontWeight } from "../../utils/fonts";
5
5
  import { IOText, IOTextProps, TypographicStyleProps } from "./IOText";
6
6
 
7
+ type H2StyleProps = TypographicStyleProps & {
8
+ weight?: Extract<IOFontWeight, "Semibold" | "Bold">;
9
+ };
10
+
7
11
  export const h2FontSize: IOFontSize = 26;
8
12
  export const h2LineHeight = 34;
9
13
 
10
14
  /**
11
15
  * `H2` typographic style
12
16
  */
13
- export const H2 = forwardRef<View, TypographicStyleProps>(
14
- ({ color: customColor, ...props }, ref?: ForwardedRef<View>) => {
17
+ export const H2 = forwardRef<View, H2StyleProps>(
18
+ (
19
+ { weight: customWeight, color: customColor, ...props },
20
+ ref?: ForwardedRef<View>
21
+ ) => {
15
22
  const theme = useIOTheme();
16
23
  const { newTypefaceEnabled } = useIONewTypeface();
17
24
 
@@ -19,7 +26,7 @@ export const H2 = forwardRef<View, TypographicStyleProps>(
19
26
  ...props,
20
27
  dynamicTypeRamp: "title1", // iOS only
21
28
  font: newTypefaceEnabled ? "Titillio" : "TitilliumSansPro",
22
- weight: "Semibold",
29
+ weight: customWeight ?? "Semibold",
23
30
  size: h2FontSize,
24
31
  lineHeight: h2LineHeight,
25
32
  color: customColor ?? theme["textHeading-default"]
@@ -1,13 +1,9 @@
1
1
  import React, { ForwardedRef, forwardRef } from "react";
2
2
  import { View } from "react-native";
3
3
  import { useIONewTypeface, useIOTheme } from "../../core";
4
- import { IOFontSize, IOFontWeight } from "../../utils/fonts";
4
+ import { IOFontSize } from "../../utils/fonts";
5
5
  import { IOText, IOTextProps, TypographicStyleProps } from "./IOText";
6
6
 
7
- type H3StyleProps = TypographicStyleProps & {
8
- weight?: Extract<IOFontWeight, "Semibold" | "Bold">;
9
- };
10
-
11
7
  /* Common typographic styles */
12
8
  export const h3FontSize: IOFontSize = 22;
13
9
  export const h3LineHeight = 33;
@@ -15,11 +11,8 @@ export const h3LineHeight = 33;
15
11
  /**
16
12
  * `H3` typographic style
17
13
  */
18
- export const H3 = forwardRef<View, H3StyleProps>(
19
- (
20
- { weight: customWeight, color: customColor, ...props },
21
- ref?: ForwardedRef<View>
22
- ) => {
14
+ export const H3 = forwardRef<View, TypographicStyleProps>(
15
+ ({ color: customColor, ...props }, ref?: ForwardedRef<View>) => {
23
16
  const theme = useIOTheme();
24
17
  const { newTypefaceEnabled } = useIONewTypeface();
25
18
 
@@ -27,7 +20,7 @@ export const H3 = forwardRef<View, H3StyleProps>(
27
20
  ...props,
28
21
  dynamicTypeRamp: "title2", // iOS only
29
22
  font: newTypefaceEnabled ? "Titillio" : "TitilliumSansPro",
30
- weight: customWeight ?? "Semibold",
23
+ weight: "Semibold",
31
24
  size: h3FontSize,
32
25
  lineHeight: h3LineHeight,
33
26
  color: customColor ?? theme["textHeading-default"]
@@ -167,10 +167,6 @@ export const IOButtonStyles = StyleSheet.create({
167
167
  },
168
168
  buttonSizeSmall: {
169
169
  height: btnSizeDefault
170
- },
171
- /* Widths */
172
- dimensionsDefault: {
173
- alignSelf: "flex-start"
174
170
  }
175
171
  });
176
172