import { jsx as _jsx } from "react/jsx-runtime";
import { useMemo } from 'react';
import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, BroomMotion as ClearCells, TrashBin, Xmark, } from '@gravity-ui/icons';
import { Icon } from '@gravity-ui/uikit';
import { i18n } from "../../../../../../../i18n/yfm-table/index.js";
import { FloatingMenu } from "../FloatingMenu/FloatingMenu.js";
export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multiple, dndHandler, acnhorElement, onMenuOpenToggle, onClearCellsClick, onInsertBeforeClick, onInsertAfterClick, onRemoveRangeClick, onRemoveTableClick, }) {
    const dropdownItems = useMemo(() => [
        [
            {
                text: i18n(`${type}.add.before`),
                qa: `g-md-yfm-table-action-add-${type}-before`,
                action: onInsertBeforeClick,
                iconStart: _jsx(Icon, { data: type === 'row' ? ArrowUp : ArrowLeft }),
            },
            {
                text: i18n(`${type}.add.after`),
                qa: `g-md-yfm-table-action-add-${type}-after`,
                action: onInsertAfterClick,
                iconStart: _jsx(Icon, { data: type === 'row' ? ArrowDown : ArrowRight }),
            },
        ],
        [
            {
                text: i18n('cells.clear'),
                qa: `g-md-yfm-table-${type}-clear-cells`,
                action: onClearCellsClick,
                iconStart: _jsx(Icon, { data: ClearCells }),
            },
        ],
        [
            {
                text: i18n(`${type}.remove${multiple ? '.multiple' : ''}`),
                qa: `g-md-yfm-table-action-remove-${type}`,
                action: onRemoveRangeClick,
                iconStart: _jsx(Icon, { data: Xmark }),
            },
            {
                theme: 'danger',
                text: i18n('table.remove'),
                qa: 'g-md-yfm-table-action-remove-table',
                action: onRemoveTableClick,
                iconStart: _jsx(Icon, { data: TrashBin }),
            },
        ],
    ], [
        type,
        multiple,
        onClearCellsClick,
        onInsertAfterClick,
        onInsertBeforeClick,
        onRemoveRangeClick,
        onRemoveTableClick,
    ]);
    return (_jsx(FloatingMenu, { dirtype: type, canDrag: dndHandler ? dndHandler.canDrag() : false, onOpenToggle: onMenuOpenToggle, anchorElement: acnhorElement, switcherMouseProps: dndHandler
            ? {
                onMouseLeave: dndHandler.control_handleMouseLeave,
                onMouseDown: dndHandler.control_handleMouseDown,
                onMouseMove: dndHandler.control_handleMouseMove,
                onMouseUp: dndHandler.control_handleMouseUp,
            }
            : undefined, dropdownItems: dropdownItems }));
};
//# sourceMappingURL=FloatingMenuControl.js.map
