Skip to content

Commit

Permalink
bugfix: add config files and fix the build error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
云数 committed Dec 18, 2019
1 parent e78e1d0 commit 2da0eda
Show file tree
Hide file tree
Showing 11 changed files with 6,089 additions and 22,780 deletions.
4 changes: 4 additions & 0 deletions packages/react-schema-editor/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
*.log
build
__tests__
1 change: 1 addition & 0 deletions packages/react-schema-editor/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../scripts/jest.base')
38 changes: 38 additions & 0 deletions packages/react-schema-editor/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@uform/react-schema-editor",
"version": "1.0.0-beta.1",
"license": "MIT",
"main": "lib",
"repository": {
"type": "git",
"url": "git+https://github.com/alibaba/uform.git"
},
"bugs": {
"url": "https://github.com/alibaba/uform/issues"
},
"homepage": "https://github.com/alibaba/uform#readme",
"engines": {
"npm": ">=3.0.0"
},
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc --declaration"
},
"devDependencies": {
"typescript": "^3.5.2"
},
"peerDependencies": {
"@babel/runtime": "^7.4.4",
"@types/json-schema": "^7.0.3",
"@types/react": "^16.8.23",
"react": ">=16.8.0",
"react-dom": ">=16.8.0",
"react-eva": "^1.1.7"
},
"dependencies": {
},
"publishConfig": {
"access": "public"
},
"gitHead": "4d068dad6183e8da294a4c899a158326c0b0b050"
}
10 changes: 4 additions & 6 deletions packages/react-schema-editor/src/components/SchemaCode.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useState } from 'react'
import { Button, Drawer, Icon, Tooltip, notification } from 'antd';
import {Drawer, Icon, Tooltip, notification } from 'antd';
import MonacoEditor from 'react-monaco-editor'
import moment from 'moment';
import { ISchemaCodeProps } from '../utils/types'

const options = {
selectOnLineNumbers: true
};
// const options = {
// selectOnLineNumbers: true
// };

const styles = {
icon: {
Expand Down Expand Up @@ -76,12 +76,10 @@ export const SchemaCode: React.FC<ISchemaCodeProps> = ({
placement="right"
visible={showDrawer}
closable={false}
hasMask={false}
bodyStyle={{ padding: 0, height: '100%' }}
onClose={() => setShowDrawer(false)} >
<div style={{ display: 'flex', flexDirection: 'row', height: '100%' }}>
<MonacoEditor
style={{ flexGrow: '1' }}
language="json"
theme="vs-dark"
onChange={(schema) => onChange(JSON.parse(schema))}
Expand Down
25 changes: 4 additions & 21 deletions packages/react-schema-editor/src/components/SchemaTree.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from 'react'
import React from 'react'
import { Tree, Row, Col, Icon } from 'antd'
import { ISchemaTreeProps } from '../utils/types'
import * as fp from 'lodash/fp'
Expand Down Expand Up @@ -32,30 +32,12 @@ const xRules = {
whitespace: {}
}

const components = [
{
name: 'Input',
'x-component-props': {
value: {},
disabled: {},
onChange: {}
}
},
{
name: 'Switch',
'x-component-props': {
checked: {},
disabled: {},
onChange: {}
}
}
]

const TreeNode = Tree.TreeNode

export const SchemaTree: React.FC<ISchemaTreeProps> = ({
schema,
onChange
onChange,
components
}) => {
const [selectedPath, setSelectedPath] = React.useState(null)

Expand Down Expand Up @@ -150,6 +132,7 @@ export const SchemaTree: React.FC<ISchemaTreeProps> = ({
<Tree
defaultExpandAll
showIcon
showLine
draggable
onSelect={handleSelect}
onDrop={handleDrop}
Expand Down
26 changes: 21 additions & 5 deletions packages/react-schema-editor/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
import React from 'react'
import { Button, Icon, Row, Col } from 'antd'
import React, { useState } from 'react'
import { Button, Row, Col, Radio } from 'antd'
import { SchemaTree } from './components/SchemaTree'
import { SchemaCode } from './components/SchemaCode'
import nextComponents from './utils/nextCompProps'
import antdComponents from './utils/antdCompProps'

import 'antd/dist/antd.css'

export const SchemaEditor: React.FC<{
schema: any
onChange: (schema: any) => void
}> = ({ schema, onChange }) => {
const [componentType, setComponentType] = useState('antd');

function handleTypeChange(e) {
setComponentType(e.target.value);
}

return (
<div className="schema-editor">
<div className="schema-menus">
<Button type="primary">快速生成</Button>
<Button className="schema-preview-btn">
{/* <Button className="schema-preview-btn">
<Icon type="success"></Icon>预览
</Button>
</Button> */}
<span className="select-component-type">
选择组件类型:
<Radio.Group onChange={handleTypeChange}>
<Radio value="antd">Ant Design组件</Radio>
<Radio value="fusion">Fusion Design组件</Radio>
</Radio.Group>
</span>

</div>
<Row className="schema-editor-main" style={{ minHeight: '350px' }}>
<Col span={24} className="schema-col schema-tree splitter">
<SchemaTree schema={schema} onChange={onChange} />
<SchemaTree schema={schema} onChange={onChange} components={componentType === 'fusion' ? nextComponents : antdComponents}/>
</Col>
<Col
className="schema-col schema-code"
Expand Down
4 changes: 4 additions & 0 deletions packages/react-schema-editor/src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
.schema-preview-btn {
float: right;
}

.select-component-type {
margin-left: 200px;
}
}

.splitter {
Expand Down
Loading

0 comments on commit 2da0eda

Please sign in to comment.