@ledgerhq/lumen-ui-rnative 0.1.52 → 0.1.53

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 (42) hide show
  1. package/dist/module/index.js +1 -1
  2. package/dist/module/index.js.map +1 -1
  3. package/dist/module/lib/Components/BottomSheet/BottomSheet.js +4 -1
  4. package/dist/module/lib/Components/BottomSheet/BottomSheet.js.map +1 -1
  5. package/dist/module/lib/Components/BottomSheet/BottomSheet.mdx +133 -2
  6. package/dist/module/lib/Components/BottomSheet/BottomSheet.stories.js +114 -7
  7. package/dist/module/lib/Components/BottomSheet/BottomSheet.stories.js.map +1 -1
  8. package/dist/module/lib/Components/BottomSheet/BottomSheet.test.js +150 -1
  9. package/dist/module/lib/Components/BottomSheet/BottomSheet.test.js.map +1 -1
  10. package/dist/module/lib/Components/BottomSheet/BottomSheetContent.js +35 -0
  11. package/dist/module/lib/Components/BottomSheet/BottomSheetContent.js.map +1 -0
  12. package/dist/module/lib/Components/BottomSheet/BottomSheetFooter.js +43 -0
  13. package/dist/module/lib/Components/BottomSheet/BottomSheetFooter.js.map +1 -0
  14. package/dist/module/lib/Components/BottomSheet/Scrollables.js +18 -3
  15. package/dist/module/lib/Components/BottomSheet/Scrollables.js.map +1 -1
  16. package/dist/module/lib/Components/BottomSheet/index.js +2 -0
  17. package/dist/module/lib/Components/BottomSheet/index.js.map +1 -1
  18. package/dist/typescript/src/index.d.ts +1 -1
  19. package/dist/typescript/src/index.d.ts.map +1 -1
  20. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheet.d.ts +8 -1
  21. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheet.d.ts.map +1 -1
  22. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetContent.d.ts +3 -0
  23. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetContent.d.ts.map +1 -0
  24. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetFooter.d.ts +3 -0
  25. package/dist/typescript/src/lib/Components/BottomSheet/BottomSheetFooter.d.ts.map +1 -0
  26. package/dist/typescript/src/lib/Components/BottomSheet/Scrollables.d.ts +1 -0
  27. package/dist/typescript/src/lib/Components/BottomSheet/Scrollables.d.ts.map +1 -1
  28. package/dist/typescript/src/lib/Components/BottomSheet/index.d.ts +2 -0
  29. package/dist/typescript/src/lib/Components/BottomSheet/index.d.ts.map +1 -1
  30. package/dist/typescript/src/lib/Components/BottomSheet/types.d.ts +2 -0
  31. package/dist/typescript/src/lib/Components/BottomSheet/types.d.ts.map +1 -1
  32. package/package.json +1 -1
  33. package/src/index.ts +1 -1
  34. package/src/lib/Components/BottomSheet/BottomSheet.mdx +133 -2
  35. package/src/lib/Components/BottomSheet/BottomSheet.stories.tsx +111 -5
  36. package/src/lib/Components/BottomSheet/BottomSheet.test.tsx +140 -0
  37. package/src/lib/Components/BottomSheet/BottomSheet.tsx +25 -9
  38. package/src/lib/Components/BottomSheet/BottomSheetContent.tsx +44 -0
  39. package/src/lib/Components/BottomSheet/BottomSheetFooter.tsx +47 -0
  40. package/src/lib/Components/BottomSheet/Scrollables.tsx +25 -12
  41. package/src/lib/Components/BottomSheet/index.ts +2 -0
  42. package/src/lib/Components/BottomSheet/types.ts +2 -1
@@ -5,8 +5,9 @@ import {
5
5
  BottomSheetScrollView as GorhomBottomSheetScrollView,
6
6
  BottomSheetVirtualizedList as GorhomBottomSheetVirtualizedList,
7
7
  } from '@gorhom/bottom-sheet';
8
- import type { ViewStyle } from 'react-native';
8
+ import { createContext, useContext } from 'react';
9
9
  import { useStyleSheet } from '../../../styles';
10
+ import { useBottomSheetContext } from './BottomSheet';
10
11
  import type {
11
12
  BottomSheetViewProps,
12
13
  BottomSheetFlatListProps,
@@ -15,16 +16,29 @@ import type {
15
16
  BottomSheetVirtualizedListProps,
16
17
  } from './types';
17
18
 
19
+ const BottomSheetScrollableViewContext = createContext(false);
20
+ export const useIsInsideScrollableView = () =>
21
+ useContext(BottomSheetScrollableViewContext);
22
+
23
+ const useHasFooter = () => {
24
+ const ctx = useBottomSheetContext({
25
+ consumerName: 'BottomSheetScrollable',
26
+ contextRequired: false,
27
+ });
28
+ return ctx?.hasFooter ?? false;
29
+ };
30
+
18
31
  const useScrollableStyles = () => {
32
+ const hasFooter = useHasFooter();
19
33
  return useStyleSheet(
20
34
  (t) => ({
21
35
  container: {
22
36
  flex: 1,
23
37
  paddingHorizontal: t.spacings.s16,
24
- paddingBottom: t.spacings.s16,
38
+ paddingBottom: hasFooter ? 0 : t.spacings.s16,
25
39
  },
26
40
  }),
27
- [],
41
+ [hasFooter],
28
42
  );
29
43
  };
30
44
 
@@ -36,11 +50,10 @@ export const BottomSheetView = ({
36
50
  const styles = useScrollableStyles();
37
51
 
38
52
  return (
39
- <GorhomBottomSheetView
40
- style={[styles.container as ViewStyle, style]}
41
- {...props}
42
- >
43
- {children}
53
+ <GorhomBottomSheetView style={[styles.container, style]} {...props}>
54
+ <BottomSheetScrollableViewContext.Provider value={true}>
55
+ {children}
56
+ </BottomSheetScrollableViewContext.Provider>
44
57
  </GorhomBottomSheetView>
45
58
  );
46
59
  };
@@ -56,7 +69,7 @@ export const BottomSheetFlatList = ({
56
69
  return (
57
70
  <GorhomBottomSheetFlatList
58
71
  ref={ref}
59
- style={[styles.container as ViewStyle, style]}
72
+ style={[styles.container, style]}
60
73
  {...props}
61
74
  >
62
75
  {children}
@@ -75,7 +88,7 @@ export const BottomSheetSectionList = ({
75
88
  return (
76
89
  <GorhomBottomSheetSectionList
77
90
  ref={ref}
78
- style={[styles.container as ViewStyle, style]}
91
+ style={[styles.container, style]}
79
92
  {...props}
80
93
  >
81
94
  {children}
@@ -94,7 +107,7 @@ export const BottomSheetScrollView = ({
94
107
  return (
95
108
  <GorhomBottomSheetScrollView
96
109
  ref={ref}
97
- style={[styles.container as ViewStyle, style]}
110
+ style={[styles.container, style]}
98
111
  {...props}
99
112
  >
100
113
  {children}
@@ -113,7 +126,7 @@ export const BottomSheetVirtualizedList = ({
113
126
  return (
114
127
  <GorhomBottomSheetVirtualizedList
115
128
  ref={ref}
116
- style={[styles.container as ViewStyle, style]}
129
+ style={[styles.container, style]}
117
130
  {...props}
118
131
  >
119
132
  {children}
@@ -2,5 +2,7 @@ export { BottomSheet } from './BottomSheet';
2
2
  export * from './Scrollables';
3
3
  export * from './useBottomSheetRef';
4
4
  export * from './BottomSheetHeader';
5
+ export * from './BottomSheetFooter';
6
+ export * from './BottomSheetContent';
5
7
  export * from './types';
6
8
  export { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
@@ -184,7 +184,7 @@ export type BottomSheetHeaderProps = {
184
184
  */
185
185
  spacing?: boolean;
186
186
  } & Omit<StyledViewProps, 'children'>;
187
-
187
+ export type BottomSheetContentProps = StyledViewProps;
188
188
  export type BottomSheetViewProps = Parameters<typeof GorhomBottomSheetView>[0];
189
189
  export type BottomSheetFlatListProps = Parameters<
190
190
  typeof GorhomBottomSheetFlatList
@@ -198,3 +198,4 @@ export type BottomSheetScrollViewProps = Parameters<
198
198
  export type BottomSheetVirtualizedListProps = Parameters<
199
199
  typeof GorhomBottomSheetVirtualizedList
200
200
  >[0];
201
+ export type BottomSheetFooterProps = StyledViewProps;