@pagopa/io-app-design-system 5.6.3 → 5.6.5

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 (31) hide show
  1. package/lib/commonjs/components/buttons/IOButton/IOButton.js +5 -5
  2. package/lib/commonjs/components/buttons/IOButton/IOButton.js.map +1 -1
  3. package/lib/commonjs/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +29 -29
  4. package/lib/commonjs/components/claimsSelector/ClaimsSelector.js +35 -13
  5. package/lib/commonjs/components/claimsSelector/ClaimsSelector.js.map +1 -1
  6. package/lib/commonjs/components/claimsSelector/__test__/ClaimsSelector.test.js +16 -3
  7. package/lib/commonjs/components/claimsSelector/__test__/ClaimsSelector.test.js.map +1 -1
  8. package/lib/commonjs/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +295 -0
  9. package/lib/commonjs/components/searchInput/SearchInput.js +8 -5
  10. package/lib/commonjs/components/searchInput/SearchInput.js.map +1 -1
  11. package/lib/module/components/buttons/IOButton/IOButton.js +5 -5
  12. package/lib/module/components/buttons/IOButton/IOButton.js.map +1 -1
  13. package/lib/module/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +29 -29
  14. package/lib/module/components/claimsSelector/ClaimsSelector.js +36 -14
  15. package/lib/module/components/claimsSelector/ClaimsSelector.js.map +1 -1
  16. package/lib/module/components/claimsSelector/__test__/ClaimsSelector.test.js +16 -3
  17. package/lib/module/components/claimsSelector/__test__/ClaimsSelector.test.js.map +1 -1
  18. package/lib/module/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +295 -0
  19. package/lib/module/components/searchInput/SearchInput.js +9 -6
  20. package/lib/module/components/searchInput/SearchInput.js.map +1 -1
  21. package/lib/typescript/components/buttons/IOButton/IOButton.d.ts.map +1 -1
  22. package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts +2 -1
  23. package/lib/typescript/components/claimsSelector/ClaimsSelector.d.ts.map +1 -1
  24. package/lib/typescript/components/searchInput/SearchInput.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/components/buttons/IOButton/IOButton.tsx +9 -5
  27. package/src/components/buttons/IOButton/__test__/__snapshots__/IOButton.test.tsx.snap +29 -29
  28. package/src/components/claimsSelector/ClaimsSelector.tsx +49 -22
  29. package/src/components/claimsSelector/__test__/ClaimsSelector.test.tsx +21 -3
  30. package/src/components/claimsSelector/__test__/__snapshots__/ClaimsSelector.test.tsx.snap +295 -0
  31. package/src/components/searchInput/SearchInput.tsx +13 -5
@@ -1,5 +1,5 @@
1
1
  import React, { Fragment } from "react";
2
- import { StyleSheet, View } from "react-native";
2
+ import { Image, StyleSheet, View } from "react-native";
3
3
  import Animated from "react-native-reanimated";
4
4
  import { TouchableWithoutFeedback } from "react-native-gesture-handler";
5
5
  import LinearGradient from "react-native-linear-gradient";
@@ -54,8 +54,9 @@ type Props = {
54
54
 
55
55
  type Item = {
56
56
  id: string;
57
- title: string;
57
+ value: string;
58
58
  description: string;
59
+ type?: "text" | "image";
59
60
  };
60
61
 
61
62
  export const ClaimsSelector = ({
@@ -88,25 +89,47 @@ export const ClaimsSelector = ({
88
89
  onToggle?.(!expanded);
89
90
  };
90
91
 
91
- const body = items.map((item, index) => (
92
- <Fragment key={item.id}>
93
- {index !== 0 && <Divider />}
94
- {selectionEnabled ? (
95
- <ListItemCheckbox
96
- value={item.title}
97
- description={item.description}
98
- selected={selectedItemIds?.includes(item.id)}
99
- onValueChange={
100
- onItemSelected
101
- ? selected => onItemSelected(item, selected)
102
- : undefined
103
- }
104
- />
105
- ) : (
106
- <ListItemInfo reversed value={item.title} label={item.description} />
107
- )}
108
- </Fragment>
109
- ));
92
+ const renderClaimItem = (item: Item, index: number) => {
93
+ const { id, value, description, type = "text" } = item;
94
+ return (
95
+ <Fragment key={id}>
96
+ {index !== 0 && <Divider />}
97
+ {
98
+ // We do not support checkbox selection for images, as it is not needed now
99
+ selectionEnabled && type === "text" ? (
100
+ <ListItemCheckbox
101
+ value={value}
102
+ description={description}
103
+ selected={selectedItemIds?.includes(id)}
104
+ onValueChange={
105
+ onItemSelected
106
+ ? selected => onItemSelected(item, selected)
107
+ : undefined
108
+ }
109
+ />
110
+ ) : (
111
+ <ListItemInfo
112
+ value={
113
+ type === "image" ? (
114
+ <Image
115
+ source={{ uri: value }}
116
+ style={styles.imageClaim}
117
+ resizeMode="contain"
118
+ accessibilityIgnoresInvertColors
119
+ />
120
+ ) : (
121
+ value
122
+ )
123
+ }
124
+ label={description}
125
+ accessibilityRole={type}
126
+ reversed
127
+ />
128
+ )
129
+ }
130
+ </Fragment>
131
+ );
132
+ };
110
133
 
111
134
  return (
112
135
  <View
@@ -141,7 +164,7 @@ export const ClaimsSelector = ({
141
164
  style={[bodyInnerStyle, styles.bodyInnerContainer]}
142
165
  onLayout={onBodyLayout}
143
166
  >
144
- {body}
167
+ {items.map(renderClaimItem)}
145
168
  </View>
146
169
  </Animated.View>
147
170
 
@@ -181,5 +204,9 @@ const styles = StyleSheet.create({
181
204
  // Avoid gradient overlaps with border radius
182
205
  left: accordionBodySpacing,
183
206
  right: accordionBodySpacing
207
+ },
208
+ imageClaim: {
209
+ width: 160,
210
+ aspectRatio: 3 / 4
184
211
  }
185
212
  });
@@ -11,7 +11,7 @@ describe("ClaimsSelector", () => {
11
11
  items={[
12
12
  {
13
13
  id: "name",
14
- title: "Mario Rossi",
14
+ value: "Mario Rossi",
15
15
  description: "Nome e cognome"
16
16
  }
17
17
  ]}
@@ -27,7 +27,7 @@ describe("ClaimsSelector", () => {
27
27
  items={[
28
28
  {
29
29
  id: "name",
30
- title: "Mario Rossi",
30
+ value: "Mario Rossi",
31
31
  description: "Nome e cognome"
32
32
  }
33
33
  ]}
@@ -44,7 +44,7 @@ describe("ClaimsSelector", () => {
44
44
  items={[
45
45
  {
46
46
  id: "name",
47
- title: "Mario Rossi",
47
+ value: "Mario Rossi",
48
48
  description: "Nome e cognome"
49
49
  }
50
50
  ]}
@@ -52,4 +52,22 @@ describe("ClaimsSelector", () => {
52
52
  );
53
53
  expect(claimsSelector).toMatchSnapshot();
54
54
  });
55
+
56
+ it("ClaimsSelector Snapshot (custom component)", () => {
57
+ const claimsSelector = TestRenderer.create(
58
+ <ClaimsSelector
59
+ title="Patente di guida"
60
+ selectionEnabled={false}
61
+ items={[
62
+ {
63
+ id: "name",
64
+ value: "data:image/png;base64,iVBORw0KGgoAAAANSUh",
65
+ description: "Nome e cognome",
66
+ type: "image"
67
+ }
68
+ ]}
69
+ />
70
+ );
71
+ expect(claimsSelector).toMatchSnapshot();
72
+ });
55
73
  });
@@ -523,6 +523,300 @@ exports[`ClaimsSelector ClaimsSelector Snapshot (controlled) 1`] = `
523
523
  </View>
524
524
  `;
525
525
 
526
+ exports[`ClaimsSelector ClaimsSelector Snapshot (custom component) 1`] = `
527
+ <View
528
+ style={
529
+ [
530
+ {
531
+ "borderCurve": "continuous",
532
+ "borderRadius": 8,
533
+ "borderWidth": 1,
534
+ },
535
+ {
536
+ "backgroundColor": "#F4F5F8",
537
+ "borderColor": "#E8EBF1",
538
+ },
539
+ ]
540
+ }
541
+ >
542
+ <RNGestureHandlerButton
543
+ collapsable={false}
544
+ delayLongPress={600}
545
+ enabled={true}
546
+ exclusive={true}
547
+ handlerTag={4}
548
+ handlerType="NativeViewGestureHandler"
549
+ innerRef={null}
550
+ onGestureHandlerEvent={[Function]}
551
+ onGestureHandlerStateChange={[Function]}
552
+ rippleColor="transparent"
553
+ style={
554
+ [
555
+ undefined,
556
+ {
557
+ "cursor": undefined,
558
+ },
559
+ ]
560
+ }
561
+ touchSoundDisabled={false}
562
+ >
563
+ <View
564
+ accessibilityLabel="Patente di guida"
565
+ accessibilityRole="button"
566
+ accessibilityState={
567
+ {
568
+ "expanded": false,
569
+ }
570
+ }
571
+ accessible={true}
572
+ collapsable={false}
573
+ style={{}}
574
+ >
575
+ <View
576
+ style={
577
+ {
578
+ "alignItems": "center",
579
+ "flexDirection": "row",
580
+ "justifyContent": "space-between",
581
+ "padding": 16,
582
+ }
583
+ }
584
+ >
585
+ <Text
586
+ allowFontScaling={true}
587
+ dynamicTypeRamp="headline"
588
+ maxFontSizeMultiplier={1.5}
589
+ style={
590
+ [
591
+ {},
592
+ {
593
+ "color": "#0E0F13",
594
+ "fontFamily": "Titillio",
595
+ "fontSize": 16,
596
+ "fontStyle": "normal",
597
+ "fontWeight": "600",
598
+ "lineHeight": 24,
599
+ },
600
+ ]
601
+ }
602
+ >
603
+ Patente di guida
604
+ </Text>
605
+ <View
606
+ style={
607
+ {
608
+ "transform": [
609
+ {
610
+ "rotate": "0deg",
611
+ },
612
+ ],
613
+ }
614
+ }
615
+ >
616
+ <RNSVGSvgView
617
+ accessibilityElementsHidden={true}
618
+ accessibilityLabel=""
619
+ accessible={false}
620
+ align="xMidYMid"
621
+ bbHeight={24}
622
+ bbWidth={24}
623
+ color="#0B3EE3"
624
+ focusable={false}
625
+ height={24}
626
+ importantForAccessibility="no-hide-descendants"
627
+ meetOrSlice={0}
628
+ minX={0}
629
+ minY={0}
630
+ style={
631
+ [
632
+ {
633
+ "backgroundColor": "transparent",
634
+ "borderWidth": 0,
635
+ },
636
+ {
637
+ "flex": 0,
638
+ "height": 24,
639
+ "width": 24,
640
+ },
641
+ ]
642
+ }
643
+ vbHeight={24}
644
+ vbWidth={24}
645
+ width={24}
646
+ >
647
+ <RNSVGGroup
648
+ fill={
649
+ {
650
+ "payload": 4278190080,
651
+ "type": 0,
652
+ }
653
+ }
654
+ >
655
+ <RNSVGPath
656
+ clipRule={0}
657
+ d="M18.7071 8.29289c.3905.39053.3905 1.02369 0 1.41422l-6 5.99999c-.3905.3905-1.0237.3905-1.4142 0L5.29289 9.70711c-.39052-.39053-.39052-1.02369 0-1.41422.39053-.39052 1.02369-.39052 1.41422 0L12 13.5858l5.2929-5.29291c.3905-.39052 1.0237-.39052 1.4142 0Z"
658
+ fill={
659
+ {
660
+ "type": 2,
661
+ }
662
+ }
663
+ fillRule={0}
664
+ propList={
665
+ [
666
+ "fill",
667
+ "fillRule",
668
+ ]
669
+ }
670
+ />
671
+ </RNSVGGroup>
672
+ </RNSVGSvgView>
673
+ </View>
674
+ </View>
675
+ </View>
676
+ </RNGestureHandlerButton>
677
+ <View
678
+ style={
679
+ [
680
+ {
681
+ "height": 0,
682
+ },
683
+ {
684
+ "overflow": "hidden",
685
+ },
686
+ ]
687
+ }
688
+ >
689
+ <View
690
+ onLayout={[Function]}
691
+ style={
692
+ [
693
+ {
694
+ "padding": 16,
695
+ "paddingTop": 0,
696
+ "position": "absolute",
697
+ "width": "100%",
698
+ },
699
+ {
700
+ "width": "100%",
701
+ },
702
+ ]
703
+ }
704
+ >
705
+ <View
706
+ accessibilityLabel="Nome e cognome; "
707
+ accessibilityRole="image"
708
+ accessible={true}
709
+ style={
710
+ {
711
+ "marginHorizontal": -24,
712
+ "paddingHorizontal": 24,
713
+ "paddingVertical": 12,
714
+ }
715
+ }
716
+ >
717
+ <View
718
+ style={
719
+ [
720
+ {
721
+ "alignItems": "center",
722
+ "flexDirection": "row",
723
+ "justifyContent": "space-between",
724
+ },
725
+ {
726
+ "columnGap": 12,
727
+ },
728
+ ]
729
+ }
730
+ >
731
+ <View
732
+ style={
733
+ {
734
+ "flex": 1,
735
+ }
736
+ }
737
+ >
738
+ <View
739
+ accessible={true}
740
+ style={
741
+ {
742
+ "flexDirection": "column-reverse",
743
+ }
744
+ }
745
+ >
746
+ <Text
747
+ allowFontScaling={true}
748
+ dynamicTypeRamp="footnote"
749
+ maxFontSizeMultiplier={1.5}
750
+ style={
751
+ [
752
+ {},
753
+ {
754
+ "color": "#555C70",
755
+ "fontFamily": "Titillio",
756
+ "fontSize": 14,
757
+ "fontStyle": "normal",
758
+ "fontWeight": "400",
759
+ "lineHeight": 21,
760
+ },
761
+ ]
762
+ }
763
+ >
764
+ Nome e cognome
765
+ </Text>
766
+ <Image
767
+ accessibilityIgnoresInvertColors={true}
768
+ resizeMode="contain"
769
+ source={
770
+ {
771
+ "uri": "data:image/png;base64,iVBORw0KGgoAAAANSUh",
772
+ }
773
+ }
774
+ style={
775
+ {
776
+ "aspectRatio": 0.75,
777
+ "width": 160,
778
+ }
779
+ }
780
+ />
781
+ </View>
782
+ </View>
783
+ </View>
784
+ </View>
785
+ </View>
786
+ </View>
787
+ <BVLinearGradient
788
+ colors={
789
+ [
790
+ 16053752,
791
+ 4294243832,
792
+ ]
793
+ }
794
+ endPoint={
795
+ {
796
+ "x": 0.5,
797
+ "y": 1,
798
+ }
799
+ }
800
+ locations={null}
801
+ startPoint={
802
+ {
803
+ "x": 0.5,
804
+ "y": 0,
805
+ }
806
+ }
807
+ style={
808
+ {
809
+ "bottom": 0,
810
+ "height": 16,
811
+ "left": 16,
812
+ "position": "absolute",
813
+ "right": 16,
814
+ }
815
+ }
816
+ />
817
+ </View>
818
+ `;
819
+
526
820
  exports[`ClaimsSelector ClaimsSelector Snapshot (uncontrolled) 1`] = `
527
821
  <View
528
822
  style={
@@ -1158,6 +1452,7 @@ exports[`ClaimsSelector ClaimsSelector Snapshot (unselectable items) 1`] = `
1158
1452
  >
1159
1453
  <View
1160
1454
  accessibilityLabel="Nome e cognome; Mario Rossi"
1455
+ accessibilityRole="text"
1161
1456
  accessible={true}
1162
1457
  style={
1163
1458
  {
@@ -36,7 +36,11 @@ import {
36
36
  useIONewTypeface,
37
37
  useIOTheme
38
38
  } from "../../core";
39
- import { IOFontSize, makeFontStyleObject } from "../../utils/fonts";
39
+ import {
40
+ IOFontSize,
41
+ IOMaxFontSizeMultiplier,
42
+ makeFontStyleObject
43
+ } from "../../utils/fonts";
40
44
  import { Icon, IOIconSizeScale } from "../icons";
41
45
  import {
42
46
  buttonTextFontSize,
@@ -46,6 +50,7 @@ import {
46
50
 
47
51
  /* Component visual attributes */
48
52
  const inputPaddingHorizontal: IOSpacingScale = 12;
53
+ const inputPaddingVertical: IOSpacingScale = 8;
49
54
  const inputPaddingClearButton: IOSpacingScale = 8;
50
55
  const inputRadius: number = 8;
51
56
  const iconMargin: IOSpacingScale = 8;
@@ -54,8 +59,6 @@ const iconCloseSize: IOIconSizeScale = 24;
54
59
  const inputFontSizePlaceholder: IOFontSize = 14;
55
60
  const cancelButtonMargin: IOSpacingScale = 16;
56
61
  const inputTransitionDuration: number = 250;
57
- const inputHeightIOS: number = 36;
58
- const inputHeightAndroid: number = 42;
59
62
 
60
63
  type SearchInputPressableProps = {
61
64
  onPress: (event: GestureResponderEvent) => void;
@@ -260,6 +263,7 @@ export const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
260
263
  returnKeyType="search"
261
264
  accessibilityRole={"search"}
262
265
  accessibilityLabel={accessibilityLabel}
266
+ numberOfLines={1}
263
267
  style={[
264
268
  {
265
269
  color: IOColors[theme["textBody-default"]],
@@ -284,7 +288,9 @@ export const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
284
288
  onChangeText={handleChangeText}
285
289
  value={value}
286
290
  autoFocus={autoFocus}
291
+ maxFontSizeMultiplier={IOMaxFontSizeMultiplier}
287
292
  />
293
+
288
294
  <AnimatedPressable
289
295
  style={[styles.clearButton, clearButtonAnimatedStyle]}
290
296
  onPress={handleClear}
@@ -358,10 +364,11 @@ const styles = StyleSheet.create({
358
364
  flexGrow: 1
359
365
  },
360
366
  textInputIOS: {
361
- height: inputHeightIOS
367
+ paddingVertical: inputPaddingVertical
362
368
  },
363
369
  textInputAndroid: {
364
- height: inputHeightAndroid
370
+ textAlignVertical: "center",
371
+ overflow: "hidden"
365
372
  },
366
373
  iconContainer: {
367
374
  marginRight: iconMargin
@@ -372,6 +379,7 @@ const styles = StyleSheet.create({
372
379
  paddingLeft: cancelButtonMargin
373
380
  },
374
381
  clearButton: {
382
+ transformOrigin: "center",
375
383
  marginLeft: iconMargin
376
384
  }
377
385
  });