UNPKG

@zohodesk/dot

Version:

In this Library, we Provide Some Basic Components to Build Your Application

75 lines (74 loc) 2.96 kB
import React from 'react'; import { defaultProps } from "./props/defaultProps"; import { propTypes } from "./props/propTypes"; import { Container, Box } from '@zohodesk/components/es/v1/Layout'; import style from "../../FormAction/FormAction.module.css"; export const LeftSide = props => { props.children; }; export const RightSide = props => { props.children; }; export const Center = props => { props.children; }; export default function FormAction(props) { let { size, children, paddingLeftSize, paddingRightClass, dataSelectorId } = props; let leftbuttonGroup = [], rightbuttonGroup = [], centerbuttonGroup = []; React.Children.map(children, child => { if (!child) { return child; } else if (child.type === LeftSide) { leftbuttonGroup = leftbuttonGroup.concat(child.props.children); } else if (child.type === RightSide) { rightbuttonGroup = rightbuttonGroup.concat(child.props.children); } else if (child.type === Center) { centerbuttonGroup = centerbuttonGroup.concat(child.props.children); } else { leftbuttonGroup.push(child); } }); let hasLeftChild = leftbuttonGroup.length > 0; let hasRightChild = rightbuttonGroup.length > 0; let hasCenterChild = centerbuttonGroup.length > 0; return /*#__PURE__*/React.createElement("div", { className: style.wrapperDiv, "data-selector-id": dataSelectorId }, /*#__PURE__*/React.createElement(Container, { alignBox: "row", isCover: false, align: hasCenterChild ? 'around' : hasRightChild && !hasLeftChild ? 'right' : null, className: ` ${`${style.footerParent} ${hasCenterChild ? '' : style[`${paddingLeftSize ? paddingLeftSize : size}Padding`]} ${paddingRightClass}`} ${style[`${size}Footer`]} ` }, hasLeftChild ? /*#__PURE__*/React.createElement(Box, { flexible: hasRightChild ? true : false, shrink: !hasRightChild && hasLeftChild ? true : false }, leftbuttonGroup.length > 1 ? leftbuttonGroup.map((item, index) => /*#__PURE__*/React.createElement("div", { className: style.marginRight, key: index }, item)) : leftbuttonGroup[0]) : null, hasRightChild ? /*#__PURE__*/React.createElement(Box, { shrink: hasRightChild && !hasLeftChild ? true : false }, rightbuttonGroup.length > 1 ? rightbuttonGroup.map((item, index) => /*#__PURE__*/React.createElement("div", { className: style.marginRight, key: index }, item)) : rightbuttonGroup[0]) : null, hasCenterChild ? /*#__PURE__*/React.createElement(Box, null, centerbuttonGroup.length > 1 ? centerbuttonGroup.map((item, index) => /*#__PURE__*/React.createElement("div", { className: style.marginRight, key: index }, item)) : centerbuttonGroup[0]) : null)); } FormAction.propTypes = propTypes; FormAction.defaultProps = defaultProps; // if (__DOCS__) { // FormAction.docs = { // componentGroup: 'Atom' // }; // }