Skip to content

Commit ea7a59f

Browse files
committed
Add documentation texts for editor
1 parent 03b7d30 commit ea7a59f

File tree

11 files changed

+229
-13
lines changed

11 files changed

+229
-13
lines changed

.npmignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/react-renderer-demo/src/components/navigation/mapper.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ListItem from '@mui/material/ListItem';
66
import ListItemText from '@mui/material/ListItemText';
77
import ListSubheader from '@mui/material/ListSubheader';
88
import Typography from '@mui/material/Typography';
9+
import Chip from '@mui/material/Chip';
910
import ExpandLess from '@mui/icons-material/ExpandLess';
1011
import ExpandMore from '@mui/icons-material/ExpandMore';
1112
import Collapse from '@mui/material/Collapse';
@@ -78,7 +79,7 @@ const StyledList = styled(List)(() => ({
7879
},
7980
}));
8081

81-
const FinalList = ({ title, level, link, fields, previousLinks = [], renderItems, openable = true, open = false }) => {
82+
const FinalList = ({ title, level, link, fields, previousLinks = [], renderItems, openable = true, open = false, chip }) => {
8283
const [isOpen, setIsOpen] = useState(openable ? open : true);
8384

8485
const closeNav = () => setIsOpen((state) => !state);
@@ -88,6 +89,7 @@ const FinalList = ({ title, level, link, fields, previousLinks = [], renderItems
8889
{title && (
8990
<ListItem button onClick={openable ? closeNav : null} className={'listItem'}>
9091
<ListItemText primary={title} className={'listItemText'} />
92+
{chip && <Chip label={chip} size="small" color="warning" variant="outlined" />}
9193
{openable ? isOpen ? <ExpandLess /> : <ExpandMore /> : null}
9294
</ListItem>
9395
)}

packages/react-renderer-demo/src/components/navigation/schemas/editor.schema.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
const editorSchema = [
2-
{
3-
component: 'pro-editor',
4-
linkText: 'Pro Editor',
5-
},
62
{
73
component: 'dnd',
84
linkText: 'Drag and Drop',
95
},
6+
{
7+
component: 'core-editor',
8+
linkText: 'Core editor',
9+
},
10+
{
11+
component: 'pro-editor',
12+
linkText: 'Pro Editor',
13+
},
1014
{
1115
component: 'live-editor',
1216
linkText: 'Live Editor',

packages/react-renderer-demo/src/components/navigation/schemas/provider-mappers.schema.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ const providedMappersSchema = [
4343
link: 'aws-northstar',
4444
linkText: 'AWS Northstar',
4545
},
46+
{
47+
link: 'evergreen',
48+
linkText: 'Evergreen',
49+
},
4650
{
4751
subHeader: true,
4852
noRoute: true,

packages/react-renderer-demo/src/components/navigation/schemas/schema.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ const schema = [
6060
fields: customExamplesSchema,
6161
},
6262
{
63-
title: 'Pro Editor',
63+
title: 'Editor utilities',
6464
link: 'editor',
6565
noRoute: true,
6666
fields: editorSchema,
67+
chip: 'Preview',
6768
},
6869
{
6970
linkText: 'Form builder',

packages/react-renderer-demo/src/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = withBundleAnalyzer(
5050
},
5151
crossOrigin: 'anonymous',
5252
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
53-
distDir: './dist',
53+
distDir: '../dist',
5454
swcMinify: true,
5555
webpack: (config, options) => {
5656
config.resolve.alias = {
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import DocPage from '@docs/doc-page';
2+
import ComponentMapperBar from '@docs/component-mapper-bar';
3+
import Alert from '@mui/material/Alert';
4+
5+
<DocPage>
6+
7+
# Core Editor
8+
9+
<ComponentMapperBar prefix="mui" github="https://github.com/data-driven-forms/editor/tree/main/packages/editor-core" npm="https://www.npmjs.com/package/@data-driven-forms%2Feditor-core" npmSvg="https://badge.fury.io/js/@data-driven-forms%2Feditor-core.svg" />
10+
11+
<br />
12+
13+
<Alert severity="warning">This component is work-in-progress and in preview. API is unstable.</Alert>
14+
15+
<br />
16+
17+
`@data-driven-forms/editor-core` is a set of components and utilities allowing to build a custom Data Driven Forms Drag And Drop editor based on [Data Driven Forms Drag And Drop](/editor/dnd) library.
18+
19+
## Installation
20+
21+
```bash
22+
npm install --save @data-driven-forms/editor-core @data-driven-forms/dnd
23+
```
24+
or
25+
```bash
26+
yarn add @data-driven-forms/editor-core @data-driven-forms/dnd
27+
```
28+
29+
## API
30+
31+
### Component
32+
33+
*({ id: string, container: string, HandleProps?: AnyObject, Handle?: Component }) => React.Node*
34+
35+
A wrapper around [useComponent](/editor/dnd#usecomponent) and [useHandle](/editor/dnd#usehandle). Returns a wrapper around a rendered form field.
36+
37+
### Container
38+
39+
*({ id: string, container?: string, isRoot?: boolean, Handle?: Component, HandleProps?: AnyProps, ListProps?: AnyProps, Component: Component }) => React.Node*
40+
41+
A wrapper around [useContainer](/editor/dnd#usecontainer).
42+
43+
### convertToSchema
44+
45+
*(state: ) => schema*
46+
47+
A function converting DnD state to DDF schema.
48+
49+
### Editor
50+
51+
A wrapper providing DnD and Editor functionality.
52+
53+
### MenuItem
54+
55+
*({ component: string, Component?: Component, componentInitialProps?: AnyObject }) => React.Node*
56+
57+
A component for selecting new components and dragging them into the form container.
58+
59+
### prepareCondition
60+
61+
A function preparing DnD `condition` to DDF `condition`. Checks and removes all unfinished configuration.
62+
63+
### prepareValidate
64+
65+
A function preparing DnD `validate` to DDF `validate`. Checks and removes all unfinished configuration, esnures that only valid validators are passed to components..
66+
67+
### Properties
68+
69+
A properties editor for selected components.
70+
71+
### reducer
72+
73+
Extended DnD Reducer with additional functionality.
74+
75+
### useEditor
76+
77+
Setups Editor reducer.
78+
79+
</DocPage>

packages/react-renderer-demo/src/pages/editor/dnd.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,70 @@ import Alert from '@mui/material/Alert';
1616

1717
`@data-driven-forms/dnd` is a library providing drag and drop functionality for React components. This custom light-weight library currently supports mouse and touch input, is highly customisable and supports deep nesting of container elements.
1818

19+
## Installation
20+
21+
```bash
22+
npm install --save @data-driven-forms/dnd
23+
```
24+
or
25+
```bash
26+
yarn add @data-driven-forms/dnd
27+
```
28+
29+
### API
30+
31+
### dispatchContext
32+
33+
An utility to create an context for `dispatch` function.
34+
35+
### DropCursor
36+
37+
A component handling moving cursor and selecting the correct place to move dragged element.
38+
39+
### findTargetElement
40+
41+
An utility function to go over all elements' positions stored in state and selecting the correct place.
42+
43+
### pauseEvent
44+
45+
An utility to stop an event from propagation and default action.
46+
47+
### Provider
48+
49+
A wrapper providing all neccessary components.
50+
51+
### reducer
52+
53+
A reducer providing the basic drag and drop functionality.
54+
55+
### stateContext
56+
57+
An utility to create an context for a drag and drop `state`.
58+
59+
### useComponent
60+
61+
*({ id: any }) => { ref, component }*
62+
63+
A hook to connect a component to DnD state. Requires an id of the component. Returns a `ref` and the `component` object from the state.
64+
65+
### useContainer
66+
67+
*({ id?: any, isRoot?: boolean }) => { ref, container, id }*
68+
69+
A hook to connect a container to DnD state. Requires an id of the container or a root in case the container is the root container. Returns a `ref`, `id` and the `container` object from the state.
70+
71+
### useDispatch
72+
73+
An utility to obtain a dispatch function for the DnD reducer.
74+
75+
### useHandle
76+
77+
*({component: string, sourceContainer?: string }) => { onClick, onMouseDown, onTouchStart }*
78+
79+
A hook returning handle events for a component handle. Requires an `id` of the component.
80+
81+
### useState
82+
83+
An utility to obtain a state object for the DnD reducer.
84+
1985
</DocPage>

packages/react-renderer-demo/src/pages/editor/pro-editor.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,32 @@ import Alert from '@mui/material/Alert';
1414

1515
<br />
1616

17-
`@data-driven-forms/editor-pro` is a component
17+
`@data-driven-forms/editor-pro` is a prebuilt Drag And Drop editor supporting custom provided mappers. The UI is built on Evergreen UI Framework. Check the [live example](/editor/live-editor).
18+
19+
## Installation
20+
21+
```bash
22+
npm install --save @data-driven-forms/editor-pro
23+
```
24+
or
25+
```bash
26+
yarn add @data-driven-forms/editor-pro
27+
```
28+
29+
30+
**Features**
31+
32+
- component editing
33+
- condition editing
34+
- validator editing
35+
36+
## Usage
37+
38+
```jsx
39+
import Editor from '@data-driven-forms/editor-pro/editor'
40+
41+
<Editor />
42+
```
43+
44+
1845
</DocPage>

packages/react-renderer-demo/src/pages/live-editor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import CloseIcon from '@mui/icons-material/Close';
1717
import PanToolIcon from '@mui/icons-material/PanTool';
1818
import PropTypes from 'prop-types';
1919
import componentMapper from '@data-driven-forms/mui-component-mapper/component-mapper';
20+
import Alert from '@mui/material/Alert';
2021

2122
import CodeEditor from '../components/code-editor';
2223
import {
@@ -35,6 +36,7 @@ import {
3536
RIGHT_TITLE,
3637
STEP,
3738
} from '../helpers/field-properties';
39+
import Link from 'next/link';
3840

3941
const Root = styled('div')(({ theme }) => ({
4042
'& .builderWrapper': {
@@ -183,6 +185,9 @@ const LiveEditor = () => {
183185
<Typography variant="h4" component="h1" gutterBottom>
184186
Form builder
185187
</Typography>
188+
<Alert severity="warning">
189+
This editor is no longer supported. Please check <Link href="/editor/pro-editor">Pro Editor</Link> instead.
190+
</Alert>
186191
<FormBuilder
187192
builderMapper={reducedMapper}
188193
pickerMapper={pickerMapper}

0 commit comments

Comments
 (0)