@metamask-previews/design-system-react-native 0.11.0-preview.fa05289 → 0.13.0-preview.69c659c
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/CHANGELOG.md +30 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.types.cjs.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.types.d.cts +7 -9
- package/dist/components/AvatarNetwork/AvatarNetwork.types.d.cts.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.types.d.mts +7 -9
- package/dist/components/AvatarNetwork/AvatarNetwork.types.d.mts.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.types.mjs.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.cjs +8 -8
- package/dist/components/BadgeWrapper/BadgeWrapper.cjs.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.d.cts.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.d.mts.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.mjs +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.mjs.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.types.cjs.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.types.d.cts +4 -51
- package/dist/components/BadgeWrapper/BadgeWrapper.types.d.cts.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.types.d.mts +4 -51
- package/dist/components/BadgeWrapper/BadgeWrapper.types.d.mts.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.types.mjs.map +1 -1
- package/dist/components/BadgeWrapper/index.cjs +3 -3
- package/dist/components/BadgeWrapper/index.cjs.map +1 -1
- package/dist/components/BadgeWrapper/index.d.cts +1 -2
- package/dist/components/BadgeWrapper/index.d.cts.map +1 -1
- package/dist/components/BadgeWrapper/index.d.mts +1 -2
- package/dist/components/BadgeWrapper/index.d.mts.map +1 -1
- package/dist/components/BadgeWrapper/index.mjs +1 -1
- package/dist/components/BadgeWrapper/index.mjs.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.constants.cjs +8 -8
- package/dist/components/BannerAlert/BannerAlert.constants.cjs.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.constants.d.cts +2 -2
- package/dist/components/BannerAlert/BannerAlert.constants.d.cts.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.constants.d.mts +2 -2
- package/dist/components/BannerAlert/BannerAlert.constants.d.mts.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.constants.mjs +2 -2
- package/dist/components/BannerAlert/BannerAlert.constants.mjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.cjs +2 -1
- package/dist/components/BannerBase/BannerBase.cjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.d.cts.map +1 -1
- package/dist/components/BannerBase/BannerBase.d.mts.map +1 -1
- package/dist/components/BannerBase/BannerBase.mjs +2 -1
- package/dist/components/BannerBase/BannerBase.mjs.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.cjs +2 -2
- package/dist/components/BottomSheet/BottomSheet.cjs.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.d.cts +30 -0
- package/dist/components/BottomSheet/BottomSheet.d.cts.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.d.mts +30 -0
- package/dist/components/BottomSheet/BottomSheet.d.mts.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.mjs +2 -2
- package/dist/components/BottomSheet/BottomSheet.mjs.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.cjs +2 -2
- package/dist/components/BottomSheetDialog/BottomSheetDialog.cjs.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.d.cts +30 -0
- package/dist/components/BottomSheetDialog/BottomSheetDialog.d.cts.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.d.mts +30 -0
- package/dist/components/BottomSheetDialog/BottomSheetDialog.d.mts.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs +2 -2
- package/dist/components/BottomSheetDialog/BottomSheetDialog.mjs.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.types.cjs.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.types.d.cts +7 -0
- package/dist/components/BottomSheetDialog/BottomSheetDialog.types.d.cts.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.types.d.mts +7 -0
- package/dist/components/BottomSheetDialog/BottomSheetDialog.types.d.mts.map +1 -1
- package/dist/components/BottomSheetDialog/BottomSheetDialog.types.mjs.map +1 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.cjs +2 -2
- package/dist/components/BottomSheetHeader/BottomSheetHeader.cjs.map +1 -1
- package/dist/components/BottomSheetHeader/BottomSheetHeader.mjs +2 -2
- package/dist/components/BottomSheetHeader/BottomSheetHeader.mjs.map +1 -1
- package/dist/components/Box/Box.constants.cjs.map +1 -1
- package/dist/components/Box/Box.constants.d.cts +1 -1
- package/dist/components/Box/Box.constants.d.cts.map +1 -1
- package/dist/components/Box/Box.constants.d.mts +1 -1
- package/dist/components/Box/Box.constants.d.mts.map +1 -1
- package/dist/components/Box/Box.constants.mjs.map +1 -1
- package/dist/components/Box/Box.types.cjs.map +1 -1
- package/dist/components/Box/Box.types.d.cts +3 -107
- package/dist/components/Box/Box.types.d.cts.map +1 -1
- package/dist/components/Box/Box.types.d.mts +3 -107
- package/dist/components/Box/Box.types.d.mts.map +1 -1
- package/dist/components/Box/Box.types.mjs.map +1 -1
- package/dist/components/Box/index.cjs +7 -7
- package/dist/components/Box/index.cjs.map +1 -1
- package/dist/components/Box/index.d.cts +1 -2
- package/dist/components/Box/index.d.cts.map +1 -1
- package/dist/components/Box/index.d.mts +1 -2
- package/dist/components/Box/index.d.mts.map +1 -1
- package/dist/components/Box/index.mjs +1 -1
- package/dist/components/Box/index.mjs.map +1 -1
- package/dist/components/BoxHorizontal/BoxHorizontal.cjs +18 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.cjs.map +1 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.d.cts +7 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.d.cts.map +1 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.d.mts +7 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.d.mts.map +1 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.mjs +18 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.mjs.map +1 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.types.cjs +3 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.types.cjs.map +1 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.types.d.cts +13 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.types.d.cts.map +1 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.types.d.mts +13 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.types.d.mts.map +1 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.types.mjs +2 -0
- package/dist/components/BoxHorizontal/BoxHorizontal.types.mjs.map +1 -0
- package/dist/components/BoxHorizontal/index.cjs +6 -0
- package/dist/components/BoxHorizontal/index.cjs.map +1 -0
- package/dist/components/BoxHorizontal/index.d.cts +3 -0
- package/dist/components/BoxHorizontal/index.d.cts.map +1 -0
- package/dist/components/BoxHorizontal/index.d.mts +3 -0
- package/dist/components/BoxHorizontal/index.d.mts.map +1 -0
- package/dist/components/BoxHorizontal/index.mjs +2 -0
- package/dist/components/BoxHorizontal/index.mjs.map +1 -0
- package/dist/components/BoxVertical/BoxVertical.cjs +18 -0
- package/dist/components/BoxVertical/BoxVertical.cjs.map +1 -0
- package/dist/components/BoxVertical/BoxVertical.d.cts +7 -0
- package/dist/components/BoxVertical/BoxVertical.d.cts.map +1 -0
- package/dist/components/BoxVertical/BoxVertical.d.mts +7 -0
- package/dist/components/BoxVertical/BoxVertical.d.mts.map +1 -0
- package/dist/components/BoxVertical/BoxVertical.mjs +18 -0
- package/dist/components/BoxVertical/BoxVertical.mjs.map +1 -0
- package/dist/components/BoxVertical/BoxVertical.types.cjs +3 -0
- package/dist/components/BoxVertical/BoxVertical.types.cjs.map +1 -0
- package/dist/components/BoxVertical/BoxVertical.types.d.cts +13 -0
- package/dist/components/BoxVertical/BoxVertical.types.d.cts.map +1 -0
- package/dist/components/BoxVertical/BoxVertical.types.d.mts +13 -0
- package/dist/components/BoxVertical/BoxVertical.types.d.mts.map +1 -0
- package/dist/components/BoxVertical/BoxVertical.types.mjs +2 -0
- package/dist/components/BoxVertical/BoxVertical.types.mjs.map +1 -0
- package/dist/components/BoxVertical/index.cjs +6 -0
- package/dist/components/BoxVertical/index.cjs.map +1 -0
- package/dist/components/BoxVertical/index.d.cts +3 -0
- package/dist/components/BoxVertical/index.d.cts.map +1 -0
- package/dist/components/BoxVertical/index.d.mts +3 -0
- package/dist/components/BoxVertical/index.d.mts.map +1 -0
- package/dist/components/BoxVertical/index.mjs +2 -0
- package/dist/components/BoxVertical/index.mjs.map +1 -0
- package/dist/components/Icon/assets/candlestick.svg +1 -1
- package/dist/components/Input/Input.cjs +4 -3
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.constants.cjs +69 -0
- package/dist/components/Input/Input.constants.cjs.map +1 -0
- package/dist/components/Input/Input.constants.d.cts +11 -0
- package/dist/components/Input/Input.constants.d.cts.map +1 -0
- package/dist/components/Input/Input.constants.d.mts +11 -0
- package/dist/components/Input/Input.constants.d.mts.map +1 -0
- package/dist/components/Input/Input.constants.mjs +66 -0
- package/dist/components/Input/Input.constants.mjs.map +1 -0
- package/dist/components/Input/Input.d.cts.map +1 -1
- package/dist/components/Input/Input.d.mts.map +1 -1
- package/dist/components/Input/Input.mjs +4 -3
- package/dist/components/Input/Input.mjs.map +1 -1
- package/dist/components/KeyValueRow/KeyValueLabel/KeyValueLabel.cjs +33 -0
- package/dist/components/KeyValueRow/KeyValueLabel/KeyValueLabel.cjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueLabel/KeyValueLabel.d.cts +14 -0
- package/dist/components/KeyValueRow/KeyValueLabel/KeyValueLabel.d.cts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueLabel/KeyValueLabel.d.mts +14 -0
- package/dist/components/KeyValueRow/KeyValueLabel/KeyValueLabel.d.mts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueLabel/KeyValueLabel.mjs +35 -0
- package/dist/components/KeyValueRow/KeyValueLabel/KeyValueLabel.mjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRoot/KeyValueRoot.cjs +39 -0
- package/dist/components/KeyValueRow/KeyValueRoot/KeyValueRoot.cjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRoot/KeyValueRoot.d.cts +25 -0
- package/dist/components/KeyValueRow/KeyValueRoot/KeyValueRoot.d.cts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRoot/KeyValueRoot.d.mts +25 -0
- package/dist/components/KeyValueRow/KeyValueRoot/KeyValueRoot.d.mts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRoot/KeyValueRoot.mjs +41 -0
- package/dist/components/KeyValueRow/KeyValueRoot/KeyValueRoot.mjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.cjs +76 -0
- package/dist/components/KeyValueRow/KeyValueRow.cjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.d.cts +25 -0
- package/dist/components/KeyValueRow/KeyValueRow.d.cts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.d.mts +25 -0
- package/dist/components/KeyValueRow/KeyValueRow.d.mts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.mjs +77 -0
- package/dist/components/KeyValueRow/KeyValueRow.mjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.types.cjs +29 -0
- package/dist/components/KeyValueRow/KeyValueRow.types.cjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.types.d.cts +177 -0
- package/dist/components/KeyValueRow/KeyValueRow.types.d.cts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.types.d.mts +177 -0
- package/dist/components/KeyValueRow/KeyValueRow.types.d.mts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.types.mjs +26 -0
- package/dist/components/KeyValueRow/KeyValueRow.types.mjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.utils.cjs +6 -0
- package/dist/components/KeyValueRow/KeyValueRow.utils.cjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.utils.d.cts +3 -0
- package/dist/components/KeyValueRow/KeyValueRow.utils.d.cts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.utils.d.mts +3 -0
- package/dist/components/KeyValueRow/KeyValueRow.utils.d.mts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueRow.utils.mjs +2 -0
- package/dist/components/KeyValueRow/KeyValueRow.utils.mjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueSection/KeyValueSection.cjs +29 -0
- package/dist/components/KeyValueRow/KeyValueSection/KeyValueSection.cjs.map +1 -0
- package/dist/components/KeyValueRow/KeyValueSection/KeyValueSection.d.cts +17 -0
- package/dist/components/KeyValueRow/KeyValueSection/KeyValueSection.d.cts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueSection/KeyValueSection.d.mts +17 -0
- package/dist/components/KeyValueRow/KeyValueSection/KeyValueSection.d.mts.map +1 -0
- package/dist/components/KeyValueRow/KeyValueSection/KeyValueSection.mjs +31 -0
- package/dist/components/KeyValueRow/KeyValueSection/KeyValueSection.mjs.map +1 -0
- package/dist/components/KeyValueRow/index.cjs +15 -0
- package/dist/components/KeyValueRow/index.cjs.map +1 -0
- package/dist/components/KeyValueRow/index.d.cts +3 -0
- package/dist/components/KeyValueRow/index.d.cts.map +1 -0
- package/dist/components/KeyValueRow/index.d.mts +3 -0
- package/dist/components/KeyValueRow/index.d.mts.map +1 -0
- package/dist/components/KeyValueRow/index.mjs +3 -0
- package/dist/components/KeyValueRow/index.mjs.map +1 -0
- package/dist/components/Text/Text.types.cjs.map +1 -1
- package/dist/components/Text/Text.types.d.cts +1 -1
- package/dist/components/Text/Text.types.d.mts +1 -1
- package/dist/components/Text/Text.types.mjs.map +1 -1
- package/dist/components/TextButton/TextButton.cjs +12 -36
- package/dist/components/TextButton/TextButton.cjs.map +1 -1
- package/dist/components/TextButton/TextButton.d.cts.map +1 -1
- package/dist/components/TextButton/TextButton.d.mts.map +1 -1
- package/dist/components/TextButton/TextButton.mjs +14 -38
- package/dist/components/TextButton/TextButton.mjs.map +1 -1
- package/dist/components/TextButton/TextButton.types.cjs.map +1 -1
- package/dist/components/TextButton/TextButton.types.d.cts +8 -60
- package/dist/components/TextButton/TextButton.types.d.cts.map +1 -1
- package/dist/components/TextButton/TextButton.types.d.mts +8 -60
- package/dist/components/TextButton/TextButton.types.d.mts.map +1 -1
- package/dist/components/TextButton/TextButton.types.mjs.map +1 -1
- package/dist/components/TextButton/index.cjs +1 -3
- package/dist/components/TextButton/index.cjs.map +1 -1
- package/dist/components/TextButton/index.d.cts +0 -1
- package/dist/components/TextButton/index.d.cts.map +1 -1
- package/dist/components/TextButton/index.d.mts +0 -1
- package/dist/components/TextButton/index.d.mts.map +1 -1
- package/dist/components/TextButton/index.mjs +0 -1
- package/dist/components/TextButton/index.mjs.map +1 -1
- package/dist/components/TextField/TextField.cjs +22 -8
- package/dist/components/TextField/TextField.cjs.map +1 -1
- package/dist/components/TextField/TextField.d.cts +0 -2
- package/dist/components/TextField/TextField.d.cts.map +1 -1
- package/dist/components/TextField/TextField.d.mts +0 -2
- package/dist/components/TextField/TextField.d.mts.map +1 -1
- package/dist/components/TextField/TextField.mjs +22 -8
- package/dist/components/TextField/TextField.mjs.map +1 -1
- package/dist/components/TextField/TextField.types.cjs +0 -10
- package/dist/components/TextField/TextField.types.cjs.map +1 -1
- package/dist/components/TextField/TextField.types.d.cts +0 -14
- package/dist/components/TextField/TextField.types.d.cts.map +1 -1
- package/dist/components/TextField/TextField.types.d.mts +0 -14
- package/dist/components/TextField/TextField.types.d.mts.map +1 -1
- package/dist/components/TextField/TextField.types.mjs +1 -9
- package/dist/components/TextField/TextField.types.mjs.map +1 -1
- package/dist/components/TextField/index.cjs +1 -3
- package/dist/components/TextField/index.cjs.map +1 -1
- package/dist/components/TextField/index.d.cts +0 -1
- package/dist/components/TextField/index.d.cts.map +1 -1
- package/dist/components/TextField/index.d.mts +0 -1
- package/dist/components/TextField/index.d.mts.map +1 -1
- package/dist/components/TextField/index.mjs +0 -1
- package/dist/components/TextField/index.mjs.map +1 -1
- package/dist/components/index.cjs +6 -4
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +6 -2
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +6 -2
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +4 -2
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.cjs.map +1 -1
- package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.d.cts +2 -5
- package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.d.cts.map +1 -1
- package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.d.mts +2 -5
- package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.d.mts.map +1 -1
- package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.mjs.map +1 -1
- package/dist/types/index.cjs +3 -203
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +2 -210
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +2 -210
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs +2 -202
- package/dist/types/index.mjs.map +1 -1
- package/package.json +5 -6
- package/dist/components/TextButton/TextButton.constants.cjs +0 -12
- package/dist/components/TextButton/TextButton.constants.cjs.map +0 -1
- package/dist/components/TextButton/TextButton.constants.d.cts +0 -4
- package/dist/components/TextButton/TextButton.constants.d.cts.map +0 -1
- package/dist/components/TextButton/TextButton.constants.d.mts +0 -4
- package/dist/components/TextButton/TextButton.constants.d.mts.map +0 -1
- package/dist/components/TextButton/TextButton.constants.mjs +0 -9
- package/dist/components/TextButton/TextButton.constants.mjs.map +0 -1
- package/dist/components/TextField/TextField.constants.cjs +0 -13
- package/dist/components/TextField/TextField.constants.cjs.map +0 -1
- package/dist/components/TextField/TextField.constants.d.cts +0 -6
- package/dist/components/TextField/TextField.constants.d.cts.map +0 -1
- package/dist/components/TextField/TextField.constants.d.mts +0 -6
- package/dist/components/TextField/TextField.constants.d.mts.map +0 -1
- package/dist/components/TextField/TextField.constants.mjs +0 -10
- package/dist/components/TextField/TextField.constants.mjs.map +0 -1
|
@@ -4,46 +4,22 @@ function $importDefault(module) {
|
|
|
4
4
|
}
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
|
-
import {
|
|
8
|
-
import $React, { useCallback } from "react";
|
|
7
|
+
import $React, { useState } from "react";
|
|
9
8
|
const React = $importDefault($React);
|
|
10
|
-
import {
|
|
11
|
-
import { TextButtonSize } from "../../types/index.mjs";
|
|
12
|
-
import { Icon, IconSize } from "../Icon/index.mjs";
|
|
9
|
+
import { TextVariant, TextColor } from "../../types/index.mjs";
|
|
13
10
|
import { Text, FontWeight } from "../Text/index.mjs";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return 'text-primary-inverse';
|
|
27
|
-
}
|
|
28
|
-
return pressed ? 'text-primary-default-pressed' : 'text-primary-default';
|
|
29
|
-
}, [isInverse]);
|
|
30
|
-
const getTextDecoration = useCallback((pressed) => isInverse || pressed ? 'underline' : 'no-underline', [isInverse]);
|
|
31
|
-
return (<Text>
|
|
32
|
-
<Pressable accessibilityRole={accessibilityRole ?? 'button'} accessibilityLabel={accessibilityLabel} disabled={isDisabled} style={({ pressed }) => [
|
|
33
|
-
{ transform: [{ translateY: baselineOffset }] },
|
|
34
|
-
tw `flex-row items-center ${pressed ? 'bg-pressed' : 'bg-transparent'} ${isDisabled ? 'opacity-50' : 'opacity-100'} ${twClassName}`,
|
|
35
|
-
style,
|
|
36
|
-
]} {...props}>
|
|
37
|
-
{({ pressed }) => (<>
|
|
38
|
-
{startIconName ? (<Icon name={startIconName} size={IconSize.Sm} testID="start-icon" twClassName={`${getTextColor(pressed)} mr-1`} {...startIconProps}/>) : (startAccessory)}
|
|
39
|
-
|
|
40
|
-
<Text variant={MAP_TEXTBUTTON_SIZE_TEXTVARIANT[size]} fontWeight={FontWeight.Medium} {...textProps} twClassName={` ${getTextColor(pressed)} ${getTextDecoration(pressed)} ${textProps?.twClassName ?? ''} `}>
|
|
41
|
-
{children}
|
|
42
|
-
</Text>
|
|
43
|
-
|
|
44
|
-
{endIconName ? (<Icon name={endIconName} size={IconSize.Sm} testID="end-icon" twClassName={`${getTextColor(pressed)} ml-1`} {...endIconProps}/>) : (endAccessory)}
|
|
45
|
-
</>)}
|
|
46
|
-
</Pressable>
|
|
11
|
+
export const TextButton = ({ children, variant = TextVariant.BodyMd, fontWeight = FontWeight.Medium, twClassName, accessibilityRole = 'link', onPress, onPressIn, onPressOut, suppressHighlighting = true, ...rest }) => {
|
|
12
|
+
const [pressed, setPressed] = useState(false);
|
|
13
|
+
const handlePressIn = (e) => {
|
|
14
|
+
setPressed(true);
|
|
15
|
+
onPressIn?.(e);
|
|
16
|
+
};
|
|
17
|
+
const handlePressOut = (e) => {
|
|
18
|
+
setPressed(false);
|
|
19
|
+
onPressOut?.(e);
|
|
20
|
+
};
|
|
21
|
+
return (<Text {...rest} accessibilityRole={accessibilityRole} variant={variant} fontWeight={fontWeight} color={pressed ? TextColor.PrimaryDefaultPressed : TextColor.PrimaryDefault} twClassName={twClassName} onPress={onPress} onPressIn={handlePressIn} onPressOut={handlePressOut} suppressHighlighting={suppressHighlighting}>
|
|
22
|
+
{children}
|
|
47
23
|
</Text>);
|
|
48
24
|
};
|
|
49
25
|
//# sourceMappingURL=TextButton.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextButton.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"TextButton.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAO,EAAE,QAAQ,EAAE,cAAc;;AAExC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,8BAAoB;AACrD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,0BAAgB;AAI3C,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EACpD,QAAQ,EACR,OAAO,GAAG,WAAW,CAAC,MAAM,EAC5B,UAAU,GAAG,UAAU,CAAC,MAAM,EAC9B,WAAW,EACX,iBAAiB,GAAG,MAAM,EAC1B,OAAO,EACP,SAAS,EACT,UAAU,EACV,oBAAoB,GAAG,IAAI,EAC3B,GAAG,IAAI,EACR,EAAE,EAAE;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,MAAM,aAAa,GAA8C,CAAC,CAAC,EAAE,EAAE;QACrE,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC;IAEF,MAAM,cAAc,GAA+C,CAAC,CAAC,EAAE,EAAE;QACvE,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,IAAI,CACH,IAAI,IAAI,CAAC,CACT,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,KAAK,CAAC,CACJ,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS,CAAC,cAAc,CACrE,CACD,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,SAAS,CAAC,CAAC,aAAa,CAAC,CACzB,UAAU,CAAC,CAAC,cAAc,CAAC,CAC3B,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,CAE3C;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useState } from 'react';\n\nimport { TextVariant, TextColor } from '../../types';\nimport { Text, FontWeight } from '../Text';\n\nimport type { TextButtonProps } from './TextButton.types';\n\nexport const TextButton: React.FC<TextButtonProps> = ({\n children,\n variant = TextVariant.BodyMd,\n fontWeight = FontWeight.Medium,\n twClassName,\n accessibilityRole = 'link',\n onPress,\n onPressIn,\n onPressOut,\n suppressHighlighting = true,\n ...rest\n}) => {\n const [pressed, setPressed] = useState(false);\n\n const handlePressIn: NonNullable<TextButtonProps['onPressIn']> = (e) => {\n setPressed(true);\n onPressIn?.(e);\n };\n\n const handlePressOut: NonNullable<TextButtonProps['onPressOut']> = (e) => {\n setPressed(false);\n onPressOut?.(e);\n };\n\n return (\n <Text\n {...rest}\n accessibilityRole={accessibilityRole}\n variant={variant}\n fontWeight={fontWeight}\n color={\n pressed ? TextColor.PrimaryDefaultPressed : TextColor.PrimaryDefault\n }\n twClassName={twClassName}\n onPress={onPress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n suppressHighlighting={suppressHighlighting}\n >\n {children}\n </Text>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextButton.types.cjs","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"TextButton.types.cjs","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TextProps } from '../Text';\n\n/**\n * Props for `TextButton`, a text-only control for links and inline actions.\n * Extends {@link Text} props.\n */\nexport type TextButtonProps = Omit<\n TextProps,\n 'children' | 'color' | 'onPress'\n> & {\n /**\n * Content shown as the label.\n */\n children: React.ReactNode;\n /**\n * Called when the user presses the label. Primary interaction for this control.\n */\n onPress?: TextProps['onPress'];\n};\n"]}
|
|
@@ -1,68 +1,16 @@
|
|
|
1
|
-
import type { PressableProps, StyleProp, ViewStyle } from "react-native/index.js";
|
|
2
|
-
import type { TextButtonSize } from "../../types/index.cjs";
|
|
3
|
-
import type { IconProps, IconName } from "../Icon/index.cjs";
|
|
4
1
|
import type { TextProps } from "../Text/index.cjs";
|
|
5
2
|
/**
|
|
6
|
-
* TextButton
|
|
3
|
+
* Props for `TextButton`, a text-only control for links and inline actions.
|
|
4
|
+
* Extends {@link Text} props.
|
|
7
5
|
*/
|
|
8
|
-
export type TextButtonProps = {
|
|
6
|
+
export type TextButtonProps = Omit<TextProps, 'children' | 'color' | 'onPress'> & {
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
8
|
+
* Content shown as the label.
|
|
11
9
|
*/
|
|
12
|
-
children:
|
|
10
|
+
children: React.ReactNode;
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @default TextButtonSize.BodyMd
|
|
12
|
+
* Called when the user presses the label. Primary interaction for this control.
|
|
17
13
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* Optional props to be passed to the Text component when children is a string
|
|
21
|
-
*/
|
|
22
|
-
textProps?: Omit<Partial<TextProps>, 'children'>;
|
|
23
|
-
/**
|
|
24
|
-
* Optional prop to specify an icon to show at the start of the button
|
|
25
|
-
*/
|
|
26
|
-
startIconName?: IconName;
|
|
27
|
-
/**
|
|
28
|
-
* Optional prop to pass additional properties to the start icon
|
|
29
|
-
*/
|
|
30
|
-
startIconProps?: Partial<IconProps>;
|
|
31
|
-
/**
|
|
32
|
-
* Optional prop for a custom element to show at the start of the button
|
|
33
|
-
*/
|
|
34
|
-
startAccessory?: React.ReactNode;
|
|
35
|
-
/**
|
|
36
|
-
* Optional prop to specify an icon to show at the end of the button
|
|
37
|
-
*/
|
|
38
|
-
endIconName?: IconName;
|
|
39
|
-
/**
|
|
40
|
-
* Optional prop to pass additional properties to the end icon
|
|
41
|
-
*/
|
|
42
|
-
endIconProps?: Partial<IconProps>;
|
|
43
|
-
/**
|
|
44
|
-
* Optional prop for a custom element to show at the end of the button
|
|
45
|
-
*/
|
|
46
|
-
endAccessory?: React.ReactNode;
|
|
47
|
-
/**
|
|
48
|
-
* Optional prop that when true, disables the button
|
|
49
|
-
*
|
|
50
|
-
* @default false
|
|
51
|
-
*/
|
|
52
|
-
isDisabled?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Optional prop to show the inverse state of the button, which is reserved for buttons on colored backgrounds.
|
|
55
|
-
*
|
|
56
|
-
* @default false
|
|
57
|
-
*/
|
|
58
|
-
isInverse?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Optional prop to add twrnc overriding classNames.
|
|
61
|
-
*/
|
|
62
|
-
twClassName?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Optional prop to control the style.
|
|
65
|
-
*/
|
|
66
|
-
style?: StyleProp<ViewStyle>;
|
|
67
|
-
} & Omit<PressableProps, 'disabled'>;
|
|
14
|
+
onPress?: TextProps['onPress'];
|
|
15
|
+
};
|
|
68
16
|
//# sourceMappingURL=TextButton.types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextButton.types.d.cts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"TextButton.types.d.cts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,SAAS,EACT,UAAU,GAAG,OAAO,GAAG,SAAS,CACjC,GAAG;IACF;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAChC,CAAC"}
|
|
@@ -1,68 +1,16 @@
|
|
|
1
|
-
import type { PressableProps, StyleProp, ViewStyle } from "react-native/index.js";
|
|
2
|
-
import type { TextButtonSize } from "../../types/index.mjs";
|
|
3
|
-
import type { IconProps, IconName } from "../Icon/index.mjs";
|
|
4
1
|
import type { TextProps } from "../Text/index.mjs";
|
|
5
2
|
/**
|
|
6
|
-
* TextButton
|
|
3
|
+
* Props for `TextButton`, a text-only control for links and inline actions.
|
|
4
|
+
* Extends {@link Text} props.
|
|
7
5
|
*/
|
|
8
|
-
export type TextButtonProps = {
|
|
6
|
+
export type TextButtonProps = Omit<TextProps, 'children' | 'color' | 'onPress'> & {
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
8
|
+
* Content shown as the label.
|
|
11
9
|
*/
|
|
12
|
-
children:
|
|
10
|
+
children: React.ReactNode;
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @default TextButtonSize.BodyMd
|
|
12
|
+
* Called when the user presses the label. Primary interaction for this control.
|
|
17
13
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* Optional props to be passed to the Text component when children is a string
|
|
21
|
-
*/
|
|
22
|
-
textProps?: Omit<Partial<TextProps>, 'children'>;
|
|
23
|
-
/**
|
|
24
|
-
* Optional prop to specify an icon to show at the start of the button
|
|
25
|
-
*/
|
|
26
|
-
startIconName?: IconName;
|
|
27
|
-
/**
|
|
28
|
-
* Optional prop to pass additional properties to the start icon
|
|
29
|
-
*/
|
|
30
|
-
startIconProps?: Partial<IconProps>;
|
|
31
|
-
/**
|
|
32
|
-
* Optional prop for a custom element to show at the start of the button
|
|
33
|
-
*/
|
|
34
|
-
startAccessory?: React.ReactNode;
|
|
35
|
-
/**
|
|
36
|
-
* Optional prop to specify an icon to show at the end of the button
|
|
37
|
-
*/
|
|
38
|
-
endIconName?: IconName;
|
|
39
|
-
/**
|
|
40
|
-
* Optional prop to pass additional properties to the end icon
|
|
41
|
-
*/
|
|
42
|
-
endIconProps?: Partial<IconProps>;
|
|
43
|
-
/**
|
|
44
|
-
* Optional prop for a custom element to show at the end of the button
|
|
45
|
-
*/
|
|
46
|
-
endAccessory?: React.ReactNode;
|
|
47
|
-
/**
|
|
48
|
-
* Optional prop that when true, disables the button
|
|
49
|
-
*
|
|
50
|
-
* @default false
|
|
51
|
-
*/
|
|
52
|
-
isDisabled?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Optional prop to show the inverse state of the button, which is reserved for buttons on colored backgrounds.
|
|
55
|
-
*
|
|
56
|
-
* @default false
|
|
57
|
-
*/
|
|
58
|
-
isInverse?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Optional prop to add twrnc overriding classNames.
|
|
61
|
-
*/
|
|
62
|
-
twClassName?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Optional prop to control the style.
|
|
65
|
-
*/
|
|
66
|
-
style?: StyleProp<ViewStyle>;
|
|
67
|
-
} & Omit<PressableProps, 'disabled'>;
|
|
14
|
+
onPress?: TextProps['onPress'];
|
|
15
|
+
};
|
|
68
16
|
//# sourceMappingURL=TextButton.types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextButton.types.d.mts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"TextButton.types.d.mts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,SAAS,EACT,UAAU,GAAG,OAAO,GAAG,SAAS,CACjC,GAAG;IACF;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAChC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextButton.types.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"TextButton.types.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TextProps } from '../Text';\n\n/**\n * Props for `TextButton`, a text-only control for links and inline actions.\n * Extends {@link Text} props.\n */\nexport type TextButtonProps = Omit<\n TextProps,\n 'children' | 'color' | 'onPress'\n> & {\n /**\n * Content shown as the label.\n */\n children: React.ReactNode;\n /**\n * Called when the user presses the label. Primary interaction for this control.\n */\n onPress?: TextProps['onPress'];\n};\n"]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextButton =
|
|
4
|
-
var types_1 = require("../../types/index.cjs");
|
|
5
|
-
Object.defineProperty(exports, "TextButtonSize", { enumerable: true, get: function () { return types_1.TextButtonSize; } });
|
|
3
|
+
exports.TextButton = void 0;
|
|
6
4
|
var TextButton_1 = require("./TextButton.cjs");
|
|
7
5
|
Object.defineProperty(exports, "TextButton", { enumerable: true, get: function () { return TextButton_1.TextButton; } });
|
|
8
6
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAAjC,wGAAA,UAAU,OAAA","sourcesContent":["export { TextButton } from './TextButton';\nexport type { TextButtonProps } from './TextButton.types';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAqB;AAC1C,YAAY,EAAE,eAAe,EAAE,+BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAqB;AAC1C,YAAY,EAAE,eAAe,EAAE,+BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAqB","sourcesContent":["export { TextButton } from './TextButton';\nexport type { TextButtonProps } from './TextButton.types';\n"]}
|
|
@@ -6,14 +6,25 @@ const react_1 = require("react");
|
|
|
6
6
|
const react_native_1 = require("react-native/index.js");
|
|
7
7
|
const types_1 = require("../../types/index.cjs");
|
|
8
8
|
const Input_1 = require("../Input/index.cjs");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function getContainerBorderColorClass(isDisabled, isFocused, isError) {
|
|
10
|
+
if (isDisabled) {
|
|
11
|
+
return 'border-muted';
|
|
12
|
+
}
|
|
13
|
+
if (isError) {
|
|
14
|
+
return 'border-error-default';
|
|
15
|
+
}
|
|
16
|
+
if (isFocused) {
|
|
17
|
+
return 'border-default';
|
|
18
|
+
}
|
|
19
|
+
return 'border-muted';
|
|
20
|
+
}
|
|
21
|
+
exports.TextField = (0, react_1.forwardRef)(({ style, startAccessory, endAccessory, isError = false, inputElement, isDisabled = false, autoFocus = false, twClassName, onBlur, onFocus, testID, ...props }, ref) => {
|
|
12
22
|
const [isFocused, setIsFocused] = (0, react_1.useState)(autoFocus);
|
|
13
23
|
const inputRef = (0, react_1.useRef)(null);
|
|
14
24
|
const tw = (0, design_system_twrnc_preset_1.useTailwind)();
|
|
15
25
|
(0, react_1.useImperativeHandle)(ref, () => inputRef.current, []);
|
|
16
|
-
const
|
|
26
|
+
const borderColorClass = getContainerBorderColorClass(isDisabled, isFocused, isError);
|
|
27
|
+
const containerStyle = (0, react_1.useMemo)(() => tw.style('flex-row', 'items-center', 'gap-3', 'rounded-lg', 'h-12', 'border', borderColorClass, 'px-4', 'bg-muted', isDisabled && 'opacity-50', twClassName), [borderColorClass, isDisabled, twClassName, tw]);
|
|
17
28
|
const onBlurHandler = (0, react_1.useCallback)((e) => {
|
|
18
29
|
if (!isDisabled) {
|
|
19
30
|
setIsFocused(false);
|
|
@@ -32,11 +43,14 @@ exports.TextField = (0, react_1.forwardRef)(({ style, size = TextField_types_1.T
|
|
|
32
43
|
}
|
|
33
44
|
}, [isDisabled]);
|
|
34
45
|
return (<react_native_1.Pressable testID={testID} style={[containerStyle, style]} onPress={onPressHandler} accessible={false}>
|
|
35
|
-
{startAccessory
|
|
36
|
-
<react_native_1.View style={tw.style('flex-1')}>
|
|
37
|
-
{inputElement ?? (<Input_1.Input {...props} ref={inputRef} textVariant={types_1.TextVariant.BodyMd} isDisabled={isDisabled} autoFocus={autoFocus} onBlur={onBlurHandler} onFocus={onFocusHandler} isStateStylesDisabled
|
|
46
|
+
{startAccessory}
|
|
47
|
+
<react_native_1.View style={tw.style('min-h-0 flex-1 justify-center')}>
|
|
48
|
+
{inputElement ?? (<Input_1.Input {...props} ref={inputRef} textVariant={types_1.TextVariant.BodyMd} isDisabled={isDisabled} autoFocus={autoFocus} onBlur={onBlurHandler} onFocus={onFocusHandler} isStateStylesDisabled
|
|
49
|
+
// Row is `h-12` (48px) with `border` on the Pressable (1px top + bottom). Inner TextInput
|
|
50
|
+
// uses 46px height so the field matches a 48px-tall control without vertical overflow.
|
|
51
|
+
twClassName="h-[46px] bg-transparent border-0" numberOfLines={1} multiline={false}/>)}
|
|
38
52
|
</react_native_1.View>
|
|
39
|
-
{endAccessory
|
|
53
|
+
{endAccessory}
|
|
40
54
|
</react_native_1.Pressable>);
|
|
41
55
|
});
|
|
42
56
|
//# sourceMappingURL=TextField.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.cjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":";;;AAAA,8FAA4E;AAC5E,iCAOe;AACf,wDAA0D;AAE1D,iDAA0C;AAC1C,8CAAiC;
|
|
1
|
+
{"version":3,"file":"TextField.cjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"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","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Pressable, TextInput, View } from 'react-native';\n\nimport { TextVariant } from '../../types';\nimport { Input } from '../Input';\n\nimport type { TextFieldProps } from './TextField.types';\n\nfunction getContainerBorderColorClass(\n isDisabled: boolean,\n isFocused: boolean,\n isError: boolean,\n): string {\n if (isDisabled) {\n return 'border-muted';\n }\n if (isError) {\n return 'border-error-default';\n }\n if (isFocused) {\n return 'border-default';\n }\n return 'border-muted';\n}\n\nexport const TextField = forwardRef<TextInput, TextFieldProps>(\n (\n {\n style,\n startAccessory,\n endAccessory,\n isError = false,\n inputElement,\n isDisabled = false,\n autoFocus = false,\n twClassName,\n onBlur,\n onFocus,\n testID,\n ...props\n },\n ref,\n ) => {\n const [isFocused, setIsFocused] = useState(autoFocus);\n const inputRef = useRef<TextInput>(null);\n const tw = useTailwind();\n\n useImperativeHandle<TextInput | null, TextInput | null>(\n ref,\n () => inputRef.current,\n [],\n );\n\n const borderColorClass = getContainerBorderColorClass(\n isDisabled,\n isFocused,\n isError,\n );\n\n const containerStyle = useMemo(\n () =>\n tw.style(\n 'flex-row',\n 'items-center',\n 'gap-3',\n 'rounded-lg',\n 'h-12',\n 'border',\n borderColorClass,\n 'px-4',\n 'bg-muted',\n isDisabled && 'opacity-50',\n twClassName,\n ),\n [borderColorClass, isDisabled, twClassName, tw],\n );\n\n const onBlurHandler = useCallback(\n (e: Parameters<NonNullable<TextFieldProps['onBlur']>>[0]) => {\n if (!isDisabled) {\n setIsFocused(false);\n onBlur?.(e);\n }\n },\n [isDisabled, onBlur],\n );\n\n const onFocusHandler = useCallback(\n (e: Parameters<NonNullable<TextFieldProps['onFocus']>>[0]) => {\n if (!isDisabled) {\n setIsFocused(true);\n onFocus?.(e);\n }\n },\n [isDisabled, onFocus],\n );\n\n const onPressHandler = useCallback(() => {\n if (!isDisabled && inputRef.current) {\n inputRef.current.focus();\n }\n }, [isDisabled]);\n\n return (\n <Pressable\n testID={testID}\n style={[containerStyle, style]}\n onPress={onPressHandler}\n accessible={false}\n >\n {startAccessory}\n <View style={tw.style('min-h-0 flex-1 justify-center')}>\n {inputElement ?? (\n <Input\n {...props}\n ref={inputRef}\n textVariant={TextVariant.BodyMd}\n isDisabled={isDisabled}\n autoFocus={autoFocus}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n isStateStylesDisabled\n // Row is `h-12` (48px) with `border` on the Pressable (1px top + bottom). Inner TextInput\n // uses 46px height so the field matches a 48px-tall control without vertical overflow.\n twClassName=\"h-[46px] bg-transparent border-0\"\n numberOfLines={1}\n multiline={false}\n />\n )}\n </View>\n {endAccessory}\n </Pressable>\n );\n },\n);\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { TextInput } from "react-native/index.js";
|
|
2
|
-
import { TextFieldSize } from "./TextField.types.cjs";
|
|
3
2
|
export declare const TextField: import("react").ForwardRefExoticComponent<Omit<import("../Input/index.cjs").InputProps, "style" | "textVariant" | "isStateStylesDisabled"> & {
|
|
4
|
-
size?: TextFieldSize | undefined;
|
|
5
3
|
startAccessory?: import("react").ReactNode;
|
|
6
4
|
endAccessory?: import("react").ReactNode;
|
|
7
5
|
isError?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.d.cts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AASA,OAAO,EAAa,SAAS,EAAQ,8BAAqB;
|
|
1
|
+
{"version":3,"file":"TextField.d.cts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AASA,OAAO,EAAa,SAAS,EAAQ,8BAAqB;AAwB1D,eAAO,MAAM,SAAS;;;;;;;6CA6GrB,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { TextInput } from "react-native/index.js";
|
|
2
|
-
import { TextFieldSize } from "./TextField.types.mjs";
|
|
3
2
|
export declare const TextField: import("react").ForwardRefExoticComponent<Omit<import("../Input/index.mjs").InputProps, "style" | "textVariant" | "isStateStylesDisabled"> & {
|
|
4
|
-
size?: TextFieldSize | undefined;
|
|
5
3
|
startAccessory?: import("react").ReactNode;
|
|
6
4
|
endAccessory?: import("react").ReactNode;
|
|
7
5
|
isError?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.d.mts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AASA,OAAO,EAAa,SAAS,EAAQ,8BAAqB;
|
|
1
|
+
{"version":3,"file":"TextField.d.mts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AASA,OAAO,EAAa,SAAS,EAAQ,8BAAqB;AAwB1D,eAAO,MAAM,SAAS;;;;;;;6CA6GrB,CAAC"}
|
|
@@ -3,14 +3,25 @@ import { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState
|
|
|
3
3
|
import { Pressable, TextInput, View } from "react-native/index.js";
|
|
4
4
|
import { TextVariant } from "../../types/index.mjs";
|
|
5
5
|
import { Input } from "../Input/index.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function getContainerBorderColorClass(isDisabled, isFocused, isError) {
|
|
7
|
+
if (isDisabled) {
|
|
8
|
+
return 'border-muted';
|
|
9
|
+
}
|
|
10
|
+
if (isError) {
|
|
11
|
+
return 'border-error-default';
|
|
12
|
+
}
|
|
13
|
+
if (isFocused) {
|
|
14
|
+
return 'border-default';
|
|
15
|
+
}
|
|
16
|
+
return 'border-muted';
|
|
17
|
+
}
|
|
18
|
+
export const TextField = forwardRef(({ style, startAccessory, endAccessory, isError = false, inputElement, isDisabled = false, autoFocus = false, twClassName, onBlur, onFocus, testID, ...props }, ref) => {
|
|
9
19
|
const [isFocused, setIsFocused] = useState(autoFocus);
|
|
10
20
|
const inputRef = useRef(null);
|
|
11
21
|
const tw = useTailwind();
|
|
12
22
|
useImperativeHandle(ref, () => inputRef.current, []);
|
|
13
|
-
const
|
|
23
|
+
const borderColorClass = getContainerBorderColorClass(isDisabled, isFocused, isError);
|
|
24
|
+
const containerStyle = useMemo(() => tw.style('flex-row', 'items-center', 'gap-3', 'rounded-lg', 'h-12', 'border', borderColorClass, 'px-4', 'bg-muted', isDisabled && 'opacity-50', twClassName), [borderColorClass, isDisabled, twClassName, tw]);
|
|
14
25
|
const onBlurHandler = useCallback((e) => {
|
|
15
26
|
if (!isDisabled) {
|
|
16
27
|
setIsFocused(false);
|
|
@@ -29,11 +40,14 @@ export const TextField = forwardRef(({ style, size = TextFieldSize.Md, startAcce
|
|
|
29
40
|
}
|
|
30
41
|
}, [isDisabled]);
|
|
31
42
|
return (<Pressable testID={testID} style={[containerStyle, style]} onPress={onPressHandler} accessible={false}>
|
|
32
|
-
{startAccessory
|
|
33
|
-
<View style={tw.style('flex-1')}>
|
|
34
|
-
{inputElement ?? (<Input {...props} ref={inputRef} textVariant={TextVariant.BodyMd} isDisabled={isDisabled} autoFocus={autoFocus} onBlur={onBlurHandler} onFocus={onFocusHandler} isStateStylesDisabled
|
|
43
|
+
{startAccessory}
|
|
44
|
+
<View style={tw.style('min-h-0 flex-1 justify-center')}>
|
|
45
|
+
{inputElement ?? (<Input {...props} ref={inputRef} textVariant={TextVariant.BodyMd} isDisabled={isDisabled} autoFocus={autoFocus} onBlur={onBlurHandler} onFocus={onFocusHandler} isStateStylesDisabled
|
|
46
|
+
// Row is `h-12` (48px) with `border` on the Pressable (1px top + bottom). Inner TextInput
|
|
47
|
+
// uses 46px height so the field matches a 48px-tall control without vertical overflow.
|
|
48
|
+
twClassName="h-[46px] bg-transparent border-0" numberOfLines={1} multiline={false}/>)}
|
|
35
49
|
</View>
|
|
36
|
-
{endAccessory
|
|
50
|
+
{endAccessory}
|
|
37
51
|
</Pressable>);
|
|
38
52
|
});
|
|
39
53
|
//# sourceMappingURL=TextField.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.mjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,EACL,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,OAAO,EACP,MAAM,EACN,QAAQ,EACT,cAAc;AACf,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,8BAAqB;AAE1D,OAAO,EAAE,WAAW,EAAE,8BAAoB;AAC1C,OAAO,EAAE,KAAK,EAAE,2BAAiB;
|
|
1
|
+
{"version":3,"file":"TextField.mjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,EACL,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,OAAO,EACP,MAAM,EACN,QAAQ,EACT,cAAc;AACf,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,8BAAqB;AAE1D,OAAO,EAAE,WAAW,EAAE,8BAAoB;AAC1C,OAAO,EAAE,KAAK,EAAE,2BAAiB;AAIjC,SAAS,4BAA4B,CACnC,UAAmB,EACnB,SAAkB,EAClB,OAAgB;IAEhB,IAAI,UAAU,EAAE;QACd,OAAO,cAAc,CAAC;KACvB;IACD,IAAI,OAAO,EAAE;QACX,OAAO,sBAAsB,CAAC;KAC/B;IACD,IAAI,SAAS,EAAE;QACb,OAAO,gBAAgB,CAAC;KACzB;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CACjC,CACE,EACE,KAAK,EACL,cAAc,EACd,YAAY,EACZ,OAAO,GAAG,KAAK,EACf,YAAY,EACZ,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,WAAW,EACX,MAAM,EACN,OAAO,EACP,MAAM,EACN,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,MAAM,CAAY,IAAI,CAAC,CAAC;IACzC,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IAEzB,mBAAmB,CACjB,GAAG,EACH,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EACtB,EAAE,CACH,CAAC;IAEF,MAAM,gBAAgB,GAAG,4BAA4B,CACnD,UAAU,EACV,SAAS,EACT,OAAO,CACR,CAAC;IAEF,MAAM,cAAc,GAAG,OAAO,CAC5B,GAAG,EAAE,CACH,EAAE,CAAC,KAAK,CACN,UAAU,EACV,cAAc,EACd,OAAO,EACP,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,UAAU,IAAI,YAAY,EAC1B,WAAW,CACZ,EACH,CAAC,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC,CAChD,CAAC;IAEF,MAAM,aAAa,GAAG,WAAW,CAC/B,CAAC,CAAuD,EAAE,EAAE;QAC1D,IAAI,CAAC,UAAU,EAAE;YACf,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;SACb;IACH,CAAC,EACD,CAAC,UAAU,EAAE,MAAM,CAAC,CACrB,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,CAAwD,EAAE,EAAE;QAC3D,IAAI,CAAC,UAAU,EAAE;YACf,YAAY,CAAC,IAAI,CAAC,CAAC;YACnB,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACd;IACH,CAAC,EACD,CAAC,UAAU,EAAE,OAAO,CAAC,CACtB,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE;QACtC,IAAI,CAAC,UAAU,IAAI,QAAQ,CAAC,OAAO,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;SAC1B;IACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,CAAC,SAAS,CACR,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,KAAK,CAAC,CAAC,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAC/B,OAAO,CAAC,CAAC,cAAc,CAAC,CACxB,UAAU,CAAC,CAAC,KAAK,CAAC,CAElB;QAAA,CAAC,cAAc,CACf;QAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CACrD;UAAA,CAAC,YAAY,IAAI,CACf,CAAC,KAAK,CACJ,IAAI,KAAK,CAAC,CACV,GAAG,CAAC,CAAC,QAAQ,CAAC,CACd,WAAW,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAChC,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,SAAS,CAAC,CAAC,SAAS,CAAC,CACrB,MAAM,CAAC,CAAC,aAAa,CAAC,CACtB,OAAO,CAAC,CAAC,cAAc,CAAC,CACxB,qBAAqB;QACrB,0FAA0F;QAC1F,uFAAuF;QACvF,WAAW,CAAC,kCAAkC,CAC9C,aAAa,CAAC,CAAC,CAAC,CAAC,CACjB,SAAS,CAAC,CAAC,KAAK,CAAC,EACjB,CACH,CACH;QAAA,EAAE,IAAI,CACN;QAAA,CAAC,YAAY,CACf;MAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Pressable, TextInput, View } from 'react-native';\n\nimport { TextVariant } from '../../types';\nimport { Input } from '../Input';\n\nimport type { TextFieldProps } from './TextField.types';\n\nfunction getContainerBorderColorClass(\n isDisabled: boolean,\n isFocused: boolean,\n isError: boolean,\n): string {\n if (isDisabled) {\n return 'border-muted';\n }\n if (isError) {\n return 'border-error-default';\n }\n if (isFocused) {\n return 'border-default';\n }\n return 'border-muted';\n}\n\nexport const TextField = forwardRef<TextInput, TextFieldProps>(\n (\n {\n style,\n startAccessory,\n endAccessory,\n isError = false,\n inputElement,\n isDisabled = false,\n autoFocus = false,\n twClassName,\n onBlur,\n onFocus,\n testID,\n ...props\n },\n ref,\n ) => {\n const [isFocused, setIsFocused] = useState(autoFocus);\n const inputRef = useRef<TextInput>(null);\n const tw = useTailwind();\n\n useImperativeHandle<TextInput | null, TextInput | null>(\n ref,\n () => inputRef.current,\n [],\n );\n\n const borderColorClass = getContainerBorderColorClass(\n isDisabled,\n isFocused,\n isError,\n );\n\n const containerStyle = useMemo(\n () =>\n tw.style(\n 'flex-row',\n 'items-center',\n 'gap-3',\n 'rounded-lg',\n 'h-12',\n 'border',\n borderColorClass,\n 'px-4',\n 'bg-muted',\n isDisabled && 'opacity-50',\n twClassName,\n ),\n [borderColorClass, isDisabled, twClassName, tw],\n );\n\n const onBlurHandler = useCallback(\n (e: Parameters<NonNullable<TextFieldProps['onBlur']>>[0]) => {\n if (!isDisabled) {\n setIsFocused(false);\n onBlur?.(e);\n }\n },\n [isDisabled, onBlur],\n );\n\n const onFocusHandler = useCallback(\n (e: Parameters<NonNullable<TextFieldProps['onFocus']>>[0]) => {\n if (!isDisabled) {\n setIsFocused(true);\n onFocus?.(e);\n }\n },\n [isDisabled, onFocus],\n );\n\n const onPressHandler = useCallback(() => {\n if (!isDisabled && inputRef.current) {\n inputRef.current.focus();\n }\n }, [isDisabled]);\n\n return (\n <Pressable\n testID={testID}\n style={[containerStyle, style]}\n onPress={onPressHandler}\n accessible={false}\n >\n {startAccessory}\n <View style={tw.style('min-h-0 flex-1 justify-center')}>\n {inputElement ?? (\n <Input\n {...props}\n ref={inputRef}\n textVariant={TextVariant.BodyMd}\n isDisabled={isDisabled}\n autoFocus={autoFocus}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n isStateStylesDisabled\n // Row is `h-12` (48px) with `border` on the Pressable (1px top + bottom). Inner TextInput\n // uses 46px height so the field matches a 48px-tall control without vertical overflow.\n twClassName=\"h-[46px] bg-transparent border-0\"\n numberOfLines={1}\n multiline={false}\n />\n )}\n </View>\n {endAccessory}\n </Pressable>\n );\n },\n);\n"]}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextFieldSize = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* TextFieldSize enum.
|
|
6
|
-
*/
|
|
7
|
-
var TextFieldSize;
|
|
8
|
-
(function (TextFieldSize) {
|
|
9
|
-
TextFieldSize["Sm"] = "sm";
|
|
10
|
-
TextFieldSize["Md"] = "md";
|
|
11
|
-
TextFieldSize["Lg"] = "lg";
|
|
12
|
-
})(TextFieldSize || (exports.TextFieldSize = TextFieldSize = {}));
|
|
13
3
|
//# sourceMappingURL=TextField.types.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.types.cjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextField.types.cjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport type { InputProps } from '../Input/Input.types';\n\n/**\n * TextField component props.\n */\nexport type TextFieldProps = Omit<\n InputProps,\n 'textVariant' | 'isStateStylesDisabled' | 'style'\n> & {\n /**\n * Optional content to display before the Input.\n */\n startAccessory?: ReactNode;\n /**\n * Optional content to display after the Input.\n */\n endAccessory?: ReactNode;\n /**\n * Optional boolean to show the error state.\n *\n * @default false\n */\n isError?: boolean;\n /**\n * Optional prop to replace the default Input with a custom element.\n */\n inputElement?: ReactNode;\n /**\n * Optional prop to add twrnc overriding classNames.\n */\n twClassName?: string;\n /**\n * Optional prop to customize the container style.\n */\n style?: StyleProp<ViewStyle>;\n};\n"]}
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { StyleProp, ViewStyle } from "react-native/index.js";
|
|
3
3
|
import type { InputProps } from "../Input/Input.types.cjs";
|
|
4
|
-
/**
|
|
5
|
-
* TextFieldSize enum.
|
|
6
|
-
*/
|
|
7
|
-
export declare enum TextFieldSize {
|
|
8
|
-
Sm = "sm",
|
|
9
|
-
Md = "md",
|
|
10
|
-
Lg = "lg"
|
|
11
|
-
}
|
|
12
4
|
/**
|
|
13
5
|
* TextField component props.
|
|
14
6
|
*/
|
|
15
7
|
export type TextFieldProps = Omit<InputProps, 'textVariant' | 'isStateStylesDisabled' | 'style'> & {
|
|
16
|
-
/**
|
|
17
|
-
* Optional prop for size of the TextField.
|
|
18
|
-
*
|
|
19
|
-
* @default TextFieldSize.Md
|
|
20
|
-
*/
|
|
21
|
-
size?: TextFieldSize;
|
|
22
8
|
/**
|
|
23
9
|
* Optional content to display before the Input.
|
|
24
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.types.d.cts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,8BAAqB;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,iCAA6B;AAEvD;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"TextField.types.d.cts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,8BAAqB;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,iCAA6B;AAEvD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,UAAU,EACV,aAAa,GAAG,uBAAuB,GAAG,OAAO,CAClD,GAAG;IACF;;OAEG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC"}
|