feat:配置中允许空对象和 null (#1224)

* options 支持配置 selectFirst 自动选择第一个

* 文档优化;修复 cxd 下 toast 展现不一致问题 (#1219)

* Panel 支持更多的 className 配置

* feat:配置中允许空对象和 null

Co-authored-by: 2betop <2betop.cn@gmail.com>
This commit is contained in:
吴多益 2020-12-22 14:59:57 +08:00 committed by GitHub
parent 3bef1ade98
commit 0f76b48f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View File

@ -309,7 +309,8 @@ export function renderChild(
? {type: 'tpl', tpl: String(node)}
: (node as Schema);
const detectData =
schema.detectField === '&' ? props : props[schema.detectField || 'data'];
schema &&
(schema.detectField === '&' ? props : props[schema.detectField || 'data']);
const exprProps = detectData
? getExprProperties(schema, detectData, undefined, props)
: null;
@ -503,8 +504,10 @@ class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
const props = this.props;
if (
props.schema.type !== nextProps.schema.type ||
props.schema.$$id !== nextProps.schema.$$id
props.schema &&
nextProps.schema &&
(props.schema.type !== nextProps.schema.type ||
props.schema.$$id !== nextProps.schema.$$id)
) {
this.resolveRenderer(nextProps);
}
@ -542,7 +545,7 @@ class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
let schema = props.schema;
let path = props.$path;
if (schema.$ref) {
if (schema && schema.$ref) {
schema = {
...props.resolveDefinitions(schema.$ref),
...schema
@ -577,7 +580,7 @@ class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
) {
let {schema, $path, env, ...rest} = this.props;
if (schema.$ref) {
if (schema && schema.$ref) {
const result = this.resolveRenderer(this.props, true);
schema = result.schema;
$path = result.path;
@ -606,6 +609,10 @@ class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
render(): JSX.Element | null {
let {$path, schema, ...rest} = this.props;
if (schema === null) {
return null;
}
if (schema.$ref) {
const result = this.resolveRenderer(this.props, true);
schema = result.schema;
@ -635,6 +642,8 @@ class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
forwardedRef: isSFC ? this.refFn : undefined,
render: this.renderChild
});
} else if (Object.keys(schema).length === 0) {
return null;
} else if (!this.renderer) {
return (
<LazyComponent

View File

@ -1064,6 +1064,7 @@ export default class Form extends React.Component<FormProps, object> {
(Array.isArray(controls) &&
controls.some(
item =>
item &&
!!~['submit', 'button', 'reset', 'button-group'].indexOf(
(item as Schema).type
)

View File

@ -261,6 +261,7 @@ export const TableStore = iRendererStore
function getFilteredColumns() {
return self.columns.filter(
item =>
item &&
isVisible(item.pristine, self.data) &&
(item.type === '__checkme'
? self.selectable &&
@ -562,7 +563,9 @@ export const TableStore = iRendererStore
(self.combineNum = parseInt(config.combineNum as any, 10) || 0);
if (config.columns && Array.isArray(config.columns)) {
let columns: Array<SColumn> = config.columns.concat();
let columns: Array<SColumn> = config.columns
.filter(column => column)
.concat();
if (!columns.length) {
columns.push({
type: 'text',