import React from 'react';
import { Chevron } from '../../icons/Chevron/index.js';
import { Copy } from '../../icons/Copy/index.js';
import { MoreIcon } from '../../icons/More/index.js';
import { Plus } from '../../icons/Plus/index.js';
import { X } from '../../icons/X/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import * as PopupList from '../Popup/PopupButtonList/index.js';
import Popup from '../Popup/index.js';
const baseClass = 'array-actions';
export const ArrayAction = ({ addRow, duplicateRow, hasMaxRows, index, moveRow, removeRow, rowCount })=>{
    const { t } = useTranslation();
    return /*#__PURE__*/ React.createElement(Popup, {
        button: /*#__PURE__*/ React.createElement(MoreIcon, null),
        buttonClassName: `${baseClass}__button`,
        className: baseClass,
        horizontalAlign: "center",
        render: ({ close })=>{
            return /*#__PURE__*/ React.createElement(PopupList.ButtonGroup, {
                buttonSize: "small"
            }, index !== 0 && /*#__PURE__*/ React.createElement(PopupList.Button, {
                className: `${baseClass}__action ${baseClass}__move-up`,
                onClick: ()=>{
                    moveRow(index, index - 1);
                    close();
                }
            }, /*#__PURE__*/ React.createElement("div", {
                className: `${baseClass}__action-chevron`
            }, /*#__PURE__*/ React.createElement(Chevron, {
                direction: "up"
            })), t('general:moveUp')), index < rowCount - 1 && /*#__PURE__*/ React.createElement(PopupList.Button, {
                className: `${baseClass}__action`,
                onClick: ()=>{
                    moveRow(index, index + 1);
                    close();
                }
            }, /*#__PURE__*/ React.createElement("div", {
                className: `${baseClass}__action-chevron`
            }, /*#__PURE__*/ React.createElement(Chevron, null)), t('general:moveDown')), !hasMaxRows && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(PopupList.Button, {
                className: `${baseClass}__action ${baseClass}__add`,
                onClick: ()=>{
                    addRow(index + 1);
                    close();
                }
            }, /*#__PURE__*/ React.createElement(Plus, null), t('general:addBelow')), /*#__PURE__*/ React.createElement(PopupList.Button, {
                className: `${baseClass}__action ${baseClass}__duplicate`,
                onClick: ()=>{
                    duplicateRow(index);
                    close();
                }
            }, /*#__PURE__*/ React.createElement(Copy, null), t('general:duplicate'))), /*#__PURE__*/ React.createElement(PopupList.Button, {
                className: `${baseClass}__action ${baseClass}__remove`,
                onClick: ()=>{
                    removeRow(index);
                    close();
                }
            }, /*#__PURE__*/ React.createElement(X, null), t('general:remove')));
        },
        size: "medium"
    });
};

//# sourceMappingURL=index.js.map