UNPKG

@indec/form-builder

Version:

Form builder

64 lines (63 loc) 3.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _Icons = require("../../../Icons"); var _jsxRuntime = require("react/jsx-runtime"); function ActionButtons(_ref) { var isSectionMultiple = _ref.isSectionMultiple, sectionsLength = _ref.sectionsLength, onEdit = _ref.onEdit, onDelete = _ref.onDelete, onView = _ref.onView, isReadOnly = _ref.isReadOnly, onMoveUp = _ref.onMoveUp, onMoveDown = _ref.onMoveDown, position = _ref.position, showEditButton = _ref.showEditButton; return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", { className: "fb:flex fb:flex-row fb:gap-2", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", { type: "button", "data-testid": "read-only-button", onClick: onView, className: "fb:p-2 fb:rounded-full fb:text-yellow-600 hover:fb:bg-yellow-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-yellow-500 focus:fb:ring-offset-2", "aria-label": "View", children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.EyeIcon, {}) }), !isReadOnly && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [sectionsLength > 1 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [onMoveUp && position > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", { type: "button", "data-testid": "move-up-button", onClick: onMoveUp, className: "fb:p-2 fb:rounded-full fb:text-blue-600 hover:fb:bg-blue-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-blue-500 focus:fb:ring-offset-2", "aria-label": "Move up", children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.ArrowUpIcon, {}) }), onMoveDown && position < sectionsLength - 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", { type: "button", "data-testid": "move-down-button", onClick: onMoveDown, className: "fb:p-2 fb:rounded-full fb:text-blue-600 hover:fb:bg-blue-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-blue-500 focus:fb:ring-offset-2", "aria-label": "Move down", children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.ArrowDownIcon, {}) })] }), showEditButton && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", { type: "button", "data-testid": "edit-button", onClick: onEdit, className: "p-2 rounded-full text-blue-600 hover:bg-blue-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2", "aria-label": "Edit", children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.EditIcon, {}) }), isSectionMultiple && sectionsLength > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", { type: "button", "data-testid": "delete-button", onClick: onDelete, className: "fb:p-2 fb:rounded-full fb:text-red-600 hover:fb:bg-red-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-red-500 focus:fb:ring-offset-2", "aria-label": "Delete", children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.TrashIcon, {}) })] })] }); } var _default = exports["default"] = ActionButtons;