Skip to content

Commit 77b54eb

Browse files
committed
mc
Signed-off-by: Simon Bruneaud <[email protected]>
1 parent 2045e50 commit 77b54eb

File tree

2 files changed

+76
-29
lines changed

2 files changed

+76
-29
lines changed

libs/ui-rnative/.storybook/main.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,34 @@ const config: StorybookConfig = {
2727
...config.resolve.alias,
2828
'react-native': 'react-native-web',
2929
'react-native-svg': 'react-native-svg-web',
30+
// Stub out the doctor module that has CommonJS issues
31+
'react-native-css-interop/doctor':
32+
'react-native-css-interop/dist/runtime/web/api',
3033
};
34+
// Force resolution to use browser/module builds instead of CommonJS
35+
config.resolve.conditions = ['browser', 'module', 'import', 'default'];
36+
config.resolve.mainFields = ['browser', 'module', 'main'];
3137

3238
return mergeConfig(config, {
33-
plugins: [nxViteTsPaths()],
39+
plugins: [
40+
nxViteTsPaths(),
41+
{
42+
name: 'inject-exports',
43+
enforce: 'post',
44+
generateBundle(_options, bundle) {
45+
// Inject exports definition at the start of chunks that reference it
46+
for (const fileName in bundle) {
47+
const chunk = bundle[fileName];
48+
if (
49+
chunk.type === 'chunk' &&
50+
chunk.code.includes('Object.defineProperty(exports,')
51+
) {
52+
chunk.code = `const exports = {};\n${chunk.code}`;
53+
}
54+
}
55+
},
56+
},
57+
],
3458
css: {
3559
postcss: {
3660
plugins: [
@@ -39,6 +63,17 @@ const config: StorybookConfig = {
3963
],
4064
},
4165
},
66+
optimizeDeps: {
67+
esbuildOptions: {
68+
mainFields: ['browser', 'module', 'main'],
69+
},
70+
},
71+
build: {
72+
commonjsOptions: {
73+
include: [/node_modules/],
74+
transformMixedEsModules: true,
75+
},
76+
},
4277
});
4378
},
4479

libs/ui-rnative/src/lib/Components/BottomSheet/Scrollables.tsx

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '@gorhom/bottom-sheet';
88
import { cn } from '@ledgerhq/ldls-utils-shared';
99
import { cva } from 'class-variance-authority';
10-
import { remapProps } from 'nativewind';
10+
import { cssInterop } from 'nativewind';
1111
import { FC } from 'react';
1212

1313
const styles = cva('mt-16 flex-1 px-16 pb-24');
@@ -26,15 +26,35 @@ export type BottomSheetVirtualizedListProps = Parameters<
2626
typeof GorhomBottomSheetVirtualizedList
2727
>[0];
2828

29+
// Apply cssInterop to map className to style prop for Gorhom components
30+
const StyledBottomSheetView = cssInterop(GorhomBottomSheetView, {
31+
className: 'style',
32+
});
33+
const StyledBottomSheetFlatList = cssInterop(GorhomBottomSheetFlatList, {
34+
className: 'style',
35+
});
36+
const StyledBottomSheetSectionList = cssInterop(GorhomBottomSheetSectionList, {
37+
className: 'style',
38+
});
39+
const StyledBottomSheetScrollView = cssInterop(GorhomBottomSheetScrollView, {
40+
className: 'style',
41+
});
42+
const StyledBottomSheetVirtualizedList = cssInterop(
43+
GorhomBottomSheetVirtualizedList,
44+
{
45+
className: 'style',
46+
},
47+
);
48+
2949
export const BottomSheetView: FC<BottomSheetViewProps> = ({
3050
children,
3151
className,
3252
...props
3353
}) => {
3454
return (
35-
<_BottomSheetView className={cn(className, styles())} {...props}>
55+
<StyledBottomSheetView className={cn(className, styles())} {...props}>
3656
{children}
37-
</_BottomSheetView>
57+
</StyledBottomSheetView>
3858
);
3959
};
4060

@@ -44,56 +64,48 @@ export const BottomSheetFlatList: FC<BottomSheetFlatListProps> = ({
4464
...props
4565
}) => {
4666
return (
47-
<_BottomSheetFlatList className={cn(className, styles())} {...props}>
67+
<StyledBottomSheetFlatList className={cn(className, styles())} {...props}>
4868
{children}
49-
</_BottomSheetFlatList>
69+
</StyledBottomSheetFlatList>
5070
);
5171
};
72+
5273
export const BottomSheetSectionList: FC<BottomSheetSectionListProps> = ({
5374
children,
5475
className,
5576
...props
5677
}) => {
5778
return (
58-
<_BottomSheetSectionList className={cn(className, styles())} {...props}>
79+
<StyledBottomSheetSectionList
80+
className={cn(className, styles())}
81+
{...props}
82+
>
5983
{children}
60-
</_BottomSheetSectionList>
84+
</StyledBottomSheetSectionList>
6185
);
6286
};
87+
6388
export const BottomSheetScrollView: FC<BottomSheetScrollViewProps> = ({
6489
children,
6590
className,
6691
...props
6792
}) => {
6893
return (
69-
<_BottomSheetScrollView className={cn(className, styles())} {...props}>
94+
<StyledBottomSheetScrollView className={cn(className, styles())} {...props}>
7095
{children}
71-
</_BottomSheetScrollView>
96+
</StyledBottomSheetScrollView>
7297
);
7398
};
99+
74100
export const BottomSheetVirtualizedList: FC<
75101
BottomSheetVirtualizedListProps
76102
> = ({ children, className, ...props }) => {
77103
return (
78-
<_BottomSheetVirtualizedList className={cn(className, styles())} {...props}>
104+
<StyledBottomSheetVirtualizedList
105+
className={cn(className, styles())}
106+
{...props}
107+
>
79108
{children}
80-
</_BottomSheetVirtualizedList>
109+
</StyledBottomSheetVirtualizedList>
81110
);
82111
};
83-
84-
const _BottomSheetView = remapProps(GorhomBottomSheetView, {
85-
className: 'style',
86-
});
87-
const _BottomSheetFlatList = remapProps(GorhomBottomSheetFlatList, {
88-
className: 'style',
89-
});
90-
const _BottomSheetSectionList = remapProps(GorhomBottomSheetSectionList, {
91-
className: 'style',
92-
});
93-
const _BottomSheetScrollView = remapProps(GorhomBottomSheetScrollView, {
94-
className: 'style',
95-
});
96-
const _BottomSheetVirtualizedList = remapProps(
97-
GorhomBottomSheetVirtualizedList,
98-
{ className: 'style' },
99-
);

0 commit comments

Comments
 (0)