@pagopa/io-app-design-system 1.3.2 → 1.5.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/README.md +11 -0
- package/lib/commonjs/components/accordion/AccordionItem.js +137 -0
- package/lib/commonjs/components/accordion/AccordionItem.js.map +1 -0
- package/lib/commonjs/components/accordion/index.js +4 -4
- package/lib/commonjs/components/accordion/index.js.map +1 -1
- package/lib/commonjs/components/alert/Alert.js +1 -1
- package/lib/commonjs/components/alert/Alert.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/buttons/ButtonExtendedOutline.js +1 -1
- package/lib/commonjs/components/buttons/ButtonExtendedOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonLink.js +6 -6
- package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +10 -10
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +5 -5
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButton.js +4 -4
- package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonContained.js +4 -4
- package/lib/commonjs/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonSolid.js +5 -5
- package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/commonjs/components/common/LogoPaymentWithFallback.js +49 -0
- package/lib/commonjs/components/common/LogoPaymentWithFallback.js.map +1 -0
- package/lib/commonjs/components/index.js +22 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/layout/BlockButtons.js +82 -0
- package/lib/commonjs/components/layout/BlockButtons.js.map +1 -0
- package/lib/commonjs/components/layout/FooterWithButtons.js +41 -0
- package/lib/commonjs/components/layout/FooterWithButtons.js.map +1 -0
- package/lib/commonjs/components/layout/index.js +11 -0
- package/lib/commonjs/components/layout/index.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemAction.js +1 -1
- package/lib/commonjs/components/listitems/ListItemAction.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/ListItemIDP.js +1 -1
- package/lib/commonjs/components/listitems/ListItemIDP.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/ListItemTransaction.js +47 -29
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/hooks/useListItemSpringAnimation.js +1 -1
- package/lib/commonjs/components/listitems/hooks/useListItemSpringAnimation.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/tabs/TabNavigation.js +2 -2
- package/lib/commonjs/components/tabs/TabNavigation.js.map +1 -1
- package/lib/commonjs/components/{accordion/IOAccordion.js → textInput/TextInput.js} +5 -27
- package/lib/commonjs/components/textInput/TextInput.js.map +1 -0
- package/lib/commonjs/components/textInput/TextInputBase.js +233 -0
- package/lib/commonjs/components/textInput/TextInputBase.js.map +1 -0
- package/lib/commonjs/components/textInput/TextInputPassword.js +36 -0
- package/lib/commonjs/components/textInput/TextInputPassword.js.map +1 -0
- package/lib/commonjs/components/textInput/TextInputValidation.js +57 -0
- package/lib/commonjs/components/textInput/TextInputValidation.js.map +1 -0
- package/lib/commonjs/components/textInput/index.js +39 -0
- package/lib/commonjs/components/textInput/index.js.map +1 -0
- package/lib/commonjs/core/IOAnimations.js +5 -0
- package/lib/commonjs/core/IOAnimations.js.map +1 -1
- package/lib/commonjs/core/IOShapes.js +3 -1
- package/lib/commonjs/core/IOShapes.js.map +1 -1
- package/lib/commonjs/stories/ButtonDS.stories.js +34 -0
- package/lib/commonjs/stories/ButtonDS.stories.js.map +1 -0
- package/lib/commonjs/stories/H1.stories.js +33 -0
- package/lib/commonjs/stories/H1.stories.js.map +1 -0
- package/lib/commonjs/stories/H2.stories.js +33 -0
- package/lib/commonjs/stories/H2.stories.js.map +1 -0
- package/lib/commonjs/stories/H3.stories.js +33 -0
- package/lib/commonjs/stories/H3.stories.js.map +1 -0
- package/lib/commonjs/stories/H4.stories.js +33 -0
- package/lib/commonjs/stories/H4.stories.js.map +1 -0
- package/lib/commonjs/stories/H5.stories.js +33 -0
- package/lib/commonjs/stories/H5.stories.js.map +1 -0
- package/lib/commonjs/stories/H6.stories.js +33 -0
- package/lib/commonjs/stories/H6.stories.js.map +1 -0
- package/lib/commonjs/stories/Label.stories.js +33 -0
- package/lib/commonjs/stories/Label.stories.js.map +1 -0
- package/lib/commonjs/stories/LabelSmall.stories.js +33 -0
- package/lib/commonjs/stories/LabelSmall.stories.js.map +1 -0
- package/lib/commonjs/stories/Link.stories.js +33 -0
- package/lib/commonjs/stories/Link.stories.js.map +1 -0
- package/lib/commonjs/stories/Monospace.stories.js +33 -0
- package/lib/commonjs/stories/Monospace.stories.js.map +1 -0
- package/lib/commonjs/utils/accessibility.js +19 -0
- package/lib/commonjs/utils/accessibility.js.map +1 -0
- package/lib/commonjs/utils/fonts.js +13 -4
- package/lib/commonjs/utils/fonts.js.map +1 -1
- package/lib/commonjs/utils/object.js +16 -0
- package/lib/commonjs/utils/object.js.map +1 -0
- package/lib/commonjs/utils/textInput/index.js +24 -0
- package/lib/commonjs/utils/textInput/index.js.map +1 -0
- package/lib/commonjs/utils/url.js +14 -0
- package/lib/commonjs/utils/url.js.map +1 -0
- package/lib/module/components/accordion/AccordionItem.js +126 -0
- package/lib/module/components/accordion/AccordionItem.js.map +1 -0
- package/lib/module/components/accordion/index.js +1 -1
- package/lib/module/components/accordion/index.js.map +1 -1
- package/lib/module/components/alert/Alert.js +1 -1
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/banner/Banner.js +1 -1
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/buttons/ButtonExtendedOutline.js +1 -1
- package/lib/module/components/buttons/ButtonExtendedOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonLink.js +6 -6
- package/lib/module/components/buttons/ButtonLink.js.map +1 -1
- package/lib/module/components/buttons/ButtonOutline.js +10 -10
- package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonSolid.js +5 -5
- package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/IconButton.js +4 -4
- package/lib/module/components/buttons/IconButton.js.map +1 -1
- package/lib/module/components/buttons/IconButtonContained.js +4 -4
- package/lib/module/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/module/components/buttons/IconButtonSolid.js +5 -5
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/module/components/common/LogoPaymentWithFallback.js +40 -0
- package/lib/module/components/common/LogoPaymentWithFallback.js.map +1 -0
- package/lib/module/components/index.js +2 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/layout/BlockButtons.js +73 -0
- package/lib/module/components/layout/BlockButtons.js.map +1 -0
- package/lib/module/components/layout/FooterWithButtons.js +32 -0
- package/lib/module/components/layout/FooterWithButtons.js.map +1 -0
- package/lib/module/components/layout/index.js +1 -0
- package/lib/module/components/layout/index.js.map +1 -1
- package/lib/module/components/listitems/ListItemAction.js +1 -1
- package/lib/module/components/listitems/ListItemAction.js.map +1 -1
- package/lib/module/components/listitems/ListItemCheckbox.js +1 -1
- package/lib/module/components/listitems/ListItemCheckbox.js.map +1 -1
- package/lib/module/components/listitems/ListItemIDP.js +1 -1
- package/lib/module/components/listitems/ListItemIDP.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfoCopy.js +1 -1
- package/lib/module/components/listitems/ListItemInfoCopy.js.map +1 -1
- package/lib/module/components/listitems/ListItemNav.js +1 -1
- package/lib/module/components/listitems/ListItemNav.js.map +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/module/components/listitems/ListItemRadio.js +1 -1
- package/lib/module/components/listitems/ListItemRadio.js.map +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js +48 -30
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/hooks/useListItemSpringAnimation.js +1 -1
- package/lib/module/components/listitems/hooks/useListItemSpringAnimation.js.map +1 -1
- package/lib/module/components/tabs/TabItem.js +1 -1
- package/lib/module/components/tabs/TabItem.js.map +1 -1
- package/lib/module/components/tabs/TabNavigation.js +2 -2
- package/lib/module/components/tabs/TabNavigation.js.map +1 -1
- package/lib/module/components/textInput/TextInput.js +4 -0
- package/lib/module/components/textInput/TextInput.js.map +1 -0
- package/lib/module/components/textInput/TextInputBase.js +225 -0
- package/lib/module/components/textInput/TextInputBase.js.map +1 -0
- package/lib/module/components/textInput/TextInputPassword.js +27 -0
- package/lib/module/components/textInput/TextInputPassword.js.map +1 -0
- package/lib/module/components/textInput/TextInputValidation.js +47 -0
- package/lib/module/components/textInput/TextInputValidation.js.map +1 -0
- package/lib/module/components/textInput/index.js +4 -0
- package/lib/module/components/textInput/index.js.map +1 -0
- package/lib/module/core/IOAnimations.js +5 -0
- package/lib/module/core/IOAnimations.js.map +1 -1
- package/lib/module/core/IOShapes.js +1 -0
- package/lib/module/core/IOShapes.js.map +1 -1
- package/lib/module/stories/ButtonDS.stories.js +27 -0
- package/lib/module/stories/ButtonDS.stories.js.map +1 -0
- package/lib/module/stories/H1.stories.js +26 -0
- package/lib/module/stories/H1.stories.js.map +1 -0
- package/lib/module/stories/H2.stories.js +26 -0
- package/lib/module/stories/H2.stories.js.map +1 -0
- package/lib/module/stories/H3.stories.js +26 -0
- package/lib/module/stories/H3.stories.js.map +1 -0
- package/lib/module/stories/H4.stories.js +26 -0
- package/lib/module/stories/H4.stories.js.map +1 -0
- package/lib/module/stories/H5.stories.js +26 -0
- package/lib/module/stories/H5.stories.js.map +1 -0
- package/lib/module/stories/H6.stories.js +26 -0
- package/lib/module/stories/H6.stories.js.map +1 -0
- package/lib/module/stories/Label.stories.js +26 -0
- package/lib/module/stories/Label.stories.js.map +1 -0
- package/lib/module/stories/LabelSmall.stories.js +26 -0
- package/lib/module/stories/LabelSmall.stories.js.map +1 -0
- package/lib/module/stories/Link.stories.js +26 -0
- package/lib/module/stories/Link.stories.js.map +1 -0
- package/lib/module/stories/Monospace.stories.js +26 -0
- package/lib/module/stories/Monospace.stories.js.map +1 -0
- package/lib/module/utils/accessibility.js +10 -0
- package/lib/module/utils/accessibility.js.map +1 -0
- package/lib/module/utils/fonts.js +13 -4
- package/lib/module/utils/fonts.js.map +1 -1
- package/lib/module/utils/object.js +7 -0
- package/lib/module/utils/object.js.map +1 -0
- package/lib/module/utils/textInput/index.js +17 -0
- package/lib/module/utils/textInput/index.js.map +1 -0
- package/lib/module/utils/url.js +7 -0
- package/lib/module/utils/url.js.map +1 -0
- package/lib/typescript/components/accordion/AccordionItem.d.ts +14 -0
- package/lib/typescript/components/accordion/AccordionItem.d.ts.map +1 -0
- package/lib/typescript/components/accordion/index.d.ts +1 -1
- package/lib/typescript/components/accordion/index.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonSolid.d.ts +16 -0
- package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +1 -1
- package/lib/typescript/components/common/LogoPaymentWithFallback.d.ts +27 -0
- package/lib/typescript/components/common/LogoPaymentWithFallback.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +2 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/layout/BlockButtons.d.ts +53 -0
- package/lib/typescript/components/layout/BlockButtons.d.ts.map +1 -0
- package/lib/typescript/components/layout/FooterWithButtons.d.ts +9 -0
- package/lib/typescript/components/layout/FooterWithButtons.d.ts.map +1 -0
- package/lib/typescript/components/layout/index.d.ts +1 -0
- package/lib/typescript/components/layout/index.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts +13 -5
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
- package/lib/typescript/components/textInput/TextInput.d.ts +6 -0
- package/lib/typescript/components/textInput/TextInput.d.ts.map +1 -0
- package/lib/typescript/components/textInput/TextInputBase.d.ts +28 -0
- package/lib/typescript/components/textInput/TextInputBase.d.ts.map +1 -0
- package/lib/typescript/components/textInput/TextInputPassword.d.ts +6 -0
- package/lib/typescript/components/textInput/TextInputPassword.d.ts.map +1 -0
- package/lib/typescript/components/textInput/TextInputValidation.d.ts +9 -0
- package/lib/typescript/components/textInput/TextInputValidation.d.ts.map +1 -0
- package/lib/typescript/components/textInput/index.d.ts +4 -0
- package/lib/typescript/components/textInput/index.d.ts.map +1 -0
- package/lib/typescript/core/IOAnimations.d.ts +5 -0
- package/lib/typescript/core/IOAnimations.d.ts.map +1 -1
- package/lib/typescript/core/IOShapes.d.ts +1 -0
- package/lib/typescript/core/IOShapes.d.ts.map +1 -1
- package/lib/typescript/stories/ButtonDS.stories.d.ts +14 -0
- package/lib/typescript/stories/ButtonDS.stories.d.ts.map +1 -0
- package/lib/typescript/stories/H1.stories.d.ts +19 -0
- package/lib/typescript/stories/H1.stories.d.ts.map +1 -0
- package/lib/typescript/stories/H2.stories.d.ts +19 -0
- package/lib/typescript/stories/H2.stories.d.ts.map +1 -0
- package/lib/typescript/stories/H3.stories.d.ts +19 -0
- package/lib/typescript/stories/H3.stories.d.ts.map +1 -0
- package/lib/typescript/stories/H4.stories.d.ts +19 -0
- package/lib/typescript/stories/H4.stories.d.ts.map +1 -0
- package/lib/typescript/stories/H5.stories.d.ts +27 -0
- package/lib/typescript/stories/H5.stories.d.ts.map +1 -0
- package/lib/typescript/stories/H6.stories.d.ts +19 -0
- package/lib/typescript/stories/H6.stories.d.ts.map +1 -0
- package/lib/typescript/stories/Label.stories.d.ts +19 -0
- package/lib/typescript/stories/Label.stories.d.ts.map +1 -0
- package/lib/typescript/stories/LabelSmall.stories.d.ts +21 -0
- package/lib/typescript/stories/LabelSmall.stories.d.ts.map +1 -0
- package/lib/typescript/stories/Link.stories.d.ts +21 -0
- package/lib/typescript/stories/Link.stories.d.ts.map +1 -0
- package/lib/typescript/stories/Monospace.stories.d.ts +19 -0
- package/lib/typescript/stories/Monospace.stories.d.ts.map +1 -0
- package/lib/typescript/utils/accessibility.d.ts +6 -0
- package/lib/typescript/utils/accessibility.d.ts.map +1 -0
- package/lib/typescript/utils/fonts.d.ts.map +1 -1
- package/lib/typescript/utils/object.d.ts +5 -0
- package/lib/typescript/utils/object.d.ts.map +1 -0
- package/lib/typescript/utils/textInput/index.d.ts +9 -0
- package/lib/typescript/utils/textInput/index.d.ts.map +1 -0
- package/lib/typescript/utils/types.d.ts +1 -0
- package/lib/typescript/utils/types.d.ts.map +1 -1
- package/lib/typescript/utils/url.d.ts +8 -0
- package/lib/typescript/utils/url.d.ts.map +1 -0
- package/package.json +25 -4
- package/src/components/accordion/AccordionItem.tsx +165 -0
- package/src/components/accordion/index.tsx +1 -1
- package/src/components/buttons/ButtonSolid.tsx +16 -0
- package/src/components/common/LogoPaymentWithFallback.tsx +60 -0
- package/src/components/index.tsx +2 -0
- package/src/components/layout/BlockButtons.tsx +142 -0
- package/src/components/layout/FooterWithButtons.tsx +37 -0
- package/src/components/layout/index.tsx +1 -0
- package/src/components/listitems/ListItemTransaction.tsx +86 -39
- package/src/components/textInput/TextInput.tsx +15 -0
- package/src/components/textInput/TextInputBase.tsx +327 -0
- package/src/components/textInput/TextInputPassword.tsx +36 -0
- package/src/components/textInput/TextInputValidation.tsx +71 -0
- package/src/components/textInput/index.tsx +3 -0
- package/src/core/IOAnimations.ts +5 -0
- package/src/core/IOShapes.ts +1 -0
- package/src/stories/ButtonDS.stories.ts +31 -0
- package/src/stories/H1.stories.ts +28 -0
- package/src/stories/H2.stories.ts +28 -0
- package/src/stories/H3.stories.ts +28 -0
- package/src/stories/H4.stories.ts +28 -0
- package/src/stories/H5.stories.ts +28 -0
- package/src/stories/H6.stories.ts +28 -0
- package/src/stories/Label.stories.ts +28 -0
- package/src/stories/LabelSmall.stories.ts +28 -0
- package/src/stories/Link.stories.ts +28 -0
- package/src/stories/Monospace.stories.ts +28 -0
- package/src/utils/accessibility.ts +17 -0
- package/src/utils/fonts.ts +12 -5
- package/src/utils/object.ts +12 -0
- package/src/utils/textInput/index.ts +29 -0
- package/src/utils/types.ts +2 -0
- package/src/utils/url.ts +9 -0
- package/lib/commonjs/components/accordion/IOAccordion.js.map +0 -1
- package/lib/module/components/accordion/IOAccordion.js +0 -26
- package/lib/module/components/accordion/IOAccordion.js.map +0 -1
- package/lib/typescript/components/accordion/IOAccordion.d.ts +0 -13
- package/lib/typescript/components/accordion/IOAccordion.d.ts.map +0 -1
- package/src/components/accordion/IOAccordion.tsx +0 -35
|
@@ -3,19 +3,25 @@ import { pipe } from "fp-ts/lib/function";
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { ImageURISource, StyleSheet, View } from "react-native";
|
|
5
5
|
import Placeholder from "rn-placeholder";
|
|
6
|
+
|
|
6
7
|
import {
|
|
7
8
|
IOColors,
|
|
9
|
+
IOListItemLogoMargin,
|
|
8
10
|
IOListItemStyles,
|
|
9
11
|
IOListItemVisualParams,
|
|
10
12
|
IOStyles,
|
|
11
13
|
IOVisualCostants,
|
|
12
14
|
useIOTheme
|
|
13
15
|
} from "../../core";
|
|
16
|
+
|
|
17
|
+
import { LogoPaymentWithFallback } from "../common/LogoPaymentWithFallback";
|
|
18
|
+
import { isImageUri } from "../../utils/url";
|
|
14
19
|
import { WithTestID } from "../../utils/types";
|
|
20
|
+
import { getAccessibleAmountText } from "../../utils/accessibility";
|
|
15
21
|
import { Avatar } from "../avatar/Avatar";
|
|
16
22
|
import { Badge } from "../badge/Badge";
|
|
17
|
-
import { Icon } from "../icons";
|
|
18
|
-
import { IOLogoPaymentType
|
|
23
|
+
import { IOIconSizeScale, Icon } from "../icons";
|
|
24
|
+
import { IOLogoPaymentType } from "../logos";
|
|
19
25
|
import { VSpacer } from "../spacer";
|
|
20
26
|
import { H6, LabelSmall } from "../typography";
|
|
21
27
|
import {
|
|
@@ -23,103 +29,144 @@ import {
|
|
|
23
29
|
PressableListItemBase
|
|
24
30
|
} from "./PressableListItemsBase";
|
|
25
31
|
|
|
26
|
-
type
|
|
32
|
+
export type ListItemTransactionStatus =
|
|
33
|
+
| "success"
|
|
34
|
+
| "failure"
|
|
35
|
+
| "pending"
|
|
36
|
+
| "cancelled"
|
|
37
|
+
| "refunded"
|
|
38
|
+
| "reversal";
|
|
39
|
+
|
|
40
|
+
type PaymentLogoIcon = IOLogoPaymentType | ImageURISource | React.ReactNode;
|
|
41
|
+
|
|
27
42
|
export type ListItemTransaction = WithTestID<
|
|
28
43
|
PressableBaseProps & {
|
|
29
44
|
hasChevronRight?: boolean;
|
|
30
45
|
isLoading?: boolean;
|
|
31
|
-
|
|
46
|
+
/**
|
|
47
|
+
* A logo that will be displayed on the left of the list item.
|
|
48
|
+
*
|
|
49
|
+
* Must be a {@link IOLogoPaymentType} or an {@link ImageURISource} or an {@link Icon}.
|
|
50
|
+
*/
|
|
51
|
+
paymentLogoIcon?: PaymentLogoIcon;
|
|
32
52
|
subtitle: string;
|
|
33
53
|
title: string;
|
|
34
54
|
} & (
|
|
35
55
|
| {
|
|
36
|
-
transactionStatus: "success";
|
|
56
|
+
transactionStatus: "success" | "refunded";
|
|
57
|
+
badgeText?: string;
|
|
37
58
|
transactionAmount: string;
|
|
38
59
|
}
|
|
39
60
|
| {
|
|
40
|
-
transactionStatus: "failure" | "pending";
|
|
61
|
+
transactionStatus: "failure" | "pending" | "cancelled" | "reversal";
|
|
62
|
+
badgeText: string;
|
|
41
63
|
transactionAmount?: string;
|
|
42
64
|
}
|
|
43
65
|
)
|
|
44
66
|
>;
|
|
45
67
|
|
|
46
68
|
type LeftComponentProps = {
|
|
47
|
-
|
|
69
|
+
logoIcon: PaymentLogoIcon;
|
|
48
70
|
};
|
|
49
71
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
const CARD_LOGO_SIZE: IOIconSizeScale = 24;
|
|
73
|
+
const MUNICIPALITY_LOGO_SIZE = 44;
|
|
74
|
+
// this is the <Avatar/>'s "small" size,
|
|
75
|
+
// since it is bigger than the card logos, we use
|
|
76
|
+
// it as a base size for homogeneous sizing via container size.
|
|
54
77
|
|
|
55
|
-
const LeftComponent = ({
|
|
56
|
-
if (
|
|
57
|
-
return <Avatar
|
|
58
|
-
} else {
|
|
59
|
-
return (
|
|
60
|
-
<View
|
|
61
|
-
style={{
|
|
62
|
-
width: IOVisualCostants.avatarSizeSmall,
|
|
63
|
-
height: IOVisualCostants.avatarSizeSmall,
|
|
64
|
-
alignItems: "center",
|
|
65
|
-
justifyContent: "center"
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
<LogoPayment name={logoNameOrUrl} />
|
|
69
|
-
</View>
|
|
70
|
-
);
|
|
78
|
+
const LeftComponent = ({ logoIcon }: LeftComponentProps) => {
|
|
79
|
+
if (isImageUri(logoIcon)) {
|
|
80
|
+
return <Avatar logoUri={[logoIcon]} size="small" shape="circle" />;
|
|
71
81
|
}
|
|
82
|
+
if (React.isValidElement(logoIcon)) {
|
|
83
|
+
return <>{logoIcon}</>;
|
|
84
|
+
}
|
|
85
|
+
return (
|
|
86
|
+
<LogoPaymentWithFallback
|
|
87
|
+
brand={logoIcon as IOLogoPaymentType}
|
|
88
|
+
size={CARD_LOGO_SIZE}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
72
91
|
};
|
|
73
92
|
|
|
74
93
|
export const ListItemTransaction = ({
|
|
75
94
|
accessibilityLabel,
|
|
76
95
|
hasChevronRight = false,
|
|
77
96
|
isLoading = false,
|
|
78
|
-
|
|
97
|
+
paymentLogoIcon,
|
|
79
98
|
onPress,
|
|
80
99
|
subtitle,
|
|
81
100
|
testID,
|
|
82
101
|
title,
|
|
83
102
|
transactionAmount,
|
|
103
|
+
badgeText,
|
|
84
104
|
transactionStatus = "success"
|
|
85
105
|
}: ListItemTransaction) => {
|
|
86
106
|
const theme = useIOTheme();
|
|
87
107
|
|
|
108
|
+
const maybeBadgeText = pipe(
|
|
109
|
+
badgeText,
|
|
110
|
+
O.fromNullable,
|
|
111
|
+
O.getOrElse(() => "-")
|
|
112
|
+
);
|
|
113
|
+
|
|
88
114
|
if (isLoading) {
|
|
89
115
|
return <SkeletonComponent />;
|
|
90
116
|
}
|
|
91
117
|
|
|
92
|
-
const designSystemBlue: IOColors = "
|
|
118
|
+
const designSystemBlue: IOColors = "blueIO-500";
|
|
93
119
|
const ListItemTransactionContent = () => {
|
|
94
120
|
const TransactionAmountOrBadgeComponent = () => {
|
|
95
121
|
switch (transactionStatus) {
|
|
96
122
|
case "success":
|
|
97
123
|
return (
|
|
98
|
-
<H6
|
|
99
|
-
{transactionAmount
|
|
124
|
+
<H6
|
|
125
|
+
accessibilityLabel={getAccessibleAmountText(transactionAmount)}
|
|
126
|
+
color={hasChevronRight ? designSystemBlue : "black"}
|
|
127
|
+
>
|
|
128
|
+
{transactionAmount || ""}
|
|
129
|
+
</H6>
|
|
130
|
+
);
|
|
131
|
+
case "refunded":
|
|
132
|
+
return (
|
|
133
|
+
<H6
|
|
134
|
+
accessibilityLabel={getAccessibleAmountText(transactionAmount)}
|
|
135
|
+
color={hasChevronRight ? designSystemBlue : "success-700"}
|
|
136
|
+
>
|
|
137
|
+
{transactionAmount || ""}
|
|
100
138
|
</H6>
|
|
101
139
|
);
|
|
102
|
-
|
|
103
140
|
case "failure":
|
|
104
|
-
|
|
141
|
+
case "cancelled":
|
|
142
|
+
return <Badge variant="error" text={maybeBadgeText} />;
|
|
143
|
+
case "reversal":
|
|
144
|
+
return <Badge variant="lightBlue" text={maybeBadgeText} />;
|
|
105
145
|
case "pending":
|
|
106
|
-
return <Badge variant="info" text={
|
|
146
|
+
return <Badge variant="info" text={maybeBadgeText} />;
|
|
107
147
|
}
|
|
108
148
|
};
|
|
109
149
|
|
|
110
150
|
return (
|
|
111
151
|
<>
|
|
112
|
-
{
|
|
113
|
-
<View
|
|
114
|
-
|
|
152
|
+
{paymentLogoIcon && (
|
|
153
|
+
<View
|
|
154
|
+
style={{
|
|
155
|
+
marginRight: IOListItemLogoMargin,
|
|
156
|
+
width: MUNICIPALITY_LOGO_SIZE,
|
|
157
|
+
alignItems: "center"
|
|
158
|
+
}}
|
|
159
|
+
>
|
|
160
|
+
<LeftComponent logoIcon={paymentLogoIcon} />
|
|
115
161
|
</View>
|
|
116
162
|
)}
|
|
117
163
|
<View style={IOStyles.flex}>
|
|
118
|
-
<
|
|
164
|
+
<LabelSmall numberOfLines={2} color={theme["textBody-default"]}>
|
|
165
|
+
{title}
|
|
166
|
+
</LabelSmall>
|
|
119
167
|
<LabelSmall weight="Regular" color={theme["textBody-tertiary"]}>
|
|
120
168
|
{subtitle}
|
|
121
169
|
</LabelSmall>
|
|
122
|
-
<VSpacer size={4} />
|
|
123
170
|
</View>
|
|
124
171
|
<View style={Styles.rightSection}>
|
|
125
172
|
<TransactionAmountOrBadgeComponent />
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { TextInputBase } from "./TextInputBase";
|
|
3
|
+
|
|
4
|
+
type TextInputProps = Omit<
|
|
5
|
+
React.ComponentProps<typeof TextInputBase>,
|
|
6
|
+
| "rightElement"
|
|
7
|
+
| "status"
|
|
8
|
+
| "bottomMessageColor"
|
|
9
|
+
| "isPassword"
|
|
10
|
+
| "errorMessage"
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
export const TextInput = (props: TextInputProps) => (
|
|
14
|
+
<TextInputBase {...props} />
|
|
15
|
+
);
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/* eslint-disable functional/immutable-data */
|
|
2
|
+
import {
|
|
3
|
+
Pressable,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
TextInput,
|
|
6
|
+
View,
|
|
7
|
+
ViewStyle
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
10
|
+
import Animated, {
|
|
11
|
+
Easing,
|
|
12
|
+
useAnimatedStyle,
|
|
13
|
+
useSharedValue,
|
|
14
|
+
withTiming
|
|
15
|
+
} from "react-native-reanimated";
|
|
16
|
+
import { IOColors, IOSpacingScale, IOStyles } from "../../core";
|
|
17
|
+
import { IOIcons, Icon } from "../icons";
|
|
18
|
+
import { HSpacer } from "../spacer";
|
|
19
|
+
import { LabelSmall } from "../typography";
|
|
20
|
+
import { InputType } from "../../utils/types";
|
|
21
|
+
import { getInputPropsByType } from "../../utils/textInput";
|
|
22
|
+
import { makeFontStyleObject } from "../../utils/fonts";
|
|
23
|
+
|
|
24
|
+
type InputStatus = "initial" | "focused" | "disabled" | "error";
|
|
25
|
+
|
|
26
|
+
type RNTextInputProps = Pick<
|
|
27
|
+
React.ComponentProps<typeof TextInput>,
|
|
28
|
+
"keyboardType" | "inputMode" | "textContentType" | "autoComplete"
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
type InputTextProps = {
|
|
32
|
+
placeholder: string;
|
|
33
|
+
value: string;
|
|
34
|
+
onChangeText: (value: string) => void;
|
|
35
|
+
accessibilityLabel?: string;
|
|
36
|
+
textInputProps?: RNTextInputProps;
|
|
37
|
+
inputTyoe?: InputType;
|
|
38
|
+
status?: InputStatus;
|
|
39
|
+
icon?: IOIcons;
|
|
40
|
+
rightElement?: React.ReactNode;
|
|
41
|
+
counterLimit?: number;
|
|
42
|
+
bottomMessage?: string;
|
|
43
|
+
bottomMessageColor?: IOColors;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
isPassword?: boolean;
|
|
46
|
+
onBlur?: () => void;
|
|
47
|
+
onFocus?: () => void;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const styles = StyleSheet.create({
|
|
51
|
+
textInput: {
|
|
52
|
+
...IOStyles.row,
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
paddingVertical: 8,
|
|
55
|
+
height: 60,
|
|
56
|
+
borderRadius: 8,
|
|
57
|
+
paddingHorizontal: 12
|
|
58
|
+
},
|
|
59
|
+
textInputStyle: {
|
|
60
|
+
...IOStyles.flex,
|
|
61
|
+
...makeFontStyleObject("Regular", false, "ReadexPro"),
|
|
62
|
+
fontSize: 16,
|
|
63
|
+
marginTop: IOSpacingScale[2],
|
|
64
|
+
lineHeight: 24,
|
|
65
|
+
height: "100%"
|
|
66
|
+
},
|
|
67
|
+
textInputLabelWrapper: {
|
|
68
|
+
position: "absolute",
|
|
69
|
+
paddingHorizontal: 12,
|
|
70
|
+
zIndex: 10,
|
|
71
|
+
bottom: 0,
|
|
72
|
+
top: 0,
|
|
73
|
+
justifyContent: "center"
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
type InputTextHelperRow = Pick<
|
|
78
|
+
InputTextProps,
|
|
79
|
+
"value" | "counterLimit" | "bottomMessage" | "bottomMessageColor"
|
|
80
|
+
>;
|
|
81
|
+
|
|
82
|
+
const HelperRow = ({
|
|
83
|
+
value,
|
|
84
|
+
counterLimit,
|
|
85
|
+
bottomMessage,
|
|
86
|
+
bottomMessageColor = "grey-700"
|
|
87
|
+
}: InputTextHelperRow) => {
|
|
88
|
+
const valueCount = useMemo(() => value.length, [value]);
|
|
89
|
+
|
|
90
|
+
const helperRowStyle: ViewStyle = useMemo(() => {
|
|
91
|
+
if (counterLimit && bottomMessage) {
|
|
92
|
+
return {
|
|
93
|
+
justifyContent: "space-between"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (counterLimit) {
|
|
97
|
+
return {
|
|
98
|
+
justifyContent: "flex-end"
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (bottomMessage) {
|
|
102
|
+
return {
|
|
103
|
+
justifyContent: "flex-start"
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {};
|
|
107
|
+
}, [counterLimit, bottomMessage]);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<View
|
|
111
|
+
style={[
|
|
112
|
+
IOStyles.row,
|
|
113
|
+
{
|
|
114
|
+
alignItems: "center",
|
|
115
|
+
paddingHorizontal: 10
|
|
116
|
+
},
|
|
117
|
+
helperRowStyle
|
|
118
|
+
]}
|
|
119
|
+
>
|
|
120
|
+
{bottomMessage && (
|
|
121
|
+
<LabelSmall weight="Regular" color={bottomMessageColor}>
|
|
122
|
+
{bottomMessage}
|
|
123
|
+
</LabelSmall>
|
|
124
|
+
)}
|
|
125
|
+
{counterLimit && (
|
|
126
|
+
<LabelSmall
|
|
127
|
+
weight="Regular"
|
|
128
|
+
color="grey-700"
|
|
129
|
+
>{`${valueCount} / ${counterLimit}`}</LabelSmall>
|
|
130
|
+
)}
|
|
131
|
+
</View>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const TextInputBase = ({
|
|
136
|
+
disabled = false,
|
|
137
|
+
placeholder,
|
|
138
|
+
value = "",
|
|
139
|
+
onChangeText,
|
|
140
|
+
accessibilityLabel,
|
|
141
|
+
textInputProps,
|
|
142
|
+
inputTyoe = "default",
|
|
143
|
+
status,
|
|
144
|
+
icon,
|
|
145
|
+
rightElement,
|
|
146
|
+
counterLimit,
|
|
147
|
+
bottomMessage,
|
|
148
|
+
bottomMessageColor,
|
|
149
|
+
onBlur,
|
|
150
|
+
onFocus,
|
|
151
|
+
isPassword
|
|
152
|
+
}: InputTextProps) => {
|
|
153
|
+
const labelSharedValue = useSharedValue<boolean>(false);
|
|
154
|
+
const [inputStatus, setInputStatus] = React.useState<InputStatus>(
|
|
155
|
+
disabled ? "disabled" : "initial"
|
|
156
|
+
);
|
|
157
|
+
const isSecretInput = useMemo(() => isPassword, [isPassword]);
|
|
158
|
+
const inputRef = useRef<TextInput>(null);
|
|
159
|
+
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
if (status) {
|
|
162
|
+
setInputStatus(status);
|
|
163
|
+
}
|
|
164
|
+
}, [status]);
|
|
165
|
+
|
|
166
|
+
const boxStyle: ViewStyle = useMemo(() => {
|
|
167
|
+
if (inputStatus === "focused") {
|
|
168
|
+
return {
|
|
169
|
+
borderColor: IOColors["blueIO-500"],
|
|
170
|
+
borderWidth: 2
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (inputStatus === "error") {
|
|
174
|
+
return {
|
|
175
|
+
borderColor: IOColors["error-600"],
|
|
176
|
+
borderWidth: 1
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
borderColor: IOColors["grey-200"],
|
|
181
|
+
borderWidth: 1
|
|
182
|
+
};
|
|
183
|
+
}, [inputStatus]);
|
|
184
|
+
|
|
185
|
+
const animatedLabelProps = useAnimatedStyle(() => ({
|
|
186
|
+
fontSize: withTiming(labelSharedValue.value ? 12 : 16, {
|
|
187
|
+
duration: 300,
|
|
188
|
+
easing: Easing.elastic(0.85)
|
|
189
|
+
}),
|
|
190
|
+
transform: [
|
|
191
|
+
{
|
|
192
|
+
translateY: withTiming(labelSharedValue.value ? -14 : 0, {
|
|
193
|
+
duration: 300,
|
|
194
|
+
easing: Easing.elastic(0.85)
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
}));
|
|
199
|
+
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
if (value.length > 0) {
|
|
202
|
+
labelSharedValue.value = true;
|
|
203
|
+
} else {
|
|
204
|
+
if (inputStatus !== "focused") {
|
|
205
|
+
labelSharedValue.value = false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}, [labelSharedValue, value, inputStatus]);
|
|
209
|
+
|
|
210
|
+
const onTextInputPress = () => {
|
|
211
|
+
if (disabled) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
labelSharedValue.value = true;
|
|
215
|
+
setInputStatus("focused");
|
|
216
|
+
inputRef?.current?.focus();
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const onChangeTextHandler = useCallback(
|
|
220
|
+
(text: string) => {
|
|
221
|
+
if (counterLimit && text.length > counterLimit) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
onChangeText(text);
|
|
225
|
+
},
|
|
226
|
+
[counterLimit, onChangeText]
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
const onBlurHandler = useCallback(() => {
|
|
230
|
+
if (!value) {
|
|
231
|
+
labelSharedValue.value = false;
|
|
232
|
+
}
|
|
233
|
+
onBlur?.();
|
|
234
|
+
setInputStatus("initial");
|
|
235
|
+
}, [value, labelSharedValue, onBlur]);
|
|
236
|
+
|
|
237
|
+
const derivedInputProps = useMemo(
|
|
238
|
+
() => getInputPropsByType(inputTyoe),
|
|
239
|
+
[inputTyoe]
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
const inputValue = useMemo(
|
|
243
|
+
() =>
|
|
244
|
+
derivedInputProps && derivedInputProps.valueFormat
|
|
245
|
+
? derivedInputProps.valueFormat(value)
|
|
246
|
+
: value,
|
|
247
|
+
[value, derivedInputProps]
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<>
|
|
252
|
+
<Pressable
|
|
253
|
+
onPress={onTextInputPress}
|
|
254
|
+
style={[
|
|
255
|
+
inputStatus === "disabled" ? { opacity: 0.5 } : {},
|
|
256
|
+
boxStyle,
|
|
257
|
+
styles.textInput
|
|
258
|
+
]}
|
|
259
|
+
accessible={false}
|
|
260
|
+
accessibilityRole={"none"}
|
|
261
|
+
>
|
|
262
|
+
{icon && (
|
|
263
|
+
<>
|
|
264
|
+
<Icon name={icon} color="grey-300" size={24} />
|
|
265
|
+
<HSpacer size={8} />
|
|
266
|
+
</>
|
|
267
|
+
)}
|
|
268
|
+
<TextInput
|
|
269
|
+
{...(derivedInputProps
|
|
270
|
+
? derivedInputProps.textInputProps
|
|
271
|
+
: textInputProps)}
|
|
272
|
+
accessible
|
|
273
|
+
editable={!disabled}
|
|
274
|
+
secureTextEntry={isSecretInput}
|
|
275
|
+
disableFullscreenUI={true}
|
|
276
|
+
blurOnSubmit={true}
|
|
277
|
+
ref={inputRef}
|
|
278
|
+
accessibilityState={{ disabled }}
|
|
279
|
+
accessibilityLabel={accessibilityLabel ?? placeholder}
|
|
280
|
+
onFocus={() => {
|
|
281
|
+
setInputStatus("focused");
|
|
282
|
+
labelSharedValue.value = true;
|
|
283
|
+
onFocus?.();
|
|
284
|
+
}}
|
|
285
|
+
maxLength={counterLimit}
|
|
286
|
+
onBlur={onBlurHandler}
|
|
287
|
+
value={inputValue}
|
|
288
|
+
onChangeText={onChangeTextHandler}
|
|
289
|
+
style={styles.textInputStyle}
|
|
290
|
+
/>
|
|
291
|
+
{/** Left value is due to the absolute position of the label in order to let it
|
|
292
|
+
* translate to top on focus
|
|
293
|
+
*/}
|
|
294
|
+
<Animated.View
|
|
295
|
+
style={[styles.textInputLabelWrapper, icon ? { left: 32 } : {}]}
|
|
296
|
+
>
|
|
297
|
+
<Animated.Text
|
|
298
|
+
numberOfLines={1}
|
|
299
|
+
accessible={false}
|
|
300
|
+
style={[
|
|
301
|
+
animatedLabelProps,
|
|
302
|
+
{
|
|
303
|
+
color: IOColors["grey-700"]
|
|
304
|
+
}
|
|
305
|
+
]}
|
|
306
|
+
>
|
|
307
|
+
{placeholder}
|
|
308
|
+
</Animated.Text>
|
|
309
|
+
</Animated.View>
|
|
310
|
+
{rightElement && (
|
|
311
|
+
<View style={{ marginLeft: "auto" }}>
|
|
312
|
+
<HSpacer size={8} />
|
|
313
|
+
{rightElement}
|
|
314
|
+
</View>
|
|
315
|
+
)}
|
|
316
|
+
</Pressable>
|
|
317
|
+
{(bottomMessage || counterLimit) && (
|
|
318
|
+
<HelperRow
|
|
319
|
+
value={value}
|
|
320
|
+
bottomMessage={bottomMessage}
|
|
321
|
+
bottomMessageColor={bottomMessageColor}
|
|
322
|
+
counterLimit={counterLimit}
|
|
323
|
+
/>
|
|
324
|
+
)}
|
|
325
|
+
</>
|
|
326
|
+
);
|
|
327
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { IconButton } from "../buttons";
|
|
3
|
+
import { TextInputBase } from "./TextInputBase";
|
|
4
|
+
|
|
5
|
+
type TextInputPasswordProps = Omit<
|
|
6
|
+
React.ComponentProps<typeof TextInputBase>,
|
|
7
|
+
"isPassword"
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export const TextInputPassword = (props: TextInputPasswordProps) => {
|
|
11
|
+
const { onBlur, disabled } = props;
|
|
12
|
+
const [showPassword, setShowPassword] = React.useState<boolean>(false);
|
|
13
|
+
|
|
14
|
+
const rightElement = (
|
|
15
|
+
<IconButton
|
|
16
|
+
icon={showPassword ? "eyeShow" : "eyeHide"}
|
|
17
|
+
disabled={disabled}
|
|
18
|
+
onPress={() => setShowPassword(v => !v)}
|
|
19
|
+
accessibilityLabel="Toggle secret input"
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const onBlurHandler = React.useCallback(() => {
|
|
24
|
+
setShowPassword(false);
|
|
25
|
+
onBlur?.();
|
|
26
|
+
}, [onBlur]);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<TextInputBase
|
|
30
|
+
{...props}
|
|
31
|
+
onBlur={onBlurHandler}
|
|
32
|
+
rightElement={rightElement}
|
|
33
|
+
isPassword={!showPassword}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { IOIcons, Icon } from "../icons";
|
|
3
|
+
import { IOColors } from "../../core/IOColors";
|
|
4
|
+
import { triggerHaptic } from "../../functions";
|
|
5
|
+
import { TextInputBase } from "./TextInputBase";
|
|
6
|
+
|
|
7
|
+
type TextInputValidationProps = Omit<
|
|
8
|
+
React.ComponentProps<typeof TextInputBase>,
|
|
9
|
+
"rightElement" | "status" | "bottomMessageColor" | "isPassword"
|
|
10
|
+
> & {
|
|
11
|
+
onValidate: (value: string) => boolean;
|
|
12
|
+
errorMessage?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const TextInputValidation = (props: TextInputValidationProps) => {
|
|
16
|
+
const { onValidate, errorMessage, value, bottomMessage, onBlur, onFocus } =
|
|
17
|
+
props;
|
|
18
|
+
const [isValid, setIsValid] = React.useState<boolean | undefined>(undefined);
|
|
19
|
+
|
|
20
|
+
const onBlurHandler = React.useCallback(() => {
|
|
21
|
+
const validation = onValidate(value);
|
|
22
|
+
setIsValid(validation);
|
|
23
|
+
if (!validation) {
|
|
24
|
+
triggerHaptic("notificationError");
|
|
25
|
+
} else {
|
|
26
|
+
triggerHaptic("notificationSuccess");
|
|
27
|
+
}
|
|
28
|
+
onBlur?.();
|
|
29
|
+
}, [onValidate, value, onBlur]);
|
|
30
|
+
|
|
31
|
+
const onFocusHandler = React.useCallback(() => {
|
|
32
|
+
setIsValid(undefined);
|
|
33
|
+
onFocus?.();
|
|
34
|
+
}, [onFocus]);
|
|
35
|
+
|
|
36
|
+
const labelError = React.useMemo(
|
|
37
|
+
() => (isValid === false && errorMessage ? errorMessage : bottomMessage),
|
|
38
|
+
[isValid, errorMessage, bottomMessage]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const labelErrorColor: IOColors | undefined = React.useMemo(
|
|
42
|
+
() => (isValid === false && errorMessage ? "error-600" : undefined),
|
|
43
|
+
[isValid, errorMessage]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const rightIcon = React.useMemo(
|
|
47
|
+
() =>
|
|
48
|
+
isValid !== undefined && (
|
|
49
|
+
<Icon
|
|
50
|
+
name={(isValid ? "success" : "errorFilled") as IOIcons}
|
|
51
|
+
color={(isValid ? "green" : "error-600") as IOColors}
|
|
52
|
+
size={24}
|
|
53
|
+
/>
|
|
54
|
+
),
|
|
55
|
+
[isValid]
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<TextInputBase
|
|
60
|
+
{...props}
|
|
61
|
+
status={isValid === false ? "error" : undefined}
|
|
62
|
+
bottomMessage={labelError}
|
|
63
|
+
bottomMessageColor={labelErrorColor}
|
|
64
|
+
rightElement={rightIcon}
|
|
65
|
+
onBlur={onBlurHandler}
|
|
66
|
+
onFocus={onFocusHandler}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default TextInputValidation;
|
package/src/core/IOAnimations.ts
CHANGED
package/src/core/IOShapes.ts
CHANGED
|
@@ -18,3 +18,4 @@ export const IOTagRadius: IORadiusScale = 6;
|
|
|
18
18
|
export const IOBottomSheetHeaderRadius: IORadiusScale = 24;
|
|
19
19
|
export const IOListItemIDPRadius: IORadiusScale = IODefaultRadius;
|
|
20
20
|
export const IOBadgeRadius: IORadiusScale = 24;
|
|
21
|
+
export const IOAccordionRadius: IORadiusScale = IODefaultRadius;
|