@razorpay/blade
Version:
The Design System that powers Razorpay
81 lines (78 loc) • 3.96 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { useModalContext } from './ModalContext.js';
import { componentIds } from './constants.js';
import '../../utils/index.js';
import { BaseHeader } from '../BaseHeaderFooter/BaseHeader.js';
import '../Box/BaseBox/index.js';
import '../../tokens/global/index.js';
import '../Button/IconButton/index.js';
import '../Icons/index.js';
import '../../utils/metaAttribute/index.js';
import '../../utils/assignWithoutSideEffects/index.js';
import { componentZIndices } from '../../utils/componentZIndices.js';
import '../../utils/makeAnalyticsAttribute/index.js';
import { jsx } from 'react/jsx-runtime';
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
import { makeSize } from '../../utils/makeSize/makeSize.js';
import { size } from '../../tokens/global/size.js';
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
import { IconButton } from '../Button/IconButton/IconButton.js';
import CloseIcon from '../Icons/CloseIcon/CloseIcon.js';
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
var _excluded = ["leading", "subtitle", "title", "titleSuffix", "trailing"];
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 _ModalHeader = function _ModalHeader(_ref) {
var leading = _ref.leading,
subtitle = _ref.subtitle,
title = _ref.title,
titleSuffix = _ref.titleSuffix,
trailing = _ref.trailing,
rest = _objectWithoutProperties(_ref, _excluded);
var _useModalContext = useModalContext(),
close = _useModalContext.close,
defaultInitialFocusRef = _useModalContext.defaultInitialFocusRef,
isDismissible = _useModalContext.isDismissible;
var isHeaderEmpty = !(title || subtitle || leading || trailing);
return isHeaderEmpty ? /*#__PURE__*/jsx(BaseBox, _objectSpread(_objectSpread({
display: "flex",
alignItems: "center",
justifyContent: "center",
position: "absolute",
top: "spacing.5",
right: "spacing.5",
width: makeSize(size[28]),
height: makeSize(size[28]),
flexShrink: 0,
backgroundColor: "popup.background.gray.subtle",
borderRadius: "max",
zIndex: componentZIndices.modal
}, makeAnalyticsAttribute(rest)), {}, {
children: isDismissible && /*#__PURE__*/jsx(IconButton, {
ref: defaultInitialFocusRef,
size: "large",
icon: CloseIcon,
accessibilityLabel: "Close",
onClick: function onClick() {
return close === null || close === void 0 ? void 0 : close();
}
})
})) : /*#__PURE__*/jsx(BaseHeader, _objectSpread({
metaComponentName: MetaConstants.ModalHeader,
title: title,
subtitle: subtitle,
leading: leading,
trailing: trailing,
titleSuffix: titleSuffix,
closeButtonRef: defaultInitialFocusRef,
showCloseButton: isDismissible,
onCloseButtonClick: close
}, makeAnalyticsAttribute(rest)));
};
var ModalHeader = /*#__PURE__*/assignWithoutSideEffects(_ModalHeader, {
componentId: componentIds.ModalHeader
});
export { ModalHeader };
//# sourceMappingURL=ModalHeader.web.js.map