import React, { useEffect, useState } from 'react';
import { isInPageBuilderIframe } from './pageBuilderMode.js';
/**
* Shared in-editor placeholder for widgets that render nothing until they're
* configured. On the live storefront an unconfigured widget should render
* nothing (return null); but in the page-builder iframe that makes a freshly
* dropped widget invisible and unselectable except via the Layers panel.
*
* Drop this in the widget's empty branch instead of `return null`:
*
* if (rows.length === 0) {
* return ;
* }
*
* It renders the dashed placeholder ONLY inside the page-builder iframe, and
* only after mount — the first (SSR) render is `null` so it matches the
* production storefront output and never trips hydration.
*/
export function WidgetEmptyState({
type,
title,
hint,
icon
}: {
/** Widget type id — emitted as `data-evershop-pb-empty` for tooling. */
type: string;
title: string;
hint: string;
/** Optional custom glyph; defaults to a generic block icon. */
icon?: React.ReactNode;
}): React.ReactElement | null {
const [isClient, setIsClient] = useState(false);
useEffect(() => {
setIsClient(true);
}, []);
if (!isClient || !isInPageBuilderIframe()) return null;
return (
);
}