import { Switch } from '@components/common/ui/Switch.js';
import { ChevronDown } from 'lucide-react';
import React, { useEffect, useState } from 'react';
/**
* Drawer-style primitives shared by every widget setting form. Same vocabulary
* across the codebase: an 11px-label `Field`, a collapsible `Section` card,
* a `Segmented` radio-style control, and a `Slider` whose drag commits on
* release (controlled-value updates on every frame made dragging feel like
* a click — see slideshow drawer history).
*
* Until this module landed, every drawer (Slideshow / Banner / Menu /
* Collection / Columns) inlined its own copies. Behaviour now flows from
* here; the per-widget files just compose these.
*/
// ---------------------------------------------------------------------------
// Field — label + (hint) + child input.
// ---------------------------------------------------------------------------
export function Field({
label,
hint,
children
}: {
label?: string;
hint?: string;
children: React.ReactNode;
}) {
return (
{label && (
{label}
)}
{children}
{hint &&
{hint}
}
);
}
// ---------------------------------------------------------------------------
// Section — collapsible card with a title row and optional right-slot.
// ---------------------------------------------------------------------------
export function Section({
title,
children,
rightSlot,
defaultOpen = true
}: {
title: string;
children: React.ReactNode;
rightSlot?: React.ReactNode;
defaultOpen?: boolean;
}) {
const [open, setOpen] = useState(defaultOpen);
return (