@uform/core
Advanced tools
Comparing version 1.0.0-rc.0 to 1.0.0-rc.1
@@ -175,2 +175,23 @@ "use strict"; | ||
} | ||
function updateRecoverableShownState(parentState, childState, name) { | ||
var lastShownState = env.lastShownStates[childState.path]; | ||
var lastStateValue = childState[name]; | ||
if (parentState[name] && lastShownState && lastShownState[name] === false) { | ||
childState[name] = false; | ||
delete lastShownState[name]; | ||
if (!lastShownState.hasOwnProperty('visible') && | ||
!lastShownState.hasOwnProperty('display')) { | ||
delete env.lastShownStates[childState.path]; | ||
} | ||
} | ||
else { | ||
childState[name] = parentState[name]; | ||
} | ||
if (!parentState[name] && !lastStateValue) { | ||
if (!lastShownState) { | ||
env.lastShownStates[childState.path] = {}; | ||
} | ||
env.lastShownStates[childState.path][name] = false; | ||
} | ||
} | ||
function onFieldChange(_a) { | ||
@@ -224,6 +245,6 @@ var field = _a.field, path = _a.path; | ||
if (visibleChanged) { | ||
state.visible = published.visible; | ||
updateRecoverableShownState(published, state, 'visible'); | ||
} | ||
if (displayChanged) { | ||
state.display = published.display; | ||
updateRecoverableShownState(published, state, 'display'); | ||
} | ||
@@ -271,4 +292,4 @@ }, true); | ||
var mountedChanged = field.isDirty('mounted'); | ||
var initializedChnaged = field.isDirty('initialized'); | ||
if (initializedChnaged) { | ||
var initializedChanged = field.isDirty('initialized'); | ||
if (initializedChanged) { | ||
heart.publish(types_1.LifeCycleTypes.ON_FIELD_INIT, field); | ||
@@ -280,6 +301,6 @@ } | ||
if (visibleChanged) { | ||
state.visible = published.visible; | ||
updateRecoverableShownState(published, state, 'visible'); | ||
} | ||
if (displayChanged) { | ||
state.display = published.display; | ||
updateRecoverableShownState(published, state, 'display'); | ||
} | ||
@@ -334,3 +355,2 @@ }, true); | ||
field = graph.get(nodePath); | ||
field = createField(field); | ||
if (types_1.isField(field)) { | ||
@@ -443,3 +463,2 @@ graph.replace(nodePath, field); | ||
field = graph.get(nodePath); | ||
field = createField(field); | ||
if (types_1.isVirtualField(field)) { | ||
@@ -1076,2 +1095,3 @@ graph.replace(nodePath, field); | ||
removeNodes: {}, | ||
lastShownStates: {}, | ||
submittingTask: undefined | ||
@@ -1078,0 +1098,0 @@ }; |
{ | ||
"name": "@uform/core", | ||
"version": "1.0.0-rc.0", | ||
"version": "1.0.0-rc.1", | ||
"license": "MIT", | ||
@@ -29,4 +29,4 @@ "main": "lib", | ||
"dependencies": { | ||
"@uform/shared": "^1.0.0-rc.0", | ||
"@uform/validator": "^1.0.0-rc.0", | ||
"@uform/shared": "^1.0.0-rc.1", | ||
"@uform/validator": "^1.0.0-rc.1", | ||
"immer": "^3.2.0" | ||
@@ -37,3 +37,3 @@ }, | ||
}, | ||
"gitHead": "d66cee79ee61c227f5beaac446b83c37b143ee42" | ||
"gitHead": "ccc85e3792758ca89f267fd3e521cda2b61a8202" | ||
} |
@@ -171,2 +171,31 @@ import { | ||
function updateRecoverableShownState( | ||
parentState: | ||
| IVirtualFieldState<VirtualFieldProps> | ||
| IFieldState<FieldProps>, | ||
childState: IVirtualFieldState<VirtualFieldProps> | IFieldState<FieldProps>, | ||
name: 'visible' | 'display' | ||
) { | ||
const lastShownState = env.lastShownStates[childState.path] | ||
const lastStateValue = childState[name] | ||
if (parentState[name] && lastShownState && lastShownState[name] === false) { | ||
childState[name] = false | ||
delete lastShownState[name] | ||
if ( | ||
!lastShownState.hasOwnProperty('visible') && | ||
!lastShownState.hasOwnProperty('display') | ||
) { | ||
delete env.lastShownStates[childState.path] | ||
} | ||
} else { | ||
childState[name] = parentState[name] | ||
} | ||
if (!parentState[name] && !lastStateValue) { | ||
if (!lastShownState) { | ||
env.lastShownStates[childState.path] = {} | ||
} | ||
env.lastShownStates[childState.path][name] = false | ||
} | ||
} | ||
function onFieldChange({ field, path }) { | ||
@@ -218,6 +247,6 @@ return (published: IFieldState<FieldProps>) => { | ||
if (visibleChanged) { | ||
state.visible = published.visible | ||
updateRecoverableShownState(published, state, 'visible') | ||
} | ||
if (displayChanged) { | ||
state.display = published.display | ||
updateRecoverableShownState(published, state, 'display') | ||
} | ||
@@ -268,5 +297,5 @@ }, true) | ||
const mountedChanged = field.isDirty('mounted') | ||
const initializedChnaged = field.isDirty('initialized') | ||
const initializedChanged = field.isDirty('initialized') | ||
if (initializedChnaged) { | ||
if (initializedChanged) { | ||
heart.publish(LifeCycleTypes.ON_FIELD_INIT, field) | ||
@@ -280,6 +309,6 @@ } | ||
if (visibleChanged) { | ||
state.visible = published.visible | ||
updateRecoverableShownState(published, state, 'visible') | ||
} | ||
if (displayChanged) { | ||
state.display = published.display | ||
updateRecoverableShownState(published, state, 'display') | ||
} | ||
@@ -345,3 +374,3 @@ }, | ||
field = graph.get(nodePath) | ||
field = createField(field) | ||
//field = createField(field) 如果重置会导致#565的问题,目前还没想清楚不重置会有啥问题 | ||
if (isField(field)) { | ||
@@ -475,3 +504,3 @@ graph.replace(nodePath, field) | ||
field = graph.get(nodePath) | ||
field = createField(field) | ||
//field = createField(field) 如果重置会导致#565的问题,目前还没想清楚不重置会有啥问题 | ||
if (isVirtualField(field)) { | ||
@@ -1174,2 +1203,3 @@ graph.replace(nodePath, field) | ||
removeNodes: {}, | ||
lastShownStates: {}, | ||
submittingTask: undefined | ||
@@ -1176,0 +1206,0 @@ } |
230310
4870
Updated@uform/shared@^1.0.0-rc.1
Updated@uform/validator@^1.0.0-rc.1