ferns-ui 0.47.7 → 0.47.8

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.
@@ -1,7 +1,6 @@
1
- import React from "react";
1
+ import React, { useCallback } from "react";
2
2
  import { Platform, SafeAreaView } from "react-native";
3
3
  import { Drawer } from "react-native-drawer-layout";
4
- import { Box } from "./Box";
5
4
  const DEFAULT_STYLES = {
6
5
  width: Platform.OS === "web" ? "40%" : "95%",
7
6
  height: "100%",
@@ -9,11 +8,18 @@ const DEFAULT_STYLES = {
9
8
  borderWidth: 1,
10
9
  borderColor: "gray",
11
10
  };
11
+ const addWebScroll = (isOpen) => {
12
+ if (Platform.OS === "web") {
13
+ return { display: isOpen ? "flex" : "none", overflow: "scroll" };
14
+ }
15
+ else {
16
+ return {};
17
+ }
18
+ };
12
19
  export const SideDrawer = ({ position = "left", isOpen, renderContent, onClose = () => { }, onOpen = () => { }, drawerType = "front", children, drawerStyles = {}, }) => {
13
- const renderDrawerContent = () => {
20
+ const renderDrawerContent = useCallback(() => {
14
21
  return React.createElement(SafeAreaView, null, renderContent());
15
- };
16
- return (React.createElement(Box, { height: "100%", overflow: "hidden", width: "100%" },
17
- React.createElement(Drawer, { drawerPosition: position, drawerStyle: [DEFAULT_STYLES, drawerStyles], drawerType: drawerType, open: isOpen, renderDrawerContent: renderDrawerContent, onClose: onClose, onOpen: onOpen }, children)));
22
+ }, [renderContent]);
23
+ return (React.createElement(Drawer, { drawerPosition: position, drawerStyle: [DEFAULT_STYLES, drawerStyles, addWebScroll(isOpen)], drawerType: drawerType, open: isOpen, renderDrawerContent: renderDrawerContent, onClose: onClose, onOpen: onOpen }, children));
18
24
  };
19
25
  //# sourceMappingURL=SideDrawer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SideDrawer.js","sourceRoot":"","sources":["../src/SideDrawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,Q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,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,mBAAmB,EAAE,mBAAmB,EACxC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,IAEb,QAAQ,CACF,CACV,CAAC;AACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ferns-ui",
3
- "version": "0.47.7",
3
+ "version": "0.47.8",
4
4
  "main": "dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "scripts": {
@@ -1,8 +1,7 @@
1
- import React, {ReactElement} from "react";
1
+ import React, {ReactElement, useCallback} from "react";
2
2
  import {Platform, SafeAreaView, StyleProp, ViewStyle} from "react-native";
3
3
  import {Drawer} from "react-native-drawer-layout";
4
4
 
5
- import {Box} from "./Box";
6
5
  import {SideDrawerProps} from "./Common";
7
6
 
8
7
  const DEFAULT_STYLES: StyleProp<ViewStyle> = {
@@ -13,6 +12,14 @@ const DEFAULT_STYLES: StyleProp<ViewStyle> = {
13
12
  borderColor: "gray",
14
13
  };
15
14
 
15
+ const addWebScroll = (isOpen: boolean): ViewStyle => {
16
+ if (Platform.OS === "web") {
17
+ return {display: isOpen ? "flex" : "none", overflow: "scroll"};
18
+ } else {
19
+ return {};
20
+ }
21
+ };
22
+
16
23
  export const SideDrawer = ({
17
24
  position = "left",
18
25
  isOpen,
@@ -23,22 +30,21 @@ export const SideDrawer = ({
23
30
  children,
24
31
  drawerStyles = {},
25
32
  }: SideDrawerProps): ReactElement => {
26
- const renderDrawerContent = (): ReactElement => {
33
+ const renderDrawerContent = useCallback((): ReactElement => {
27
34
  return <SafeAreaView>{renderContent()}</SafeAreaView>;
28
- };
35
+ }, [renderContent]);
36
+
29
37
  return (
30
- <Box height="100%" overflow="hidden" width="100%">
31
- <Drawer
32
- drawerPosition={position}
33
- drawerStyle={[DEFAULT_STYLES, drawerStyles]}
34
- drawerType={drawerType}
35
- open={isOpen}
36
- renderDrawerContent={renderDrawerContent}
37
- onClose={onClose}
38
- onOpen={onOpen}
39
- >
40
- {children}
41
- </Drawer>
42
- </Box>
38
+ <Drawer
39
+ drawerPosition={position}
40
+ drawerStyle={[DEFAULT_STYLES, drawerStyles, addWebScroll(isOpen)]}
41
+ drawerType={drawerType}
42
+ open={isOpen}
43
+ renderDrawerContent={renderDrawerContent}
44
+ onClose={onClose}
45
+ onOpen={onOpen}
46
+ >
47
+ {children}
48
+ </Drawer>
43
49
  );
44
50
  };