@fountain-ui/lab 2.0.0-beta.43 → 2.0.0-beta.44
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.
- package/build/commonjs/BottomSheet/BottomSheetNative.js +10 -1
- package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetNative.js +11 -2
- package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
- package/package.json +2 -2
- package/src/BottomSheet/BottomSheetNative.tsx +17 -5
|
@@ -88,6 +88,12 @@ function BottomSheet(props) {
|
|
|
88
88
|
const backgroundStyle = {
|
|
89
89
|
backgroundColor: theme.palette.paper.default
|
|
90
90
|
};
|
|
91
|
+
const contentWrapperStyle = {
|
|
92
|
+
flex: 1,
|
|
93
|
+
borderTopLeftRadius: 15,
|
|
94
|
+
borderTopRightRadius: 15,
|
|
95
|
+
overflow: 'hidden'
|
|
96
|
+
};
|
|
91
97
|
const isBackdropTransparent = backdropOpacity <= 0;
|
|
92
98
|
|
|
93
99
|
const OpacityAwareBackdrop = props => /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetBackdrop, _extends({}, props, {
|
|
@@ -111,9 +117,12 @@ function BottomSheet(props) {
|
|
|
111
117
|
enablePanDownToClose: Boolean(onChange),
|
|
112
118
|
enableDynamicSizing: enableDynamicSizing,
|
|
113
119
|
maxDynamicContentSize: maxDynamicContentSize
|
|
120
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
121
|
+
style: contentWrapperStyle
|
|
114
122
|
}, /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetScrollView, {
|
|
123
|
+
bounces: false,
|
|
115
124
|
stickyHeaderIndices: header ? [0] : undefined
|
|
116
|
-
}, header, children)));
|
|
125
|
+
}, header, children))));
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NoHandle","BottomSheet","props","backdropOpacity","children","enableDynamicSizing","header","index","maxHeightNormalizedRatio","onChange","snapPoints","indexRef","React","useRef","bottomSheetRef","height","windowHeight","useWindowDimensions","maxDynamicContentSize","Math","round","handleChange","useCallback","newIndex","current","handleDismiss","useEffect","present","dismiss","snapToIndex","theme","useTheme","shadow","modalStyle","backgroundColor","Platform","select","android","elevation","ios","web","boxShadow","backgroundStyle","palette","paper","default","isBackdropTransparent","OpacityAwareBackdrop","TransparentBackdrop","Boolean","undefined"],"sources":["BottomSheetNative.tsx"],"sourcesContent":["import React from 'react';\nimport { Platform, useWindowDimensions } from 'react-native';\nimport { useTheme } from '@fountain-ui/styles';\nimport {\n BottomSheetBackdrop,\n BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetModalProvider,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport type BottomSheetProps from './BottomSheetProps';\nimport TransparentBackdrop from './TransparentBackdrop';\n\nconst NoHandle = () => null;\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity = 0.5,\n children,\n enableDynamicSizing = true,\n header,\n index,\n maxHeightNormalizedRatio = 0.9,\n onChange,\n snapPoints = [],\n } = props;\n\n const indexRef = React.useRef<number>(-1);\n const bottomSheetRef = React.useRef<BottomSheetModal | null>(null);\n\n const { height: windowHeight } = useWindowDimensions();\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio);\n\n const handleChange = React.useCallback((newIndex: number) => {\n indexRef.current = newIndex;\n\n if (onChange) {\n onChange(newIndex);\n }\n }, [onChange]);\n\n const handleDismiss = React.useCallback(() => {\n handleChange(-1);\n }, [handleChange]);\n\n React.useEffect(() => {\n if (index === indexRef.current) {\n return;\n }\n\n if (indexRef.current < 0 && index >= 0) {\n bottomSheetRef.current?.present();\n } else if (indexRef.current >= 0 && index < 0) {\n bottomSheetRef.current?.dismiss();\n } else {\n // @ts-ignore\n bottomSheetRef.current?.snapToIndex(index);\n }\n }, [index]);\n\n const theme = useTheme();\n const shadow = theme.shadow[12];\n const modalStyle = {\n backgroundColor: '#ffffff00',\n ...Platform.select<object>({\n android: shadow?.elevation,\n ios: shadow?.shadow,\n web: shadow?.boxShadow,\n }),\n };\n const backgroundStyle = {\n backgroundColor: theme.palette.paper.default,\n };\n\n const isBackdropTransparent = backdropOpacity <= 0;\n\n const OpacityAwareBackdrop = (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={backdropOpacity}\n pressBehavior={onChange ? 'close' : 'none'}\n />\n );\n\n return (\n <BottomSheetModalProvider>\n <BottomSheetModal\n backdropComponent={isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop}\n // @ts-ignore\n backgroundStyle={backgroundStyle}\n index={index}\n handleComponent={NoHandle}\n onChange={handleChange}\n onDismiss={handleDismiss}\n ref={bottomSheetRef}\n snapPoints={snapPoints}\n style={modalStyle}\n enablePanDownToClose={Boolean(onChange)}\n enableDynamicSizing={enableDynamicSizing}\n maxDynamicContentSize={maxDynamicContentSize}\n >\n <BottomSheetScrollView
|
|
1
|
+
{"version":3,"names":["NoHandle","BottomSheet","props","backdropOpacity","children","enableDynamicSizing","header","index","maxHeightNormalizedRatio","onChange","snapPoints","indexRef","React","useRef","bottomSheetRef","height","windowHeight","useWindowDimensions","maxDynamicContentSize","Math","round","handleChange","useCallback","newIndex","current","handleDismiss","useEffect","present","dismiss","snapToIndex","theme","useTheme","shadow","modalStyle","backgroundColor","Platform","select","android","elevation","ios","web","boxShadow","backgroundStyle","palette","paper","default","contentWrapperStyle","flex","borderTopLeftRadius","borderTopRightRadius","overflow","isBackdropTransparent","OpacityAwareBackdrop","TransparentBackdrop","Boolean","undefined"],"sources":["BottomSheetNative.tsx"],"sourcesContent":["import React from 'react';\nimport { Platform, useWindowDimensions, View } from 'react-native';\nimport { useTheme } from '@fountain-ui/styles';\nimport {\n BottomSheetBackdrop,\n BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetModalProvider,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport type BottomSheetProps from './BottomSheetProps';\nimport TransparentBackdrop from './TransparentBackdrop';\n\nconst NoHandle = () => null;\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity = 0.5,\n children,\n enableDynamicSizing = true,\n header,\n index,\n maxHeightNormalizedRatio = 0.9,\n onChange,\n snapPoints = [],\n } = props;\n\n const indexRef = React.useRef<number>(-1);\n const bottomSheetRef = React.useRef<BottomSheetModal | null>(null);\n\n const { height: windowHeight } = useWindowDimensions();\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio);\n\n const handleChange = React.useCallback((newIndex: number) => {\n indexRef.current = newIndex;\n\n if (onChange) {\n onChange(newIndex);\n }\n }, [onChange]);\n\n const handleDismiss = React.useCallback(() => {\n handleChange(-1);\n }, [handleChange]);\n\n React.useEffect(() => {\n if (index === indexRef.current) {\n return;\n }\n\n if (indexRef.current < 0 && index >= 0) {\n bottomSheetRef.current?.present();\n } else if (indexRef.current >= 0 && index < 0) {\n bottomSheetRef.current?.dismiss();\n } else {\n // @ts-ignore\n bottomSheetRef.current?.snapToIndex(index);\n }\n }, [index]);\n\n const theme = useTheme();\n const shadow = theme.shadow[12];\n const modalStyle = {\n backgroundColor: '#ffffff00',\n ...Platform.select<object>({\n android: shadow?.elevation,\n ios: shadow?.shadow,\n web: shadow?.boxShadow,\n }),\n };\n const backgroundStyle = {\n backgroundColor: theme.palette.paper.default,\n };\n const contentWrapperStyle = {\n flex: 1,\n borderTopLeftRadius: 15,\n borderTopRightRadius: 15,\n overflow: 'hidden',\n };\n\n const isBackdropTransparent = backdropOpacity <= 0;\n\n const OpacityAwareBackdrop = (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={backdropOpacity}\n pressBehavior={onChange ? 'close' : 'none'}\n />\n );\n\n return (\n <BottomSheetModalProvider>\n <BottomSheetModal\n backdropComponent={isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop}\n // @ts-ignore\n backgroundStyle={backgroundStyle}\n index={index}\n handleComponent={NoHandle}\n onChange={handleChange}\n onDismiss={handleDismiss}\n ref={bottomSheetRef}\n snapPoints={snapPoints}\n style={modalStyle}\n enablePanDownToClose={Boolean(onChange)}\n enableDynamicSizing={enableDynamicSizing}\n maxDynamicContentSize={maxDynamicContentSize}\n >\n {/* @ts-ignore */}\n <View style={contentWrapperStyle}>\n <BottomSheetScrollView\n bounces={false}\n stickyHeaderIndices={header ? [0] : undefined}\n >\n {header}\n\n {children}\n </BottomSheetScrollView>\n </View>\n </BottomSheetModal>\n </BottomSheetModalProvider>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAQA;;;;;;AAEA,MAAMA,QAAQ,GAAG,MAAM,IAAvB;;AAEe,SAASC,WAAT,CAAqBC,KAArB,EAA8C;EACzD,MAAM;IACFC,eAAe,GAAG,GADhB;IAEFC,QAFE;IAGFC,mBAAmB,GAAG,IAHpB;IAIFC,MAJE;IAKFC,KALE;IAMFC,wBAAwB,GAAG,GANzB;IAOFC,QAPE;IAQFC,UAAU,GAAG;EARX,IASFR,KATJ;;EAWA,MAAMS,QAAQ,GAAGC,cAAA,CAAMC,MAAN,CAAqB,CAAC,CAAtB,CAAjB;;EACA,MAAMC,cAAc,GAAGF,cAAA,CAAMC,MAAN,CAAsC,IAAtC,CAAvB;;EAEA,MAAM;IAAEE,MAAM,EAAEC;EAAV,IAA2B,IAAAC,gCAAA,GAAjC;EACA,MAAMC,qBAAqB,GAAGC,IAAI,CAACC,KAAL,CAAWJ,YAAY,GAAGR,wBAA1B,CAA9B;;EAEA,MAAMa,YAAY,GAAGT,cAAA,CAAMU,WAAN,CAAmBC,QAAD,IAAsB;IACzDZ,QAAQ,CAACa,OAAT,GAAmBD,QAAnB;;IAEA,IAAId,QAAJ,EAAc;MACVA,QAAQ,CAACc,QAAD,CAAR;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jB,CAAxB;EAGA,MAAMC,mBAAmB,GAAG;IACxBC,IAAI,EAAE,CADkB;IAExBC,mBAAmB,EAAE,EAFG;IAGxBC,oBAAoB,EAAE,EAHE;IAIxBC,QAAQ,EAAE;EAJc,CAA5B;EAOA,MAAMC,qBAAqB,GAAGhD,eAAe,IAAI,CAAjD;;EAEA,MAAMiD,oBAAoB,GAAIlD,KAAD,iBACzB,6BAAC,gCAAD,eACQA,KADR;IAEI,cAAc,EAAE,CAFpB;IAGI,iBAAiB,EAAE,CAAC,CAHxB;IAII,OAAO,EAAEC,eAJb;IAKI,aAAa,EAAEM,QAAQ,GAAG,OAAH,GAAa;EALxC,GADJ;;EAUA,oBACI,6BAAC,qCAAD,qBACI,6BAAC,6BAAD;IACI,iBAAiB,EAAE0C,qBAAqB,GAAGE,4BAAH,GAAyBD,oBADrE,CAEI;IAFJ;IAGI,eAAe,EAAEV,eAHrB;IAII,KAAK,EAAEnC,KAJX;IAKI,eAAe,EAAEP,QALrB;IAMI,QAAQ,EAAEqB,YANd;IAOI,SAAS,EAAEI,aAPf;IAQI,GAAG,EAAEX,cART;IASI,UAAU,EAAEJ,UAThB;IAUI,KAAK,EAAEuB,UAVX;IAWI,oBAAoB,EAAEqB,OAAO,CAAC7C,QAAD,CAXjC;IAYI,mBAAmB,EAAEJ,mBAZzB;IAaI,qBAAqB,EAAEa;EAb3B,gBAgBI,6BAAC,iBAAD;IAAM,KAAK,EAAE4B;EAAb,gBACI,6BAAC,kCAAD;IACI,OAAO,EAAE,KADb;IAEI,mBAAmB,EAAExC,MAAM,GAAG,CAAC,CAAD,CAAH,GAASiD;EAFxC,GAIKjD,MAJL,EAMKF,QANL,CADJ,CAhBJ,CADJ,CADJ;AA+BH;;AAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { Platform, useWindowDimensions } from 'react-native';
|
|
4
|
+
import { Platform, useWindowDimensions, View } from 'react-native';
|
|
5
5
|
import { useTheme } from '@fountain-ui/styles';
|
|
6
6
|
import { BottomSheetBackdrop, BottomSheetModal, BottomSheetModalProvider, BottomSheetScrollView } from '@gorhom/bottom-sheet';
|
|
7
7
|
import TransparentBackdrop from './TransparentBackdrop';
|
|
@@ -68,6 +68,12 @@ export default function BottomSheet(props) {
|
|
|
68
68
|
const backgroundStyle = {
|
|
69
69
|
backgroundColor: theme.palette.paper.default
|
|
70
70
|
};
|
|
71
|
+
const contentWrapperStyle = {
|
|
72
|
+
flex: 1,
|
|
73
|
+
borderTopLeftRadius: 15,
|
|
74
|
+
borderTopRightRadius: 15,
|
|
75
|
+
overflow: 'hidden'
|
|
76
|
+
};
|
|
71
77
|
const isBackdropTransparent = backdropOpacity <= 0;
|
|
72
78
|
|
|
73
79
|
const OpacityAwareBackdrop = props => /*#__PURE__*/React.createElement(BottomSheetBackdrop, _extends({}, props, {
|
|
@@ -91,9 +97,12 @@ export default function BottomSheet(props) {
|
|
|
91
97
|
enablePanDownToClose: Boolean(onChange),
|
|
92
98
|
enableDynamicSizing: enableDynamicSizing,
|
|
93
99
|
maxDynamicContentSize: maxDynamicContentSize
|
|
100
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
101
|
+
style: contentWrapperStyle
|
|
94
102
|
}, /*#__PURE__*/React.createElement(BottomSheetScrollView, {
|
|
103
|
+
bounces: false,
|
|
95
104
|
stickyHeaderIndices: header ? [0] : undefined
|
|
96
|
-
}, header, children)));
|
|
105
|
+
}, header, children))));
|
|
97
106
|
}
|
|
98
107
|
;
|
|
99
108
|
//# sourceMappingURL=BottomSheetNative.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Platform","useWindowDimensions","useTheme","BottomSheetBackdrop","BottomSheetModal","BottomSheetModalProvider","BottomSheetScrollView","TransparentBackdrop","NoHandle","BottomSheet","props","backdropOpacity","children","enableDynamicSizing","header","index","maxHeightNormalizedRatio","onChange","snapPoints","indexRef","useRef","bottomSheetRef","height","windowHeight","maxDynamicContentSize","Math","round","handleChange","useCallback","newIndex","current","handleDismiss","useEffect","present","dismiss","snapToIndex","theme","shadow","modalStyle","backgroundColor","select","android","elevation","ios","web","boxShadow","backgroundStyle","palette","paper","default","isBackdropTransparent","OpacityAwareBackdrop","Boolean","undefined"],"sources":["BottomSheetNative.tsx"],"sourcesContent":["import React from 'react';\nimport { Platform, useWindowDimensions } from 'react-native';\nimport { useTheme } from '@fountain-ui/styles';\nimport {\n BottomSheetBackdrop,\n BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetModalProvider,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport type BottomSheetProps from './BottomSheetProps';\nimport TransparentBackdrop from './TransparentBackdrop';\n\nconst NoHandle = () => null;\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity = 0.5,\n children,\n enableDynamicSizing = true,\n header,\n index,\n maxHeightNormalizedRatio = 0.9,\n onChange,\n snapPoints = [],\n } = props;\n\n const indexRef = React.useRef<number>(-1);\n const bottomSheetRef = React.useRef<BottomSheetModal | null>(null);\n\n const { height: windowHeight } = useWindowDimensions();\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio);\n\n const handleChange = React.useCallback((newIndex: number) => {\n indexRef.current = newIndex;\n\n if (onChange) {\n onChange(newIndex);\n }\n }, [onChange]);\n\n const handleDismiss = React.useCallback(() => {\n handleChange(-1);\n }, [handleChange]);\n\n React.useEffect(() => {\n if (index === indexRef.current) {\n return;\n }\n\n if (indexRef.current < 0 && index >= 0) {\n bottomSheetRef.current?.present();\n } else if (indexRef.current >= 0 && index < 0) {\n bottomSheetRef.current?.dismiss();\n } else {\n // @ts-ignore\n bottomSheetRef.current?.snapToIndex(index);\n }\n }, [index]);\n\n const theme = useTheme();\n const shadow = theme.shadow[12];\n const modalStyle = {\n backgroundColor: '#ffffff00',\n ...Platform.select<object>({\n android: shadow?.elevation,\n ios: shadow?.shadow,\n web: shadow?.boxShadow,\n }),\n };\n const backgroundStyle = {\n backgroundColor: theme.palette.paper.default,\n };\n\n const isBackdropTransparent = backdropOpacity <= 0;\n\n const OpacityAwareBackdrop = (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={backdropOpacity}\n pressBehavior={onChange ? 'close' : 'none'}\n />\n );\n\n return (\n <BottomSheetModalProvider>\n <BottomSheetModal\n backdropComponent={isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop}\n // @ts-ignore\n backgroundStyle={backgroundStyle}\n index={index}\n handleComponent={NoHandle}\n onChange={handleChange}\n onDismiss={handleDismiss}\n ref={bottomSheetRef}\n snapPoints={snapPoints}\n style={modalStyle}\n enablePanDownToClose={Boolean(onChange)}\n enableDynamicSizing={enableDynamicSizing}\n maxDynamicContentSize={maxDynamicContentSize}\n >\n <BottomSheetScrollView
|
|
1
|
+
{"version":3,"names":["React","Platform","useWindowDimensions","View","useTheme","BottomSheetBackdrop","BottomSheetModal","BottomSheetModalProvider","BottomSheetScrollView","TransparentBackdrop","NoHandle","BottomSheet","props","backdropOpacity","children","enableDynamicSizing","header","index","maxHeightNormalizedRatio","onChange","snapPoints","indexRef","useRef","bottomSheetRef","height","windowHeight","maxDynamicContentSize","Math","round","handleChange","useCallback","newIndex","current","handleDismiss","useEffect","present","dismiss","snapToIndex","theme","shadow","modalStyle","backgroundColor","select","android","elevation","ios","web","boxShadow","backgroundStyle","palette","paper","default","contentWrapperStyle","flex","borderTopLeftRadius","borderTopRightRadius","overflow","isBackdropTransparent","OpacityAwareBackdrop","Boolean","undefined"],"sources":["BottomSheetNative.tsx"],"sourcesContent":["import React from 'react';\nimport { Platform, useWindowDimensions, View } from 'react-native';\nimport { useTheme } from '@fountain-ui/styles';\nimport {\n BottomSheetBackdrop,\n BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetModalProvider,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport type BottomSheetProps from './BottomSheetProps';\nimport TransparentBackdrop from './TransparentBackdrop';\n\nconst NoHandle = () => null;\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity = 0.5,\n children,\n enableDynamicSizing = true,\n header,\n index,\n maxHeightNormalizedRatio = 0.9,\n onChange,\n snapPoints = [],\n } = props;\n\n const indexRef = React.useRef<number>(-1);\n const bottomSheetRef = React.useRef<BottomSheetModal | null>(null);\n\n const { height: windowHeight } = useWindowDimensions();\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio);\n\n const handleChange = React.useCallback((newIndex: number) => {\n indexRef.current = newIndex;\n\n if (onChange) {\n onChange(newIndex);\n }\n }, [onChange]);\n\n const handleDismiss = React.useCallback(() => {\n handleChange(-1);\n }, [handleChange]);\n\n React.useEffect(() => {\n if (index === indexRef.current) {\n return;\n }\n\n if (indexRef.current < 0 && index >= 0) {\n bottomSheetRef.current?.present();\n } else if (indexRef.current >= 0 && index < 0) {\n bottomSheetRef.current?.dismiss();\n } else {\n // @ts-ignore\n bottomSheetRef.current?.snapToIndex(index);\n }\n }, [index]);\n\n const theme = useTheme();\n const shadow = theme.shadow[12];\n const modalStyle = {\n backgroundColor: '#ffffff00',\n ...Platform.select<object>({\n android: shadow?.elevation,\n ios: shadow?.shadow,\n web: shadow?.boxShadow,\n }),\n };\n const backgroundStyle = {\n backgroundColor: theme.palette.paper.default,\n };\n const contentWrapperStyle = {\n flex: 1,\n borderTopLeftRadius: 15,\n borderTopRightRadius: 15,\n overflow: 'hidden',\n };\n\n const isBackdropTransparent = backdropOpacity <= 0;\n\n const OpacityAwareBackdrop = (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={backdropOpacity}\n pressBehavior={onChange ? 'close' : 'none'}\n />\n );\n\n return (\n <BottomSheetModalProvider>\n <BottomSheetModal\n backdropComponent={isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop}\n // @ts-ignore\n backgroundStyle={backgroundStyle}\n index={index}\n handleComponent={NoHandle}\n onChange={handleChange}\n onDismiss={handleDismiss}\n ref={bottomSheetRef}\n snapPoints={snapPoints}\n style={modalStyle}\n enablePanDownToClose={Boolean(onChange)}\n enableDynamicSizing={enableDynamicSizing}\n maxDynamicContentSize={maxDynamicContentSize}\n >\n {/* @ts-ignore */}\n <View style={contentWrapperStyle}>\n <BottomSheetScrollView\n bounces={false}\n stickyHeaderIndices={header ? [0] : undefined}\n >\n {header}\n\n {children}\n </BottomSheetScrollView>\n </View>\n </BottomSheetModal>\n </BottomSheetModalProvider>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,QAAT,EAAmBC,mBAAnB,EAAwCC,IAAxC,QAAoD,cAApD;AACA,SAASC,QAAT,QAAyB,qBAAzB;AACA,SACIC,mBADJ,EAGIC,gBAHJ,EAIIC,wBAJJ,EAKIC,qBALJ,QAMO,sBANP;AAQA,OAAOC,mBAAP,MAAgC,uBAAhC;;AAEA,MAAMC,QAAQ,GAAG,MAAM,IAAvB;;AAEA,eAAe,SAASC,WAAT,CAAqBC,KAArB,EAA8C;EACzD,MAAM;IACFC,eAAe,GAAG,GADhB;IAEFC,QAFE;IAGFC,mBAAmB,GAAG,IAHpB;IAIFC,MAJE;IAKFC,KALE;IAMFC,wBAAwB,GAAG,GANzB;IAOFC,QAPE;IAQFC,UAAU,GAAG;EARX,IASFR,KATJ;EAWA,MAAMS,QAAQ,GAAGrB,KAAK,CAACsB,MAAN,CAAqB,CAAC,CAAtB,CAAjB;EACA,MAAMC,cAAc,GAAGvB,KAAK,CAACsB,MAAN,CAAsC,IAAtC,CAAvB;EAEA,MAAM;IAAEE,M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KADb;IAEI,mBAAmB,EAAEpC,MAAM,GAAG,CAAC,CAAD,CAAH,GAAS4C;EAFxC,GAIK5C,MAJL,EAMKF,QANL,CADJ,CAhBJ,CADJ,CADJ;AA+BH;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fountain-ui/lab",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.44",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Fountain-UI Team",
|
|
6
6
|
"description": "Incubator for Fountain-UI React components.",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "d6c9346f8fd3675ac5096ee5caaad3f372f9def6"
|
|
74
74
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Platform, useWindowDimensions } from 'react-native';
|
|
2
|
+
import { Platform, useWindowDimensions, View } from 'react-native';
|
|
3
3
|
import { useTheme } from '@fountain-ui/styles';
|
|
4
4
|
import {
|
|
5
5
|
BottomSheetBackdrop,
|
|
@@ -71,6 +71,12 @@ export default function BottomSheet(props: BottomSheetProps) {
|
|
|
71
71
|
const backgroundStyle = {
|
|
72
72
|
backgroundColor: theme.palette.paper.default,
|
|
73
73
|
};
|
|
74
|
+
const contentWrapperStyle = {
|
|
75
|
+
flex: 1,
|
|
76
|
+
borderTopLeftRadius: 15,
|
|
77
|
+
borderTopRightRadius: 15,
|
|
78
|
+
overflow: 'hidden',
|
|
79
|
+
};
|
|
74
80
|
|
|
75
81
|
const isBackdropTransparent = backdropOpacity <= 0;
|
|
76
82
|
|
|
@@ -101,11 +107,17 @@ export default function BottomSheet(props: BottomSheetProps) {
|
|
|
101
107
|
enableDynamicSizing={enableDynamicSizing}
|
|
102
108
|
maxDynamicContentSize={maxDynamicContentSize}
|
|
103
109
|
>
|
|
104
|
-
|
|
105
|
-
|
|
110
|
+
{/* @ts-ignore */}
|
|
111
|
+
<View style={contentWrapperStyle}>
|
|
112
|
+
<BottomSheetScrollView
|
|
113
|
+
bounces={false}
|
|
114
|
+
stickyHeaderIndices={header ? [0] : undefined}
|
|
115
|
+
>
|
|
116
|
+
{header}
|
|
106
117
|
|
|
107
|
-
|
|
108
|
-
|
|
118
|
+
{children}
|
|
119
|
+
</BottomSheetScrollView>
|
|
120
|
+
</View>
|
|
109
121
|
</BottomSheetModal>
|
|
110
122
|
</BottomSheetModalProvider>
|
|
111
123
|
);
|