Skip to content

Commit

Permalink
fix: fix controlled props can not update
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Sep 29, 2021
1 parent 729410a commit dcffdeb
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 130 deletions.
18 changes: 10 additions & 8 deletions formily/antd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
},
"devDependencies": {
"@designable/react-settings-form": "1.0.0-beta.10",
"@formily/antd": "^2.0.0-rc.10",
"@formily/core": "^2.0.0-rc.10",
"@formily/react": "^2.0.0-rc.10",
"@formily/shared": "^2.0.0-rc.10",
"@formily/antd": "^2.0.0-rc.12",
"@formily/core": "^2.0.0-rc.12",
"@formily/react": "^2.0.0-rc.12",
"@formily/shared": "^2.0.0-rc.12",
"@formily/reactive": "^2.0.0-rc.12",
"autoprefixer": "^9.0",
"file-loader": "^5.0.2",
"fs-extra": "^8.1.0",
Expand All @@ -46,10 +47,11 @@
"webpack-dev-server": "^3.10.1"
},
"peerDependencies": {
"@formily/antd": "^2.0.0-rc.10",
"@formily/core": "^2.0.0-rc.10",
"@formily/react": "^2.0.0-rc.10",
"@formily/shared": "^2.0.0-rc.10",
"@formily/antd": "^2.0.0-rc.12",
"@formily/core": "^2.0.0-rc.12",
"@formily/react": "^2.0.0-rc.12",
"@formily/shared": "^2.0.0-rc.12",
"@formily/reactive": "^2.0.0-rc.12",
"@types/react": ">=16.8.0 || >=17.0.0",
"@types/react-dom": ">=16.8.0 || >=17.0.0",
"antd": "^4.0.0",
Expand Down
5 changes: 3 additions & 2 deletions formily/antd/src/components/Field/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { FormPath } from '@formily/core'
import { toJS } from '@formily/reactive'
import {
ArrayField,
Field as InternalField,
Expand Down Expand Up @@ -112,10 +113,10 @@ const toDesignableFieldProps = (
const componentProps = schema['x-component-props'] || {}

if (decorator) {
results.decorator = [decorator, { ...decoratorProps }]
results.decorator = [decorator, toJS(decoratorProps)]
}
if (component) {
results.component = [component, { ...componentProps }]
results.component = [component, toJS(componentProps)]
}
if (decorator) {
FormPath.setIn(results['decorator'][1], nodeIdAttrName, id)
Expand Down
18 changes: 10 additions & 8 deletions formily/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
},
"devDependencies": {
"@designable/react-settings-form": "1.0.0-beta.10",
"@formily/core": "^2.0.0-rc.10",
"@formily/next": "^2.0.0-rc.10",
"@formily/react": "^2.0.0-rc.10",
"@formily/shared": "^2.0.0-rc.10",
"@formily/core": "^2.0.0-rc.12",
"@formily/next": "^2.0.0-rc.12",
"@formily/react": "^2.0.0-rc.12",
"@formily/shared": "^2.0.0-rc.12",
"@formily/reactive": "^2.0.0-rc.12",
"autoprefixer": "^9.0",
"file-loader": "^5.0.2",
"fs-extra": "^8.1.0",
Expand All @@ -47,10 +48,11 @@
},
"peerDependencies": {
"@alifd/next": "^1.23.0",
"@formily/core": "^2.0.0-rc.10",
"@formily/next": "^2.0.0-rc.10",
"@formily/react": "^2.0.0-rc.10",
"@formily/shared": "^2.0.0-rc.10",
"@formily/core": "^2.0.0-rc.12",
"@formily/next": "^2.0.0-rc.12",
"@formily/reactive": "^2.0.0-rc.12",
"@formily/react": "^2.0.0-rc.12",
"@formily/shared": "^2.0.0-rc.12",
"@types/react": ">=16.8.0 || >=17.0.0",
"@types/react-dom": ">=16.8.0 || >=17.0.0",
"antd": "^4.0.0",
Expand Down
5 changes: 3 additions & 2 deletions formily/next/src/components/Field/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { FormPath } from '@formily/core'
import { toJS } from '@formily/reactive'
import {
ArrayField,
Field as InternalField,
Expand Down Expand Up @@ -112,10 +113,10 @@ const toDesignableFieldProps = (
const componentProps = schema['x-component-props'] || {}

if (decorator) {
results.decorator = [decorator, { ...decoratorProps }]
results.decorator = [decorator, toJS(decoratorProps)]
}
if (component) {
results.component = [component, { ...componentProps }]
results.component = [component, toJS(componentProps)]
}
if (decorator) {
FormPath.setIn(results['decorator'][1], nodeIdAttrName, id)
Expand Down
16 changes: 8 additions & 8 deletions formily/setters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
"start": "webpack-dev-server --config playground/webpack.dev.ts"
},
"devDependencies": {
"@formily/antd": "^2.0.0-rc.10",
"@formily/core": "^2.0.0-rc.10",
"@formily/react": "^2.0.0-rc.10",
"@formily/shared": "^2.0.0-rc.10",
"@formily/antd": "^2.0.0-rc.12",
"@formily/core": "^2.0.0-rc.12",
"@formily/react": "^2.0.0-rc.12",
"@formily/shared": "^2.0.0-rc.12",
"antd": "^4.0.0"
},
"peerDependencies": {
"@formily/antd": "^2.0.0-rc.10",
"@formily/core": "^2.0.0-rc.10",
"@formily/react": "^2.0.0-rc.10",
"@formily/shared": "^2.0.0-rc.10",
"@formily/antd": "^2.0.0-rc.12",
"@formily/core": "^2.0.0-rc.12",
"@formily/react": "^2.0.0-rc.12",
"@formily/shared": "^2.0.0-rc.12",
"@types/react": ">=16.8.0 || >=17.0.0",
"@types/react-dom": ">=16.8.0 || >=17.0.0",
"antd": "^4.0.0",
Expand Down
8 changes: 4 additions & 4 deletions formily/transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
"access": "public"
},
"devDependencies": {
"@formily/core": "^2.0.0-rc.10",
"@formily/json-schema": "^2.0.0-rc.10"
"@formily/core": "^2.0.0-rc.12",
"@formily/json-schema": "^2.0.0-rc.12"
},
"peerDependencies": {
"@formily/core": "^2.0.0-rc.10",
"@formily/json-schema": "^2.0.0-rc.10"
"@formily/core": "^2.0.0-rc.12",
"@formily/json-schema": "^2.0.0-rc.12"
},
"dependencies": {
"@designable/core": "1.0.0-beta.10",
Expand Down
12 changes: 6 additions & 6 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"build:umd": "rollup --config"
},
"devDependencies": {
"@formily/json-schema": "^2.0.0-rc.10",
"@formily/path": "^2.0.0-rc.10",
"@formily/reactive": "^2.0.0-rc.10"
"@formily/json-schema": "^2.0.0-rc.12",
"@formily/path": "^2.0.0-rc.12",
"@formily/reactive": "^2.0.0-rc.12"
},
"peerDependencies": {
"@formily/json-schema": "^2.0.0-rc.10",
"@formily/path": "^2.0.0-rc.10",
"@formily/reactive": "^2.0.0-rc.10"
"@formily/json-schema": "^2.0.0-rc.12",
"@formily/path": "^2.0.0-rc.12",
"@formily/reactive": "^2.0.0-rc.12"
},
"dependencies": {
"@designable/shared": "1.0.0-beta.10",
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/models/TreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,7 @@ export class TreeNode {
if (node.componentName) {
this.componentName = node.componentName
}
this.props = {
...this.designerProps?.defaultProps,
...node.props,
}
this.props = node.props ?? {}
if (node.hidden) {
this.hidden = node.hidden
}
Expand Down
4 changes: 2 additions & 2 deletions packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"@designable/react-sandbox": "1.0.0-beta.10",
"@designable/react-settings-form": "1.0.0-beta.10",
"@designable/shared": "1.0.0-beta.10",
"@formily/reactive": "^2.0.0-rc.10",
"@formily/reactive-react": "^2.0.0-rc.10",
"@formily/reactive": "^2.0.0-rc.12",
"@formily/reactive-react": "^2.0.0-rc.12",
"antd": "^4.15.2",
"react": "^16.8.x",
"react-dom": "^16.8.x",
Expand Down
24 changes: 12 additions & 12 deletions packages/react-settings-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
"build:umd": "rollup --config"
},
"peerDependencies": {
"@formily/antd": "^2.0.0-rc.10",
"@formily/core": "^2.0.0-rc.10",
"@formily/react": "^2.0.0-rc.10",
"@formily/reactive": "^2.0.0-rc.10",
"@formily/reactive-react": "^2.0.0-rc.10",
"@formily/shared": "^2.0.0-rc.10",
"@formily/antd": "^2.0.0-rc.12",
"@formily/core": "^2.0.0-rc.12",
"@formily/react": "^2.0.0-rc.12",
"@formily/reactive": "^2.0.0-rc.12",
"@formily/reactive-react": "^2.0.0-rc.12",
"@formily/shared": "^2.0.0-rc.12",
"antd": "^4.0.0"
},
"devDependencies": {
"@formily/antd": "^2.0.0-rc.10",
"@formily/core": "^2.0.0-rc.10",
"@formily/react": "^2.0.0-rc.10",
"@formily/reactive": "^2.0.0-rc.10",
"@formily/reactive-react": "^2.0.0-rc.10",
"@formily/shared": "^2.0.0-rc.10",
"@formily/antd": "^2.0.0-rc.12",
"@formily/core": "^2.0.0-rc.12",
"@formily/react": "^2.0.0-rc.12",
"@formily/reactive": "^2.0.0-rc.12",
"@formily/reactive-react": "^2.0.0-rc.12",
"@formily/shared": "^2.0.0-rc.12",
"antd": "^4.15.5"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-settings-form/src/SettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const SettingsForm: React.FC<ISettingFormProps> = observer(
)
const form = useMemo(() => {
return createForm({
values: node?.props,
initialValues: node?.designerProps?.defaultProps,
values: node.props,
effects(form) {
useLocales(node)
useSnapshot(operation)
Expand Down
8 changes: 4 additions & 4 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"build:umd": "rollup --config"
},
"devDependencies": {
"@formily/reactive": "^2.0.0-rc.10",
"@formily/reactive-react": "^2.0.0-rc.10"
"@formily/reactive": "^2.0.0-rc.12",
"@formily/reactive-react": "^2.0.0-rc.12"
},
"peerDependencies": {
"@formily/reactive": "^2.0.0-rc.10",
"@formily/reactive-react": "^2.0.0-rc.10",
"@formily/reactive": "^2.0.0-rc.12",
"@formily/reactive-react": "^2.0.0-rc.12",
"antd": "^4.15.4",
"react": "16.x || 17.x"
},
Expand Down
Loading

0 comments on commit dcffdeb

Please sign in to comment.