'use client';
import React, { useRef } from 'react';
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
import { useForm } from '../../forms/Form/context.js';
import FormSubmit from '../../forms/Submit/index.js';
import useHotkey from '../../hooks/useHotkey.js';
import { useEditDepth } from '../../providers/EditDepth/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
const DefaultSaveButton = ({ label, save })=>{
    const ref = useRef(null);
    const editDepth = useEditDepth();
    useHotkey({
        cmdCtrlKey: true,
        editDepth,
        keyCodes: [
            's'
        ]
    }, (e)=>{
        e.preventDefault();
        e.stopPropagation();
        if (ref?.current) {
            ref.current.click();
        }
    });
    return /*#__PURE__*/ React.createElement(FormSubmit, {
        buttonId: "action-save",
        onClick: save,
        ref: ref,
        size: "small",
        type: "button"
    }, label);
};
export const Save = ({ CustomComponent })=>{
    const { t } = useTranslation();
    const { submit } = useForm();
    return /*#__PURE__*/ React.createElement(RenderCustomComponent, {
        CustomComponent: CustomComponent,
        DefaultComponent: DefaultSaveButton,
        componentProps: {
            DefaultButton: DefaultSaveButton,
            label: t('general:save'),
            save: submit
        }
    });
};

//# sourceMappingURL=index.js.map