UNPKG

@wix/design-system

Version:

@wix/design-system

143 lines 7.76 kB
import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; import { st, classes } from './CustomModalLayout.st.css.js'; import BaseModalLayout from '../BaseModalLayout'; import Button from '../Button'; import { TooltipCommonProps } from '../common/PropTypes/TooltipCommon'; import deprecationLog from '../utils/deprecationLog'; const CustomModalLayout = ({ theme = 'standard', // TODO: add default value for skin once theme is removed actionsSize = 'small', removeContentPadding = false, showHeaderDivider = 'auto', showFooterDivider = 'auto', overflowY = 'auto', style = {}, ...propsWithNoDefaults }) => { const { children, width, maxWidth, height, maxHeight, className, footnoteSkin, ...restProps } = { theme, actionsSize, ...propsWithNoDefaults, }; const skin = restProps.skin || theme; useEffect(() => { if (theme) { deprecationLog('<CustomModalLayout/> - prop "theme" is deprecated and will be removed in next major release, please use "skin" property instead.'); } }, [theme]); return (React.createElement(BaseModalLayout, { ...restProps, skin: skin, className: st(classes.root, { removeContentPadding, showHeaderDivider: showHeaderDivider === true, showFooterDivider: showFooterDivider === true, }, className), style: { ...style, width: width !== undefined ? width : style.width, maxWidth: maxWidth !== undefined ? maxWidth : style.maxWidth, 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, { skin: footnoteSkin }))); }; CustomModalLayout.Title = BaseModalLayout.Header.Title; CustomModalLayout.displayName = 'CustomModalLayout'; CustomModalLayout.propTypes = { /** ...BaseModalLayout.propTypes, */ /** Specifies a CSS class name to be appended to the component’s root element. * @internal */ className: PropTypes.string, /** Applies a data-hook HTML attribute to be used in the tests */ dataHook: PropTypes.string, /** @deprecated use closeButtonProps instead. */ onCloseButtonClick: PropTypes.func, /** @deprecated use helpButtonProps instead. */ onHelpButtonClick: PropTypes.func, /** Sets the appearance of modal (i.e., changes the skin of primary and secondary action buttons) */ skin: PropTypes.oneOf(['standard', 'premium', 'destructive']), /** @deprecated use skin prop instead */ 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, /** Sets the look and feel of the footnote */ footnoteSkin: PropTypes.oneOf(['neutral', 'light']), /** 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]), /** Sets the maximum width of component; if content area is longer than maxWidth, it scrolls horizontally */ maxWidth: 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, /** Sets object of CSS styles */ style: PropTypes.any, /** Help button props. */ helpButtonProps: PropTypes.shape({ onClick: PropTypes.func, size: PropTypes.oneOf(['small', 'medium', 'large']), skin: PropTypes.oneOf([ 'standard', 'standardFilled', 'light', 'lightFilled', 'dark', 'transparent', ]), }), /** Close button props. */ closeButtonProps: PropTypes.shape({ onClick: PropTypes.func, size: PropTypes.oneOf(['small', 'medium', 'large']), skin: PropTypes.oneOf([ 'standard', 'standardFilled', 'light', 'lightFilled', 'dark', 'transparent', ]), }), }; export default CustomModalLayout; //# sourceMappingURL=CustomModalLayout.js.map