Merge remote-tracking branch 'upstream/master'

* upstream/master:
  调整,为了方便写编辑器
  renderChild 把 index 传过去
  调整样式
  fix doc
  layout 样式调整
  Each 添加 index 变量
  给 Each 添加 placehoder
This commit is contained in:
wuduoyi 2020-10-14 12:17:21 +08:00
commit 900b5b0048
11 changed files with 77 additions and 28 deletions

View File

@ -99,7 +99,7 @@ CRUD即增删改查组件主要用来展现数据列表并支持各类
### 增
其实这个渲染器并没有包含新增功能,新增功能其实还是依靠其他位置放个弹框表单完成,弹框完事了会自动让页面里面的 CRUD 刷新如:
其实这个渲染器并没有包含新增功能,新增功能其实还是依靠其他位置放个弹框表单完成,弹框完事了会自动让页面里面的 CRUD 刷新如:
```schema:height="600" scope="body"
[

View File

@ -0,0 +1,7 @@
.#{$ns}Each {
&-placeholder {
color: $text--muted-color;
text-align: center;
padding: $gap-sm;
}
}

View File

@ -14,6 +14,9 @@
&-content {
padding: $Page-content-paddingY $Page-content-paddingX;
position: relative;
height: 100%;
width: 100%;
}
&-main > &-header {

View File

@ -3,12 +3,13 @@
table-layout: fixed;
border-spacing: 0;
width: 100%;
height: 100%;
// height: 100%;
& > .#{$ns}Hbox-col {
&-col {
display: table-cell;
vertical-align: top;
height: 100%;
width: 100%;
float: none;
}
}

View File

@ -235,7 +235,7 @@ body {
@include media-breakpoint-up(md) {
.#{$ns}Layout {
display: flex;
flex-direction: row;
flex-direction: column;
flex-wrap: wrap;
justify-content: stretch;
@ -247,9 +247,8 @@ body {
&-content,
& > &-body {
flex-grow: 1;
width: 0;
height: 0;
position: relative;
height: auto;
}
&--boxed {

View File

@ -504,6 +504,7 @@ $Satus-icon-width: px2rem(14px);
@import '../components/spinner';
@import '../components/button-group';
@import '../components/dropdown';
@import '../components/each';
@import '../components/collapse';
@import '../components/color';
@import '../components/condition-builder';

View File

@ -187,6 +187,7 @@ pre {
@import '../components/spinner';
@import '../components/button-group';
@import '../components/dropdown';
@import '../components/each';
@import '../components/collapse';
@import '../components/color';
@import '../components/condition-builder';

View File

@ -50,6 +50,7 @@ $Form-input-borderColor: #cfdadd;
@import '../components/spinner';
@import '../components/button-group';
@import '../components/dropdown';
@import '../components/each';
@import '../components/collapse';
@import '../components/color';
@import '../components/condition-builder';

View File

@ -21,6 +21,8 @@ export interface EachSchema extends BaseSchema {
name?: string;
items?: SchemaCollection;
placeholder?: string;
}
export interface EachProps extends RendererProps {
@ -30,12 +32,23 @@ export interface EachProps extends RendererProps {
export default class Each extends React.Component<EachProps> {
static propsList: Array<string> = ['name', 'items', 'value'];
static defaultProps: Partial<EachProps> = {
className: ''
static defaultProps = {
className: '',
placeholder: '暂无内容'
};
render() {
const {data, name, className, render, value, items} = this.props;
const {
data,
name,
className,
render,
value,
items,
placeholder,
classnames: cx,
translate: __
} = this.props;
const arr =
typeof value !== 'undefined'
@ -50,18 +63,24 @@ export default class Each extends React.Component<EachProps> {
: resolveVariable(name, data);
return (
<div className={className}>
{Array.isArray(arr) && items
? arr.map((item: any, index: number) =>
render(`item/${index}`, items, {
data: createObject(
data,
isObject(item) ? item : {[name]: item, item: item}
),
key: index
})
)
: null}
<div className={cx('Each', className)}>
{Array.isArray(arr) && items ? (
arr.map((item: any, index: number) =>
render(`item/${index}`, items, {
data: createObject(
data,
isObject(item)
? {index, ...item}
: {[name]: item, item: item, index}
),
key: index
})
)
) : (
<div className={cx('Each-placeholder')}>
{render('placeholder', __(placeholder))}
</div>
)}
</div>
);
}

View File

@ -79,12 +79,12 @@ export class HBoxRenderer extends React.Component<HBoxProps, any> {
>
{itemRender
? itemRender(column, key, length, this.props)
: this.renderChild(`column/${key}`, column)}
: this.renderChild(`column/${key}`, column, key)}
</div>
);
}
renderChild(region: string, node: Schema) {
renderChild(region: string, node: Schema, index: number) {
const {render, renderFormItems, formMode, store, $path} = this.props;
if (node && !node.type && (node.controls || node.tabs || node.feildSet)) {
@ -108,6 +108,14 @@ export class HBoxRenderer extends React.Component<HBoxProps, any> {
return render(region, node.body || node);
}
renderColumns() {
const {columns} = this.props;
return columns.map((column, key) =>
this.renderColumn(column, key, columns.length)
);
}
render() {
const {className, columns, gap, classPrefix: ns} = this.props;
@ -119,11 +127,7 @@ export class HBoxRenderer extends React.Component<HBoxProps, any> {
className
)}
>
<div className={`${ns}Hbox`}>
{columns.map((column: any, key: number) =>
this.renderColumn(column, key, columns.length)
)}
</div>
<div className={`${ns}Hbox`}>{this.renderColumns()}</div>
</div>
);
}

View File

@ -6,11 +6,24 @@ import {isVisible} from '../utils/helper';
import {BaseSchema, SchemaObject} from '../Schema';
export type HBoxColumnObject = {
/**
* CSS
*/
columnClassName?: string;
/**
*
*/
width?: number | string;
/**
*
*/
height?: number | string;
/**
*
*/
style?: {
[propName: string]: any;
};