@ledgerhq/lumen-ui-rnative 0.1.25 → 0.1.27

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 (83) 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/Button/Button.stories.js.map +1 -1
  8. package/dist/module/lib/Components/CardButton/CardButton.stories.js.map +1 -1
  9. package/dist/module/lib/Components/DotCount/DotCount.js +128 -0
  10. package/dist/module/lib/Components/DotCount/DotCount.js.map +1 -0
  11. package/dist/module/lib/Components/DotCount/DotCount.mdx +86 -0
  12. package/dist/module/lib/Components/DotCount/DotCount.stories.js +172 -0
  13. package/dist/module/lib/Components/DotCount/DotCount.stories.js.map +1 -0
  14. package/dist/module/lib/Components/DotCount/DotCount.test.js +174 -0
  15. package/dist/module/lib/Components/DotCount/DotCount.test.js.map +1 -0
  16. package/dist/module/lib/Components/DotCount/index.js +5 -0
  17. package/dist/module/lib/Components/DotCount/index.js.map +1 -0
  18. package/dist/module/lib/Components/DotCount/types.js +4 -0
  19. package/dist/module/lib/Components/DotCount/types.js.map +1 -0
  20. package/dist/module/lib/Components/DotIndicator/DotIndicator.js +89 -0
  21. package/dist/module/lib/Components/DotIndicator/DotIndicator.js.map +1 -0
  22. package/dist/module/lib/Components/DotIndicator/DotIndicator.mdx +82 -0
  23. package/dist/module/lib/Components/DotIndicator/DotIndicator.stories.js +84 -0
  24. package/dist/module/lib/Components/DotIndicator/DotIndicator.stories.js.map +1 -0
  25. package/dist/module/lib/Components/DotIndicator/DotIndicator.test.js +136 -0
  26. package/dist/module/lib/Components/DotIndicator/DotIndicator.test.js.map +1 -0
  27. package/dist/module/lib/Components/DotIndicator/index.js +5 -0
  28. package/dist/module/lib/Components/DotIndicator/index.js.map +1 -0
  29. package/dist/module/lib/Components/DotIndicator/types.js +4 -0
  30. package/dist/module/lib/Components/DotIndicator/types.js.map +1 -0
  31. package/dist/module/lib/Components/Link/Link.stories.js.map +1 -1
  32. package/dist/module/lib/Components/Spot/Spot.stories.js.map +1 -1
  33. package/dist/module/lib/Components/Subheader/Subheader.js +1 -1
  34. package/dist/module/lib/Components/TabBar/TabBar.js +16 -13
  35. package/dist/module/lib/Components/TabBar/TabBar.js.map +1 -1
  36. package/dist/module/lib/Components/Utility/Gradient/utils/resolveGradientColor.js.map +1 -1
  37. package/dist/module/lib/Components/index.js +2 -0
  38. package/dist/module/lib/Components/index.js.map +1 -1
  39. package/dist/typescript/src/index.d.ts +1 -0
  40. package/dist/typescript/src/index.d.ts.map +1 -1
  41. package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts +1 -1
  42. package/dist/typescript/src/lib/Components/Avatar/Avatar.d.ts.map +1 -1
  43. package/dist/typescript/src/lib/Components/DotCount/DotCount.d.ts +3 -0
  44. package/dist/typescript/src/lib/Components/DotCount/DotCount.d.ts.map +1 -0
  45. package/dist/typescript/src/lib/Components/DotCount/index.d.ts +3 -0
  46. package/dist/typescript/src/lib/Components/DotCount/index.d.ts.map +1 -0
  47. package/dist/typescript/src/lib/Components/DotCount/types.d.ts +40 -0
  48. package/dist/typescript/src/lib/Components/DotCount/types.d.ts.map +1 -0
  49. package/dist/typescript/src/lib/Components/DotIndicator/DotIndicator.d.ts +3 -0
  50. package/dist/typescript/src/lib/Components/DotIndicator/DotIndicator.d.ts.map +1 -0
  51. package/dist/typescript/src/lib/Components/DotIndicator/index.d.ts +3 -0
  52. package/dist/typescript/src/lib/Components/DotIndicator/index.d.ts.map +1 -0
  53. package/dist/typescript/src/lib/Components/DotIndicator/types.d.ts +25 -0
  54. package/dist/typescript/src/lib/Components/DotIndicator/types.d.ts.map +1 -0
  55. package/dist/typescript/src/lib/Components/TabBar/TabBar.d.ts.map +1 -1
  56. package/dist/typescript/src/lib/Components/Utility/Gradient/utils/resolveGradientColor.d.ts +2 -2
  57. package/dist/typescript/src/lib/Components/Utility/Gradient/utils/resolveGradientColor.d.ts.map +1 -1
  58. package/dist/typescript/src/lib/Components/index.d.ts +2 -0
  59. package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
  60. package/package.json +1 -1
  61. package/src/index.ts +1 -0
  62. package/src/lib/Components/Avatar/Avatar.test.tsx +17 -27
  63. package/src/lib/Components/Avatar/Avatar.tsx +24 -21
  64. package/src/lib/Components/Button/Button.stories.tsx +1 -1
  65. package/src/lib/Components/CardButton/CardButton.stories.tsx +2 -2
  66. package/src/lib/Components/DotCount/DotCount.mdx +86 -0
  67. package/src/lib/Components/DotCount/DotCount.stories.tsx +124 -0
  68. package/src/lib/Components/DotCount/DotCount.test.tsx +150 -0
  69. package/src/lib/Components/DotCount/DotCount.tsx +130 -0
  70. package/src/lib/Components/DotCount/index.ts +2 -0
  71. package/src/lib/Components/DotCount/types.ts +40 -0
  72. package/src/lib/Components/DotIndicator/DotIndicator.mdx +82 -0
  73. package/src/lib/Components/DotIndicator/DotIndicator.stories.tsx +67 -0
  74. package/src/lib/Components/DotIndicator/DotIndicator.test.tsx +132 -0
  75. package/src/lib/Components/DotIndicator/DotIndicator.tsx +97 -0
  76. package/src/lib/Components/DotIndicator/index.ts +2 -0
  77. package/src/lib/Components/DotIndicator/types.ts +25 -0
  78. package/src/lib/Components/Link/Link.stories.tsx +1 -1
  79. package/src/lib/Components/Spot/Spot.stories.tsx +2 -2
  80. package/src/lib/Components/Subheader/Subheader.tsx +1 -1
  81. package/src/lib/Components/TabBar/TabBar.tsx +17 -16
  82. package/src/lib/Components/Utility/Gradient/utils/resolveGradientColor.ts +2 -2
  83. package/src/lib/Components/index.ts +2 -0
@@ -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
  () => ({
@@ -29,11 +29,11 @@ export const resolveGradientColor = (
29
29
  export const processGradientStops = (
30
30
  stops: GradientStop[],
31
31
  bgColors: BackgroundColors,
32
- ): Array<{
32
+ ): {
33
33
  color: string;
34
34
  offset: number;
35
35
  opacity: number;
36
- }> => {
36
+ }[] => {
37
37
  const stopCount = stops.length;
38
38
 
39
39
  return stops.map((stop, index) => {
@@ -4,6 +4,8 @@ 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';