@fakel/rest-admin
Version:
An application that makes it easier to work with your API
42 lines (41 loc) • 3.37 kB
JavaScript
"use strict";
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);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var col_1 = __importDefault(require("antd/lib/col"));
var row_1 = __importDefault(require("antd/lib/row"));
var card_1 = __importDefault(require("antd/lib/card"));
var space_1 = __importDefault(require("antd/lib/space"));
var InputsIteratorActions_1 = __importDefault(require("./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_1.default.createElement(space_1.default, { style: style || { width: '50vw' }, direction: "vertical" }, records && customLayout
? customLayout(props, arrayName)
: records.map(function (record, index) {
return (react_1.default.createElement(card_1.default, { style: { width: '100%' }, extra: (actionPosition && actionPosition === 'header' && actions) || (react_1.default.createElement(InputsIteratorActions_1.default, { arrayHelpers: arrayHelpers, index: index, disabledDownArrow: index === records.length - 1, disabledUpArrow: index === 0, addButton: addButton, removeButton: removeButton, moveUpButton: moveUpButton, moveDownButton: moveDownButton })), title: title },
react_1.default.createElement(row_1.default, { justify: "space-between", align: "middle" },
react_1.default.createElement(col_1.default, { span: 20 }, typeof children === 'function'
? children({
name: arrayName + "." + index,
record: record,
})
: react_1.default.Children.map(children, function (child) {
return react_1.default.cloneElement(child, __assign(__assign({}, child.props), { name: arrayName + "." + index + "." + child.props.name, value: record[child.props.name], record: record }));
})),
react_1.default.createElement(col_1.default, { style: { display: 'flex', justifyContent: 'flex-end' }, span: 4 }, actionPosition === 'body' && (react_1.default.createElement(InputsIteratorActions_1.default, { direction: "vertical", arrayHelpers: arrayHelpers, index: index, disabledDownArrow: index === records.length - 1, disabledUpArrow: index === 0, addButton: addButton, removeButton: removeButton, moveUpButton: moveUpButton, moveDownButton: moveDownButton }))))));
})));
};
exports.default = InputsIterator;