'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { useModal } from '@faceless-ui/modal';
import { getTranslation } from '@payloadcms/translations';
import React, { useEffect } from 'react';
import { Drawer } from '../../../elements/Drawer/index.js';
import { useTranslation } from '../../../providers/Translation/index.js';
import { BlockSelector } from '../BlockSelector/index.js';
export const BlocksDrawer = (props)=>{
    const { addRow, addRowIndex, blocks, drawerSlug, labels } = props;
    const { closeModal, isModalOpen } = useModal();
    const { i18n, t } = useTranslation();
    const [searchTermOverride, setSearchTermOverride] = React.useState('');
    useEffect(()=>{
        if (!isModalOpen(drawerSlug)) {
            setSearchTermOverride('');
        }
    }, [
        isModalOpen,
        drawerSlug
    ]);
    return /*#__PURE__*/ _jsxDEV(Drawer, {
        slug: drawerSlug,
        title: t('fields:addLabel', {
            label: getTranslation(labels.singular, i18n)
        }),
        children: /*#__PURE__*/ _jsxDEV(BlockSelector, {
            blocks: blocks,
            onSelect: (slug)=>{
                void addRow(addRowIndex, slug);
                closeModal(drawerSlug);
            },
            searchTerm: searchTermOverride
        }, void 0, false, {
            fileName: "src/fields/Blocks/BlocksDrawer/index.tsx",
            lineNumber: 38,
            columnNumber: 7
        }, this)
    }, void 0, false, {
        fileName: "src/fields/Blocks/BlocksDrawer/index.tsx",
        lineNumber: 34,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map