@ledgerhq/lumen-ui-rnative 0.1.36 → 0.1.38
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/dist/module/lib/Animations/Pulse/Pulse.mdx +1 -1
- package/dist/module/lib/Animations/Spin/Spin.mdx +1 -1
- package/dist/module/lib/Components/AddressInput/AddressInput.mdx +1 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.js +68 -39
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.js.map +1 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.mdx +7 -1
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.stories.js +24 -0
- package/dist/module/lib/Components/AmountDisplay/AmountDisplay.stories.js.map +1 -1
- package/dist/module/lib/Components/AmountDisplay/types.js.map +1 -1
- package/dist/module/lib/Components/AmountInput/AmountInput.js +109 -72
- package/dist/module/lib/Components/AmountInput/AmountInput.js.map +1 -1
- package/dist/module/lib/Components/AmountInput/AmountInput.mdx +13 -1
- package/dist/module/lib/Components/AmountInput/AmountInput.stories.js +53 -0
- package/dist/module/lib/Components/AmountInput/AmountInput.stories.js.map +1 -1
- package/dist/module/lib/Components/Avatar/Avatar.js +6 -5
- package/dist/module/lib/Components/Avatar/Avatar.js.map +1 -1
- package/dist/module/lib/Components/Avatar/Avatar.mdx +3 -1
- package/dist/module/lib/Components/Avatar/Avatar.test.js +10 -13
- package/dist/module/lib/Components/Avatar/Avatar.test.js.map +1 -1
- package/dist/module/lib/Components/Banner/Banner.mdx +1 -1
- package/dist/module/lib/Components/BottomSheet/BottomSheet.mdx +1 -1
- package/dist/module/lib/Components/Button/Button.mdx +1 -1
- package/dist/module/lib/Components/Card/Card.stories.js +4 -9
- package/dist/module/lib/Components/Card/Card.stories.js.map +1 -1
- package/dist/module/lib/Components/CardButton/CardButton.mdx +1 -1
- package/dist/module/lib/Components/Checkbox/Checkbox.mdx +1 -1
- package/dist/module/lib/Components/Divider/Divider.mdx +1 -1
- package/dist/module/lib/Components/DotIcon/DotIcon.js +51 -27
- package/dist/module/lib/Components/DotIcon/DotIcon.js.map +1 -1
- package/dist/module/lib/Components/DotIcon/DotIcon.mdx +92 -0
- package/dist/module/lib/Components/DotIcon/DotIcon.stories.js +57 -0
- package/dist/module/lib/Components/DotIcon/DotIcon.stories.js.map +1 -1
- package/dist/module/lib/Components/DotIndicator/DotIndicator.js +5 -5
- package/dist/module/lib/Components/DotIndicator/DotIndicator.js.map +1 -1
- package/dist/module/lib/Components/DotIndicator/DotIndicator.mdx +4 -4
- package/dist/module/lib/Components/DotIndicator/DotIndicator.stories.js +3 -3
- package/dist/module/lib/Components/DotIndicator/DotIndicator.test.js +12 -2
- package/dist/module/lib/Components/DotIndicator/DotIndicator.test.js.map +1 -1
- package/dist/module/lib/Components/DotSymbol/DotSymbol.js +59 -34
- package/dist/module/lib/Components/DotSymbol/DotSymbol.js.map +1 -1
- package/dist/module/lib/Components/DotSymbol/DotSymbol.mdx +79 -2
- package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js +60 -0
- package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js.map +1 -1
- package/dist/module/lib/Components/IconButton/IconButton.mdx +1 -1
- package/dist/module/lib/Components/InteractiveIcon/InteractiveIcon.mdx +1 -1
- package/dist/module/lib/Components/Label/Label.js +1 -1
- package/dist/module/lib/Components/Link/Link.mdx +1 -1
- package/dist/module/lib/Components/MediaBanner/MediaBanner.mdx +1 -1
- package/dist/module/lib/Components/MediaButton/MediaButton.js +19 -19
- package/dist/module/lib/Components/MediaButton/MediaButton.js.map +1 -1
- package/dist/module/lib/Components/MediaButton/MediaButton.mdx +5 -5
- package/dist/module/lib/Components/MediaButton/MediaButton.stories.js +17 -17
- package/dist/module/lib/Components/MediaButton/MediaButton.stories.js.map +1 -1
- package/dist/module/lib/Components/MediaButton/MediaButton.test.js +4 -4
- package/dist/module/lib/Components/MediaButton/MediaButton.test.js.map +1 -1
- package/dist/module/lib/Components/MediaImage/MediaImage.js +24 -6
- package/dist/module/lib/Components/MediaImage/MediaImage.js.map +1 -1
- package/dist/module/lib/Components/MediaImage/MediaImage.mdx +1 -1
- package/dist/module/lib/Components/MediaImage/MediaImage.stories.js +47 -0
- package/dist/module/lib/Components/MediaImage/MediaImage.stories.js.map +1 -1
- package/dist/module/lib/Components/NavBar/CoinCapsule.js +2 -2
- package/dist/module/lib/Components/NavBar/CoinCapsule.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.js +2 -2
- package/dist/module/lib/Components/NavBar/NavBar.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.mdx +2 -2
- package/dist/module/lib/Components/NavBar/NavBar.stories.js +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.stories.js.map +1 -1
- package/dist/module/lib/Components/NavBar/NavBar.test.js +3 -3
- package/dist/module/lib/Components/NavBar/NavBar.test.js.map +1 -1
- package/dist/module/lib/Components/OptionList/OptionList.mdx +1 -1
- package/dist/module/lib/Components/OptionList/OptionList.stories.js +4 -4
- package/dist/module/lib/Components/OptionList/OptionList.stories.js.map +1 -1
- package/dist/module/lib/Components/PageIndicator/PageIndicator.js +13 -8
- package/dist/module/lib/Components/PageIndicator/PageIndicator.js.map +1 -1
- package/dist/module/lib/Components/PageIndicator/PageIndicator.test.js +58 -0
- package/dist/module/lib/Components/PageIndicator/PageIndicator.test.js.map +1 -1
- package/dist/module/lib/Components/SearchInput/SearchInput.mdx +1 -1
- package/dist/module/lib/Components/SegmentedControl/SegmentedControl.mdx +1 -1
- package/dist/module/lib/Components/Spinner/Spinner.mdx +1 -1
- package/dist/module/lib/Components/Spot/Spot.mdx +1 -1
- package/dist/module/lib/Components/Stepper/Stepper.mdx +1 -1
- package/dist/module/lib/Components/Subheader/Subheader.mdx +1 -1
- package/dist/module/lib/Components/Switch/Switch.mdx +1 -1
- package/dist/module/lib/Components/TabBar/TabBar.mdx +1 -1
- package/dist/module/lib/Components/TextInput/TextInput.mdx +1 -1
- package/dist/module/lib/Components/ThemeProvider/ThemeProvider.js +2 -5
- package/dist/module/lib/Components/ThemeProvider/ThemeProvider.js.map +1 -1
- package/dist/module/lib/Components/Tile/Tile.mdx +1 -1
- package/dist/module/lib/Components/Tooltip/Tooltip.mdx +1 -1
- package/dist/module/lib/Components/index.js +0 -1
- package/dist/module/lib/Components/index.js.map +1 -1
- package/dist/module/lib/Symbols/Icons/Lightbulb.js +3 -3
- package/dist/module/lib/Symbols/Icons/Lightbulb.js.map +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/AmountDisplay.d.ts +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/AmountDisplay.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/index.d.ts +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountDisplay/types.d.ts +10 -3
- package/dist/typescript/src/lib/Components/AmountDisplay/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountInput/AmountInput.d.ts +1 -1
- package/dist/typescript/src/lib/Components/AmountInput/AmountInput.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/AmountInput/types.d.ts +12 -0
- package/dist/typescript/src/lib/Components/AmountInput/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts +1 -1
- package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotIcon/DotIcon.d.ts +3 -2
- package/dist/typescript/src/lib/Components/DotIcon/DotIcon.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotIcon/types.d.ts +7 -1
- package/dist/typescript/src/lib/Components/DotIcon/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotIndicator/types.d.ts +2 -2
- package/dist/typescript/src/lib/Components/DotSymbol/DotSymbol.d.ts +1 -1
- package/dist/typescript/src/lib/Components/DotSymbol/DotSymbol.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DotSymbol/types.d.ts +7 -1
- package/dist/typescript/src/lib/Components/DotSymbol/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/Label/Label.d.ts +1 -1
- package/dist/typescript/src/lib/Components/MediaButton/MediaButton.d.ts +5 -5
- package/dist/typescript/src/lib/Components/MediaButton/MediaButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaButton/types.d.ts +6 -6
- package/dist/typescript/src/lib/Components/MediaButton/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/MediaImage.d.ts +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/MediaImage.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/MediaImage/types.d.ts +7 -1
- package/dist/typescript/src/lib/Components/MediaImage/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/NavBar/CoinCapsule.d.ts +1 -1
- package/dist/typescript/src/lib/Components/NavBar/CoinCapsule.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/NavBar/NavBar.d.ts +1 -1
- package/dist/typescript/src/lib/Components/NavBar/NavBar.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/NavBar/types.d.ts +3 -3
- package/dist/typescript/src/lib/Components/NavBar/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/PageIndicator/PageIndicator.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/index.d.ts +0 -1
- package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Animations/Pulse/Pulse.mdx +1 -1
- package/src/lib/Animations/Spin/Spin.mdx +1 -1
- package/src/lib/Components/AddressInput/AddressInput.mdx +1 -1
- package/src/lib/Components/AmountDisplay/AmountDisplay.mdx +7 -1
- package/src/lib/Components/AmountDisplay/AmountDisplay.stories.tsx +18 -0
- package/src/lib/Components/AmountDisplay/AmountDisplay.tsx +71 -40
- package/src/lib/Components/AmountDisplay/index.ts +5 -1
- package/src/lib/Components/AmountDisplay/types.ts +12 -3
- package/src/lib/Components/AmountInput/AmountInput.mdx +13 -1
- package/src/lib/Components/AmountInput/AmountInput.stories.tsx +68 -1
- package/src/lib/Components/AmountInput/AmountInput.tsx +118 -75
- package/src/lib/Components/AmountInput/types.ts +14 -0
- package/src/lib/Components/Avatar/Avatar.mdx +3 -1
- package/src/lib/Components/Avatar/Avatar.test.tsx +16 -18
- package/src/lib/Components/Avatar/Avatar.tsx +9 -8
- package/src/lib/Components/Banner/Banner.mdx +1 -1
- package/src/lib/Components/BottomSheet/BottomSheet.mdx +1 -1
- package/src/lib/Components/Button/Button.mdx +1 -1
- package/src/lib/Components/Card/Card.stories.tsx +1 -3
- package/src/lib/Components/CardButton/CardButton.mdx +1 -1
- package/src/lib/Components/Checkbox/Checkbox.mdx +1 -1
- package/src/lib/Components/Divider/Divider.mdx +1 -1
- package/src/lib/Components/DotIcon/DotIcon.mdx +92 -0
- package/src/lib/Components/DotIcon/DotIcon.stories.tsx +43 -0
- package/src/lib/Components/DotIcon/DotIcon.tsx +35 -15
- package/src/lib/Components/DotIcon/types.ts +7 -1
- package/src/lib/Components/DotIndicator/DotIndicator.mdx +4 -4
- package/src/lib/Components/DotIndicator/DotIndicator.stories.tsx +2 -2
- package/src/lib/Components/DotIndicator/DotIndicator.test.tsx +12 -2
- package/src/lib/Components/DotIndicator/DotIndicator.tsx +5 -5
- package/src/lib/Components/DotIndicator/types.ts +2 -2
- package/src/lib/Components/DotSymbol/DotSymbol.mdx +79 -2
- package/src/lib/Components/DotSymbol/DotSymbol.stories.tsx +32 -0
- package/src/lib/Components/DotSymbol/DotSymbol.tsx +46 -25
- package/src/lib/Components/DotSymbol/types.ts +7 -1
- package/src/lib/Components/IconButton/IconButton.mdx +1 -1
- package/src/lib/Components/InteractiveIcon/InteractiveIcon.mdx +1 -1
- package/src/lib/Components/Label/Label.tsx +1 -1
- package/src/lib/Components/Link/Link.mdx +1 -1
- package/src/lib/Components/MediaBanner/MediaBanner.mdx +1 -1
- package/src/lib/Components/MediaButton/MediaButton.mdx +5 -5
- package/src/lib/Components/MediaButton/MediaButton.stories.tsx +29 -15
- package/src/lib/Components/MediaButton/MediaButton.test.tsx +4 -4
- package/src/lib/Components/MediaButton/MediaButton.tsx +35 -22
- package/src/lib/Components/MediaButton/types.ts +6 -6
- package/src/lib/Components/MediaImage/MediaImage.mdx +1 -1
- package/src/lib/Components/MediaImage/MediaImage.stories.tsx +21 -0
- package/src/lib/Components/MediaImage/MediaImage.tsx +14 -2
- package/src/lib/Components/MediaImage/types.ts +7 -1
- package/src/lib/Components/NavBar/CoinCapsule.tsx +2 -2
- package/src/lib/Components/NavBar/NavBar.mdx +2 -2
- package/src/lib/Components/NavBar/NavBar.stories.tsx +3 -1
- package/src/lib/Components/NavBar/NavBar.test.tsx +3 -3
- package/src/lib/Components/NavBar/NavBar.tsx +2 -2
- package/src/lib/Components/NavBar/types.ts +3 -3
- package/src/lib/Components/OptionList/OptionList.mdx +1 -1
- package/src/lib/Components/OptionList/OptionList.stories.tsx +4 -4
- package/src/lib/Components/PageIndicator/PageIndicator.test.tsx +78 -0
- package/src/lib/Components/PageIndicator/PageIndicator.tsx +15 -7
- package/src/lib/Components/SearchInput/SearchInput.mdx +1 -1
- package/src/lib/Components/SegmentedControl/SegmentedControl.mdx +1 -1
- package/src/lib/Components/Spinner/Spinner.mdx +1 -1
- package/src/lib/Components/Spot/Spot.mdx +1 -1
- package/src/lib/Components/Stepper/Stepper.mdx +1 -1
- package/src/lib/Components/Subheader/Subheader.mdx +1 -1
- package/src/lib/Components/Switch/Switch.mdx +1 -1
- package/src/lib/Components/TabBar/TabBar.mdx +1 -1
- package/src/lib/Components/TextInput/TextInput.mdx +1 -1
- package/src/lib/Components/ThemeProvider/ThemeProvider.tsx +1 -4
- package/src/lib/Components/Tile/Tile.mdx +1 -1
- package/src/lib/Components/Tooltip/Tooltip.mdx +1 -1
- package/src/lib/Components/index.ts +0 -1
- package/src/lib/Symbols/Icons/Lightbulb.tsx +3 -3
- package/dist/module/lib/Components/Select/GlobalSelectBottomSheet.js +0 -155
- package/dist/module/lib/Components/Select/GlobalSelectBottomSheet.js.map +0 -1
- package/dist/module/lib/Components/Select/GlobalSelectContext.js +0 -78
- package/dist/module/lib/Components/Select/GlobalSelectContext.js.map +0 -1
- package/dist/module/lib/Components/Select/Select.js +0 -366
- package/dist/module/lib/Components/Select/Select.js.map +0 -1
- package/dist/module/lib/Components/Select/Select.mdx +0 -596
- package/dist/module/lib/Components/Select/Select.stories.js +0 -304
- package/dist/module/lib/Components/Select/Select.stories.js.map +0 -1
- package/dist/module/lib/Components/Select/Select.test.js +0 -123
- package/dist/module/lib/Components/Select/Select.test.js.map +0 -1
- package/dist/module/lib/Components/Select/SelectContext.js +0 -38
- package/dist/module/lib/Components/Select/SelectContext.js.map +0 -1
- package/dist/module/lib/Components/Select/index.js +0 -6
- package/dist/module/lib/Components/Select/index.js.map +0 -1
- package/dist/module/lib/Components/Select/types.js +0 -4
- package/dist/module/lib/Components/Select/types.js.map +0 -1
- package/dist/typescript/src/lib/Components/Select/GlobalSelectBottomSheet.d.ts +0 -20
- package/dist/typescript/src/lib/Components/Select/GlobalSelectBottomSheet.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/GlobalSelectContext.d.ts +0 -44
- package/dist/typescript/src/lib/Components/Select/GlobalSelectContext.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/Select.d.ts +0 -52
- package/dist/typescript/src/lib/Components/Select/Select.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/SelectContext.d.ts +0 -36
- package/dist/typescript/src/lib/Components/Select/SelectContext.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/index.d.ts +0 -4
- package/dist/typescript/src/lib/Components/Select/index.d.ts.map +0 -1
- package/dist/typescript/src/lib/Components/Select/types.d.ts +0 -130
- package/dist/typescript/src/lib/Components/Select/types.d.ts.map +0 -1
- package/src/lib/Components/Select/GlobalSelectBottomSheet.tsx +0 -180
- package/src/lib/Components/Select/GlobalSelectContext.tsx +0 -103
- package/src/lib/Components/Select/Select.mdx +0 -596
- package/src/lib/Components/Select/Select.stories.tsx +0 -266
- package/src/lib/Components/Select/Select.test.tsx +0 -117
- package/src/lib/Components/Select/Select.tsx +0 -469
- package/src/lib/Components/Select/SelectContext.tsx +0 -68
- package/src/lib/Components/Select/index.ts +0 -3
- package/src/lib/Components/Select/types.ts +0 -149
|
@@ -12,7 +12,7 @@ import CommonRulesDoAndDont from '../../../../.storybook/components/DoVsDont/Com
|
|
|
12
12
|
|
|
13
13
|
<Meta title='Communication/AmountDisplay' of={AmountDisplayStories} />
|
|
14
14
|
|
|
15
|
-
#
|
|
15
|
+
# AmountDisplay
|
|
16
16
|
|
|
17
17
|
<CustomTabs>
|
|
18
18
|
<Tab label="Overview">
|
|
@@ -39,6 +39,12 @@ The AmountDisplay component renders formatted monetary amounts with flexible cur
|
|
|
39
39
|
<Canvas of={AmountDisplayStories.Base} />
|
|
40
40
|
<Controls of={AmountDisplayStories.Base} />
|
|
41
41
|
|
|
42
|
+
### Size
|
|
43
|
+
|
|
44
|
+
The `size` prop controls the typographic scale of the amount display. Use `md` (default) for primary amounts and `sm` for secondary or contextual amounts.
|
|
45
|
+
|
|
46
|
+
<Canvas of={AmountDisplayStories.Sizes} />
|
|
47
|
+
|
|
42
48
|
### Privacy
|
|
43
49
|
|
|
44
50
|
The `hidden` prop allows you to toggle amount visibility for privacy-sensitive applications. When set to `true`, the component displays bullet points (••••) instead of the actual amount, while keeping the currency symbol visible. The example below demonstrates toggling amount visibility with a button.
|
|
@@ -79,6 +79,12 @@ const meta: Meta<typeof AmountDisplay> = {
|
|
|
79
79
|
type: 'boolean',
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
|
+
size: {
|
|
83
|
+
control: {
|
|
84
|
+
type: 'select',
|
|
85
|
+
},
|
|
86
|
+
options: ['sm', 'md'],
|
|
87
|
+
},
|
|
82
88
|
},
|
|
83
89
|
parameters: {
|
|
84
90
|
layout: 'centered',
|
|
@@ -109,6 +115,18 @@ export const Base: Story = {
|
|
|
109
115
|
},
|
|
110
116
|
};
|
|
111
117
|
|
|
118
|
+
export const Sizes: Story = {
|
|
119
|
+
args: {
|
|
120
|
+
value: 1234.56,
|
|
121
|
+
},
|
|
122
|
+
render: (props) => (
|
|
123
|
+
<View style={{ alignItems: 'center', gap: 24 }}>
|
|
124
|
+
<AmountDisplay {...props} size='md' />
|
|
125
|
+
<AmountDisplay {...props} size='sm' />
|
|
126
|
+
</View>
|
|
127
|
+
),
|
|
128
|
+
};
|
|
129
|
+
|
|
112
130
|
export const WithHideButton: Story = {
|
|
113
131
|
render: (props) => {
|
|
114
132
|
const [hidden, setHidden] = useState(false);
|
|
@@ -8,6 +8,7 @@ import Animated, {
|
|
|
8
8
|
withTiming,
|
|
9
9
|
} from 'react-native-reanimated';
|
|
10
10
|
import { useCommonTranslation } from '../../../i18n';
|
|
11
|
+
import type { LumenTypographyTokenName } from '../../../styles';
|
|
11
12
|
import { useStyleSheet } from '../../../styles';
|
|
12
13
|
import { Pulse } from '../../Animations/Pulse';
|
|
13
14
|
import { useTimingConfig } from '../../Animations/useTimingConfig';
|
|
@@ -15,38 +16,66 @@ import { RuntimeConstants } from '../../utils';
|
|
|
15
16
|
import { Box } from '../Utility';
|
|
16
17
|
import type {
|
|
17
18
|
AmountDisplayProps,
|
|
19
|
+
AmountDisplaySize,
|
|
18
20
|
DigitStripListProps,
|
|
19
21
|
DigitStripProps,
|
|
22
|
+
DigitWidths,
|
|
20
23
|
} from './types';
|
|
21
24
|
import { DIGITS } from './types';
|
|
22
25
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
const TYPOGRAPHY_WIDTHS = {
|
|
27
|
+
heading1SemiBold: {
|
|
28
|
+
0: 25,
|
|
29
|
+
1: 15.5,
|
|
30
|
+
2: 23.5,
|
|
31
|
+
3: 24.5,
|
|
32
|
+
4: 25.5,
|
|
33
|
+
5: 23.5,
|
|
34
|
+
6: 25,
|
|
35
|
+
7: 22,
|
|
36
|
+
8: 24.5,
|
|
37
|
+
9: 24.5,
|
|
38
|
+
},
|
|
39
|
+
heading2SemiBold: {
|
|
40
|
+
0: 17.5,
|
|
41
|
+
1: 11,
|
|
42
|
+
2: 16.5,
|
|
43
|
+
3: 17,
|
|
44
|
+
4: 18,
|
|
45
|
+
5: 16,
|
|
46
|
+
6: 17.5,
|
|
47
|
+
7: 15,
|
|
48
|
+
8: 17,
|
|
49
|
+
9: 17,
|
|
50
|
+
},
|
|
51
|
+
heading4SemiBold: {
|
|
52
|
+
0: 13,
|
|
53
|
+
1: 8.5,
|
|
54
|
+
2: 12.5,
|
|
55
|
+
3: 12.5,
|
|
56
|
+
4: 13,
|
|
57
|
+
5: 12,
|
|
58
|
+
6: 12.5,
|
|
59
|
+
7: 11.5,
|
|
60
|
+
8: 12.5,
|
|
61
|
+
9: 12.5,
|
|
62
|
+
},
|
|
63
|
+
} as const satisfies Partial<Record<LumenTypographyTokenName, DigitWidths>>;
|
|
64
|
+
|
|
65
|
+
type MeasuredTypography = keyof typeof TYPOGRAPHY_WIDTHS;
|
|
66
|
+
|
|
67
|
+
type SizeTypographyConfig = {
|
|
68
|
+
integer: MeasuredTypography;
|
|
69
|
+
decimal: MeasuredTypography;
|
|
34
70
|
};
|
|
35
71
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
2: 16.5,
|
|
40
|
-
3: 17,
|
|
41
|
-
4: 18,
|
|
42
|
-
5: 16,
|
|
43
|
-
6: 17.5,
|
|
44
|
-
7: 15,
|
|
45
|
-
8: 17,
|
|
46
|
-
9: 17,
|
|
72
|
+
const SIZE_TYPOGRAPHY: Record<AmountDisplaySize, SizeTypographyConfig> = {
|
|
73
|
+
md: { integer: 'heading1SemiBold', decimal: 'heading2SemiBold' },
|
|
74
|
+
sm: { integer: 'heading2SemiBold', decimal: 'heading4SemiBold' },
|
|
47
75
|
};
|
|
48
76
|
|
|
49
|
-
const useStyles = () => {
|
|
77
|
+
const useStyles = (size: AmountDisplaySize) => {
|
|
78
|
+
const typography = SIZE_TYPOGRAPHY[size];
|
|
50
79
|
return useStyleSheet(
|
|
51
80
|
(t) => ({
|
|
52
81
|
container: {
|
|
@@ -61,19 +90,19 @@ const useStyles = () => {
|
|
|
61
90
|
paddingBottom: t.spacings.s2,
|
|
62
91
|
},
|
|
63
92
|
integerText: {
|
|
64
|
-
...t.typographies.
|
|
93
|
+
...t.typographies[typography.integer],
|
|
65
94
|
color: t.colors.text.base,
|
|
66
95
|
},
|
|
67
96
|
decimalText: {
|
|
68
|
-
...t.typographies.
|
|
97
|
+
...t.typographies[typography.decimal],
|
|
69
98
|
color: t.colors.text.muted,
|
|
70
99
|
},
|
|
71
100
|
currencyStartText: {
|
|
72
|
-
...t.typographies.
|
|
101
|
+
...t.typographies[typography.integer],
|
|
73
102
|
color: t.colors.text.base,
|
|
74
103
|
},
|
|
75
104
|
currencyEndText: {
|
|
76
|
-
...t.typographies.
|
|
105
|
+
...t.typographies[typography.decimal],
|
|
77
106
|
color: t.colors.text.muted,
|
|
78
107
|
},
|
|
79
108
|
spacingStart: {
|
|
@@ -83,7 +112,7 @@ const useStyles = () => {
|
|
|
83
112
|
marginLeft: t.spacings.s4,
|
|
84
113
|
},
|
|
85
114
|
}),
|
|
86
|
-
[],
|
|
115
|
+
[typography],
|
|
87
116
|
);
|
|
88
117
|
};
|
|
89
118
|
|
|
@@ -136,10 +165,8 @@ const useAnimatedDigitStrip = ({
|
|
|
136
165
|
};
|
|
137
166
|
|
|
138
167
|
const DigitStrip = memo(
|
|
139
|
-
({ value, textStyle, animate,
|
|
140
|
-
const targetWidth =
|
|
141
|
-
type === 'integer' ? INTEGER_DIGIT_WIDTHS : DECIMAL_DIGIT_WIDTHS
|
|
142
|
-
)[value];
|
|
168
|
+
({ value, textStyle, animate, widths }: DigitStripProps) => {
|
|
169
|
+
const targetWidth = widths[value];
|
|
143
170
|
const lineHeight = textStyle.lineHeight;
|
|
144
171
|
const width = useSharedValue<number>(targetWidth);
|
|
145
172
|
const { animatedStyle } = useAnimatedDigitStrip({
|
|
@@ -176,7 +203,7 @@ const DigitStrip = memo(
|
|
|
176
203
|
DigitStrip.displayName = 'DigitStrip';
|
|
177
204
|
|
|
178
205
|
const DigitStripList = memo(
|
|
179
|
-
({ items, textStyle, animate,
|
|
206
|
+
({ items, textStyle, animate, widths }: DigitStripListProps) => {
|
|
180
207
|
return items.map((item, index) => {
|
|
181
208
|
const key = items.length - index;
|
|
182
209
|
if (item.type === 'separator') {
|
|
@@ -192,7 +219,7 @@ const DigitStripList = memo(
|
|
|
192
219
|
value={Number(item.value) as DigitStripProps['value']}
|
|
193
220
|
animate={animate}
|
|
194
221
|
textStyle={textStyle}
|
|
195
|
-
|
|
222
|
+
widths={widths}
|
|
196
223
|
/>
|
|
197
224
|
);
|
|
198
225
|
});
|
|
@@ -233,15 +260,16 @@ DigitStripList.displayName = 'DigitStripList';
|
|
|
233
260
|
* <AmountDisplay value={1234.56} formatter={usdFormatter} hidden={true} />
|
|
234
261
|
* ```
|
|
235
262
|
*/
|
|
236
|
-
export
|
|
263
|
+
export function AmountDisplay({
|
|
237
264
|
value,
|
|
238
265
|
formatter,
|
|
239
266
|
hidden = false,
|
|
240
267
|
loading = false,
|
|
241
268
|
animate = true,
|
|
269
|
+
size = 'md',
|
|
242
270
|
...props
|
|
243
|
-
}: AmountDisplayProps)
|
|
244
|
-
const styles = useStyles();
|
|
271
|
+
}: AmountDisplayProps) {
|
|
272
|
+
const styles = useStyles(size);
|
|
245
273
|
const { t } = useCommonTranslation();
|
|
246
274
|
const parts = formatter(value);
|
|
247
275
|
const splitDigits = useSplitText(parts);
|
|
@@ -250,6 +278,9 @@ export const AmountDisplay = ({
|
|
|
250
278
|
hidden,
|
|
251
279
|
t('components.amountDisplay.amountHiddenAriaLabel'),
|
|
252
280
|
);
|
|
281
|
+
const typography = SIZE_TYPOGRAPHY[size];
|
|
282
|
+
const integerWidths = TYPOGRAPHY_WIDTHS[typography.integer];
|
|
283
|
+
const decimalWidths = TYPOGRAPHY_WIDTHS[typography.decimal];
|
|
253
284
|
|
|
254
285
|
return (
|
|
255
286
|
<Box
|
|
@@ -281,7 +312,7 @@ export const AmountDisplay = ({
|
|
|
281
312
|
items={splitDigits.integerPart}
|
|
282
313
|
textStyle={styles.integerText}
|
|
283
314
|
animate={animate}
|
|
284
|
-
|
|
315
|
+
widths={integerWidths}
|
|
285
316
|
/>
|
|
286
317
|
)}
|
|
287
318
|
</View>
|
|
@@ -296,7 +327,7 @@ export const AmountDisplay = ({
|
|
|
296
327
|
items={splitDigits.decimalPart}
|
|
297
328
|
textStyle={styles.decimalText}
|
|
298
329
|
animate={animate}
|
|
299
|
-
|
|
330
|
+
widths={decimalWidths}
|
|
300
331
|
/>
|
|
301
332
|
)}
|
|
302
333
|
{parts.currencyPosition === 'end' && (
|
|
@@ -312,4 +343,4 @@ export const AmountDisplay = ({
|
|
|
312
343
|
</Pulse>
|
|
313
344
|
</Box>
|
|
314
345
|
);
|
|
315
|
-
}
|
|
346
|
+
}
|
|
@@ -6,13 +6,17 @@ export type { FormattedValue };
|
|
|
6
6
|
|
|
7
7
|
export const DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as const;
|
|
8
8
|
|
|
9
|
-
type
|
|
9
|
+
type Digit = (typeof DIGITS)[number];
|
|
10
|
+
|
|
11
|
+
export type AmountDisplaySize = 'sm' | 'md';
|
|
12
|
+
|
|
13
|
+
export type DigitWidths = Record<Digit, number>;
|
|
10
14
|
|
|
11
15
|
export type DigitStripProps = {
|
|
12
|
-
value:
|
|
16
|
+
value: Digit;
|
|
13
17
|
animate: boolean;
|
|
14
18
|
textStyle: TextStyle & { lineHeight: number };
|
|
15
|
-
|
|
19
|
+
widths: DigitWidths;
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
export type DigitStripListProps = {
|
|
@@ -48,4 +52,9 @@ export type AmountDisplayProps = ViewProps & {
|
|
|
48
52
|
* @default true
|
|
49
53
|
*/
|
|
50
54
|
animate?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The size variant of the amount display.
|
|
57
|
+
* @default 'md'
|
|
58
|
+
*/
|
|
59
|
+
size?: AmountDisplaySize;
|
|
51
60
|
} & Omit<StyledViewProps, 'children'>;
|
|
@@ -7,7 +7,7 @@ import CommonRulesDoAndDont from '../../../../.storybook/components/DoVsDont/Com
|
|
|
7
7
|
|
|
8
8
|
<Meta title='Input/AmountInput' of={AmountInputStories} />
|
|
9
9
|
|
|
10
|
-
#
|
|
10
|
+
# AmountInput
|
|
11
11
|
|
|
12
12
|
<CustomTabs>
|
|
13
13
|
<Tab label="Overview">
|
|
@@ -29,6 +29,18 @@ AmountInput is a specialized input component designed for handling numeric value
|
|
|
29
29
|
|
|
30
30
|
> **Layout:** The AmountInput component takes the full width of its container by default. You can control the width by using the `style` prop or by wrapping in a container.
|
|
31
31
|
|
|
32
|
+
### Size
|
|
33
|
+
|
|
34
|
+
Use the `size` prop to control typography scale.
|
|
35
|
+
|
|
36
|
+
<Canvas of={AmountInputStories.Size} />
|
|
37
|
+
|
|
38
|
+
### Alignment
|
|
39
|
+
|
|
40
|
+
Use the `align` prop to position the amount within its container. Defaults to `center`. Use `start` or `end` for left- or right-aligned layouts.
|
|
41
|
+
|
|
42
|
+
<Canvas of={AmountInputStories.Alignment} />
|
|
43
|
+
|
|
32
44
|
### Currency Text Position
|
|
33
45
|
|
|
34
46
|
The currency text can be positioned on either the **left** (default) or **right** side of the input:
|
|
@@ -2,7 +2,18 @@ import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { View } from 'react-native';
|
|
4
4
|
import { AmountInput } from './AmountInput';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type AmountInputAlign,
|
|
7
|
+
type AmountInputProps,
|
|
8
|
+
type AmountInputSize,
|
|
9
|
+
} from './types';
|
|
10
|
+
|
|
11
|
+
const ALIGNMENTS: AmountInputAlign[] = ['start', 'center', 'end'];
|
|
12
|
+
|
|
13
|
+
const SIZES: { size: AmountInputSize; value: string }[] = [
|
|
14
|
+
{ size: 'md', value: '1234.56' },
|
|
15
|
+
{ size: 'sm', value: '55 555' },
|
|
16
|
+
];
|
|
6
17
|
|
|
7
18
|
const meta: Meta<typeof AmountInput> = {
|
|
8
19
|
component: AmountInput,
|
|
@@ -16,6 +27,15 @@ const meta: Meta<typeof AmountInput> = {
|
|
|
16
27
|
},
|
|
17
28
|
},
|
|
18
29
|
},
|
|
30
|
+
argTypes: {
|
|
31
|
+
isInvalid: {
|
|
32
|
+
control: 'boolean',
|
|
33
|
+
description: 'Marks the input as invalid for error styling.',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
args: {
|
|
37
|
+
isInvalid: false,
|
|
38
|
+
},
|
|
19
39
|
};
|
|
20
40
|
|
|
21
41
|
export default meta;
|
|
@@ -68,6 +88,53 @@ export const WithValue: Story = {
|
|
|
68
88
|
},
|
|
69
89
|
};
|
|
70
90
|
|
|
91
|
+
export const Size: Story = {
|
|
92
|
+
render: () => (
|
|
93
|
+
<View
|
|
94
|
+
style={{
|
|
95
|
+
width: '100%',
|
|
96
|
+
maxWidth: 320,
|
|
97
|
+
alignItems: 'center',
|
|
98
|
+
gap: 24,
|
|
99
|
+
padding: 24,
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
{SIZES.map(({ size, value }) => (
|
|
103
|
+
<AmountInput
|
|
104
|
+
key={size}
|
|
105
|
+
size={size}
|
|
106
|
+
value={value}
|
|
107
|
+
currencyText='$'
|
|
108
|
+
onChangeText={() => {}}
|
|
109
|
+
/>
|
|
110
|
+
))}
|
|
111
|
+
</View>
|
|
112
|
+
),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const Alignment: Story = {
|
|
116
|
+
render: () => (
|
|
117
|
+
<View
|
|
118
|
+
style={{
|
|
119
|
+
width: '100%',
|
|
120
|
+
maxWidth: 320,
|
|
121
|
+
gap: 24,
|
|
122
|
+
padding: 24,
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
{ALIGNMENTS.map((align) => (
|
|
126
|
+
<AmountInput
|
|
127
|
+
key={align}
|
|
128
|
+
align={align}
|
|
129
|
+
value='1234.56'
|
|
130
|
+
currencyText='$'
|
|
131
|
+
onChangeText={() => {}}
|
|
132
|
+
/>
|
|
133
|
+
))}
|
|
134
|
+
</View>
|
|
135
|
+
),
|
|
136
|
+
};
|
|
137
|
+
|
|
71
138
|
export const CurrencyPositionLeft: Story = {
|
|
72
139
|
render: (args) => <AmountInputStory {...args} />,
|
|
73
140
|
args: {
|