@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.
- package/lib/commonjs/components/alert/Alert.js +1 -2
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/alert/AlertEdgeToEdge.js +2 -2
- package/lib/commonjs/components/alert/AlertEdgeToEdge.js.map +1 -1
- package/lib/commonjs/components/badge/Badge.js +95 -14
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/banner/Banner.js +1 -1
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +2 -2
- package/lib/commonjs/components/buttons/ButtonLink.js +1 -1
- package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +3 -3
- package/lib/commonjs/components/featureInfo/FeatureInfo.js +3 -2
- package/lib/commonjs/components/featureInfo/FeatureInfo.js.map +1 -1
- package/lib/commonjs/components/layout/HeaderFirstLevel.js +1 -0
- package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemCheckbox.js +1 -1
- package/lib/commonjs/components/listitems/ListItemCheckbox.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemInfo.js +1 -1
- package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemInfoCopy.js +1 -1
- package/lib/commonjs/components/listitems/ListItemInfoCopy.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemNav.js +1 -1
- package/lib/commonjs/components/listitems/ListItemNav.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemRadio.js +1 -1
- package/lib/commonjs/components/listitems/ListItemRadio.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemRadioWithAmount.js +2 -2
- package/lib/commonjs/components/listitems/ListItemRadioWithAmount.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemSwitch.js +1 -1
- package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js +2 -2
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +7 -7
- package/lib/commonjs/components/modules/ModuleAttachment.js +1 -1
- package/lib/commonjs/components/modules/ModuleAttachment.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleCheckout.js +1 -1
- package/lib/commonjs/components/modules/ModuleCheckout.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleCredential.js +1 -1
- package/lib/commonjs/components/modules/ModuleCredential.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleNavigation.js +3 -2
- package/lib/commonjs/components/modules/ModuleNavigation.js.map +1 -1
- package/lib/commonjs/components/modules/ModulePaymentNotice.js +2 -2
- package/lib/commonjs/components/modules/ModulePaymentNotice.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleSummary.js +1 -1
- package/lib/commonjs/components/modules/ModuleSummary.js.map +1 -1
- package/lib/commonjs/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
- package/lib/commonjs/components/otpInput/BoxedInput.js +4 -6
- package/lib/commonjs/components/otpInput/BoxedInput.js.map +1 -1
- package/lib/commonjs/components/otpInput/OTPInput.js +5 -4
- package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
- package/lib/commonjs/components/stack/Stack.js +2 -2
- package/lib/commonjs/components/stack/Stack.js.map +1 -1
- package/lib/commonjs/components/tabs/TabItem.js +1 -1
- package/lib/commonjs/components/tabs/TabItem.js.map +1 -1
- package/lib/commonjs/components/tag/Tag.js +40 -26
- package/lib/commonjs/components/tag/Tag.js.map +1 -1
- package/lib/commonjs/components/textInput/TextInputBase.js +2 -2
- package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -1
- package/lib/commonjs/components/typography/{LabelSmall.js → BodySmall.js} +8 -10
- package/lib/commonjs/components/typography/BodySmall.js.map +1 -0
- package/lib/commonjs/components/typography/ButtonText.js +1 -3
- package/lib/commonjs/components/typography/ButtonText.js.map +1 -1
- package/lib/commonjs/components/typography/H3.js +3 -6
- package/lib/commonjs/components/typography/H3.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/IOText.js.map +1 -1
- package/lib/commonjs/components/typography/__test__/__snapshots__/typography.test.tsx.snap +118 -161
- package/lib/commonjs/components/typography/__test__/typography.test.js +6 -18
- package/lib/commonjs/components/typography/__test__/typography.test.js.map +1 -1
- package/lib/commonjs/components/typography/index.js +28 -72
- package/lib/commonjs/components/typography/index.js.map +1 -1
- package/lib/commonjs/core/IOColors.js +9 -1
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/commonjs/utils/fonts.js.map +1 -1
- package/lib/module/components/alert/Alert.js +2 -3
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/alert/AlertEdgeToEdge.js +2 -2
- package/lib/module/components/alert/AlertEdgeToEdge.js.map +1 -1
- package/lib/module/components/badge/Badge.js +96 -15
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/banner/Banner.js +2 -2
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +2 -2
- package/lib/module/components/buttons/ButtonLink.js +1 -1
- package/lib/module/components/buttons/ButtonLink.js.map +1 -1
- package/lib/module/components/buttons/ButtonOutline.js +1 -1
- package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +3 -3
- package/lib/module/components/featureInfo/FeatureInfo.js +4 -3
- package/lib/module/components/featureInfo/FeatureInfo.js.map +1 -1
- package/lib/module/components/layout/HeaderFirstLevel.js +1 -0
- package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -1
- package/lib/module/components/listitems/ListItemCheckbox.js +2 -2
- package/lib/module/components/listitems/ListItemCheckbox.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfo.js +2 -2
- package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfoCopy.js +2 -2
- package/lib/module/components/listitems/ListItemInfoCopy.js.map +1 -1
- package/lib/module/components/listitems/ListItemNav.js +2 -2
- package/lib/module/components/listitems/ListItemNav.js.map +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js +2 -2
- package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/module/components/listitems/ListItemRadio.js +2 -2
- package/lib/module/components/listitems/ListItemRadio.js.map +1 -1
- package/lib/module/components/listitems/ListItemRadioWithAmount.js +3 -3
- package/lib/module/components/listitems/ListItemRadioWithAmount.js.map +1 -1
- package/lib/module/components/listitems/ListItemSwitch.js +2 -2
- package/lib/module/components/listitems/ListItemSwitch.js.map +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js +3 -3
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +7 -7
- package/lib/module/components/modules/ModuleAttachment.js +2 -2
- package/lib/module/components/modules/ModuleAttachment.js.map +1 -1
- package/lib/module/components/modules/ModuleCheckout.js +2 -2
- package/lib/module/components/modules/ModuleCheckout.js.map +1 -1
- package/lib/module/components/modules/ModuleCredential.js +2 -2
- package/lib/module/components/modules/ModuleCredential.js.map +1 -1
- package/lib/module/components/modules/ModuleNavigation.js +4 -3
- package/lib/module/components/modules/ModuleNavigation.js.map +1 -1
- package/lib/module/components/modules/ModulePaymentNotice.js +3 -3
- package/lib/module/components/modules/ModulePaymentNotice.js.map +1 -1
- package/lib/module/components/modules/ModuleSummary.js +2 -2
- package/lib/module/components/modules/ModuleSummary.js.map +1 -1
- package/lib/module/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
- package/lib/module/components/otpInput/BoxedInput.js +5 -7
- package/lib/module/components/otpInput/BoxedInput.js.map +1 -1
- package/lib/module/components/otpInput/OTPInput.js +5 -4
- package/lib/module/components/otpInput/OTPInput.js.map +1 -1
- package/lib/module/components/stack/Stack.js +2 -2
- package/lib/module/components/stack/Stack.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +2 -2
- package/lib/module/components/tabs/TabItem.js.map +1 -1
- package/lib/module/components/tag/Tag.js +41 -27
- package/lib/module/components/tag/Tag.js.map +1 -1
- package/lib/module/components/textInput/TextInputBase.js +3 -3
- package/lib/module/components/textInput/TextInputBase.js.map +1 -1
- package/lib/module/components/typography/{LabelSmall.js → BodySmall.js} +6 -8
- package/lib/module/components/typography/BodySmall.js.map +1 -0
- package/lib/module/components/typography/ButtonText.js +1 -3
- package/lib/module/components/typography/ButtonText.js.map +1 -1
- package/lib/module/components/typography/H3.js +3 -6
- package/lib/module/components/typography/H3.js.map +1 -1
- package/lib/module/components/typography/H6.js +4 -5
- package/lib/module/components/typography/H6.js.map +1 -1
- package/lib/module/components/typography/IOText.js.map +1 -1
- package/lib/module/components/typography/__test__/__snapshots__/typography.test.tsx.snap +118 -161
- package/lib/module/components/typography/__test__/typography.test.js +6 -18
- package/lib/module/components/typography/__test__/typography.test.js.map +1 -1
- package/lib/module/components/typography/index.js +6 -10
- package/lib/module/components/typography/index.js.map +1 -1
- package/lib/module/core/IOColors.js +9 -1
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/module/utils/fonts.js.map +1 -1
- package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
- package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts +1 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/featureInfo/FeatureInfo.d.ts.map +1 -1
- package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemSwitch.d.ts.map +1 -1
- package/lib/typescript/components/modules/ModuleNavigation.d.ts.map +1 -1
- package/lib/typescript/components/otpInput/BoxedInput.d.ts.map +1 -1
- package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
- package/lib/typescript/components/tag/Tag.d.ts +13 -8
- package/lib/typescript/components/tag/Tag.d.ts.map +1 -1
- package/lib/typescript/components/typography/Body.d.ts +1 -1
- package/lib/typescript/components/typography/Body.d.ts.map +1 -1
- package/lib/typescript/components/typography/BodyMonospace.d.ts +1 -1
- package/lib/typescript/components/typography/BodySmall.d.ts +13 -0
- package/lib/typescript/components/typography/BodySmall.d.ts.map +1 -0
- package/lib/typescript/components/typography/ButtonText.d.ts +1 -1
- package/lib/typescript/components/typography/ButtonText.d.ts.map +1 -1
- package/lib/typescript/components/typography/Caption.d.ts +1 -1
- package/lib/typescript/components/typography/H1.d.ts +1 -1
- package/lib/typescript/components/typography/H2.d.ts +1 -1
- package/lib/typescript/components/typography/H3.d.ts +3 -1
- package/lib/typescript/components/typography/H3.d.ts.map +1 -1
- package/lib/typescript/components/typography/H4.d.ts +1 -1
- package/lib/typescript/components/typography/H5.d.ts +1 -1
- package/lib/typescript/components/typography/H6.d.ts +1 -1
- package/lib/typescript/components/typography/H6.d.ts.map +1 -1
- package/lib/typescript/components/typography/Hero.d.ts +1 -1
- package/lib/typescript/components/typography/IOText.d.ts +2 -2
- package/lib/typescript/components/typography/IOText.d.ts.map +1 -1
- package/lib/typescript/components/typography/LabelMini.d.ts +1 -1
- package/lib/typescript/components/typography/LabelMini.d.ts.map +1 -1
- package/lib/typescript/components/typography/index.d.ts +6 -10
- package/lib/typescript/components/typography/index.d.ts.map +1 -1
- package/lib/typescript/components/typography/markdown/MdH1.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH2.d.ts +1 -1
- package/lib/typescript/components/typography/markdown/MdH3.d.ts +1 -1
- package/lib/typescript/core/IOColors.d.ts +2 -1
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/lib/typescript/utils/fonts.d.ts +3 -3
- package/lib/typescript/utils/fonts.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/alert/Alert.tsx +3 -4
- package/src/components/alert/AlertEdgeToEdge.tsx +3 -3
- package/src/components/badge/Badge.tsx +109 -19
- package/src/components/banner/Banner.tsx +7 -5
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +2 -2
- package/src/components/buttons/ButtonLink.tsx +1 -1
- package/src/components/buttons/ButtonOutline.tsx +1 -1
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +3 -3
- package/src/components/featureInfo/FeatureInfo.tsx +6 -6
- package/src/components/layout/HeaderFirstLevel.tsx +1 -0
- package/src/components/listitems/ListItemCheckbox.tsx +3 -3
- package/src/components/listitems/ListItemInfo.tsx +3 -3
- package/src/components/listitems/ListItemInfoCopy.tsx +3 -3
- package/src/components/listitems/ListItemNav.tsx +3 -3
- package/src/components/listitems/ListItemNavAlert.tsx +3 -3
- package/src/components/listitems/ListItemRadio.tsx +3 -3
- package/src/components/listitems/ListItemRadioWithAmount.tsx +5 -5
- package/src/components/listitems/ListItemSwitch.tsx +4 -4
- package/src/components/listitems/ListItemTransaction.tsx +5 -5
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +7 -7
- package/src/components/modules/ModuleAttachment.tsx +3 -3
- package/src/components/modules/ModuleCheckout.tsx +3 -3
- package/src/components/modules/ModuleCredential.tsx +3 -3
- package/src/components/modules/ModuleNavigation.tsx +6 -4
- package/src/components/modules/ModulePaymentNotice.tsx +5 -5
- package/src/components/modules/ModuleSummary.tsx +3 -3
- package/src/components/numberpad/__test__/__snapshots__/NumberPad.test.tsx.snap +1 -1
- package/src/components/otpInput/BoxedInput.tsx +6 -5
- package/src/components/otpInput/OTPInput.tsx +23 -8
- package/src/components/stack/Stack.tsx +2 -2
- package/src/components/tabs/TabItem.tsx +3 -3
- package/src/components/tag/Tag.tsx +66 -33
- package/src/components/textInput/TextInputBase.tsx +5 -5
- package/src/components/typography/Body.tsx +1 -1
- package/src/components/typography/{LabelSmall.tsx → BodySmall.tsx} +7 -14
- package/src/components/typography/ButtonText.tsx +2 -4
- package/src/components/typography/H3.tsx +11 -8
- package/src/components/typography/H6.tsx +5 -6
- package/src/components/typography/IOText.tsx +1 -2
- package/src/components/typography/LabelMini.tsx +1 -1
- package/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +118 -161
- package/src/components/typography/__test__/typography.test.tsx +8 -24
- package/src/components/typography/index.tsx +6 -10
- package/src/core/IOColors.ts +11 -0
- package/src/utils/fonts.ts +2 -2
- package/lib/commonjs/components/typography/BaseTypography.js +0 -52
- package/lib/commonjs/components/typography/BaseTypography.js.map +0 -1
- package/lib/commonjs/components/typography/Chip.js +0 -41
- package/lib/commonjs/components/typography/Chip.js.map +0 -1
- package/lib/commonjs/components/typography/Factory.js +0 -62
- package/lib/commonjs/components/typography/Factory.js.map +0 -1
- package/lib/commonjs/components/typography/Label.js +0 -51
- package/lib/commonjs/components/typography/Label.js.map +0 -1
- package/lib/commonjs/components/typography/LabelSmall.js.map +0 -1
- package/lib/module/components/typography/BaseTypography.js +0 -44
- package/lib/module/components/typography/BaseTypography.js.map +0 -1
- package/lib/module/components/typography/Chip.js +0 -32
- package/lib/module/components/typography/Chip.js.map +0 -1
- package/lib/module/components/typography/Factory.js +0 -55
- package/lib/module/components/typography/Factory.js.map +0 -1
- package/lib/module/components/typography/Label.js +0 -42
- package/lib/module/components/typography/Label.js.map +0 -1
- package/lib/module/components/typography/LabelSmall.js.map +0 -1
- package/lib/typescript/components/typography/BaseTypography.d.ts +0 -29
- package/lib/typescript/components/typography/BaseTypography.d.ts.map +0 -1
- package/lib/typescript/components/typography/Chip.d.ts +0 -13
- package/lib/typescript/components/typography/Chip.d.ts.map +0 -1
- package/lib/typescript/components/typography/Factory.d.ts +0 -43
- package/lib/typescript/components/typography/Factory.d.ts.map +0 -1
- package/lib/typescript/components/typography/Label.d.ts +0 -13
- package/lib/typescript/components/typography/Label.d.ts.map +0 -1
- package/lib/typescript/components/typography/LabelSmall.d.ts +0 -13
- package/lib/typescript/components/typography/LabelSmall.d.ts.map +0 -1
- package/src/components/typography/BaseTypography.tsx +0 -71
- package/src/components/typography/Chip.tsx +0 -33
- package/src/components/typography/Factory.tsx +0 -98
- 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
|
-
);
|