@razorpay/blade
Version:
The Design System that powers Razorpay
55 lines (52 loc) • 3.05 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import React__default from 'react';
import { useBottomSheetContext } from './BottomSheetContext.js';
import { BaseFooter } from '../BaseHeaderFooter/BaseFooter.js';
import '../Box/BaseBox/index.js';
import { useIsomorphicLayoutEffect } from '../../utils/useIsomorphicLayoutEffect.js';
import '../../utils/metaAttribute/index.js';
import '../../utils/makeAnalyticsAttribute/index.js';
import { jsx } from 'react/jsx-runtime';
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
var _excluded = ["children"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var BottomSheetFooter = function BottomSheetFooter(_ref) {
var children = _ref.children,
dataAnalyticsProps = _objectWithoutProperties(_ref, _excluded);
var _useBottomSheetContex = useBottomSheetContext(),
setFooterHeight = _useBottomSheetContex.setFooterHeight,
isOpen = _useBottomSheetContex.isOpen,
bind = _useBottomSheetContex.bind;
var ref = React__default.useRef(null);
useIsomorphicLayoutEffect(function () {
// for some reason the calculated footer height is changing when user drags the sheet
// although i don't see a reason why, thus putting it in a setTimeout so that
// we calculate the height on the next browser paint
window.setTimeout(function () {
if (!ref.current) return;
setFooterHeight(ref.current.getBoundingClientRect().height);
});
}, [ref, isOpen]);
return /*#__PURE__*/jsx(BaseBox, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
ref: ref,
width: "100%",
flexShrink: 0,
marginTop: "auto",
backgroundColor: "popup.background.subtle",
touchAction: "none",
zIndex: 2
}, metaAttribute({
name: MetaConstants.BottomSheetFooter
})), bind === null || bind === void 0 ? void 0 : bind()), makeAnalyticsAttribute(dataAnalyticsProps)), {}, {
children: /*#__PURE__*/jsx(BaseFooter, {
children: children
})
}));
};
export { BottomSheetFooter };
//# sourceMappingURL=BottomSheetFooter.web.js.map