Skip to content

Commit b77cedb

Browse files
committed
refactor: split next version
1 parent f32b8b8 commit b77cedb

File tree

12 files changed

+87
-51
lines changed

12 files changed

+87
-51
lines changed

packages/builder/config/webpack.config.dev.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const env = getClientEnvironment(publicUrl)
2323
// It is focused on developer experience and fast rebuilds.
2424
// The production configuration is different and lives in a separate file.
2525
module.exports = {
26+
mode: 'development',
2627
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
2728
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.
2829
devtool: 'cheap-module-source-map',
@@ -196,16 +197,16 @@ module.exports = {
196197
]
197198
},
198199
plugins: [
199-
// Makes some environment variables available in index.html.
200-
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
201-
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
202-
// In development, this will be an empty string.
203-
new InterpolateHtmlPlugin(env.raw),
204200
// Generates an `index.html` file with the <script> injected.
205201
new HtmlWebpackPlugin({
206202
inject: true,
207203
template: paths.appHtml
208204
}),
205+
// Makes some environment variables available in index.html.
206+
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
207+
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
208+
// In development, this will be an empty string.
209+
new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
209210
// Add module names to factory functions so they appear in browser profiler.
210211
new webpack.NamedModulesPlugin(),
211212
// Makes some environment variables available to the JS code, for example:

packages/builder/package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"npm": ">=3.0.0"
1919
},
2020
"dependencies": {
21-
"@alifd/next": "^1.13.1",
2221
"@uform/react": "^0.1.0-alpha.14",
2322
"@uform/utils": "^0.1.0-alpha.3",
2423
"@uform/validator": "^0.1.0-alpha.3",
@@ -48,29 +47,35 @@
4847
"gitHead": "f513fc2dcca781b3f7aa588c4419bce20cba2d8b",
4948
"devDependencies": {
5049
"@alifd/next": "^1.13.1",
50+
"@alife/next": "^0.19.72",
51+
"@babel/core": "^7.3.4",
5152
"@babel/plugin-proposal-class-properties": "^7.3.4",
5253
"@babel/plugin-proposal-decorators": "^7.3.0",
5354
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
5455
"@babel/plugin-transform-runtime": "^7.3.4",
5556
"@babel/preset-env": "^7.3.4",
57+
"@babel/preset-react": "^7.0.0",
5658
"@uform/next": "^0.1.0-alpha.14",
5759
"autoprefixer": "7.1.6",
60+
"babel-loader": "^8.0.5",
5861
"case-sensitive-paths-webpack-plugin": "2.1.1",
5962
"css-loader": "0.28.7",
6063
"eslint-loader": "1.9.0",
6164
"file-loader": "1.1.5",
62-
"html-webpack-plugin": "2.29.0",
65+
"html-webpack-plugin": "^4.0.0-beta.5",
6366
"less": "^3.0.4",
6467
"less-loader": "^4.1.0",
6568
"postcss-flexbugs-fixes": "3.2.0",
6669
"postcss-loader": "2.0.8",
6770
"raf": "3.4.0",
68-
"react-dev-utils": "^5.0.1",
71+
"react": "^16.8.3",
72+
"react-dev-utils": "^7.0.3",
73+
"react-dom": "^16.8.3",
6974
"react-test-renderer": "^16.8.3",
7075
"redux-mock-store": "^1.5.3",
7176
"style-loader": "0.19.0",
7277
"url-loader": "0.6.2",
73-
"webpack": "3.8.1",
78+
"webpack": "^4.29.6",
7479
"webpack-dev-server": ">=3.1.11"
7580
}
7681
}

packages/builder/src/components/globalBtnList/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default (props) => {
2727
title: preview ? '返回编辑' : '预览',
2828
props: {
2929
onClick: () => {
30-
this.props.changePreview(!this.props.preview)
30+
props.changePreview(!props.preview)
3131
}
3232
},
3333
iconType: 'eye',
@@ -44,8 +44,8 @@ export default (props) => {
4444
onSubmit &&
4545
typeof onSubmit === 'function' &&
4646
onSubmit({
47-
schema: wrapSubmitSchema(this.props.initSchemaData),
48-
globalCfg: this.props.gbConfig
47+
schema: wrapSubmitSchema(props.initSchemaData),
48+
globalCfg: props.gbConfig
4949
})
5050
}
5151
},
@@ -60,7 +60,7 @@ export default (props) => {
6060
title: codemode ? '关闭源码' : '源码',
6161
props: {
6262
onClick: () => {
63-
_changeCodeMode(!this.props.codemode)
63+
_changeCodeMode(!props.codemode)
6464
}
6565
},
6666
iconUrl: globalBtnIconUrlWithTheme.code,

packages/builder/src/components/preview/fieldMiddleware.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import cls from 'classnames'
33
import { registerFieldMiddleware } from '../../utils/baseForm'
44

5-
export default (FormConsumer) => {
5+
export default (FormConsumer, that) => {
66
const hasRegisted = window.__hasRegisted__ || false
77
if (hasRegisted) {
88
return false
@@ -24,9 +24,9 @@ export default (FormConsumer) => {
2424
comp['x-props']._extra.__key__ === 'layout'
2525
const layoutDragProps = isLayoutWrapper
2626
? {
27-
onDragOver: ev => this.onDragOver(ev, 'layout'),
28-
onDragLeave: ev => this.onDragLeave(ev, 'layout'),
29-
onDrop: ev => this.onDrop(ev, null, 'layout', id)
27+
onDragOver: ev => that.onDragOver(ev, 'layout'),
28+
onDragLeave: ev => that.onDragLeave(ev, 'layout'),
29+
onDrop: ev => that.onDrop(ev, null, 'layout', id)
3030
}
3131
: {}
3232

@@ -43,7 +43,7 @@ export default (FormConsumer) => {
4343
<a
4444
onClick={ev => {
4545
ev.preventDefault()
46-
this.onMouseClick(id, comp, 'layout')
46+
that.onMouseClick(id, comp, 'layout')
4747
}}
4848
href='javascript:;'
4949
className='preview-line-layer-layout'
@@ -65,8 +65,8 @@ export default (FormConsumer) => {
6565
size='small'
6666
href='javascript:;'
6767
onClick={() => {
68-
this.props.changeComponent()
69-
this.deleteComponent(id)
68+
that.props.changeComponent()
69+
that.deleteComponent(id)
7070
}}
7171
title='删除'
7272
>
@@ -86,10 +86,10 @@ export default (FormConsumer) => {
8686
<div key={id} className={'comp-item'}>
8787
<div
8888
className='preview-line-bar'
89-
onDragOver={this.onDragOver}
90-
onDragLeave={this.onDragLeave}
89+
onDragOver={that.onDragOver}
90+
onDragLeave={that.onDragLeave}
9191
onDrop={ev =>
92-
this.onDrop(
92+
that.onDrop(
9393
ev,
9494
id,
9595
props.schemaPath.length > 1 ? 'layout' : '',
@@ -105,23 +105,23 @@ export default (FormConsumer) => {
105105
)}
106106
name={title}
107107
draggable
108-
onDragStart={ev => this.onDragStart(ev, id, 'move')}
108+
onDragStart={ev => that.onDragStart(ev, id, 'move')}
109109
>
110110
{React.createElement(Field, { ...props })}
111111
<div
112112
className='preview-line-layer'
113113
onClick={ev => {
114114
ev.preventDefault()
115-
this.onMouseClick(id, comp)
115+
that.onMouseClick(id, comp)
116116
}}
117117
/>
118118
<a
119119
className='preview-line-del'
120120
type='delete'
121121
size='small'
122122
onClick={() => {
123-
this.props.changeComponent()
124-
this.deleteComponent(id)
123+
that.props.changeComponent()
124+
that.deleteComponent(id)
125125
}}
126126
>
127127
删除

packages/builder/src/components/preview/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Preview extends Component {
3030
}
3131

3232
componentDidMount() {
33-
registerPreviewFieldMiddleware(FormConsumer)
33+
registerPreviewFieldMiddleware(FormConsumer, this)
3434
}
3535

3636
onMouseClick = (id, comp, type) => {

packages/builder/src/components/props/accordList.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,15 @@ export default class extends React.Component {
8282
}
8383

8484
render() {
85-
const { Accordtion } = this.props.UI
85+
const { Accordion, version: UIVersion } = this.props.UI
8686

87-
return (
88-
<Accordtion
87+
return UIVersion == '1.x' ? (
88+
<Accordion
89+
dataSource={this.state.accordionList}
90+
defaultExpandedKeys={['1']}
91+
/>
92+
) : (
93+
<Accordion
8994
dataSource={this.state.accordionList}
9095
onChange={(status, list) => {
9196
this.setState({

packages/builder/src/components/props/dataSourceEditor/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Component extends React.Component {
1616
}
1717

1818
render() {
19-
const { fieldStore = {}, value } = this.props
19+
const { fieldStore = {}, value, UI } = this.props
2020

2121
return (
2222
<div
@@ -25,6 +25,7 @@ class Component extends React.Component {
2525
}}
2626
>
2727
<DataSourceEditor
28+
UI={UI}
2829
fieldStore={fieldStore}
2930
value={value}
3031
onChange={this.handleFieldAttrChange()}

packages/builder/src/components/props/editors/fieldAttrEditors/dataSourceEditor.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,7 @@ class DataSourceEditor extends Component {
149149
const xProps = fieldStore['x-props'] || {}
150150
const { requestOptions = {} } = xProps
151151
const { data } = requestOptions
152-
const { Form, Input, Radio, Tab } = UI
153-
154-
const { Group: RadioGroup } = Radio
155-
const { TabPane } = Tab
156-
157-
this.RadioGroup = RadioGroup
158-
this.TabPane = TabPane
152+
const { Form, Input, Radio, Tab, RadioGroup, TabPane, version: UIVersion } = UI
159153

160154
const dataSource = [
161155
{
@@ -174,6 +168,12 @@ class DataSourceEditor extends Component {
174168
})
175169
}
176170

171+
const tabProps = {}
172+
tabProps[UIVersion == '1.x' ? 'shape' : 'type'] = 'text'
173+
174+
const formItemProps = {}
175+
formItemProps[UIVersion == '1.x' ? 'validateState' : 'validateStatus'] = error ? 'error' : 'success'
176+
177177
return (
178178
<Form.Item labelCol={LABEL_COL} className={this.props.className}>
179179
<RadioGroup
@@ -183,14 +183,15 @@ class DataSourceEditor extends Component {
183183
/>
184184
{dataSourceType === 'local' ? (
185185
<Form.Item
186-
validateStatus={error ? 'error' : 'success'}
186+
{...formItemProps}
187187
extra={<span style={{ color: 'red' }}>{error}</span>}
188188
>
189-
<Tab type='text' size='small'>
189+
<Tab {...tabProps} size='small'>
190190
<TabPane tab='可视化' key='visual'>
191191
<DataSourceEnum
192192
dataSource={defaultSource}
193193
onChange={this.handleEnumValueChange}
194+
UI={UI}
194195
/>
195196
</TabPane>
196197
<TabPane tab='源码' key='code'>
@@ -211,7 +212,7 @@ class DataSourceEditor extends Component {
211212
) : null}
212213
{dataSourceType === 'remote' ? (
213214
<Form.Item
214-
validateStatus={error ? 'error' : 'success'}
215+
{...formItemProps}
215216
extra={<span style={{ color: 'red' }}>{error}</span>}
216217
>
217218
<Input

packages/builder/src/components/props/editors/fieldAttrEditors/dataSourceEnum.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ class Component extends React.Component {
3232
renderItemRow = (item = {}, idx) => {
3333
const { value = '', label = '' } = item
3434
const { UI } = this.props
35+
const btnProps = {}
36+
if (UI.version == '1.x') {
37+
btnProps.text = true
38+
} else {
39+
btnProps.shape = 'text'
40+
}
3541
return (
3642
<div className='source-row' key={`${idx}`}>
3743
<ul>
@@ -52,7 +58,7 @@ class Component extends React.Component {
5258
</ul>
5359
<UI.Button
5460
className='ashbin-btn'
55-
shape='text'
61+
{...btnProps}
5662
onClick={() => this.handleDeleteItem(idx)}
5763
>
5864
<UI.Icon type='ashbin' />

packages/builder/src/components/props/propsSetting.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class PropsSetting extends Component {
140140
UI
141141
}
142142
}
143+
143144
finalSchema[configItem.name] = {
144145
...configItem,
145146
'x-props': newXprops

0 commit comments

Comments
 (0)