UNPKG

wix-style-react

Version:
104 lines 6.29 kB
import React from 'react'; import PropTypes from 'prop-types'; import { st, classes } from './CustomModalLayout.st.css'; import BaseModalLayout from '../BaseModalLayout'; import Button from '../Button'; import { TooltipCommonProps } from '../common/PropTypes/TooltipCommon'; import { WixStyleReactContext } from '../WixStyleReactProvider/context'; /** CustomModalLayout */ const CustomModalLayout = ({ // default props theme = 'standard', actionsSize = 'small', removeContentPadding = false, showHeaderDivider = 'auto', showFooterDivider = 'auto', overflowY = 'auto', style = {}, ...propsWithNoDefaults }) => { const { children, width, height, maxHeight, className, ...restProps } = { // default props theme, actionsSize, ...propsWithNoDefaults, }; return (React.createElement(WixStyleReactContext.Consumer, null, ({ newColorsBranding }) => (React.createElement(BaseModalLayout, { ...restProps, className: st(classes.root, { removeContentPadding, showHeaderDivider: showHeaderDivider === true, showFooterDivider: showFooterDivider === true, newColorsBranding, }, className), style: { ...style, width: width !== undefined ? width : style.width, height: height !== undefined ? height : style.height, maxHeight: maxHeight !== undefined ? maxHeight : style.maxHeight, }, "data-contentpadding": !removeContentPadding }, React.createElement(BaseModalLayout.Header, { showHeaderDivider: showHeaderDivider === true, titleSize: "medium", titleTag: "h2" }), React.createElement(BaseModalLayout.Content, { overflowY: overflowY, hideTopScrollDivider: showHeaderDivider !== 'auto', hideBottomScrollDivider: showFooterDivider !== 'auto' }, children), React.createElement(BaseModalLayout.Footer, { showFooterDivider: showFooterDivider === true }), React.createElement(BaseModalLayout.Footnote, null))))); }; CustomModalLayout.Title = BaseModalLayout.Header.Title; CustomModalLayout.displayName = 'CustomModalLayout'; CustomModalLayout.propTypes = { /** ...BaseModalLayout.propTypes, */ /** Applies a CSS class to the component’s root element */ className: PropTypes.string, /** Applies a data-hook HTML attribute to be used in the tests */ dataHook: PropTypes.string, /** Defines a call-back function after user clicks on the close button */ onCloseButtonClick: PropTypes.func, /** Defines a call-back function after user clicks on the help button */ onHelpButtonClick: PropTypes.func, /** Sets the appearance of modal (i.e., changes the skin of primary and secondary action buttons) */ theme: PropTypes.oneOf(['standard', 'premium', 'destructive']), /** ...Header.propTypes, */ /** Sets text title for the modal; can be used in conjunction with other components */ title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), /** Sets text subtitle for the modal; can be used in conjunction with other components */ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), /** ...Content.propTypes, */ /** Contains all modal’s content in its middle area. `<CustomModalLayout/>` children are passed as `content`, too.*/ content: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), /** ...Footer.propTypes, */ /** Sets the size of action buttons */ actionsSize: Button.propTypes.size, /** Sets text label or other content (e.g., <Loader/>) for the primary button */ primaryButtonText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), /** Defines a call-back function after user clicks on the primary button */ primaryButtonOnClick: PropTypes.func, /** Passes on any `<Button/>` properties on the primary button */ primaryButtonProps: (() => { const { dataHook, ...buttonProps } = Button.propTypes; return PropTypes.shape(buttonProps); })(), /** Passes on any `<Tooltip/>` properties on the primary button tooltip */ primaryButtonTooltipProps: PropTypes.shape({ content: PropTypes.string, ...TooltipCommonProps, }), /** Sets text label for the secondary button */ secondaryButtonText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), /** Defines a call-back function after user clicks on the secondary button */ secondaryButtonOnClick: PropTypes.func, /** Passes on any `<Button/>` properties on the secondary button */ secondaryButtonProps: (() => { const { dataHook, ...buttonProps } = Button.propTypes; return PropTypes.shape(buttonProps); })(), /** Contains a checkbox or other components at the start of the footer */ sideActions: PropTypes.node, /** ...Footnote.propTypes, */ /** Renders supplementary text or other components at the bottom of the modal */ footnote: PropTypes.node, /** CustomModalLayout */ /** Removes 30 px left and right padding from the content area */ removeContentPadding: PropTypes.bool, /** Fixes the width of component; if content area is wider than `width`, it scrolls horizontally */ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** Fixes the height of component */ height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** Sets the maximum height of component; if content area is longer than maxHeight, it scrolls vertically */ maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** Controls visibility of a header divider. When set to `auto`, it is shown only when scroll position is greater than 0. When set to `true`, it is always visible, and when set to `false`, it is always hidden. */ showHeaderDivider: PropTypes.oneOf(['auto', true, false]), /** Controls visibility of a footer divider. When set to `auto`, it is shown up until content is scrolled to the very bottom. When set to `true`, it is always visible, and when set to `false`, it is always hidden.*/ showFooterDivider: PropTypes.oneOf(['auto', true, false]), /** Determines what happens when content overflows component vertically */ overflowY: PropTypes.string, }; export default CustomModalLayout; //# sourceMappingURL=CustomModalLayout.js.map