@pagopa/io-app-design-system 3.1.0 → 4.0.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 (278) hide show
  1. package/lib/commonjs/components/alert/Alert.js +1 -2
  2. package/lib/commonjs/components/alert/Alert.js.map +1 -1
  3. package/lib/commonjs/components/alert/AlertEdgeToEdge.js +2 -2
  4. package/lib/commonjs/components/alert/AlertEdgeToEdge.js.map +1 -1
  5. package/lib/commonjs/components/badge/Badge.js +95 -14
  6. package/lib/commonjs/components/badge/Badge.js.map +1 -1
  7. package/lib/commonjs/components/banner/Banner.js +1 -1
  8. package/lib/commonjs/components/banner/Banner.js.map +1 -1
  9. package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +2 -2
  10. package/lib/commonjs/components/buttons/ButtonLink.js +1 -1
  11. package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
  12. package/lib/commonjs/components/buttons/ButtonOutline.js +1 -1
  13. package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
  14. package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +3 -3
  15. package/lib/commonjs/components/featureInfo/FeatureInfo.js +3 -2
  16. package/lib/commonjs/components/featureInfo/FeatureInfo.js.map +1 -1
  17. package/lib/commonjs/components/layout/HeaderFirstLevel.js +1 -0
  18. package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -1
  19. package/lib/commonjs/components/listitems/ListItemCheckbox.js +1 -1
  20. package/lib/commonjs/components/listitems/ListItemCheckbox.js.map +1 -1
  21. package/lib/commonjs/components/listitems/ListItemInfo.js +1 -1
  22. package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
  23. package/lib/commonjs/components/listitems/ListItemInfoCopy.js +1 -1
  24. package/lib/commonjs/components/listitems/ListItemInfoCopy.js.map +1 -1
  25. package/lib/commonjs/components/listitems/ListItemNav.js +1 -1
  26. package/lib/commonjs/components/listitems/ListItemNav.js.map +1 -1
  27. package/lib/commonjs/components/listitems/ListItemNavAlert.js +1 -1
  28. package/lib/commonjs/components/listitems/ListItemNavAlert.js.map +1 -1
  29. package/lib/commonjs/components/listitems/ListItemRadio.js +1 -1
  30. package/lib/commonjs/components/listitems/ListItemRadio.js.map +1 -1
  31. package/lib/commonjs/components/listitems/ListItemRadioWithAmount.js +2 -2
  32. package/lib/commonjs/components/listitems/ListItemRadioWithAmount.js.map +1 -1
  33. package/lib/commonjs/components/listitems/ListItemSwitch.js +1 -1
  34. package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -1
  35. package/lib/commonjs/components/listitems/ListItemTransaction.js +2 -2
  36. package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
  37. package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +7 -7
  38. package/lib/commonjs/components/modules/ModuleAttachment.js +1 -1
  39. package/lib/commonjs/components/modules/ModuleAttachment.js.map +1 -1
  40. package/lib/commonjs/components/modules/ModuleCheckout.js +1 -1
  41. package/lib/commonjs/components/modules/ModuleCheckout.js.map +1 -1
  42. package/lib/commonjs/components/modules/ModuleCredential.js +1 -1
  43. package/lib/commonjs/components/modules/ModuleCredential.js.map +1 -1
  44. package/lib/commonjs/components/modules/ModuleNavigation.js +3 -2
  45. package/lib/commonjs/components/modules/ModuleNavigation.js.map +1 -1
  46. package/lib/commonjs/components/modules/ModulePaymentNotice.js +2 -2
  47. package/lib/commonjs/components/modules/ModulePaymentNotice.js.map +1 -1
  48. package/lib/commonjs/components/modules/ModuleSummary.js +1 -1
  49. package/lib/commonjs/components/modules/ModuleSummary.js.map +1 -1
  50. package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
  51. package/lib/commonjs/components/otpInput/BoxedInput.js +4 -6
  52. package/lib/commonjs/components/otpInput/BoxedInput.js.map +1 -1
  53. package/lib/commonjs/components/otpInput/OTPInput.js +5 -4
  54. package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
  55. package/lib/commonjs/components/stack/Stack.js +2 -2
  56. package/lib/commonjs/components/stack/Stack.js.map +1 -1
  57. package/lib/commonjs/components/tabs/TabItem.js +1 -1
  58. package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
  59. package/lib/commonjs/components/tag/Tag.js +40 -26
  60. package/lib/commonjs/components/tag/Tag.js.map +1 -1
  61. package/lib/commonjs/components/textInput/TextInputBase.js +2 -2
  62. package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
  63. package/lib/commonjs/components/typography/{LabelSmall.js → BodySmall.js} +8 -10
  64. package/lib/commonjs/components/typography/BodySmall.js.map +1 -0
  65. package/lib/commonjs/components/typography/ButtonText.js +1 -3
  66. package/lib/commonjs/components/typography/ButtonText.js.map +1 -1
  67. package/lib/commonjs/components/typography/H3.js +3 -6
  68. package/lib/commonjs/components/typography/H3.js.map +1 -1
  69. package/lib/commonjs/components/typography/H6.js +4 -5
  70. package/lib/commonjs/components/typography/H6.js.map +1 -1
  71. package/lib/commonjs/components/typography/IOText.js.map +1 -1
  72. package/lib/commonjs/components/typography/__test__/__snapshots__/typography.test.tsx.snap +118 -161
  73. package/lib/commonjs/components/typography/__test__/typography.test.js +6 -18
  74. package/lib/commonjs/components/typography/__test__/typography.test.js.map +1 -1
  75. package/lib/commonjs/components/typography/index.js +28 -72
  76. package/lib/commonjs/components/typography/index.js.map +1 -1
  77. package/lib/commonjs/core/IOColors.js +9 -1
  78. package/lib/commonjs/core/IOColors.js.map +1 -1
  79. package/lib/commonjs/utils/fonts.js.map +1 -1
  80. package/lib/module/components/alert/Alert.js +2 -3
  81. package/lib/module/components/alert/Alert.js.map +1 -1
  82. package/lib/module/components/alert/AlertEdgeToEdge.js +2 -2
  83. package/lib/module/components/alert/AlertEdgeToEdge.js.map +1 -1
  84. package/lib/module/components/badge/Badge.js +96 -15
  85. package/lib/module/components/badge/Badge.js.map +1 -1
  86. package/lib/module/components/banner/Banner.js +2 -2
  87. package/lib/module/components/banner/Banner.js.map +1 -1
  88. package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +2 -2
  89. package/lib/module/components/buttons/ButtonLink.js +1 -1
  90. package/lib/module/components/buttons/ButtonLink.js.map +1 -1
  91. package/lib/module/components/buttons/ButtonOutline.js +1 -1
  92. package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
  93. package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +3 -3
  94. package/lib/module/components/featureInfo/FeatureInfo.js +4 -3
  95. package/lib/module/components/featureInfo/FeatureInfo.js.map +1 -1
  96. package/lib/module/components/layout/HeaderFirstLevel.js +1 -0
  97. package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -1
  98. package/lib/module/components/listitems/ListItemCheckbox.js +2 -2
  99. package/lib/module/components/listitems/ListItemCheckbox.js.map +1 -1
  100. package/lib/module/components/listitems/ListItemInfo.js +2 -2
  101. package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
  102. package/lib/module/components/listitems/ListItemInfoCopy.js +2 -2
  103. package/lib/module/components/listitems/ListItemInfoCopy.js.map +1 -1
  104. package/lib/module/components/listitems/ListItemNav.js +2 -2
  105. package/lib/module/components/listitems/ListItemNav.js.map +1 -1
  106. package/lib/module/components/listitems/ListItemNavAlert.js +2 -2
  107. package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
  108. package/lib/module/components/listitems/ListItemRadio.js +2 -2
  109. package/lib/module/components/listitems/ListItemRadio.js.map +1 -1
  110. package/lib/module/components/listitems/ListItemRadioWithAmount.js +3 -3
  111. package/lib/module/components/listitems/ListItemRadioWithAmount.js.map +1 -1
  112. package/lib/module/components/listitems/ListItemSwitch.js +2 -2
  113. package/lib/module/components/listitems/ListItemSwitch.js.map +1 -1
  114. package/lib/module/components/listitems/ListItemTransaction.js +3 -3
  115. package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
  116. package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +7 -7
  117. package/lib/module/components/modules/ModuleAttachment.js +2 -2
  118. package/lib/module/components/modules/ModuleAttachment.js.map +1 -1
  119. package/lib/module/components/modules/ModuleCheckout.js +2 -2
  120. package/lib/module/components/modules/ModuleCheckout.js.map +1 -1
  121. package/lib/module/components/modules/ModuleCredential.js +2 -2
  122. package/lib/module/components/modules/ModuleCredential.js.map +1 -1
  123. package/lib/module/components/modules/ModuleNavigation.js +4 -3
  124. package/lib/module/components/modules/ModuleNavigation.js.map +1 -1
  125. package/lib/module/components/modules/ModulePaymentNotice.js +3 -3
  126. package/lib/module/components/modules/ModulePaymentNotice.js.map +1 -1
  127. package/lib/module/components/modules/ModuleSummary.js +2 -2
  128. package/lib/module/components/modules/ModuleSummary.js.map +1 -1
  129. package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
  130. package/lib/module/components/otpInput/BoxedInput.js +5 -7
  131. package/lib/module/components/otpInput/BoxedInput.js.map +1 -1
  132. package/lib/module/components/otpInput/OTPInput.js +5 -4
  133. package/lib/module/components/otpInput/OTPInput.js.map +1 -1
  134. package/lib/module/components/stack/Stack.js +2 -2
  135. package/lib/module/components/stack/Stack.js.map +1 -1
  136. package/lib/module/components/tabs/TabItem.js +2 -2
  137. package/lib/module/components/tabs/TabItem.js.map +1 -1
  138. package/lib/module/components/tag/Tag.js +41 -27
  139. package/lib/module/components/tag/Tag.js.map +1 -1
  140. package/lib/module/components/textInput/TextInputBase.js +3 -3
  141. package/lib/module/components/textInput/TextInputBase.js.map +1 -1
  142. package/lib/module/components/typography/{LabelSmall.js → BodySmall.js} +6 -8
  143. package/lib/module/components/typography/BodySmall.js.map +1 -0
  144. package/lib/module/components/typography/ButtonText.js +1 -3
  145. package/lib/module/components/typography/ButtonText.js.map +1 -1
  146. package/lib/module/components/typography/H3.js +3 -6
  147. package/lib/module/components/typography/H3.js.map +1 -1
  148. package/lib/module/components/typography/H6.js +4 -5
  149. package/lib/module/components/typography/H6.js.map +1 -1
  150. package/lib/module/components/typography/IOText.js.map +1 -1
  151. package/lib/module/components/typography/__test__/__snapshots__/typography.test.tsx.snap +118 -161
  152. package/lib/module/components/typography/__test__/typography.test.js +6 -18
  153. package/lib/module/components/typography/__test__/typography.test.js.map +1 -1
  154. package/lib/module/components/typography/index.js +6 -10
  155. package/lib/module/components/typography/index.js.map +1 -1
  156. package/lib/module/core/IOColors.js +9 -1
  157. package/lib/module/core/IOColors.js.map +1 -1
  158. package/lib/module/utils/fonts.js.map +1 -1
  159. package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
  160. package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
  161. package/lib/typescript/components/banner/Banner.d.ts +1 -1
  162. package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
  163. package/lib/typescript/components/featureInfo/FeatureInfo.d.ts.map +1 -1
  164. package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -1
  165. package/lib/typescript/components/listitems/ListItemSwitch.d.ts.map +1 -1
  166. package/lib/typescript/components/modules/ModuleNavigation.d.ts.map +1 -1
  167. package/lib/typescript/components/otpInput/BoxedInput.d.ts.map +1 -1
  168. package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
  169. package/lib/typescript/components/tag/Tag.d.ts +13 -8
  170. package/lib/typescript/components/tag/Tag.d.ts.map +1 -1
  171. package/lib/typescript/components/typography/Body.d.ts +1 -1
  172. package/lib/typescript/components/typography/Body.d.ts.map +1 -1
  173. package/lib/typescript/components/typography/BodyMonospace.d.ts +1 -1
  174. package/lib/typescript/components/typography/BodySmall.d.ts +13 -0
  175. package/lib/typescript/components/typography/BodySmall.d.ts.map +1 -0
  176. package/lib/typescript/components/typography/ButtonText.d.ts +1 -1
  177. package/lib/typescript/components/typography/ButtonText.d.ts.map +1 -1
  178. package/lib/typescript/components/typography/Caption.d.ts +1 -1
  179. package/lib/typescript/components/typography/H1.d.ts +1 -1
  180. package/lib/typescript/components/typography/H2.d.ts +1 -1
  181. package/lib/typescript/components/typography/H3.d.ts +3 -1
  182. package/lib/typescript/components/typography/H3.d.ts.map +1 -1
  183. package/lib/typescript/components/typography/H4.d.ts +1 -1
  184. package/lib/typescript/components/typography/H5.d.ts +1 -1
  185. package/lib/typescript/components/typography/H6.d.ts +1 -1
  186. package/lib/typescript/components/typography/H6.d.ts.map +1 -1
  187. package/lib/typescript/components/typography/Hero.d.ts +1 -1
  188. package/lib/typescript/components/typography/IOText.d.ts +2 -2
  189. package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
  190. package/lib/typescript/components/typography/LabelMini.d.ts +1 -1
  191. package/lib/typescript/components/typography/LabelMini.d.ts.map +1 -1
  192. package/lib/typescript/components/typography/index.d.ts +6 -10
  193. package/lib/typescript/components/typography/index.d.ts.map +1 -1
  194. package/lib/typescript/components/typography/markdown/MdH1.d.ts +1 -1
  195. package/lib/typescript/components/typography/markdown/MdH2.d.ts +1 -1
  196. package/lib/typescript/components/typography/markdown/MdH3.d.ts +1 -1
  197. package/lib/typescript/core/IOColors.d.ts +2 -1
  198. package/lib/typescript/core/IOColors.d.ts.map +1 -1
  199. package/lib/typescript/utils/fonts.d.ts +3 -3
  200. package/lib/typescript/utils/fonts.d.ts.map +1 -1
  201. package/package.json +1 -1
  202. package/src/components/alert/Alert.tsx +3 -4
  203. package/src/components/alert/AlertEdgeToEdge.tsx +3 -3
  204. package/src/components/badge/Badge.tsx +109 -19
  205. package/src/components/banner/Banner.tsx +7 -5
  206. package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +2 -2
  207. package/src/components/buttons/ButtonLink.tsx +1 -1
  208. package/src/components/buttons/ButtonOutline.tsx +1 -1
  209. package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +3 -3
  210. package/src/components/featureInfo/FeatureInfo.tsx +6 -6
  211. package/src/components/layout/HeaderFirstLevel.tsx +1 -0
  212. package/src/components/listitems/ListItemCheckbox.tsx +3 -3
  213. package/src/components/listitems/ListItemInfo.tsx +3 -3
  214. package/src/components/listitems/ListItemInfoCopy.tsx +3 -3
  215. package/src/components/listitems/ListItemNav.tsx +3 -3
  216. package/src/components/listitems/ListItemNavAlert.tsx +3 -3
  217. package/src/components/listitems/ListItemRadio.tsx +3 -3
  218. package/src/components/listitems/ListItemRadioWithAmount.tsx +5 -5
  219. package/src/components/listitems/ListItemSwitch.tsx +4 -4
  220. package/src/components/listitems/ListItemTransaction.tsx +5 -5
  221. package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +7 -7
  222. package/src/components/modules/ModuleAttachment.tsx +3 -3
  223. package/src/components/modules/ModuleCheckout.tsx +3 -3
  224. package/src/components/modules/ModuleCredential.tsx +3 -3
  225. package/src/components/modules/ModuleNavigation.tsx +6 -4
  226. package/src/components/modules/ModulePaymentNotice.tsx +5 -5
  227. package/src/components/modules/ModuleSummary.tsx +3 -3
  228. package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
  229. package/src/components/otpInput/BoxedInput.tsx +6 -5
  230. package/src/components/otpInput/OTPInput.tsx +23 -8
  231. package/src/components/stack/Stack.tsx +2 -2
  232. package/src/components/tabs/TabItem.tsx +3 -3
  233. package/src/components/tag/Tag.tsx +66 -33
  234. package/src/components/textInput/TextInputBase.tsx +5 -5
  235. package/src/components/typography/Body.tsx +1 -1
  236. package/src/components/typography/{LabelSmall.tsx → BodySmall.tsx} +7 -14
  237. package/src/components/typography/ButtonText.tsx +2 -4
  238. package/src/components/typography/H3.tsx +11 -8
  239. package/src/components/typography/H6.tsx +5 -6
  240. package/src/components/typography/IOText.tsx +1 -2
  241. package/src/components/typography/LabelMini.tsx +1 -1
  242. package/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +118 -161
  243. package/src/components/typography/__test__/typography.test.tsx +8 -24
  244. package/src/components/typography/index.tsx +6 -10
  245. package/src/core/IOColors.ts +11 -0
  246. package/src/utils/fonts.ts +2 -2
  247. package/lib/commonjs/components/typography/BaseTypography.js +0 -52
  248. package/lib/commonjs/components/typography/BaseTypography.js.map +0 -1
  249. package/lib/commonjs/components/typography/Chip.js +0 -41
  250. package/lib/commonjs/components/typography/Chip.js.map +0 -1
  251. package/lib/commonjs/components/typography/Factory.js +0 -62
  252. package/lib/commonjs/components/typography/Factory.js.map +0 -1
  253. package/lib/commonjs/components/typography/Label.js +0 -51
  254. package/lib/commonjs/components/typography/Label.js.map +0 -1
  255. package/lib/commonjs/components/typography/LabelSmall.js.map +0 -1
  256. package/lib/module/components/typography/BaseTypography.js +0 -44
  257. package/lib/module/components/typography/BaseTypography.js.map +0 -1
  258. package/lib/module/components/typography/Chip.js +0 -32
  259. package/lib/module/components/typography/Chip.js.map +0 -1
  260. package/lib/module/components/typography/Factory.js +0 -55
  261. package/lib/module/components/typography/Factory.js.map +0 -1
  262. package/lib/module/components/typography/Label.js +0 -42
  263. package/lib/module/components/typography/Label.js.map +0 -1
  264. package/lib/module/components/typography/LabelSmall.js.map +0 -1
  265. package/lib/typescript/components/typography/BaseTypography.d.ts +0 -29
  266. package/lib/typescript/components/typography/BaseTypography.d.ts.map +0 -1
  267. package/lib/typescript/components/typography/Chip.d.ts +0 -13
  268. package/lib/typescript/components/typography/Chip.d.ts.map +0 -1
  269. package/lib/typescript/components/typography/Factory.d.ts +0 -43
  270. package/lib/typescript/components/typography/Factory.d.ts.map +0 -1
  271. package/lib/typescript/components/typography/Label.d.ts +0 -13
  272. package/lib/typescript/components/typography/Label.d.ts.map +0 -1
  273. package/lib/typescript/components/typography/LabelSmall.d.ts +0 -13
  274. package/lib/typescript/components/typography/LabelSmall.d.ts.map +0 -1
  275. package/src/components/typography/BaseTypography.tsx +0 -71
  276. package/src/components/typography/Chip.tsx +0 -33
  277. package/src/components/typography/Factory.tsx +0 -98
  278. package/src/components/typography/Label.tsx +0 -62
@@ -1,98 +0,0 @@
1
- import React, { useMemo } from "react";
2
- import { View } from "react-native";
3
- import { IOColors } from "../../core";
4
- import { IOFontWeight } from "../../utils/fonts";
5
- import { XOR } from "../../utils/types";
6
- import { BaseTypography } from "./BaseTypography";
7
- import {
8
- calculateWeightColor,
9
- RequiredTypographyProps,
10
- TypographyProps
11
- } from "./common";
12
-
13
- /**
14
- * Using the DefaultArgumentProps is possible to define a default fallback value for weight and color
15
- * that will be used when the fields weight and color will be undefined.
16
- */
17
- type DefaultArgumentProps<WeightPropsType, ColorsPropsType> = {
18
- defaultWeight: WeightPropsType;
19
- defaultColor: ColorsPropsType;
20
- };
21
-
22
- /**
23
- * Using the DefaultFactoryProps is possible to define a custom factory to calculate the default value for
24
- * weight and color, thus allowing to implement more sophisticated strategies.
25
- */
26
- type DefaultFactoryProps<WeightPropsType, ColorsPropsType> = {
27
- weightColorFactory: (
28
- weight?: WeightPropsType,
29
- color?: ColorsPropsType
30
- ) => RequiredTypographyProps<WeightPropsType, ColorsPropsType>;
31
- };
32
-
33
- /**
34
- * Only one type of default props strategy is allowed
35
- */
36
- type DefaultProps<WeightPropsType, ColorsPropsType> = XOR<
37
- DefaultArgumentProps<WeightPropsType, ColorsPropsType>,
38
- DefaultFactoryProps<WeightPropsType, ColorsPropsType>
39
- >;
40
-
41
- /**
42
- * The factory props will include:
43
- * - One of the two DefaultProps
44
- * - The props of {@link BaseTypographyProps} without weight and color
45
- * - The default {@link TypographyProps}
46
- */
47
- type FactoryProps<WeightPropsType, ColorsPropsType> = TypographyProps<
48
- WeightPropsType,
49
- ColorsPropsType
50
- > &
51
- DefaultProps<WeightPropsType, ColorsPropsType> &
52
- Omit<React.ComponentProps<typeof BaseTypography>, "weight" | "color">;
53
-
54
- /**
55
- * Calculate if the props is of type {@link DefaultFactoryProps}
56
- * @param props
57
- */
58
- function isDefaultFactoryProps<WeightPropsType, ColorsPropsType>(
59
- props:
60
- | DefaultFactoryProps<WeightPropsType, ColorsPropsType>
61
- | DefaultArgumentProps<WeightPropsType, ColorsPropsType>
62
- ): props is DefaultFactoryProps<WeightPropsType, ColorsPropsType> {
63
- return (
64
- (props as DefaultFactoryProps<WeightPropsType, ColorsPropsType>)
65
- .weightColorFactory !== undefined
66
- );
67
- }
68
-
69
- /**
70
- * Build a {@link BaseTypography} component, calculating the default values for weight and color if undefined.
71
- * The default values can be calculated specifying some fallback values using {@link DefaultArgumentProps}
72
- * or with a factory function to define some custom behaviour using {@link DefaultFactoryProps}
73
- * @param props
74
- * @deprecated Use `IOText` instead. Or use the new typographic styles that use it.
75
- */
76
- export function useTypographyFactory<
77
- WeightPropsType extends IOFontWeight,
78
- ColorsPropsType extends IOColors
79
- >(
80
- props: FactoryProps<WeightPropsType, ColorsPropsType>,
81
- ref?: React.ForwardedRef<View>
82
- ) {
83
- // Use different strategy to calculate the default values, based on DefaultProps
84
- const { weight, color } = useMemo(
85
- () =>
86
- isDefaultFactoryProps(props)
87
- ? props.weightColorFactory(props.weight, props.color)
88
- : calculateWeightColor(
89
- props.defaultWeight,
90
- props.defaultColor,
91
- props.weight,
92
- props.color
93
- ),
94
- [props]
95
- );
96
-
97
- return <BaseTypography weight={weight} color={color} {...props} ref={ref} />;
98
- }
@@ -1,62 +0,0 @@
1
- import React, { ForwardedRef, forwardRef } from "react";
2
- import { View } from "react-native";
3
- import { useIOExperimentalDesign, useIOTheme } from "../../core";
4
- import { IOFontFamily, IOFontWeight } from "../../utils/fonts";
5
- import {
6
- IOText,
7
- IOTextProps,
8
- TypographicStyleAsLinkProps,
9
- TypographicStyleProps
10
- } from "./IOText";
11
-
12
- type LabelProps = TypographicStyleProps & {
13
- weight?: Extract<IOFontWeight, "Regular" | "Semibold" | "Bold">;
14
- } & TypographicStyleAsLinkProps;
15
-
16
- const fontName: IOFontFamily = "Titillio";
17
- const fontWeight: IOFontWeight = "Semibold";
18
-
19
- const legacyFontName: IOFontFamily = "TitilliumSansPro";
20
- const legacyFontWeight: IOFontWeight = "Semibold";
21
-
22
- /**
23
- * `LabelSmall` typographic style
24
- */
25
- export const Label = forwardRef<View, LabelProps>(
26
- (
27
- { weight: customWeight, color: customColor, asLink, ...props },
28
- ref?: ForwardedRef<View>
29
- ) => {
30
- const theme = useIOTheme();
31
- const { isExperimental } = useIOExperimentalDesign();
32
-
33
- const defaultColor = asLink
34
- ? theme["interactiveElem-default"]
35
- : theme["textBody-tertiary"];
36
-
37
- const LabelProps: IOTextProps = {
38
- ...props,
39
- font: isExperimental ? fontName : legacyFontName,
40
- weight: customWeight
41
- ? customWeight
42
- : isExperimental
43
- ? fontWeight
44
- : legacyFontWeight,
45
- size: 16,
46
- lineHeight: 24,
47
- color: customColor ?? defaultColor,
48
- ...(asLink
49
- ? {
50
- accessibilityRole: "link",
51
- textStyle: { textDecorationLine: "underline" }
52
- }
53
- : {})
54
- };
55
-
56
- return (
57
- <IOText ref={ref} {...LabelProps}>
58
- {props.children}
59
- </IOText>
60
- );
61
- }
62
- );