@fakel/rest-admin
Version:
An application that makes it easier to work with your API
37 lines (36 loc) • 2.86 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import React from 'react';
import Col from 'antd/lib/col';
import Row from 'antd/lib/row';
import Card from 'antd/lib/card';
import Space from 'antd/lib/space';
import InputsIteratorActions from './InputsIteratorActions';
var InputsIterator = function (props) {
var arrayName = props.arrayName, style = props.style, records = props.records, customLayout = props.customLayout, actionPosition = props.actionPosition, actions = props.actions, arrayHelpers = props.arrayHelpers, addButton = props.addButton, removeButton = props.removeButton, moveUpButton = props.moveUpButton, moveDownButton = props.moveDownButton, title = props.title, children = props.children;
return (React.createElement(Space, { style: style || { width: '50vw' }, direction: "vertical" }, records && customLayout
? customLayout(props, arrayName)
: records.map(function (record, index) {
return (React.createElement(Card, { style: { width: '100%' }, extra: (actionPosition && actionPosition === 'header' && actions) || (React.createElement(InputsIteratorActions, { arrayHelpers: arrayHelpers, index: index, disabledDownArrow: index === records.length - 1, disabledUpArrow: index === 0, addButton: addButton, removeButton: removeButton, moveUpButton: moveUpButton, moveDownButton: moveDownButton })), title: title },
React.createElement(Row, { justify: "space-between", align: "middle" },
React.createElement(Col, { span: 20 }, typeof children === 'function'
? children({
name: arrayName + "." + index,
record: record,
})
: React.Children.map(children, function (child) {
return React.cloneElement(child, __assign(__assign({}, child.props), { name: arrayName + "." + index + "." + child.props.name, value: record[child.props.name], record: record }));
})),
React.createElement(Col, { style: { display: 'flex', justifyContent: 'flex-end' }, span: 4 }, actionPosition === 'body' && (React.createElement(InputsIteratorActions, { direction: "vertical", arrayHelpers: arrayHelpers, index: index, disabledDownArrow: index === records.length - 1, disabledUpArrow: index === 0, addButton: addButton, removeButton: removeButton, moveUpButton: moveUpButton, moveDownButton: moveDownButton }))))));
})));
};
export default InputsIterator;