Skip to content

Mui finishing touches #1161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Data Driven Forms is a React library used for rendering and managing forms with

:tada: Features :tada:
- **Easily readable schema**, you don't need to know any HTML or JS to be able to write your own form schemas!
- You can use your **own components** or use one of our **provided mappers**: [PatternFly 4](https://patternfly-react.surge.sh/patternfly-4/), [Material-UI](https://material-ui.com/), [Ant Design](https://ant.design/)! and more, see below!)
- You can use your **own components** or use one of our **provided mappers**: [PatternFly 4](https://patternfly-react.surge.sh/patternfly-4/), [Material-UI](https://mui.com/), [Ant Design](https://ant.design/)! and more, see below!)
- **Form state manager** out-of-the-box (including error states!)
- Fully **customizable** (you can use your own buttons, actions, etc.)!
- **Conditional** fields!
Expand Down Expand Up @@ -365,7 +365,7 @@ We are trying to avoid breaking changes. Please, open an issue and discuss the i

- [Data Driven Forms documentation](https://data-driven-forms.org/)
- [PatternFly 4 Design documentation](https://www.patternfly.org/v4/)
- [Material-UI documentation](https://material-ui.com/)
- [Material-UI documentation](https://mui.com/)
- [Ant Design documentation](https://ant.design/)
- [Semantic UI React](https://react.semantic-ui.com/)
- [BlueprintJS](https://blueprintjs.com/)
Expand Down
2 changes: 1 addition & 1 deletion packages/ant-component-mapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Data Driven Forms supports all kinds of component, basic set is consisted of:
### Useful links

- [Data Driven Forms documentation](https://data-driven-forms.org/)
- [Material-UI documentation](https://material-ui.com/)
- [Material-UI documentation](https://mui.com/)
- NPM
- [React Form Renderer](https://www.npmjs.com/package/@data-driven-forms/react-form-renderer)
- [MaterialUI Mapper](https://www.npmjs.com/package/@data-driven-forms/ant-component-mapper)
Expand Down
12 changes: 6 additions & 6 deletions packages/common/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ const createSuirCJSTransform = (env = 'commonjs') => [
const createMuiTransform = (env) => [
'transform-imports',
{
'@material-ui/lab': {
transform: (importName) => (env ? `@material-ui/lab/${env}/${importName}` : `@material-ui/lab/${importName}`),
'@mui/lab': {
transform: (importName) => (env ? `@mui/lab/${env}/${importName}` : `@mui/lab/${importName}`),
preventFullImport: false,
skipDefaultConversion: false
},
'@material-ui/core': {
transform: (importName) => (env ? `@material-ui/core/${env}/${importName}` : `@material-ui/core/${importName}`),
'@mui/material': {
transform: (importName) => (env ? `@mui/material/${env}/${importName}` : `@mui/material/${importName}`),
preventFullImport: false,
skipDefaultConversion: false
}
Expand Down Expand Up @@ -294,7 +294,7 @@ module.exports = {
presets: [['@babel/preset-env', { modules: 'commonjs' }]],
plugins: [
createSuirCJSTransform('commonjs'),
createMuiTransform(),
createMuiTransform('node'),
createPfReactTransform('js'),
createBluePrintTransform('cjs'),
createAntTransform('cjs'),
Expand All @@ -306,7 +306,7 @@ module.exports = {
presets: [['@babel/preset-env', { modules: false }]],
plugins: [
createSuirCJSTransform('es'),
createMuiTransform('esm'),
createMuiTransform(),
createPfReactTransform('esm'),
createBluePrintTransform('esm'),
createAntTransform('esm'),
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-component-mapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Material-UI component mapper for [Data Driven Forms](https://github.com/data-dri

:book: For more information please visit the [documentation](https://data-driven-forms.org/). :book:

[Material-IU docs](https://material-ui.com/)
[Material-IU docs](https://mui.com/)


**Table of Contents**
Expand Down Expand Up @@ -102,7 +102,7 @@ Data Driven Forms supports all kinds of component, basic set is consisted of:
### Useful links

- [Data Driven Forms documentation](https://data-driven-forms.org/)
- [Material-UI documentation](https://material-ui.com/)
- [Material-UI documentation](https://mui.com/)
- NPM
- [React Form Renderer](https://www.npmjs.com/package/@data-driven-forms/react-form-renderer)
- [MaterialUI Mapper](https://www.npmjs.com/package/@data-driven-forms/mui-component-mapper)
Expand Down
9 changes: 4 additions & 5 deletions packages/mui-component-mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
},
"peerDependencies": {
"@data-driven-forms/react-form-renderer": ">=3.2.1",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/styles": "^4.9.14",
"@mui/icons-material": "^5.0.4",
"@mui/material": "^5.0.4",
"@mui/styles": "^5.0.1",
"prop-types": ">=15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
Expand All @@ -44,7 +44,6 @@
"@emotion/styled": "^11.3.0",
"@mui/lab": "^5.0.0-alpha.51",
"clsx": "^1.0.4",
"lodash": "^4.17.21",
"moment": "^2.23.0"
"lodash": "^4.17.21"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { DatePickerProps as MuiDatePickerProps } from "@material-ui/pickers/DatePicker";
import { DatePickerProps as MuiDatePickerProps } from "@mui/lab/DatePicker";
import { UseFieldApiComponentConfig } from "@data-driven-forms/react-form-renderer";
import { GridProps } from "@mui/material";
import { MuiPickersUtilsProviderProps } from "@material-ui/pickers/MuiPickersUtilsProvider";

interface InternalDatePickerProps extends MuiDatePickerProps {
FormFieldGridProps: GridProps;
MuiPickersUtilsProviderProps: MuiPickersUtilsProviderProps;
DatePickerProps: MuiDatePickerProps;
}

Expand Down
3 changes: 1 addition & 2 deletions packages/mui-component-mapper/src/date-picker/date-picker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';

import MUIDatePicker from '@mui/lab/DatePicker';
import { DatePicker as MUIDatePicker } from '@mui/lab';

import FormFieldGrid from '../form-field-grid/form-field-grid';
import { validationError } from '../validation-error/validation-error';
Expand Down Expand Up @@ -63,7 +63,6 @@ DatePicker.propTypes = {
validateOnMount: PropTypes.bool,
description: PropTypes.node,
FormFieldGridProps: PropTypes.object,
MuiPickersUtilsProviderProps: PropTypes.object,
DatePickerProps: PropTypes.object,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { styled } from '@mui/material/styles';
import { styled } from '@mui/material';
import PropTypes from 'prop-types';
import clsx from 'clsx';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from 'react';
import { styled } from '@mui/material/styles';
import PropTypes from 'prop-types';
import { Grid, Button as MUIButton, Typography } from '@mui/material';
import Alert from '@mui/material/Alert';
import AlertTitle from '@mui/material/AlertTitle';
import { Alert, AlertTitle } from '@mui/material';

import FormTemplate from '@data-driven-forms/common/form-template';
import clsx from 'clsx';
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-component-mapper/src/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import parseInternalValue from '@data-driven-forms/common/select/parse-internal-
import { useFieldApi } from '@data-driven-forms/react-form-renderer';
import { TextField, CircularProgress } from '@mui/material';
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
import Autocomplete from '@mui/material/Autocomplete';
import { Autocomplete } from '@mui/material';

/**
* Returns label of selected option
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { UseFieldApiComponentConfig } from "@data-driven-forms/react-form-renderer";
import { TimePickerProps as MuiTimePickerProps } from '@material-ui/pickers';
import { TimePickerProps as MuiTimePickerProps } from '@mui/lab';
import { ReactNode } from "react";
import { MuiPickersUtilsProviderProps } from "@material-ui/pickers/MuiPickersUtilsProvider";
import { GridProps } from "@mui/material";
interface InternalTimePickerProps extends MuiTimePickerProps {
isReadOnly?: boolean;
isDisabled?: boolean;
isRequired?: boolean;
description?: ReactNode;
validateOnMount?: boolean;
locale?: string;
MuiPickersUtilsProviderProps?: MuiPickersUtilsProviderProps;
FormFieldGridProps?: GridProps;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import MUITimePicker from '@mui/lab/TimePicker';
import { TimePicker as MUITimePicker } from '@mui/lab';

import FormFieldGrid from '../form-field-grid/form-field-grid';
import { validationError } from '../validation-error/validation-error';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-form-renderer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Please use our [documentation site](https://data-driven-forms.org/). In case of

- [Data Driven Forms documentation](https://data-driven-forms.org/)
- [PatternFly 4 Design documentation](https://www.patternfly.org/v4/)
- [Material-UI documentation](https://material-ui.com/)
- [Material-UI documentation](https://mui.com/)
- [Ant Design documentation](https://ant.design/)
- [Semantic UI React](https://react.semantic-ui.com/)
- [BlueprintJS](https://blueprintjs.com/)
Expand Down
147 changes: 6 additions & 141 deletions packages/react-form-renderer/demo/index.js
Original file line number Diff line number Diff line change
@@ -1,154 +1,19 @@
/* eslint-disable camelcase */
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import { FormRenderer, useFieldApi, componentTypes, useFormApi } from '../src';
import MuiTextField from '@material-ui/core/TextField';
import Grid from '@material-ui/core/Grid';
import { FormRenderer } from '../src';

import { Button as MUIButton, Typography } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';

import FormTemplate from '@data-driven-forms/common/form-template';

const useStyles = makeStyles(() => ({
buttonGroup: {
display: 'flex',
justifyContent: 'flex-end',
'&>button:not(last-child)': {
marginLeft: 8
}
}
}));

const Form = ({ children, GridContainerProps, GridProps, ...props }) => (
<Grid item xs={12} {...GridProps}>
<form noValidate {...props}>
<Grid container item spacing={2} xs={12} {...GridContainerProps}>
{children}
</Grid>
</form>
</Grid>
);

Form.propTypes = {
children: PropTypes.node,
GridProps: PropTypes.object,
GridContainerProps: PropTypes.object
};

const Description = ({ children, GridProps, ...props }) => (
<Grid item xs={12} {...GridProps}>
<Typography variant="body1" gutterBottom {...props}>
{children}
</Typography>
</Grid>
);

Description.propTypes = {
children: PropTypes.node,
GridProps: PropTypes.object
};

const Title = ({ children, GridProps, ...props }) => (
<Grid item xs={12} {...GridProps}>
<Typography variant="h3" gutterBottom {...props}>
{children}
</Typography>
</Grid>
);

Title.propTypes = {
children: PropTypes.node,
GridProps: PropTypes.object
};

const ButtonGroup = ({ children, GridProps, ...props }) => {
const classes = useStyles();
return (
<Grid item xs={12} {...GridProps}>
<div className={classes.buttonGroup} {...props}>
{children}
</div>
</Grid>
);
};

ButtonGroup.propTypes = {
children: PropTypes.node,
GridProps: PropTypes.object
};

const Button = ({ label, variant, children, buttonType, ...props }) => (
<MUIButton color={variant} variant="contained" {...props}>
{label || children}
</MUIButton>
);

Button.propTypes = {
children: PropTypes.node,
label: PropTypes.node,
variant: PropTypes.string,
buttonType: PropTypes.string
};

const MuiFormTemplate = (props) => (
<FormTemplate FormWrapper={Form} Button={Button} ButtonGroup={ButtonGroup} Title={Title} Description={Description} {...props} />
);

export default MuiFormTemplate;

// eslint-disable-next-line react/prop-types
const TextField = (props) => {
const { input, label, isRequired, WrapperProps } = useFieldApi(props);
return (
<Grid item xs={12} {...WrapperProps}>
<MuiTextField {...input} label={label} required={isRequired} />
</Grid>
);
};

const Spy = () => {
const formApi = useFormApi();
console.log(formApi);
return null;
};

const fields = [{
name: 'optionsSpy',
component: 'spy',
}];

for (let index = 0; index < 10; index++) {
fields.push({
name: `field-${index}`,
label: `Text field ${index}`,
component: 'text-field',
...(index > 0 ? {
condition: {
when: `field-${index - 1}`,
isEmpty: true
}
} : {})
});
}

const schema = {
fields
};
import FormTemplate from './form-template';
import mapper from './form-fields-mapper';

const App = () => {
// const [values, setValues] = useState({});
return (
<div style={{ padding: 20 }}>
<FormRenderer
componentMapper={{
[componentTypes.TEXT_FIELD]: TextField,
spy: Spy
}}
componentMapper={mapper}
onSubmit={console.log}
FormTemplate={MuiFormTemplate}
schema={schema}
FormTemplate={FormTemplate}
schema={{ fields: [{ component: 'text-field', name: 'text' }] }}
subscription={{ pristine: false }}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/react-renderer-demo/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const muiTransformPlugin = [
'transform-imports',
{
'@material-ui/core': {
transform: (importName) => `@material-ui/core/${importName}`,
'@mui/material': {
transform: (importName) => `@mui/material/${importName}`,
preventFullImport: false,
skipDefaultConversion: false
}
Expand Down
3 changes: 0 additions & 3 deletions packages/react-renderer-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
"@data-driven-forms/react-form-renderer": "*",
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/styles": "^4.10.0",
"@mdx-js/loader": "^1.6.22",
"@mdx-js/react": "^1.6.22",
"@mui/icons-material": "^5.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import Common from './common.md';
### Composite props
|name|type|default|target component|
|----|----|-------|----------------|
|FormFieldGridProps|object|`{}`|[Grid](https://material-ui.com/api/grid/)|
|FormControlProps|object|`{}`|[Form Control](https://material-ui.com/api/form-control/#formcontrol-api)|
|FormGroupProps|object|`{}`|[Form Group](https://material-ui.com/api/form-group/#formgroup-api)|
|FormControlLabelProps|object|`{}`|[Form Control Label](https://material-ui.com/api/form-control-label/#formcontrollabel-api)|
|CheckboxProps|object|`{}`|[Checkbox](https://material-ui.com/api/checkbox/#checkbox-api)|
|FormLabelProps|object|`{}`|[Form label](https://material-ui.com/api/form-label/#formlabel-api)|
|FormHelperTextProps|object|`{}`|[Form helper text](https://material-ui.com/api/form-helper-text/#formhelpertext-api)|
|FormFieldGridProps|object|`{}`|[Grid](https://mui.com/api/grid/)|
|FormControlProps|object|`{}`|[Form Control](https://mui.com/api/form-control/#formcontrol-api)|
|FormGroupProps|object|`{}`|[Form Group](https://mui.com/api/form-group/#formgroup-api)|
|FormControlLabelProps|object|`{}`|[Form Control Label](https://mui.com/api/form-control-label/#formcontrollabel-api)|
|CheckboxProps|object|`{}`|[Checkbox](https://mui.com/api/checkbox/#checkbox-api)|
|FormLabelProps|object|`{}`|[Form label](https://mui.com/api/form-label/#formlabel-api)|
|FormHelperTextProps|object|`{}`|[Form helper text](https://mui.com/api/form-helper-text/#formhelpertext-api)|
Loading