import React from 'react'; import {Renderer, RendererProps} from '../factory'; import {Api, SchemaNode, Schema, Action} from '../types'; import cx from 'classnames'; import {BaseSchema, SchemaObject} from '../Schema'; export type HboxRow = SchemaObject & { rowClassName?: string; cellClassName?: string; }; /** * 垂直布局控件 * 文档:https://baidu.gitee.io/amis/docs/components/vbox */ export interface VBoxSchema extends BaseSchema { type: 'vbox'; /** * 行集合 */ rows?: Array; } export interface HBoxProps extends RendererProps, Omit {} export default class VBox extends React.Component { static propsList: Array = ['rows']; static defaultProps: Partial = {}; renderChild(region: string, node: Schema) { const {render} = this.props; return render(region, node); } renderCell(row: HboxRow, key: any) { const {classPrefix: ns} = this.props; return (
{this.renderChild(`row/${key}`, row)}
); } render() { const {className, rows, classPrefix: ns} = this.props; return (
{Array.isArray(rows) ? rows.map((row, key) => (
{this.renderCell(row, key)}
)) : null}
); } } @Renderer({ type: 'vbox', name: 'vbox' }) export class VBoxRenderer extends VBox {}