@fakel/rest-admin
Version:
An application that makes it easier to work with your API
34 lines (33 loc) • 2.32 kB
JavaScript
import React from 'react';
import DeleteOutlined from '@ant-design/icons/lib/icons/DeleteOutlined';
import PlusOutlined from '@ant-design/icons/lib/icons/PlusOutlined';
import UpOutlined from '@ant-design/icons/lib/icons/UpOutlined';
import DownOutlined from '@ant-design/icons/lib/icons/DownOutlined';
import Button from 'antd/lib/button';
import Space from 'antd/lib/space';
var InputsIteratorActions = function (_a) {
/**
* @todo: show actions
* */
var arrayHelpers = _a.arrayHelpers, index = _a.index, disabledUpArrow = _a.disabledUpArrow, disabledDownArrow = _a.disabledDownArrow, addButton = _a.addButton, removeButton = _a.removeButton, moveUpButton = _a.moveUpButton, moveDownButton = _a.moveDownButton, _b = _a.direction, direction = _b === void 0 ? 'horizontal' : _b;
var _pushHandler = function (arrayHelpers) {
arrayHelpers.push({});
};
var _removeHandler = function (arrayHelpers, index) {
arrayHelpers.remove(index);
};
var _moveUpHandler = function (arrayHelpers, fromIndex) {
var toIndex = fromIndex - 1;
arrayHelpers.swap(fromIndex, toIndex);
};
var _moveDownHandler = function (arrayHelpers, fromIndex) {
var toIndex = fromIndex + 1;
arrayHelpers.swap(fromIndex, toIndex);
};
return (React.createElement(Space, { direction: direction },
addButton ? (addButton(arrayHelpers)) : (React.createElement(Button, { type: "primary", onClick: function () { return _pushHandler(arrayHelpers); }, icon: React.createElement(PlusOutlined, null) })),
removeButton ? (removeButton(arrayHelpers)) : (React.createElement(Button, { type: "primary", danger: true, onClick: function () { return _removeHandler(arrayHelpers, index); }, icon: React.createElement(DeleteOutlined, null) })),
moveUpButton ? (moveUpButton(arrayHelpers)) : (React.createElement(Button, { disabled: disabledUpArrow, onClick: function () { return _moveUpHandler(arrayHelpers, index); }, icon: React.createElement(UpOutlined, null) })),
moveDownButton ? (moveDownButton(arrayHelpers)) : (React.createElement(Button, { disabled: disabledDownArrow, onClick: function () { return _moveDownHandler(arrayHelpers, index); }, icon: React.createElement(DownOutlined, null) }))));
};
export default InputsIteratorActions;