feat: 增加 getConfig / getItems / selected 等兼容 vision 的 API

This commit is contained in:
力皓 2021-03-31 14:34:40 +08:00
parent b0f41a7acf
commit 9a3352b054
2 changed files with 16 additions and 1 deletions

View File

@ -117,9 +117,23 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
this.disposeItems();
}
// ======= compatibles for vision ======
getConfig(): FieldConfig {
return this._config;
}
getItems(filter?: (item: SettingField | CustomView) => boolean): Array<SettingField | CustomView> {
return this._items.filter(item => {
if (filter) {
return filter(item);
}
return true;
});
}
private hotValue: any;
// ======= compatibles for vision ======
setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: any) {
if (isHotValue) {
this.setHotValue(val, extraOptions);

View File

@ -124,6 +124,7 @@ class SettingFieldView extends Component<{ field: SettingField }> {
key: field.id,
// === injection
prop: field, // for compatible vision
selected: field.top?.getNode(),
field,
// === IO
value, // reaction point