Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
const Description = ({ children }) =>
;
Description.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]),
};
const layoutMapper = {
[layoutComponents.FORM_WRAPPER]: Form,
[layoutComponents.BUTTON]: ButtonLayout,
[layoutComponents.BUTTON_GROUP]: ButtonGroupLayout,
[layoutComponents.TITLE]: Title,
[layoutComponents.DESCRIPTION]: Description,
};
export default layoutMapper;
const TitleWrapper = ({ children }) => <h3>{ children }</h3>;
TitleWrapper.propTypes = {
children: PropTypes.oneOfType([ PropTypes.node, PropTypes.arrayOf(PropTypes.node) ]).isRequired,
};
const DescriptionWrapper = ({ children }) => <p>{ children }</p>;
DescriptionWrapper.propTypes = {
children: PropTypes.oneOfType([ PropTypes.node, PropTypes.arrayOf(PropTypes.node) ]).isRequired,
};
const layoutMapper = {
[layoutComponents.FORM_WRAPPER]: FormWapper,
[layoutComponents.BUTTON]: FormButton,
[layoutComponents.BUTTON_GROUP]: ButtonGroupWrapper,
[layoutComponents.TITLE]: TitleWrapper,
[layoutComponents.DESCRIPTION]: DescriptionWrapper,
};
export default layoutMapper;
const Button = ({ children, label, variant, ...props }) => <button style="{">{ label }</button>;
const buttonGroupStyle = {
display: 'flex',
justifyContent: 'space-around',
};
const ButtonGroup = ({ children, ...props }) => (
<div style="{">
{ children }
</div>
);
const layoutComponent = {
[layoutComponents.FORM_WRAPPER]: FormWrapper,
[layoutComponents.BUTTON]: Button,
[layoutComponents.COL]: Fragment,
[layoutComponents.FORM_GROUP]: Fragment,
[layoutComponents.BUTTON_GROUP]: ButtonGroup,
[layoutComponents.ICON]: Fragment,
[layoutComponents.ARRAY_FIELD_WRAPPER]: Fragment,
[layoutComponents.HELP_BLOCK]: Fragment,
[layoutComponents.TITLE]: Title,
[layoutComponents.DESCRIPTION]: Description,
};
const LayoutMapper = () => {
const schema = {
fields: [],
title: 'Empty form with layout mapper',
description: 'If you want to see the source code, please expand the code example.',
};
const getButtonStyle = variant => ({
color: 'White',
backgroundColor: getBackgroundColor(variant),
padding: '8px 16px',
borderRadius: 4,
cursor: 'pointer',
border: 'none',
marginRight: 4,
});
const Button = ({ children, label, variant, ...props }) => <button style="{">{ label }</button>;
const layoutComponent = {
[layoutComponents.FORM_WRAPPER]: FormWrapper,
[layoutComponents.BUTTON]: Button,
[layoutComponents.BUTTON_GROUP]: ({ key, children }) => { children },
[layoutComponents.TITLE]: Fragment,
[layoutComponents.DESCRIPTION]: Fragment,
};
const TextField = ({ formOptions, label, input, isRequired, meta: { error, touched }, FieldProvider, dataType, FieldArrayProvider, ...props }) => (
<div>
<label>{ label }</label>
<br>
<input id="{">
{ touched && error && <p>{ error }</p> }
<br>
</div>
);
const ArrayItem = ({
const getButtonStyle = variant => ({
color: 'White',
backgroundColor: variant === 'primary' ? 'RebeccaPurple' : '#888',
padding: '8px 16px',
borderRadius: 4,
cursor: 'pointer',
border: 'none',
marginRight: 4,
});
const Button = ({ children, label, variant, ...props }) => <button style="{">{ label }</button>;
const layoutComponent = {
[layoutComponents.FORM_WRAPPER]: FormWrapper,
[layoutComponents.BUTTON]: Button,
[layoutComponents.BUTTON_GROUP]: ({ key, children }) => { children },
[layoutComponents.TITLE]: Title,
[layoutComponents.DESCRIPTION]: Description,
};
const TextField = ({ formOptions, customProp, label, input, isRequired, meta: { error, touched }, FieldProvider, FieldArrayProvider, dataType, ...props }) => (
<div>
<label>{ label }</label>
<input id="{">
{ touched && error && <p>{ error }</p> }
{ customProp && <p>This is a custom prop and has nothing to do with form schema</p> }
</div>
);
const CustomComponent = ({ FieldProvider, ...rest }) => (
import React from 'react';
import { layoutComponents } from '@data-driven-forms/react-form-renderer';
import Grid from '@material-ui/core/Grid';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
const layoutMapper = {
[layoutComponents.FORM_WRAPPER]: ({ children, ...props }) => <form>{ children }</form>,
[layoutComponents.BUTTON]: ({ label, variant, children, ...props }) => <button color="{">{ label || children }</button>,
[layoutComponents.BUTTON_GROUP]: ({ children }) => (
<div style="{{">
{ children }
</div>),
[layoutComponents.TITLE]: ({ children }) =>
{ children }
,
[layoutComponents.DESCRIPTION]: ({ children }) =>
{ children }
,
};
const getButtonStyle = variant => ({
color: 'White',
backgroundColor: variant === 'primary' ? 'RebeccaPurple' : '#888',
padding: '8px 16px',
borderRadius: 4,
cursor: 'pointer',
border: 'none',
marginRight: 4,
});
const Button = ({ children, label, variant, ...props }) => <button style="{">{ label }</button>;
const layoutComponent = {
[layoutComponents.FORM_WRAPPER]: FormWrapper,
[layoutComponents.BUTTON]: Button,
[layoutComponents.COL]: Fragment,
[layoutComponents.FORM_GROUP]: Fragment,
[layoutComponents.BUTTON_GROUP]: Fragment,
[layoutComponents.ICON]: Fragment,
[layoutComponents.ARRAY_FIELD_WRAPPER]: Fragment,
[layoutComponents.HELP_BLOCK]: Fragment,
[layoutComponents.TITLE]: Title,
[layoutComponents.DESCRIPTION]: Description,
};
const TextField = ({ formOptions, customProp, label, input, isRequired, meta: { error, touched }, FieldProvider, dataType, ...props }) => (
<div>
<label>{ label }</label>
<input id="{">
{ touched && error && <p>{ error }</p> }
{ customProp && <p>This is a custom prop and has nothing to do with form schema</p> }</div>
const Button = ({ children, label, variant, ...props }) => <button style="{">{ label }</button>;
const buttonGroupStyle = {
display: 'flex',
justifyContent: 'space-around',
};
const ButtonGroup = ({ children, ...props }) => (
<div style="{">
{ children }
</div>
);
const layoutComponent = {
[layoutComponents.FORM_WRAPPER]: FormWrapper,
[layoutComponents.BUTTON]: Button,
[layoutComponents.BUTTON_GROUP]: ButtonGroup,
[layoutComponents.TITLE]: Title,
[layoutComponents.DESCRIPTION]: Description,
};
const LayoutMapper = () => {
const schema = {
fields: [],
title: 'Empty form with layout mapper',
description: 'If you want to see the source code, please expand the code example.',
};
return (