23 | 元素
24 | }
25 | bordered
26 | dataSource={data}
27 | renderItem={
28 | item =>
29 | (
30 |
31 |
34 |
35 | )
36 | }
37 | />
38 | )
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/dist/styled/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';Object.defineProperty(exports,'__esModule',{value:true});exports.RowMB10=exports.SpanLH32=exports.CursorIcon=undefined;var _row=require('antd/es/row');var _row2=_interopRequireDefault(_row);var _icon=require('antd/es/icon');var _icon2=_interopRequireDefault(_icon);require('antd/es/row/style/css');require('antd/es/icon/style/css');var _styledComponents=require('styled-components');var _styledComponents2=_interopRequireDefault(_styledComponents);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var CursorIcon=exports.CursorIcon=(0,_styledComponents2.default)(_icon2.default).withConfig({displayName:'styled__CursorIcon',componentId:'ks49l4-0'})(['cursor:pointer;']);var SpanLH32=exports.SpanLH32=_styledComponents2.default.span.withConfig({displayName:'styled__SpanLH32',componentId:'ks49l4-1'})(['line-height:32px;']);var RowMB10=exports.RowMB10=(0,_styledComponents2.default)(_row2.default).withConfig({displayName:'styled__RowMB10',componentId:'ks49l4-2'})(['margin-bottom:10px;']);
--------------------------------------------------------------------------------
/src/component/FormBuilder/DeveloperContent/UrlInput/index.jsx:
--------------------------------------------------------------------------------
1 | import React,{Component} from 'react';
2 | import {observer,inject} from 'mobx-react';
3 | import {
4 | Input,
5 | Modal
6 | } from 'antd';
7 | import {
8 | action
9 | } from 'mobx';
10 | const Search = Input.Search;
11 |
12 | @inject('store')
13 | @observer
14 | export default class UrlInput extends Component{
15 | testSubmit=()=>{
16 | const {
17 | form,
18 | }=this.props;
19 | Modal.info({title:'测试表单提交',content:{JSON.stringify(form.getFieldsValue(),null,2)}});
20 | console.log(form.getFieldsValue());
21 | }
22 | @action urlChange=(e)=>{
23 | this.props.store.submitUrl=e.target.value;
24 | };
25 | render(){
26 | const {
27 | store:{
28 | submitUrl
29 | }
30 | }=this.props;
31 | return (
32 |
39 | )
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/component/FormBuilder/EditingContent/FieldNameInput/index.jsx:
--------------------------------------------------------------------------------
1 | import React,{Component} from 'react';
2 | import {
3 | inject,
4 | observer,
5 | } from 'mobx-react';
6 | import {action} from 'mobx';
7 | import {Input} from 'antd';
8 | @inject('store')
9 | @observer
10 | export default class FieldNameInput extends Component{
11 | @action handleChange=(e)=>{
12 | const {
13 | store
14 | }=this.props;
15 | store.editingData.fieldName=e.target.value;
16 | }
17 |
18 | @action handleBlur=()=>{
19 | const {
20 | store:{
21 | editingData,
22 | editingData:{
23 | fieldName
24 | },
25 | checkName,
26 | }
27 | }=this.props;
28 | editingData.fieldName=checkName(fieldName,editingData.type,1);
29 | }
30 |
31 | render(){
32 | const {
33 | store:{
34 | editingData:{
35 | fieldName
36 | }
37 | }
38 | }=this.props;
39 | return (
40 |
47 | )
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/component/FormBuilder/ElementList/Element/index.jsx:
--------------------------------------------------------------------------------
1 | import React,{Component} from 'react';
2 | import {List} from 'antd';
3 | import {FormConsume} from '../../../Context';
4 | import {
5 | DragSource,
6 | } from 'react-dnd';
7 | import {
8 | inject,
9 | observer,
10 | } from 'mobx-react';
11 | import {action} from 'mobx';
12 |
13 | const type=`ELEMENT`;
14 | //拖拽目标处理集合
15 | const source={
16 | canDrag(props){
17 | return true;
18 | },
19 | beginDrag(props,monitor,component) {
20 | return props;
21 | }
22 | }
23 |
24 | @inject('store')
25 | @observer
26 | @FormConsume
27 | @DragSource(
28 | type,
29 | source,
30 | (connect, monitor) => ({
31 | connectDragSource: connect.dragSource(),
32 | isDragging: monitor.isDragging(),
33 | connectDragPreview: connect.dragPreview(),
34 | }),
35 | )
36 | export default class Element extends Component{
37 |
38 | render(){
39 | const {
40 | connectDragSource,
41 | item,
42 | item:{
43 | name,
44 | },
45 | store:{
46 | addElement
47 | }
48 | }=this.props;
49 | return (
50 | connectDragSource &&
51 | connectDragSource(
52 | addElement(item)}
54 | style={{cursor:`pointer`}}
55 | >
56 | {name}
57 |
58 | )
59 | )
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/component/FormBuilder/EditingContent/RequiredCheckBox/index.jsx:
--------------------------------------------------------------------------------
1 | import React,{Component,Fragment} from 'react';
2 | import {
3 | inject,
4 | observer,
5 | } from 'mobx-react';
6 | import {action} from 'mobx';
7 | import {
8 | Checkbox,
9 | Input
10 | } from 'antd';
11 | @inject('store')
12 | @observer
13 | export default class RequiredCheckBox extends Component{
14 | @action requireChange=(e)=>{
15 | const {
16 | store
17 | }=this.props;
18 | store.editingData.required=e.target.checked;
19 | }
20 | @action requiredMessageChange=(e)=>{
21 | const {
22 | store,
23 | store:{
24 | editingData:data
25 | },
26 | form
27 | }=this.props;
28 | store.editingData.requiredMessage=e.target.value;
29 | // debugger
30 | const fName=data.fieldName||`invalidField`;
31 | if(!form.getFieldValue(fName)){
32 | form.setFieldsValue({[fName]:1})
33 | form.setFieldsValue({[fName]:``});
34 | setTimeout(()=>{
35 | form.validateFields();
36 | },1)
37 | }
38 | }
39 | render(){
40 | const {
41 | store:{
42 | editingData:{
43 | required,
44 | requiredMessage
45 | }
46 | }
47 | }=this.props;
48 | return (
49 |
50 |
53 | 必填
54 |
55 | {do{
56 | if(required){
57 |
63 | }
64 | }}
65 |
66 |
67 | )
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/component/FormBuilder/EditingContent/LabelEditor/index.jsx:
--------------------------------------------------------------------------------
1 | import React,{Component} from 'react';
2 | import {
3 | Drawer,
4 | Radio ,
5 | Row,
6 | Col,
7 | Divider,
8 | } from 'antd';
9 | import { Editor } from 'react-draft-wysiwyg';
10 | import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
11 | import { EditorState, convertToRaw, ContentState,convertFromHTML } from 'draft-js';
12 | import draftToHtml from 'draftjs-to-html';
13 | import htmlToDraft from 'html-to-draftjs';
14 | import update from 'immutability-helper';
15 | import {FormConsume} from '../../../Context';
16 |
17 | import {observer,inject} from 'mobx-react';
18 | import {observable,action} from 'mobx';
19 |
20 | @inject('store')
21 | @observer
22 | export default class LabelEditor extends Component{
23 |
24 | state={
25 | toolbar:[
26 | 'inline',
27 | 'blockType',
28 | 'fontSize',
29 | 'fontFamily',
30 | //'list',
31 | //'textAlign',
32 | 'colorPicker',
33 | 'link',
34 | //'embedded',
35 | 'emoji',
36 | 'image',
37 | 'remove',
38 | 'history'
39 | ],
40 | }
41 |
42 | @action onEditorStateChange=(editorState)=>{
43 | const {
44 | store,
45 | store:{
46 | editingData:data,
47 | setEditingData
48 | }
49 | }=this.props;
50 | const label=draftToHtml(convertToRaw(editorState.getCurrentContent()))
51 | setEditingData(`label`,label);
52 | store.editorState=editorState;
53 | }
54 | render(){
55 | const {
56 | state:{
57 | toolbar
58 | },
59 | props:{
60 | store:{
61 | editorState
62 | }
63 | }
64 | }=this;
65 | return (
66 |
75 | )
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/config/paths.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path');
4 | const fs = require('fs');
5 | const url = require('url');
6 |
7 | // Make sure any symlinks in the project folder are resolved:
8 | // https://github.com/facebookincubator/create-react-app/issues/637
9 | const appDirectory = fs.realpathSync(process.cwd());
10 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
11 |
12 | const envPublicUrl = process.env.PUBLIC_URL;
13 |
14 | function ensureSlash(path, needsSlash) {
15 | const hasSlash = path.endsWith('/');
16 | if (hasSlash && !needsSlash) {
17 | return path.substr(path, path.length - 1);
18 | } else if (!hasSlash && needsSlash) {
19 | return `${path}/`;
20 | } else {
21 | return path;
22 | }
23 | }
24 |
25 | const getPublicUrl = appPackageJson =>
26 | envPublicUrl || require(appPackageJson).homepage;
27 |
28 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer
29 | // "public path" at which the app is served.
30 | // Webpack needs to know it to put the right