refactor: rename internalToShell to internalToShellField

This commit is contained in:
liujuping 2023-03-16 11:11:51 +08:00 committed by 林熠
parent 64e7093053
commit ffaf58b5b5
4 changed files with 17 additions and 17 deletions

View File

@ -73,7 +73,7 @@ INode
onEffect(action: () => void): IPublicTypeDisposable;
internalToShell(): IPublicModelSettingField;
internalToShellField(): IPublicModelSettingField;
}
export class SettingField extends SettingPropEntry implements ISettingField {
@ -143,7 +143,7 @@ export class SettingField extends SettingPropEntry implements ISettingField {
}
if (isDynamicSetter(this._setter)) {
return untracked(() => {
const shellThis = this.internalToShell();
const shellThis = this.internalToShellField();
return (this._setter as IPublicTypeDynamicSetter)?.call(shellThis, shellThis!);
});
}
@ -296,7 +296,7 @@ export class SettingField extends SettingPropEntry implements ISettingField {
}
internalToShell() {
internalToShellField() {
return this.designer!.shellModelFactory.createSettingField(this);
}
}

View File

@ -35,7 +35,7 @@ export interface ISettingPropEntry extends ISettingEntry {
setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: IPublicTypeSetValueOptions): void;
internalToShell(): IPublicModelSettingField;
internalToShellField(): IPublicModelSettingField;
}
export class SettingPropEntry implements ISettingPropEntry {
@ -157,7 +157,7 @@ export class SettingPropEntry implements ISettingPropEntry {
if (this.type !== 'field') {
const { getValue } = this.extraProps;
return getValue
? getValue(this.internalToShell()!, undefined) === undefined
? getValue(this.internalToShellField()!, undefined) === undefined
? 0
: 1
: 0;
@ -196,7 +196,7 @@ export class SettingPropEntry implements ISettingPropEntry {
}
const { getValue } = this.extraProps;
try {
return getValue ? getValue(this.internalToShell()!, val) : val;
return getValue ? getValue(this.internalToShellField()!, val) : val;
} catch (e) {
console.warn(e);
return val;
@ -215,7 +215,7 @@ export class SettingPropEntry implements ISettingPropEntry {
const { setValue } = this.extraProps;
if (setValue && !extraOptions?.disableMutator) {
try {
setValue(this.internalToShell()!, val);
setValue(this.internalToShellField()!, val);
} catch (e) {
/* istanbul ignore next */
console.warn(e);
@ -238,7 +238,7 @@ export class SettingPropEntry implements ISettingPropEntry {
const { setValue } = this.extraProps;
if (setValue) {
try {
setValue(this.internalToShell()!, undefined);
setValue(this.internalToShellField()!, undefined);
} catch (e) {
/* istanbul ignore next */
console.warn(e);
@ -394,7 +394,7 @@ export class SettingPropEntry implements ISettingPropEntry {
return v;
}
internalToShell(): IPublicModelSettingField {
internalToShellField(): IPublicModelSettingField {
return this.designer!.shellModelFactory.createSettingField(this);;
}
}

View File

@ -80,7 +80,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
const { extraProps } = this.field;
const { condition } = extraProps;
try {
return typeof condition === 'function' ? condition(this.field.internalToShell()) !== false : true;
return typeof condition === 'function' ? condition(this.field.internalToShellField()) !== false : true;
} catch (error) {
console.error('exception when condition (hidden) is excuted', error);
}
@ -123,7 +123,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
if (setter.props) {
setterProps = setter.props;
if (typeof setterProps === 'function') {
setterProps = setterProps(this.field.internalToShell());
setterProps = setterProps(this.field.internalToShellField());
}
}
if (setter.initialValue != null) {
@ -190,7 +190,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
}
// 当前 field 没有 value 值时,将 initialValue 写入 field
// 之所以用 initialValue而不是 defaultValue 是为了保持跟 props.onInitial 的逻辑一致
const _initialValue = typeof initialValue === 'function' ? initialValue(this.field.internalToShell()) : initialValue;
const _initialValue = typeof initialValue === 'function' ? initialValue(this.field.internalToShellField()) : initialValue;
this.field.setValue(_initialValue);
}
@ -238,9 +238,9 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
forceInline: extraProps.forceInline,
key: field.id,
// === injection
prop: field.internalToShell(), // for compatible vision
prop: field.internalToShellField(), // for compatible vision
selected: field.top?.getNode()?.internalToShellNode(),
field: field.internalToShell(),
field: field.internalToShellField(),
// === IO
value, // reaction point
initialValue,
@ -257,7 +257,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
if (initialValue == null) {
return;
}
const value = typeof initialValue === 'function' ? initialValue(field.internalToShell()) : initialValue;
const value = typeof initialValue === 'function' ? initialValue(field.internalToShellField()) : initialValue;
this.setState({
// eslint-disable-next-line react/no-unused-state
value,
@ -316,7 +316,7 @@ class SettingGroupView extends Component<SettingGroupViewProps> {
const { field } = this.props;
const { extraProps } = field;
const { condition, display } = extraProps;
const visible = field.isSingle && typeof condition === 'function' ? condition(field.internalToShell()) !== false : true;
const visible = field.isSingle && typeof condition === 'function' ? condition(field.internalToShellField()) !== false : true;
if (!visible) {
return null;

View File

@ -143,7 +143,7 @@ export class SettingField implements IPublicModelSettingField {
if (isCustomView(item)) {
return item;
}
return item.internalToShell();
return item.internalToShellField();
});
}