UNPKG

@razorpay/blade

Version:

The Design System that powers Razorpay

19 lines (16 loc) 2.64 kB
import _slicedToArray from '@babel/runtime/helpers/slicedToArray'; import React__default from 'react'; import { BottomSheetScrollView } from '@gorhom/bottom-sheet'; import { ComponentIds } from './componentIds.js'; import { useBottomSheetContext } from './BottomSheetContext.js'; import { BaseBox } from '../Box/BaseBox/BaseBox.native.js'; import { componentIds } from '../ActionList/componentIds.js'; import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js'; import { isValidAllowedChildren } from '../../utils/isValidAllowedChildren/isValidAllowedChildren.js'; import '../../tokens/global/typography.js'; import '../../tokens/global/motion.js'; import { size } from '../../tokens/global/size.js'; import { jsx, Fragment } from 'react/jsx-runtime'; var _BottomSheetBody=function _BottomSheetBody(_ref){var children=_ref.children,_ref$padding=_ref.padding,padding=_ref$padding===void 0?'spacing.5':_ref$padding;var _useBottomSheetContex=useBottomSheetContext(),footerHeight=_useBottomSheetContex.footerHeight,setContentHeight=_useBottomSheetContex.setContentHeight,setHasBodyPadding=_useBottomSheetContex.setHasBodyPadding,isHeaderFloating=_useBottomSheetContex.isHeaderFloating;var _React$useState=React__default.useState(undefined),_React$useState2=_slicedToArray(_React$useState,2),bottomSheetHasActionList=_React$useState2[0],setBottomSheetHasActionList=_React$useState2[1];React__default.useEffect(function(){setBottomSheetHasActionList(false);React__default.Children.forEach(children,function(child){if(isValidAllowedChildren(child,componentIds.ActionList)){setBottomSheetHasActionList(true);}});},[children]);React__default.useEffect(function(){if(padding==='spacing.0'){setHasBodyPadding(false);}},[padding]);if(bottomSheetHasActionList===undefined)return jsx(Fragment,{});return jsx(Fragment,{children:bottomSheetHasActionList?children:jsx(BottomSheetScrollView,{onContentSizeChange:function onContentSizeChange(_width,height){setContentHeight(height);},style:{marginBottom:footerHeight,borderRadius:isHeaderFloating?size[16]:0},children:jsx(BaseBox,{flexShrink:1,flexGrow:1,overflow:"hidden",children:jsx(BaseBox,{paddingLeft:bottomSheetHasActionList?'spacing.3':padding,paddingRight:bottomSheetHasActionList?'spacing.3':padding,paddingTop:bottomSheetHasActionList?'spacing.3':padding,paddingBottom:bottomSheetHasActionList?'spacing.3':padding,overflow:"hidden",children:children})})})});};var BottomSheetBody=assignWithoutSideEffects(_BottomSheetBody,{componentId:ComponentIds.BottomSheetBody}); export { BottomSheetBody }; //# sourceMappingURL=BottomSheetBody.native.js.map