// This file is auto-generated by "@aria-ui/cli". Do not edit this file directly. import { registerTableHandleDragPreviewElement, type TableHandleDragPreviewElement, type TableHandleDragPreviewProps as TableHandleDragPreviewElementProps } from '@prosekit/web/table-handle'; import { createElement, forwardRef, useCallback, useRef, type ForwardedRef, type ForwardRefExoticComponent, type HTMLAttributes, type RefAttributes, useLayoutEffect } from 'react'; import { useEditorContext } from '../../contexts/editor-context.ts'; /** Props for the {@link TableHandleDragPreview} React component. */ export interface TableHandleDragPreviewProps { /** * @default null * @hidden */ editor?: TableHandleDragPreviewElementProps['editor']; } function TableHandleDragPreviewComponent(props: TableHandleDragPreviewProps, forwardedRef: ForwardedRef) { registerTableHandleDragPreviewElement(); const elementRef = useRef(null); const p0Fallback = useEditorContext(); const { editor: p0, ...restProps } = props; useLayoutEffect(() => { const element = elementRef.current as Record | null; if (!element) return; Object.assign(element, { editor: p0 ?? p0Fallback }); }); const mergedRef = useCallback( (element: TableHandleDragPreviewElement | null) => { elementRef.current = element; if (typeof forwardedRef === 'function') { forwardedRef(element); } else if (forwardedRef) { forwardedRef.current = element; } }, [forwardedRef], ); return createElement('prosekit-table-handle-drag-preview', { ...restProps, ref: mergedRef, suppressHydrationWarning: true }); } /** A React component that renders an `prosekit-table-handle-drag-preview` custom element. */ export const TableHandleDragPreview: ForwardRefExoticComponent & RefAttributes> = /* @__PURE__ */ forwardRef(TableHandleDragPreviewComponent);