import React from 'react'
import { RotateCcw, X } from 'lucide-react'
import InfoTip from './InfoTip'
// Shared storefront-style rows used by the Theme, Pages and Field Settings panels.
// the reference builder idiom: label left; read-only hex + circle swatch + reset on the right; numbers as slider + number + unit + reset.
export const inputBase = 'h-[34px] px-2.5 py-1.5 text-sm text-gray-900 border border-gray-200 rounded-md bg-white box-border focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500'
const isSet = (v) => v !== undefined && v !== null && v !== ''
export function SubHeading({ children, tip }) {
return (
{children}
{tip && }
)
}
/**
* Colour row. `value` unset shows "Inherit" (the global theme colour applies). `onClear` (optional) writes null so the
* key is really removed from the stored field (updateField merges); `onReset` (optional) restores a default.
*/
export function ColorRow({ label, value, placeholder = '#000000', onChange, onClear, onReset, tip, testId }) {
const shown = isSet(value) ? String(value) : ''
const swatch = isSet(value) ? String(value) : placeholder
const pickerValue = /^#[0-9a-fA-F]{6}$/.test(swatch) ? swatch : (/^#[0-9a-fA-F]{3}$/.test(swatch) ? `#${swatch[1]}${swatch[1]}${swatch[2]}${swatch[2]}${swatch[3]}${swatch[3]}` : '#000000')
return (