-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
48 lines (45 loc) · 1.31 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use client';
import { forwardRef, useMemo } from 'react';
import { AppDefault } from './AppDefault.js';
import type { WidgetDrawer } from './AppDrawer.js';
import { AppDrawer } from './AppDrawer.js';
import { AppProvider } from './AppProvider.js';
import type { WidgetConfig, WidgetProps } from './types/widget.js';
export const App = forwardRef<WidgetDrawer, WidgetProps>(
({ elementRef, open, onClose, integrator, ...other }, ref) => {
const config: WidgetConfig = useMemo(() => {
const config = { integrator, ...other, ...other.config };
if (config.variant === 'drawer') {
config.theme = {
...config.theme,
container: {
height: '100%',
...config.theme?.container,
},
};
}
return config;
}, [integrator, other]);
if (config.variant === 'drawer') {
console.log("if (config.variant === 'drawer') {")
return (
<AppProvider config={config}>
<AppDrawer
ref={ref}
elementRef={elementRef}
config={config}
open={open}
onClose={onClose}
>
<AppDefault />
</AppDrawer>
</AppProvider>
);
}
return (
<AppProvider config={config}>
<AppDefault />
</AppProvider>
);
},
);