@pagopa/io-app-design-system 2.1.0 → 2.1.1

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 (88) hide show
  1. package/lib/commonjs/components/common/LogoPaymentWithFallback.js +20 -11
  2. package/lib/commonjs/components/common/LogoPaymentWithFallback.js.map +1 -1
  3. package/lib/commonjs/components/listitems/ListItemInfo.js +6 -4
  4. package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
  5. package/lib/commonjs/components/listitems/ListItemTransaction.js +27 -25
  6. package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
  7. package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -10
  8. package/lib/commonjs/components/listitems/__test__/listitem.test.js +10 -4
  9. package/lib/commonjs/components/listitems/__test__/listitem.test.js.map +1 -1
  10. package/lib/commonjs/components/modules/ModuleIDP.js +2 -9
  11. package/lib/commonjs/components/modules/ModuleIDP.js.map +1 -1
  12. package/lib/commonjs/components/modules/ModulePaymentNotice.js +8 -6
  13. package/lib/commonjs/components/modules/ModulePaymentNotice.js.map +1 -1
  14. package/lib/commonjs/components/tag/Tag.js +4 -11
  15. package/lib/commonjs/components/tag/Tag.js.map +1 -1
  16. package/lib/commonjs/core/IODSExperimentalContextProvider.js +1 -2
  17. package/lib/commonjs/core/IODSExperimentalContextProvider.js.map +1 -1
  18. package/lib/commonjs/core/IOThemeContextProvider.js +1 -2
  19. package/lib/commonjs/core/IOThemeContextProvider.js.map +1 -1
  20. package/lib/commonjs/utils/accessibility.js +1 -14
  21. package/lib/commonjs/utils/accessibility.js.map +1 -1
  22. package/lib/commonjs/utils/image.js +23 -14
  23. package/lib/commonjs/utils/image.js.map +1 -1
  24. package/lib/commonjs/utils/object.js +10 -5
  25. package/lib/commonjs/utils/object.js.map +1 -1
  26. package/lib/module/components/common/LogoPaymentWithFallback.js +20 -11
  27. package/lib/module/components/common/LogoPaymentWithFallback.js.map +1 -1
  28. package/lib/module/components/listitems/ListItemInfo.js +6 -4
  29. package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
  30. package/lib/module/components/listitems/ListItemTransaction.js +27 -23
  31. package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
  32. package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -10
  33. package/lib/module/components/listitems/__test__/listitem.test.js +10 -4
  34. package/lib/module/components/listitems/__test__/listitem.test.js.map +1 -1
  35. package/lib/module/components/modules/ModuleIDP.js +3 -10
  36. package/lib/module/components/modules/ModuleIDP.js.map +1 -1
  37. package/lib/module/components/modules/ModulePaymentNotice.js +8 -6
  38. package/lib/module/components/modules/ModulePaymentNotice.js.map +1 -1
  39. package/lib/module/components/tag/Tag.js +4 -9
  40. package/lib/module/components/tag/Tag.js.map +1 -1
  41. package/lib/module/core/IODSExperimentalContextProvider.js +1 -2
  42. package/lib/module/core/IODSExperimentalContextProvider.js.map +1 -1
  43. package/lib/module/core/IOThemeContextProvider.js +1 -2
  44. package/lib/module/core/IOThemeContextProvider.js.map +1 -1
  45. package/lib/module/utils/accessibility.js +0 -9
  46. package/lib/module/utils/accessibility.js.map +1 -1
  47. package/lib/module/utils/image.js +23 -12
  48. package/lib/module/utils/image.js.map +1 -1
  49. package/lib/module/utils/object.js +10 -3
  50. package/lib/module/utils/object.js.map +1 -1
  51. package/lib/typescript/components/common/LogoPaymentWithFallback.d.ts.map +1 -1
  52. package/lib/typescript/components/listitems/ListItemInfo.d.ts +5 -3
  53. package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
  54. package/lib/typescript/components/listitems/ListItemTransaction.d.ts +11 -5
  55. package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
  56. package/lib/typescript/components/modules/ModuleIDP.d.ts.map +1 -1
  57. package/lib/typescript/components/modules/ModulePaymentNotice.d.ts +10 -4
  58. package/lib/typescript/components/modules/ModulePaymentNotice.d.ts.map +1 -1
  59. package/lib/typescript/components/tag/Tag.d.ts.map +1 -1
  60. package/lib/typescript/core/IODSExperimentalContextProvider.d.ts.map +1 -1
  61. package/lib/typescript/core/IOThemeContextProvider.d.ts.map +1 -1
  62. package/lib/typescript/utils/accessibility.d.ts +0 -5
  63. package/lib/typescript/utils/accessibility.d.ts.map +1 -1
  64. package/lib/typescript/utils/image.d.ts +2 -2
  65. package/lib/typescript/utils/image.d.ts.map +1 -1
  66. package/lib/typescript/utils/object.d.ts +1 -2
  67. package/lib/typescript/utils/object.d.ts.map +1 -1
  68. package/package.json +1 -4
  69. package/src/components/common/LogoPaymentWithFallback.tsx +15 -17
  70. package/src/components/listitems/ListItemInfo.tsx +7 -4
  71. package/src/components/listitems/ListItemTransaction.tsx +40 -46
  72. package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -10
  73. package/src/components/listitems/__test__/listitem.test.tsx +10 -4
  74. package/src/components/modules/ModuleIDP.tsx +4 -13
  75. package/src/components/modules/ModulePaymentNotice.tsx +14 -10
  76. package/src/components/tag/Tag.tsx +10 -19
  77. package/src/core/IODSExperimentalContextProvider.tsx +1 -2
  78. package/src/core/IOThemeContextProvider.tsx +1 -2
  79. package/src/utils/accessibility.ts +0 -17
  80. package/src/utils/image.ts +28 -28
  81. package/src/utils/object.ts +13 -12
  82. package/lib/commonjs/utils/dates.js +0 -20
  83. package/lib/commonjs/utils/dates.js.map +0 -1
  84. package/lib/module/utils/dates.js +0 -11
  85. package/lib/module/utils/dates.js.map +0 -1
  86. package/lib/typescript/utils/dates.d.ts +0 -9
  87. package/lib/typescript/utils/dates.d.ts.map +0 -1
  88. package/src/utils/dates.ts +0 -18
@@ -1,7 +1,4 @@
1
- import * as O from "fp-ts/lib/Option";
2
- import { pipe } from "fp-ts/lib/function";
3
1
  import * as React from "react";
4
- import { findFirstCaseInsensitive } from "../../utils/object";
5
2
  import { IOColors } from "../../core";
6
3
  import { IOIconSizeScale, Icon } from "../icons";
7
4
  import {
@@ -12,6 +9,7 @@ import {
12
9
  LogoPayment,
13
10
  LogoPaymentExt
14
11
  } from "../logos";
12
+ import { findFirstCaseInsensitive } from "../../utils/object";
15
13
 
16
14
  export type LogoPaymentWithFallback = {
17
15
  brand?: string;
@@ -42,19 +40,19 @@ export const LogoPaymentWithFallback = ({
42
40
  }: LogoPaymentWithFallback) => {
43
41
  const logos = isExtended ? IOPaymentExtLogos : IOPaymentLogos;
44
42
 
45
- return pipe(
46
- brand,
47
- O.fromNullable,
48
- O.chain(findFirstCaseInsensitive(logos)),
49
- O.map(([brand]) => brand),
50
- O.fold(
51
- () => <Icon name="creditCard" size={size} color={fallbackIconColor} />,
52
- brand =>
53
- isExtended ? (
54
- <LogoPaymentExt name={brand as IOLogoPaymentExtType} size={size} />
55
- ) : (
56
- <LogoPayment name={brand as IOLogoPaymentType} size={size} />
57
- )
58
- )
43
+ if (!brand) {
44
+ return <Icon name="creditCard" size={size} color={fallbackIconColor} />;
45
+ }
46
+
47
+ const findCase = findFirstCaseInsensitive(logos, brand);
48
+
49
+ if (!findCase) {
50
+ return <Icon name="creditCard" size={size} color={fallbackIconColor} />;
51
+ }
52
+
53
+ return isExtended ? (
54
+ <LogoPaymentExt name={findCase as IOLogoPaymentExtType} size={size} />
55
+ ) : (
56
+ <LogoPayment name={findCase as IOLogoPaymentType} size={size} />
59
57
  );
60
58
  };
@@ -1,5 +1,5 @@
1
1
  import React, { ComponentProps, useCallback, useMemo } from "react";
2
- import { Platform, View } from "react-native";
2
+ import { AccessibilityRole, Platform, View } from "react-native";
3
3
  import {
4
4
  IOListItemStyles,
5
5
  IOListItemVisualParams,
@@ -7,12 +7,12 @@ import {
7
7
  useIOTheme
8
8
  } from "../../core";
9
9
  import { WithTestID } from "../../utils/types";
10
- import { IOIconSizeScale, IOIcons, Icon } from "../icons";
11
- import { H6, LabelSmall } from "../typography";
12
- import { ButtonLink, IconButton } from "../buttons";
13
10
  import { Badge } from "../badge";
11
+ import { ButtonLink, IconButton } from "../buttons";
14
12
  import { LogoPaymentWithFallback } from "../common/LogoPaymentWithFallback";
13
+ import { IOIconSizeScale, IOIcons, Icon } from "../icons";
15
14
  import { IOLogoPaymentType } from "../logos";
15
+ import { H6, LabelSmall } from "../typography";
16
16
 
17
17
  type ButtonLinkActionProps = {
18
18
  type: "buttonLink";
@@ -41,6 +41,7 @@ export type ListItemInfo = WithTestID<{
41
41
  endElement?: EndElementProps;
42
42
  // Accessibility
43
43
  accessibilityLabel?: string;
44
+ accessibilityRole?: AccessibilityRole;
44
45
  }> &
45
46
  (
46
47
  | {
@@ -63,6 +64,7 @@ export const ListItemInfo = ({
63
64
  paymentLogoIcon,
64
65
  endElement,
65
66
  accessibilityLabel,
67
+ accessibilityRole,
66
68
  testID
67
69
  }: ListItemInfo) => {
68
70
  const theme = useIOTheme();
@@ -136,6 +138,7 @@ export const ListItemInfo = ({
136
138
  testID={testID}
137
139
  accessible={endElement === undefined ? true : false}
138
140
  accessibilityLabel={listItemAccessibilityLabel}
141
+ accessibilityRole={accessibilityRole}
139
142
  >
140
143
  <View style={IOListItemStyles.listItemInner}>
141
144
  {icon && (
@@ -1,5 +1,3 @@
1
- import * as O from "fp-ts/lib/Option";
2
- import { pipe } from "fp-ts/lib/function";
3
1
  import React from "react";
4
2
  import { ImageURISource, StyleSheet, View } from "react-native";
5
3
  import Placeholder from "rn-placeholder";
@@ -14,8 +12,6 @@ import {
14
12
  useIOExperimentalDesign,
15
13
  useIOTheme
16
14
  } from "../../core";
17
-
18
- import { getAccessibleAmountText } from "../../utils/accessibility";
19
15
  import { WithTestID } from "../../utils/types";
20
16
  import { isImageUri } from "../../utils/url";
21
17
  import { Avatar } from "../avatar/Avatar";
@@ -73,14 +69,20 @@ export type ListItemTransaction = WithTestID<
73
69
  accessible?: boolean;
74
70
  } & (
75
71
  | {
76
- transactionStatus: ListItemTransactionStatusWithoutBadge;
72
+ transaction: {
73
+ amount: string;
74
+ amountAccessibilityLabel: string;
75
+ status: ListItemTransactionStatusWithoutBadge;
76
+ };
77
77
  badgeText?: string;
78
- transactionAmount: string;
79
78
  }
80
79
  | {
81
- transactionStatus: ListItemTransactionStatusWithBadge;
80
+ transaction: {
81
+ amount?: string;
82
+ amountAccessibilityLabel?: string;
83
+ status: ListItemTransactionStatusWithBadge;
84
+ };
82
85
  badgeText: string;
83
- transactionAmount?: string;
84
86
  }
85
87
  )
86
88
  >;
@@ -119,20 +121,15 @@ export const ListItemTransaction = ({
119
121
  subtitle,
120
122
  testID,
121
123
  title,
122
- transactionAmount,
124
+ transaction: { amount, amountAccessibilityLabel, status = "success" },
123
125
  badgeText,
124
- transactionStatus = "success",
125
126
  numberOfLines = 2,
126
127
  accessible
127
128
  }: ListItemTransaction) => {
128
129
  const { isExperimental } = useIOExperimentalDesign();
129
130
  const theme = useIOTheme();
130
131
 
131
- const maybeBadgeText = pipe(
132
- badgeText,
133
- O.fromNullable,
134
- O.getOrElse(() => "-")
135
- );
132
+ const maybeBadgeText = badgeText ?? "-";
136
133
 
137
134
  if (isLoading) {
138
135
  return <SkeletonComponent />;
@@ -147,25 +144,25 @@ export const ListItemTransaction = ({
147
144
 
148
145
  const ListItemTransactionContent = () => {
149
146
  const TransactionAmountOrBadgeComponent = () => {
150
- switch (transactionStatus) {
147
+ switch (status) {
151
148
  case "success":
152
149
  return (
153
150
  <H6
154
- accessibilityLabel={getAccessibleAmountText(transactionAmount)}
151
+ accessibilityLabel={amountAccessibilityLabel}
155
152
  color={hasChevronRight ? interactiveColor : amountColor}
156
153
  numberOfLines={numberOfLines}
157
154
  >
158
- {transactionAmount || ""}
155
+ {amount || ""}
159
156
  </H6>
160
157
  );
161
158
  case "refunded":
162
159
  return (
163
160
  <H6
164
- accessibilityLabel={getAccessibleAmountText(transactionAmount)}
161
+ accessibilityLabel={amountAccessibilityLabel}
165
162
  color={hasChevronRight ? interactiveColor : successColor}
166
163
  numberOfLines={numberOfLines}
167
164
  >
168
- {transactionAmount || ""}
165
+ {amount || ""}
169
166
  </H6>
170
167
  );
171
168
  case "failure":
@@ -217,33 +214,30 @@ export const ListItemTransaction = ({
217
214
  );
218
215
  };
219
216
 
220
- return pipe(
221
- onPress,
222
- O.fromNullable,
223
- O.fold(
224
- () => (
225
- <View
226
- style={IOListItemStyles.listItem}
227
- testID={testID}
228
- accessible={accessible}
229
- accessibilityLabel={accessibilityLabel}
230
- >
231
- <View style={IOListItemStyles.listItemInner}>
232
- <ListItemTransactionContent />
233
- </View>
234
- </View>
235
- ),
236
- onPress => (
237
- <PressableListItemBase
238
- onPress={onPress}
239
- testID={testID}
240
- accessibilityLabel={accessibilityLabel}
241
- >
217
+ if (onPress) {
218
+ return (
219
+ <PressableListItemBase
220
+ onPress={onPress}
221
+ testID={testID}
222
+ accessibilityLabel={accessibilityLabel}
223
+ >
224
+ <ListItemTransactionContent />
225
+ </PressableListItemBase>
226
+ );
227
+ } else {
228
+ return (
229
+ <View
230
+ style={IOListItemStyles.listItem}
231
+ testID={testID}
232
+ accessible={accessible}
233
+ accessibilityLabel={accessibilityLabel}
234
+ >
235
+ <View style={IOListItemStyles.listItemInner}>
242
236
  <ListItemTransactionContent />
243
- </PressableListItemBase>
244
- )
245
- )
246
- );
237
+ </View>
238
+ </View>
239
+ );
240
+ }
247
241
  };
248
242
 
249
243
  const SkeletonComponent = () => (
@@ -187,11 +187,6 @@ exports[`Test List Item Components - Experimental Enabled ListItemIDP Snapshot
187
187
  />
188
188
  <Image
189
189
  accessibilityIgnoresInvertColors={true}
190
- source={
191
- {
192
- "uri": "undefined",
193
- }
194
- }
195
190
  style={
196
191
  {
197
192
  "height": 30,
@@ -1884,11 +1879,6 @@ exports[`Test List Item Components ListItemIDP Snapshot 1`] = `
1884
1879
  />
1885
1880
  <Image
1886
1881
  accessibilityIgnoresInvertColors={true}
1887
- source={
1888
- {
1889
- "uri": "undefined",
1890
- }
1891
- }
1892
1882
  style={
1893
1883
  {
1894
1884
  "height": 30,
@@ -80,8 +80,11 @@ describe("Test List Item Components", () => {
80
80
  <ListItemTransaction
81
81
  title="TITLE"
82
82
  subtitle="subtitle"
83
- transactionStatus="success"
84
- transactionAmount="€ 1.000,00"
83
+ transaction={{
84
+ status: "success",
85
+ amount: "€ 1.000,00",
86
+ amountAccessibilityLabel: "€ 1.000,00"
87
+ }}
85
88
  isLoading={true}
86
89
  onPress={onButtonPress}
87
90
  />
@@ -180,8 +183,11 @@ describe("Test List Item Components - Experimental Enabled ", () => {
180
183
  <ListItemTransaction
181
184
  title="TITLE"
182
185
  subtitle="subtitle"
183
- transactionStatus="success"
184
- transactionAmount="€ 1.000,00"
186
+ transaction={{
187
+ status: "success",
188
+ amount: "€ 1.000,00",
189
+ amountAccessibilityLabel: "€ 1.000,00"
190
+ }}
185
191
  isLoading={true}
186
192
  onPress={onButtonPress}
187
193
  />
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
- import { Image, ImageSourcePropType, Platform, StyleSheet } from "react-native";
2
+ import { Image, ImageSourcePropType, StyleSheet } from "react-native";
3
+ import { addCacheTimestampToUri } from "../../utils/image";
3
4
  import {
4
5
  IOListItemLogoMargin,
5
6
  useIOExperimentalDesign,
6
7
  useIOTheme
7
8
  } from "../../core";
8
- import { toAndroidCacheTimestamp } from "../../utils/dates";
9
9
  import { IOText } from "../typography";
10
10
  import {
11
11
  PressableModuleBase,
@@ -28,12 +28,6 @@ const styles = StyleSheet.create({
28
28
  }
29
29
  });
30
30
 
31
- // https://github.com/facebook/react-native/issues/12606
32
- // Image cache forced refresh for Android by appending
33
- // the `ts` query parameter as DDMMYYYY to simulate a 24h TTL.
34
- const androidIdpLogoForcedRefreshed = () =>
35
- Platform.OS === "android" ? `?ts=${toAndroidCacheTimestamp()}` : "";
36
-
37
31
  export const ModuleIDP = ({
38
32
  name,
39
33
  localLogo,
@@ -47,11 +41,8 @@ export const ModuleIDP = ({
47
41
  const { isExperimental } = useIOExperimentalDesign();
48
42
 
49
43
  // eslint-disable-next-line no-console
50
- const urlLogoIDP = localLogo
51
- ? localLogo
52
- : {
53
- uri: `${logo}${androidIdpLogoForcedRefreshed()}`
54
- };
44
+ const urlLogoIDP = localLogo ? localLogo : addCacheTimestampToUri(logo);
45
+
55
46
  return (
56
47
  <PressableModuleBase
57
48
  onPress={onPress}
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import { GestureResponderEvent, StyleSheet, View } from "react-native";
3
3
  import Placeholder from "rn-placeholder";
4
4
  import { IOListItemVisualParams, IOSpacer, useIOTheme } from "../../core";
5
- import { getAccessibleAmountText } from "../../utils/accessibility";
6
5
  import { WithTestID } from "../../utils/types";
7
6
  import { Badge } from "../badge";
8
7
  import { Icon } from "../icons";
@@ -29,13 +28,19 @@ export type ModulePaymentNoticeProps = WithTestID<
29
28
  onPress: (event: GestureResponderEvent) => void;
30
29
  } & (
31
30
  | {
32
- paymentNoticeStatus: Extract<PaymentNoticeStatus, "default">;
33
- paymentNoticeAmount: string;
31
+ paymentNotice: {
32
+ status: Extract<PaymentNoticeStatus, "default">;
33
+ amount: string;
34
+ amountAccessibilityLabel: string;
35
+ };
34
36
  badgeText?: never;
35
37
  }
36
38
  | {
37
- paymentNoticeStatus: Exclude<PaymentNoticeStatus, "default">;
38
- paymentNoticeAmount?: never;
39
+ paymentNotice: {
40
+ status: Exclude<PaymentNoticeStatus, "default">;
41
+ amount?: string;
42
+ amountAccessibilityLabel?: string;
43
+ };
39
44
  badgeText: string;
40
45
  }
41
46
  )
@@ -52,22 +57,21 @@ const styles = StyleSheet.create({
52
57
  const ModulePaymentNoticeContent = ({
53
58
  title,
54
59
  subtitle,
55
- paymentNoticeStatus,
56
- paymentNoticeAmount,
60
+ paymentNotice: { status, amount, amountAccessibilityLabel },
57
61
  badgeText = ""
58
62
  }: Omit<ModulePaymentNoticeProps, "isLoading" | "onPress" | "testID">) => {
59
63
  const theme = useIOTheme();
60
64
 
61
65
  const AmountOrBadgeComponent = () => {
62
- switch (paymentNoticeStatus) {
66
+ switch (status) {
63
67
  case "default":
64
68
  return (
65
69
  <H6
66
- accessibilityLabel={getAccessibleAmountText(paymentNoticeAmount)}
70
+ accessibilityLabel={amountAccessibilityLabel}
67
71
  color={theme["interactiveElem-default"]}
68
72
  numberOfLines={1}
69
73
  >
70
- {paymentNoticeAmount}
74
+ {amount}
71
75
  </H6>
72
76
  );
73
77
  case "paid":
@@ -1,5 +1,3 @@
1
- import * as O from "fp-ts/lib/Option";
2
- import { pipe } from "fp-ts/lib/function";
3
1
  import React from "react";
4
2
  import { Platform, StyleSheet, View } from "react-native";
5
3
  import {
@@ -148,23 +146,16 @@ export const Tag = ({
148
146
 
149
147
  return (
150
148
  <View testID={testID} style={styles.tag}>
151
- {pipe(
152
- variantProps,
153
- O.fromNullable,
154
- O.fold(
155
- () => null,
156
- ({ iconColor, iconName }) => (
157
- <View style={styles.iconWrapper}>
158
- <Icon
159
- name={iconName}
160
- color={iconColor}
161
- size={IOTagIconSize}
162
- accessible={!!iconAccessibilityLabel}
163
- accessibilityLabel={iconAccessibilityLabel}
164
- />
165
- </View>
166
- )
167
- )
149
+ {variantProps && (
150
+ <View style={styles.iconWrapper}>
151
+ <Icon
152
+ name={variantProps.iconName}
153
+ color={variantProps.iconColor}
154
+ size={IOTagIconSize}
155
+ accessible={!!iconAccessibilityLabel}
156
+ accessibilityLabel={iconAccessibilityLabel}
157
+ />
158
+ </View>
168
159
  )}
169
160
  {variantProps && text && <View style={styles.spacer} />}
170
161
  {text && (
@@ -1,4 +1,3 @@
1
- import { constVoid } from "fp-ts/function";
2
1
  import React from "react";
3
2
 
4
3
  type IOExperimentalContextType = {
@@ -11,7 +10,7 @@ type IOExperimentalContextType = {
11
10
  export const IOExperimentalDesignContext =
12
11
  React.createContext<IOExperimentalContextType>({
13
12
  isExperimental: false,
14
- setExperimental: constVoid
13
+ setExperimental: () => void 0
15
14
  });
16
15
 
17
16
  export const useIOExperimentalDesign = () =>
@@ -1,4 +1,3 @@
1
- import { constVoid } from "fp-ts/function";
2
1
  import React, { useMemo } from "react";
3
2
  import { Appearance } from "react-native";
4
3
  import {
@@ -24,7 +23,7 @@ export const IOThemeContext: React.Context<IOThemeContextType> =
24
23
  themeType: Appearance.getColorScheme() === "dark" ? "dark" : "light",
25
24
  theme:
26
25
  Appearance.getColorScheme() === "dark" ? IOThemes.dark : IOThemes.light,
27
- setTheme: constVoid
26
+ setTheme: () => void 0
28
27
  });
29
28
 
30
29
  export const useIOThemeContext = () => React.useContext(IOThemeContext);
@@ -1,23 +1,6 @@
1
- import { pipe } from "fp-ts/lib/function";
2
- import * as O from "fp-ts/lib/Option";
3
- import I18n from "i18n-js";
4
1
  import { useEffect, useState } from "react";
5
2
  import { AccessibilityInfo, Platform } from "react-native";
6
3
 
7
- /**
8
- * This function is used to get the text that will be read by the screen reader
9
- * with the correct minus symbol pronunciation.
10
- */
11
- export const getAccessibleAmountText = (amount?: string) =>
12
- pipe(
13
- amount,
14
- O.fromNullable,
15
- O.map(amount =>
16
- amount.replace("-", I18n.t("global.accessibility.minusSymbol"))
17
- ),
18
- O.getOrElseW(() => undefined)
19
- );
20
-
21
4
  /**
22
5
  * Query whether a bold text is currently enabled. The result is true
23
6
  * when bold text is enabled and false otherwise.
@@ -1,9 +1,4 @@
1
- import { pipe } from "fp-ts/lib/function";
2
- import { ImageURISource, Platform } from "react-native";
3
- import * as B from "fp-ts/boolean";
4
- import * as T from "io-ts";
5
- import * as E from "fp-ts/Either";
6
- import { toAndroidCacheTimestamp } from "./dates";
1
+ import { ImageSourcePropType, Platform } from "react-native";
7
2
 
8
3
  /**
9
4
  * Adds a locale timestamp to the image URI to invalidate cache on the following day if the current platform is Android.
@@ -12,27 +7,32 @@ import { toAndroidCacheTimestamp } from "./dates";
12
7
  * @returns a new source with a modified URI which includes the actual timestamp in the locale format without slashes
13
8
  * if the platform is Android and the source contains an URI. The same source otherwise.
14
9
  */
15
- export const addCacheTimestampToUri = (source: ImageURISource) => {
16
- const UriSource = T.type({
17
- uri: T.string
18
- });
10
+ export const addCacheTimestampToUri = (source: ImageSourcePropType) => {
11
+ // If the platform is not Android, return the source as is
12
+ if (Platform.OS !== "android") {
13
+ return source;
14
+ }
19
15
 
20
- return pipe(
21
- Platform.OS === "android",
22
- B.fold(
23
- () => source,
24
- () =>
25
- pipe(
26
- source,
27
- UriSource.decode,
28
- E.fold(
29
- () => source,
30
- () => ({
31
- ...source,
32
- uri: `${source.uri}?ts=${toAndroidCacheTimestamp()}`
33
- })
34
- )
35
- )
36
- )
37
- );
16
+ // If the source is a number, it's a local image return as is
17
+ if (typeof source === "number") {
18
+ return source;
19
+ }
20
+
21
+ // This invalidates the cache on the following day
22
+ const cacheBurstParam = new Date()
23
+ .toISOString()
24
+ .split("T")[0]
25
+ .replace(/-/g, "");
26
+
27
+ if (Array.isArray(source)) {
28
+ return source.map(image =>
29
+ image.uri
30
+ ? { ...image, uri: `${image.uri}?ts=${cacheBurstParam}` }
31
+ : image
32
+ );
33
+ } else {
34
+ return source.uri
35
+ ? { ...source, uri: `${source.uri}?ts=${cacheBurstParam}` }
36
+ : source;
37
+ }
38
38
  };
@@ -1,12 +1,13 @@
1
- import * as A from "fp-ts/Array";
2
- import * as O from "fp-ts/Option";
3
- import { pipe } from "fp-ts/lib/function";
4
-
5
- export const findFirstCaseInsensitive =
6
- <T>(obj: { [key: string]: T }) =>
7
- (key: string): O.Option<[string, T]> =>
8
- pipe(
9
- obj,
10
- Object.entries,
11
- A.findFirst(([k, _]) => k.toLowerCase() === key.toLowerCase())
12
- );
1
+ // Function to find the first case-insensitive logo
2
+ export const findFirstCaseInsensitive = <T>(
3
+ obj: { [key: string]: T },
4
+ key: string
5
+ ) => {
6
+ const lowerKey = key.toLowerCase();
7
+ for (const [k] of Object.entries(obj)) {
8
+ if (k.toLowerCase() === lowerKey) {
9
+ return k;
10
+ }
11
+ }
12
+ return null;
13
+ };
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.toAndroidCacheTimestamp = exports.localeDateFormat = void 0;
7
- var _i18nJs = _interopRequireDefault(require("i18n-js"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- const localeDateFormat = (date, format) => isNaN(date.getTime()) ? _i18nJs.default.t("global.date.invalid") : _i18nJs.default.strftime(date, format);
10
-
11
- /**
12
- * Generates a locale formatted timestamp,
13
- * used to force the refresh of the Image component cache for Android devices
14
- * every 24 hours.
15
- * @returns the actual locale date short format without slashes.
16
- */
17
- exports.localeDateFormat = localeDateFormat;
18
- const toAndroidCacheTimestamp = () => localeDateFormat(new Date(), _i18nJs.default.t("global.dateFormats.shortFormat").replace(/\//g, ""));
19
- exports.toAndroidCacheTimestamp = toAndroidCacheTimestamp;
20
- //# sourceMappingURL=dates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_i18nJs","_interopRequireDefault","require","obj","__esModule","default","localeDateFormat","date","format","isNaN","getTime","I18n","t","strftime","exports","toAndroidCacheTimestamp","Date","replace"],"sourceRoot":"../../../src","sources":["utils/dates.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2B,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEpB,MAAMG,gBAAgB,GAAGA,CAACC,IAAU,EAAEC,MAAc,KACzDC,KAAK,CAACF,IAAI,CAACG,OAAO,CAAC,CAAC,CAAC,GACjBC,eAAI,CAACC,CAAC,CAAC,qBAAqB,CAAC,GAC7BD,eAAI,CAACE,QAAQ,CAACN,IAAI,EAAEC,MAAM,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AALAM,OAAA,CAAAR,gBAAA,GAAAA,gBAAA;AAMO,MAAMS,uBAAuB,GAAGA,CAAA,KACrCT,gBAAgB,CACd,IAAIU,IAAI,CAAC,CAAC,EACVL,eAAI,CAACC,CAAC,CAAC,gCAAgC,CAAC,CAACK,OAAO,CAAC,KAAK,EAAE,EAAE,CAC5D,CAAC;AAACH,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
@@ -1,11 +0,0 @@
1
- import I18n from "i18n-js";
2
- export const localeDateFormat = (date, format) => isNaN(date.getTime()) ? I18n.t("global.date.invalid") : I18n.strftime(date, format);
3
-
4
- /**
5
- * Generates a locale formatted timestamp,
6
- * used to force the refresh of the Image component cache for Android devices
7
- * every 24 hours.
8
- * @returns the actual locale date short format without slashes.
9
- */
10
- export const toAndroidCacheTimestamp = () => localeDateFormat(new Date(), I18n.t("global.dateFormats.shortFormat").replace(/\//g, ""));
11
- //# sourceMappingURL=dates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["I18n","localeDateFormat","date","format","isNaN","getTime","t","strftime","toAndroidCacheTimestamp","Date","replace"],"sourceRoot":"../../../src","sources":["utils/dates.ts"],"mappings":"AAAA,OAAOA,IAAI,MAAM,SAAS;AAE1B,OAAO,MAAMC,gBAAgB,GAAGA,CAACC,IAAU,EAAEC,MAAc,KACzDC,KAAK,CAACF,IAAI,CAACG,OAAO,CAAC,CAAC,CAAC,GACjBL,IAAI,CAACM,CAAC,CAAC,qBAAqB,CAAC,GAC7BN,IAAI,CAACO,QAAQ,CAACL,IAAI,EAAEC,MAAM,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMK,uBAAuB,GAAGA,CAAA,KACrCP,gBAAgB,CACd,IAAIQ,IAAI,CAAC,CAAC,EACVT,IAAI,CAACM,CAAC,CAAC,gCAAgC,CAAC,CAACI,OAAO,CAAC,KAAK,EAAE,EAAE,CAC5D,CAAC"}
@@ -1,9 +0,0 @@
1
- export declare const localeDateFormat: (date: Date, format: string) => string;
2
- /**
3
- * Generates a locale formatted timestamp,
4
- * used to force the refresh of the Image component cache for Android devices
5
- * every 24 hours.
6
- * @returns the actual locale date short format without slashes.
7
- */
8
- export declare const toAndroidCacheTimestamp: () => string;
9
- //# sourceMappingURL=dates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../../../src/utils/dates.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,SAAU,IAAI,UAAU,MAAM,KAAG,MAG7B,CAAC;AAElC;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,cAIjC,CAAC"}
@@ -1,18 +0,0 @@
1
- import I18n from "i18n-js";
2
-
3
- export const localeDateFormat = (date: Date, format: string): string =>
4
- isNaN(date.getTime())
5
- ? I18n.t("global.date.invalid")
6
- : I18n.strftime(date, format);
7
-
8
- /**
9
- * Generates a locale formatted timestamp,
10
- * used to force the refresh of the Image component cache for Android devices
11
- * every 24 hours.
12
- * @returns the actual locale date short format without slashes.
13
- */
14
- export const toAndroidCacheTimestamp = () =>
15
- localeDateFormat(
16
- new Date(),
17
- I18n.t("global.dateFormats.shortFormat").replace(/\//g, "")
18
- );