import { ColorSwatchField, Field, ImagePickerField, Section, Segmented, Slider, useScopedFormContext } from '@components/common/page-builder/index.js'; import { _ } from '@evershop/evershop/lib/locale/translate/_'; import React from 'react'; import type { SectionPadding, SectionTint, SectionWidth } from './Section.js'; interface SectionSettingProps { sectionWidget?: { width?: SectionWidth | null; padding?: SectionPadding | null; background?: string | null; backgroundImage?: string | null; backgroundImageWidth?: number | null; backgroundImageHeight?: number | null; overlayTint?: SectionTint | null; overlayOpacity?: number | null; }; } const WIDTH_OPTIONS: ReadonlyArray<{ value: SectionWidth; label: string }> = [ { value: 'boxed', label: _('Boxed') }, { value: 'wide', label: _('Wide (full bleed)') } ]; const PADDING_OPTIONS: ReadonlyArray<{ value: SectionPadding; label: string; }> = [ { value: 'none', label: _('None') }, { value: 'sm', label: _('S') }, { value: 'md', label: _('M') }, { value: 'lg', label: _('L') }, { value: 'xl', label: _('XL') } ]; const TINT_OPTIONS: ReadonlyArray<{ value: SectionTint; label: string }> = [ { value: 'none', label: _('None') }, { value: 'dark', label: _('Dark') }, { value: 'light', label: _('Light') }, { value: 'gradient', label: _('Gradient') } ]; export default function SectionSetting({ sectionWidget }: SectionSettingProps) { const { width = 'boxed', padding = 'md', background = null, backgroundImage = null, backgroundImageWidth = null, backgroundImageHeight = null, overlayTint = 'none', overlayOpacity = 0.3 } = sectionWidget ?? {}; const { register, setValue, watch } = useScopedFormContext(); const widthV = ((watch('settings.width') as string) ?? width ?? 'boxed') as SectionWidth; const paddingV = ((watch('settings.padding') as string) ?? padding ?? 'md') as SectionPadding; const backgroundV = (watch('settings.background') as string) ?? background ?? ''; const backgroundImageV = (watch('settings.backgroundImage') as string) ?? backgroundImage ?? ''; const tintV = ((watch('settings.overlayTint') as string) ?? overlayTint ?? 'none') as SectionTint; const opacityV = (watch('settings.overlayOpacity') as number) ?? overlayOpacity ?? 0.3; return (