@ledgerhq/lumen-ui-rnative 0.1.24 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/module/index.js +1 -0
  2. package/dist/module/index.js.map +1 -1
  3. package/dist/module/lib/Components/Avatar/Avatar.js +22 -23
  4. package/dist/module/lib/Components/Avatar/Avatar.js.map +1 -1
  5. package/dist/module/lib/Components/Avatar/Avatar.test.js +17 -23
  6. package/dist/module/lib/Components/Avatar/Avatar.test.js.map +1 -1
  7. package/dist/module/lib/Components/DotCount/DotCount.js +128 -0
  8. package/dist/module/lib/Components/DotCount/DotCount.js.map +1 -0
  9. package/dist/module/lib/Components/DotCount/DotCount.mdx +86 -0
  10. package/dist/module/lib/Components/DotCount/DotCount.stories.js +172 -0
  11. package/dist/module/lib/Components/DotCount/DotCount.stories.js.map +1 -0
  12. package/dist/module/lib/Components/DotCount/DotCount.test.js +174 -0
  13. package/dist/module/lib/Components/DotCount/DotCount.test.js.map +1 -0
  14. package/dist/module/lib/Components/DotCount/index.js +5 -0
  15. package/dist/module/lib/Components/DotCount/index.js.map +1 -0
  16. package/dist/module/lib/Components/DotCount/types.js +4 -0
  17. package/dist/module/lib/Components/DotCount/types.js.map +1 -0
  18. package/dist/module/lib/Components/DotIcon/DotIcon.js +134 -0
  19. package/dist/module/lib/Components/DotIcon/DotIcon.js.map +1 -0
  20. package/dist/module/lib/Components/DotIcon/DotIcon.mdx +56 -0
  21. package/dist/module/lib/Components/DotIcon/DotIcon.stories.js +217 -0
  22. package/dist/module/lib/Components/DotIcon/DotIcon.stories.js.map +1 -0
  23. package/dist/module/lib/Components/DotIcon/DotIcon.test.js +238 -0
  24. package/dist/module/lib/Components/DotIcon/DotIcon.test.js.map +1 -0
  25. package/dist/module/lib/Components/DotIcon/index.js +5 -0
  26. package/dist/module/lib/Components/DotIcon/index.js.map +1 -0
  27. package/dist/module/lib/Components/DotIcon/types.js +4 -0
  28. package/dist/module/lib/Components/DotIcon/types.js.map +1 -0
  29. package/dist/module/lib/Components/DotIndicator/DotIndicator.js +89 -0
  30. package/dist/module/lib/Components/DotIndicator/DotIndicator.js.map +1 -0
  31. package/dist/module/lib/Components/DotIndicator/DotIndicator.mdx +82 -0
  32. package/dist/module/lib/Components/DotIndicator/DotIndicator.stories.js +84 -0
  33. package/dist/module/lib/Components/DotIndicator/DotIndicator.stories.js.map +1 -0
  34. package/dist/module/lib/Components/DotIndicator/DotIndicator.test.js +136 -0
  35. package/dist/module/lib/Components/DotIndicator/DotIndicator.test.js.map +1 -0
  36. package/dist/module/lib/Components/DotIndicator/index.js +5 -0
  37. package/dist/module/lib/Components/DotIndicator/index.js.map +1 -0
  38. package/dist/module/lib/Components/DotIndicator/types.js +4 -0
  39. package/dist/module/lib/Components/DotIndicator/types.js.map +1 -0
  40. package/dist/module/lib/Components/DotSymbol/DotSymbol.js +29 -22
  41. package/dist/module/lib/Components/DotSymbol/DotSymbol.js.map +1 -1
  42. package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js +31 -9
  43. package/dist/module/lib/Components/DotSymbol/DotSymbol.stories.js.map +1 -1
  44. package/dist/module/lib/Components/MediaImage/MediaImage.js +2 -1
  45. package/dist/module/lib/Components/MediaImage/MediaImage.js.map +1 -1
  46. package/dist/module/lib/Components/MediaImage/MediaImage.stories.js +4 -0
  47. package/dist/module/lib/Components/MediaImage/MediaImage.stories.js.map +1 -1
  48. package/dist/module/lib/Components/Spinner/Spinner.js +6 -1
  49. package/dist/module/lib/Components/Spinner/Spinner.js.map +1 -1
  50. package/dist/module/lib/Components/TabBar/TabBar.js +16 -13
  51. package/dist/module/lib/Components/TabBar/TabBar.js.map +1 -1
  52. package/dist/module/lib/Components/Tag/Tag.js +2 -0
  53. package/dist/module/lib/Components/Tag/Tag.js.map +1 -1
  54. package/dist/module/lib/Components/Tag/Tag.stories.js +8 -1
  55. package/dist/module/lib/Components/Tag/Tag.stories.js.map +1 -1
  56. package/dist/module/lib/Components/index.js +3 -0
  57. package/dist/module/lib/Components/index.js.map +1 -1
  58. package/dist/typescript/src/index.d.ts +1 -0
  59. package/dist/typescript/src/index.d.ts.map +1 -1
  60. package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts +1 -1
  61. package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts.map +1 -1
  62. package/dist/typescript/src/lib/Components/DotCount/DotCount.d.ts +3 -0
  63. package/dist/typescript/src/lib/Components/DotCount/DotCount.d.ts.map +1 -0
  64. package/dist/typescript/src/lib/Components/DotCount/index.d.ts +3 -0
  65. package/dist/typescript/src/lib/Components/DotCount/index.d.ts.map +1 -0
  66. package/dist/typescript/src/lib/Components/DotCount/types.d.ts +40 -0
  67. package/dist/typescript/src/lib/Components/DotCount/types.d.ts.map +1 -0
  68. package/dist/typescript/src/lib/Components/DotIcon/DotIcon.d.ts +30 -0
  69. package/dist/typescript/src/lib/Components/DotIcon/DotIcon.d.ts.map +1 -0
  70. package/dist/typescript/src/lib/Components/DotIcon/index.d.ts +3 -0
  71. package/dist/typescript/src/lib/Components/DotIcon/index.d.ts.map +1 -0
  72. package/dist/typescript/src/lib/Components/DotIcon/types.d.ts +40 -0
  73. package/dist/typescript/src/lib/Components/DotIcon/types.d.ts.map +1 -0
  74. package/dist/typescript/src/lib/Components/DotIndicator/DotIndicator.d.ts +3 -0
  75. package/dist/typescript/src/lib/Components/DotIndicator/DotIndicator.d.ts.map +1 -0
  76. package/dist/typescript/src/lib/Components/DotIndicator/index.d.ts +3 -0
  77. package/dist/typescript/src/lib/Components/DotIndicator/index.d.ts.map +1 -0
  78. package/dist/typescript/src/lib/Components/DotIndicator/types.d.ts +25 -0
  79. package/dist/typescript/src/lib/Components/DotIndicator/types.d.ts.map +1 -0
  80. package/dist/typescript/src/lib/Components/DotSymbol/DotSymbol.d.ts.map +1 -1
  81. package/dist/typescript/src/lib/Components/MediaImage/MediaImage.d.ts.map +1 -1
  82. package/dist/typescript/src/lib/Components/MediaImage/types.d.ts +1 -1
  83. package/dist/typescript/src/lib/Components/MediaImage/types.d.ts.map +1 -1
  84. package/dist/typescript/src/lib/Components/Spinner/Spinner.d.ts +1 -1
  85. package/dist/typescript/src/lib/Components/Spinner/Spinner.d.ts.map +1 -1
  86. package/dist/typescript/src/lib/Components/TabBar/TabBar.d.ts.map +1 -1
  87. package/dist/typescript/src/lib/Components/Tag/Tag.d.ts.map +1 -1
  88. package/dist/typescript/src/lib/Components/Tag/types.d.ts +1 -1
  89. package/dist/typescript/src/lib/Components/Tag/types.d.ts.map +1 -1
  90. package/dist/typescript/src/lib/Components/index.d.ts +3 -0
  91. package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
  92. package/package.json +1 -1
  93. package/src/index.ts +1 -0
  94. package/src/lib/Components/Avatar/Avatar.test.tsx +17 -27
  95. package/src/lib/Components/Avatar/Avatar.tsx +24 -21
  96. package/src/lib/Components/DotCount/DotCount.mdx +86 -0
  97. package/src/lib/Components/DotCount/DotCount.stories.tsx +124 -0
  98. package/src/lib/Components/DotCount/DotCount.test.tsx +150 -0
  99. package/src/lib/Components/DotCount/DotCount.tsx +130 -0
  100. package/src/lib/Components/DotCount/index.ts +2 -0
  101. package/src/lib/Components/DotCount/types.ts +40 -0
  102. package/src/lib/Components/DotIcon/DotIcon.mdx +56 -0
  103. package/src/lib/Components/DotIcon/DotIcon.stories.tsx +154 -0
  104. package/src/lib/Components/DotIcon/DotIcon.test.tsx +224 -0
  105. package/src/lib/Components/DotIcon/DotIcon.tsx +146 -0
  106. package/src/lib/Components/DotIcon/index.ts +6 -0
  107. package/src/lib/Components/DotIcon/types.ts +44 -0
  108. package/src/lib/Components/DotIndicator/DotIndicator.mdx +82 -0
  109. package/src/lib/Components/DotIndicator/DotIndicator.stories.tsx +67 -0
  110. package/src/lib/Components/DotIndicator/DotIndicator.test.tsx +132 -0
  111. package/src/lib/Components/DotIndicator/DotIndicator.tsx +97 -0
  112. package/src/lib/Components/DotIndicator/index.ts +2 -0
  113. package/src/lib/Components/DotIndicator/types.ts +25 -0
  114. package/src/lib/Components/DotSymbol/DotSymbol.stories.tsx +26 -7
  115. package/src/lib/Components/DotSymbol/DotSymbol.tsx +22 -23
  116. package/src/lib/Components/MediaImage/MediaImage.stories.tsx +1 -0
  117. package/src/lib/Components/MediaImage/MediaImage.tsx +3 -1
  118. package/src/lib/Components/MediaImage/types.ts +1 -1
  119. package/src/lib/Components/Spinner/Spinner.tsx +6 -2
  120. package/src/lib/Components/TabBar/TabBar.tsx +17 -16
  121. package/src/lib/Components/Tag/Tag.stories.tsx +11 -1
  122. package/src/lib/Components/Tag/Tag.tsx +2 -0
  123. package/src/lib/Components/Tag/types.ts +8 -1
  124. package/src/lib/Components/index.ts +3 -0
@@ -6,15 +6,13 @@ import type { SpotSize } from '../Spot';
6
6
  import { Box } from '../Utility';
7
7
  import type { DotSymbolPin, DotSymbolProps, DotSymbolSize } from './types';
8
8
 
9
- type BorderRadiusKey = 'xs' | 'sm' | 'md' | 'lg' | 'full';
10
-
11
- const shapeRadiusMap: Record<DotSymbolSize, BorderRadiusKey> = {
12
- 8: 'xs',
13
- 10: 'xs',
14
- 12: 'xs',
15
- 16: 'sm',
16
- 20: 'sm',
17
- 24: 'md',
9
+ const dotSquareRadiusMap: Record<DotSymbolSize, number> = {
10
+ 8: 2,
11
+ 10: 3,
12
+ 12: 4,
13
+ 16: 5,
14
+ 20: 6,
15
+ 24: 8,
18
16
  };
19
17
 
20
18
  const offsetBySize: Record<DotSymbolSize, number> = {
@@ -35,6 +33,7 @@ export const mediaImageDotSizeMap: Record<MediaImageSize, DotSymbolSize> = {
35
33
  40: 16,
36
34
  48: 20,
37
35
  56: 24,
36
+ 64: 24,
38
37
  };
39
38
 
40
39
  export const spotDotSizeMap: Record<SpotSize, DotSymbolSize> = {
@@ -75,9 +74,7 @@ const useStyles = ({
75
74
  (t) => {
76
75
  const sizeValue = t.sizes[`s${size}` as keyof typeof t.sizes] as number;
77
76
  const radius =
78
- shape === 'circle'
79
- ? t.borderRadius.full
80
- : t.borderRadius[shapeRadiusMap[size]];
77
+ shape === 'circle' ? t.borderRadius.full : dotSquareRadiusMap[size];
81
78
  const pinOffset = getPinOffset(pin, size);
82
79
 
83
80
  return {
@@ -142,17 +139,19 @@ export const DotSymbol = ({
142
139
  accessibilityLabel={alt}
143
140
  {...rest}
144
141
  >
145
- {children}
146
- <Box style={styles.dot}>
147
- {!error && (
148
- <Image
149
- source={{ uri: src }}
150
- style={styles.image}
151
- accessible={false}
152
- onError={() => setError(true)}
153
- testID='dot-symbol-img'
154
- />
155
- )}
142
+ <Box style={{ alignSelf: 'flex-start', position: 'relative' }}>
143
+ {children}
144
+ <Box style={styles.dot}>
145
+ {!error && (
146
+ <Image
147
+ source={{ uri: src }}
148
+ style={styles.image}
149
+ accessible={false}
150
+ onError={() => setError(true)}
151
+ testID='dot-symbol-img'
152
+ />
153
+ )}
154
+ </Box>
156
155
  </Box>
157
156
  </Box>
158
157
  );
@@ -41,6 +41,7 @@ export const SizeShowcase: Story = {
41
41
  <MediaImage src={exampleSrc} alt='Size 40' size={40} />
42
42
  <MediaImage src={exampleSrc} alt='Size 48' size={48} />
43
43
  <MediaImage src={exampleSrc} alt='Size 56' size={56} />
44
+ <MediaImage src={exampleSrc} alt='Size 64' size={64} />
44
45
  </Box>
45
46
  ),
46
47
  };
@@ -1,10 +1,11 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { Image, StyleSheet } from 'react-native';
3
3
  import { useStyleSheet } from '../../../styles';
4
+ import type { LumenStyleSheetTheme } from '../../../styles';
4
5
  import { Box } from '../Utility';
5
6
  import type { MediaImageProps, MediaImageSize, MediaImageShape } from './types';
6
7
 
7
- type BorderRadiusKey = 'xs' | 'sm' | 'md' | 'lg' | 'full';
8
+ type BorderRadiusKey = keyof LumenStyleSheetTheme['borderRadius'];
8
9
 
9
10
  const borderRadiusMap: Record<MediaImageSize, BorderRadiusKey> = {
10
11
  12: 'xs',
@@ -15,6 +16,7 @@ const borderRadiusMap: Record<MediaImageSize, BorderRadiusKey> = {
15
16
  40: 'md',
16
17
  48: 'md',
17
18
  56: 'lg',
19
+ 64: 'lg',
18
20
  };
19
21
 
20
22
  const useStyles = ({
@@ -1,6 +1,6 @@
1
1
  import type { StyledViewProps } from '../../../styles';
2
2
 
3
- export type MediaImageSize = 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56;
3
+ export type MediaImageSize = 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64;
4
4
 
5
5
  export type MediaImageShape = 'square' | 'circle';
6
6
 
@@ -1,3 +1,4 @@
1
+ import { StyleSheet } from 'react-native';
1
2
  import Svg, { Path } from 'react-native-svg';
2
3
  import { useCommonTranslation } from '../../../i18n';
3
4
  import type { LumenTextStyle } from '../../../styles';
@@ -24,17 +25,20 @@ export const Spinner = ({
24
25
  lx = {},
25
26
  size = 16,
26
27
  color,
28
+ style,
27
29
  ref,
28
30
  ...props
29
31
  }: SpinnerProps) => {
30
32
  const { t } = useCommonTranslation();
31
33
  const { theme } = useTheme();
32
34
  const resolvedColorStyle = useResolveTextStyle({ color } as LumenTextStyle);
35
+ const flatStyle = StyleSheet.flatten(style);
36
+ const styleColor = flatStyle?.color;
33
37
  const strokeColor =
34
- resolvedColorStyle?.color ?? color ?? theme.colors.text.base;
38
+ resolvedColorStyle?.color ?? color ?? styleColor ?? theme.colors.text.base;
35
39
 
36
40
  return (
37
- <Box ref={ref} lx={{ flexShrink: 0, ...lx }} {...props}>
41
+ <Box ref={ref} lx={{ flexShrink: 0, ...lx }} style={style} {...props}>
38
42
  <Spin>
39
43
  <Svg
40
44
  width={size}
@@ -1,12 +1,6 @@
1
1
  import { BlurView } from '@sbaiahmed1/react-native-blur';
2
2
  import type { ReactNode } from 'react';
3
- import {
4
- Children,
5
- isValidElement,
6
- useCallback,
7
- useEffect,
8
- useRef,
9
- } from 'react';
3
+ import { Children, isValidElement, useEffect, useMemo, useRef } from 'react';
10
4
  import type { LayoutChangeEvent } from 'react-native';
11
5
  import { Platform, StyleSheet, Text, View } from 'react-native';
12
6
  import Animated, {
@@ -19,6 +13,7 @@ import Animated, {
19
13
  } from 'react-native-reanimated';
20
14
  import { useStyleSheet, useTheme } from '../../../styles';
21
15
  import { useTimingConfig } from '../../Animations/useTimingConfig';
16
+ import { triggerHapticFeedback } from '../../Haptics';
22
17
  import { Placeholder } from '../../Symbols';
23
18
  import { Box, Pressable } from '../Utility';
24
19
  import { TabBarContextProvider, useTabBarContext } from './TabBarContext';
@@ -51,14 +46,16 @@ const useTabBarItemAnimations = ({ isActive }: { isActive: boolean }) => {
51
46
  50,
52
47
  withTiming(isActive ? 1 : 0, activeTimingConfig),
53
48
  );
54
- return () => cancelAnimation(activeProgress);
55
49
  }, [isActive, activeProgress, activeTimingConfig]);
56
50
 
51
+ useEffect(() => () => cancelAnimation(activeProgress), [activeProgress]);
52
+
57
53
  const onPressIn = () => {
58
54
  pressProgress.value = withTiming(0.9, pressInTimingConfig);
59
55
  };
60
56
 
61
57
  const onPressOut = () => {
58
+ triggerHapticFeedback('light');
62
59
  pressProgress.value = withSequence(
63
60
  withTiming(0.95, { duration: 0 }),
64
61
  withTiming(1, pressOutTimingConfig),
@@ -112,7 +109,7 @@ const useTabBarPillLayout = ({
112
109
  easing: 'easeInOut',
113
110
  });
114
111
 
115
- const getActiveIndex = useCallback((): number => {
112
+ const activeIndex = useMemo(() => {
116
113
  return Children.toArray(children).findIndex((child) => {
117
114
  if (isValidElement<TabBarItemProps>(child)) {
118
115
  return child.props.value === active;
@@ -121,6 +118,9 @@ const useTabBarPillLayout = ({
121
118
  });
122
119
  }, [active, children]);
123
120
 
121
+ const activeIndexRef = useRef(activeIndex);
122
+ activeIndexRef.current = activeIndex;
123
+
124
124
  const onLayout = (e: LayoutChangeEvent): void => {
125
125
  const { width, height } = e.nativeEvent.layout;
126
126
  const count = Children.count(children);
@@ -131,7 +131,7 @@ const useTabBarPillLayout = ({
131
131
 
132
132
  if (!hasLayoutRef.current) {
133
133
  hasLayoutRef.current = true;
134
- const index = getActiveIndex();
134
+ const index = activeIndexRef.current;
135
135
  if (index >= 0) {
136
136
  pillProgress.value = index * slotWidth;
137
137
  }
@@ -140,14 +140,15 @@ const useTabBarPillLayout = ({
140
140
 
141
141
  useEffect(() => {
142
142
  if (!hasLayoutRef.current) return;
143
- const index = getActiveIndex();
144
-
145
- if (index >= 0 && itemWidth.value > 0) {
146
- pillProgress.value = withTiming(index * itemWidth.value, timingConfig);
143
+ if (activeIndex >= 0 && itemWidth.value > 0) {
144
+ pillProgress.value = withTiming(
145
+ activeIndex * itemWidth.value,
146
+ timingConfig,
147
+ );
147
148
  }
149
+ }, [activeIndex, itemWidth, pillProgress, timingConfig]);
148
150
 
149
- return () => cancelAnimation(pillProgress);
150
- }, [itemWidth, pillProgress, getActiveIndex, timingConfig]);
151
+ useEffect(() => () => cancelAnimation(pillProgress), [pillProgress]);
151
152
 
152
153
  const animatedPillStyle = useAnimatedStyle(
153
154
  () => ({
@@ -9,7 +9,15 @@ const meta: Meta<typeof Tag> = {
9
9
  argTypes: {
10
10
  appearance: {
11
11
  control: 'select',
12
- options: ['base', 'gray', 'accent', 'success', 'error', 'warning'],
12
+ options: [
13
+ 'base',
14
+ 'gray',
15
+ 'accent',
16
+ 'accent-subtle',
17
+ 'success',
18
+ 'error',
19
+ 'warning',
20
+ ],
13
21
  },
14
22
  size: {
15
23
  control: 'radio',
@@ -47,6 +55,7 @@ export const AppearanceShowcase: Story = {
47
55
  <Tag appearance='base' label='Base' />
48
56
  <Tag appearance='gray' label='Gray' />
49
57
  <Tag appearance='accent' label='Accent' />
58
+ <Tag appearance='accent-subtle' label='Accent subtle' />
50
59
  <Tag appearance='success' label='Success' />
51
60
  <Tag appearance='error' label='Error' />
52
61
  <Tag appearance='warning' label='Warning' />
@@ -56,6 +65,7 @@ export const AppearanceShowcase: Story = {
56
65
  <Tag appearance='base' label='Base' icon={Check} />
57
66
  <Tag appearance='gray' label='Gray' icon={Check} />
58
67
  <Tag appearance='accent' label='Accent' icon={Check} />
68
+ <Tag appearance='accent-subtle' label='Accent subtle' icon={Check} />
59
69
  <Tag appearance='success' label='Success' icon={Check} />
60
70
  <Tag appearance='error' label='Error' icon={Check} />
61
71
  <Tag appearance='warning' label='Warning' icon={Check} />
@@ -23,6 +23,7 @@ const useStyles = ({
23
23
  base: t.colors.bg.mutedTransparent,
24
24
  gray: t.colors.bg.mutedTransparent,
25
25
  accent: t.colors.bg.accent,
26
+ 'accent-subtle': t.colors.bg.activeSubtle,
26
27
  success: t.colors.bg.success,
27
28
  error: t.colors.bg.error,
28
29
  warning: t.colors.bg.warning,
@@ -32,6 +33,7 @@ const useStyles = ({
32
33
  base: t.colors.text.base,
33
34
  gray: t.colors.text.muted,
34
35
  accent: t.colors.text.onAccent,
36
+ 'accent-subtle': t.colors.text.active,
35
37
  success: t.colors.text.success,
36
38
  error: t.colors.text.error,
37
39
  warning: t.colors.text.warning,
@@ -6,7 +6,14 @@ export type TagProps = {
6
6
  /**
7
7
  * The appearance of the tag.
8
8
  */
9
- appearance?: 'base' | 'gray' | 'accent' | 'success' | 'error' | 'warning';
9
+ appearance?:
10
+ | 'base'
11
+ | 'gray'
12
+ | 'accent'
13
+ | 'accent-subtle'
14
+ | 'success'
15
+ | 'error'
16
+ | 'warning';
10
17
  /**
11
18
  * The icon of the tag.
12
19
  */
@@ -4,12 +4,15 @@ export * from './AmountInput';
4
4
  export * from './Avatar';
5
5
  export * from './Banner';
6
6
  export * from './BottomSheet';
7
+ export * from './DotCount';
8
+ export * from './DotIndicator';
7
9
  export * from './Button';
8
10
  export * from './Card';
9
11
  export * from './CardButton';
10
12
  export * from './ContentBanner';
11
13
  export * from './Checkbox';
12
14
  export * from './Divider';
15
+ export * from './DotIcon';
13
16
  export * from './DotSymbol';
14
17
  export * from './Icon';
15
18
  export * from './IconButton';