@nodeject/ui-components
Version:
UI library for non-trivial components
61 lines (60 loc) • 3.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddNodesMenu = void 0;
var antd_1 = require("antd");
var React = require("react");
var icons_1 = require("../icons");
var styles = require("./AddNodesMenu.module.less");
var Text = antd_1.Typography.Text;
var AddNodesMenu = function (props) {
var _a = props.nodeActions, addChildNodeClient = _a.addChildNodeClient, deleteNodeClient = _a.deleteNodeClient, insertParentClient = _a.insertParentClient, insertSiblingAfterClient = _a.insertSiblingAfterClient, insertSiblingBeforeClient = _a.insertSiblingBeforeClient;
var nodeProps = props.nodeProps;
var nodeId = nodeProps.id;
var isRoot = nodeProps.parent === undefined;
var handleAddChild = function () {
addChildNodeClient(nodeId);
};
var handleDeleteNode = function () {
deleteNodeClient(nodeId);
};
var handleInsertParent = function () {
insertParentClient(nodeId);
};
var handleInsertSiblingBefore = function () {
insertSiblingBeforeClient(nodeId);
};
var handleInsertSiblingAfter = function () {
insertSiblingAfterClient(nodeId);
};
return (React.createElement("div", { className: styles.addNodesMenu },
!isRoot && (React.createElement("div", { style: { marginBottom: '.5rem' } },
React.createElement(antd_1.Button, { onClick: handleInsertParent, size: 'small', block: true, style: { textAlign: 'left' } },
React.createElement(icons_1.PlusCircleIcon, null),
React.createElement(Text, null,
"Insert ",
React.createElement(Text, { strong: true }, "Parent"))))),
!isRoot && (React.createElement("div", { style: { marginBottom: '.5rem' } },
React.createElement(antd_1.Button, { onClick: handleInsertSiblingBefore, size: 'small', block: true, style: { textAlign: 'left' } },
React.createElement(icons_1.PlusCircleIcon, null),
React.createElement(Text, null,
"Insert ",
React.createElement(Text, { strong: true }, "Sibling"),
" Before")))),
!isRoot && (React.createElement("div", { style: { marginBottom: '.5rem' } },
React.createElement(antd_1.Button, { onClick: handleInsertSiblingAfter, size: 'small', block: true, style: { textAlign: 'left' } },
React.createElement(icons_1.PlusCircleIcon, null),
React.createElement(Text, null,
"Add ",
React.createElement(Text, { strong: true }, "Sibling"),
" After")))),
React.createElement("div", { style: { marginBottom: isRoot ? 0 : '1.5rem' } },
React.createElement(antd_1.Button, { onClick: handleAddChild, size: 'small', block: true, type: 'primary', style: { textAlign: 'left' } },
React.createElement(icons_1.PlusCircleIcon, null),
"Add Child")),
!isRoot && (React.createElement("div", null,
React.createElement(antd_1.Popconfirm, { title: 'Delete with its children?', onConfirm: handleDeleteNode, icon: React.createElement(icons_1.HelpIcon, { style: { color: 'red' } }) },
React.createElement(antd_1.Button, { size: 'small', block: true, type: 'link', style: { color: '#ff4d4f', textAlign: 'left' } },
React.createElement(icons_1.DeleteOutlinedIcon, null),
"Delete"))))));
};
exports.AddNodesMenu = AddNodesMenu;