UNPKG

@amsterdam/bmi-component-library

Version:

A React component library based on ASC and Material-UI aimed at repurposing and sharing components across BMI projects

2 lines 3.28 kB
function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _object_without_properties(source,excluded){if(source==null)return{};var target=_object_without_properties_loose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _object_without_properties_loose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}import{jsx as _jsx}from"react/jsx-runtime";import{Children,cloneElement}from"react";import classNames from"classnames";import{ModalStyle}from"./ModalStyles";import ModalTopBar from"./ModalTopBar/ModalTopBar";import ModalContent from"./ModalContent/ModalContent";import ModalActions from"./ModalActions/ModalActions";const Modal=_param=>{var{id,children,classnames,onClose,size="md",disablePortal,open}=_param,rest=_object_without_properties(_param,["id","children","classnames","onClose","size","disablePortal","open"]);const handleClose=()=>{if(onClose){onClose()}};let hasActions=false;let childrenWithProps=null;if(children){childrenWithProps=Children.map(children,child=>{if(child.type===_jsx(Modal.TopBar,{}).type){return cloneElement(child,{id,onClose})}if(child.type===_jsx(Modal.Actions,{}).type){hasActions=true}return cloneElement(child,{id})})}const classes=classNames("modal",`modal-${size}`,classnames,{"has-actions":hasActions});return _jsx(ModalStyle,_object_spread_props(_object_spread({},rest),{id:id,"data-testid":"modal","aria-labelledby":"modal",className:classes,onClose:handleClose,open:open,disablePortal:disablePortal,children:childrenWithProps}))};Modal.TopBar=ModalTopBar;Modal.Content=ModalContent;Modal.Actions=ModalActions;export default Modal; //# sourceMappingURL=Modal.js.map