import { __ } from "@wordpress/i18n"; import { InspectorControls, PanelColorSettings } from "@wordpress/block-editor"; import { PanelBody, SelectControl, ToggleControl, TextControl, TextareaControl, RangeControl, BaseControl, ButtonGroup, Button, TabPanel, } from "@wordpress/components"; import { BOX_PADDING, BOX_BORDER, DIGITS_PADDING, DIGITS_BORDER, UNITS, COUNTDOWN_TYPES, LAYOUT_OPTIONS, LABEL_VIEW_OPTIONS, SEPARATOR_OPTIONS, ALIGN_OPTIONS, EXPIRE_TYPES, } from "./constants"; import { DIGITS_TYPO, LABEL_TYPO, EXPIRE_TITLE_TYPO, EXPIRE_TEXT_TYPO, } from "./typographyConstants"; import objAttributes from "./attributes"; const { TypographyDropdown, ResponsiveDimensionsControl, BorderShadowControl } = window.EBControls; const UNIT_LABELS = { days: __("Days", "notificationx"), hours: __("Hours", "notificationx"), minutes: __("Minutes", "notificationx"), seconds: __("Seconds", "notificationx"), }; export default function Inspector({ attributes, setAttributes }) { const { resOption, countdownType, dueTime, evergreenHours, evergreenMinutes, evergreenRecurring, recurringRestartAfter, recurringStopTime, layout, labelView, alignment, showDays, daysLabel, showHours, hoursLabel, showMinutes, minutesLabel, showSeconds, secondsLabel, showSeparator, separatorStyle, separatorColor, expireType, expiryTitle, expiryText, redirectUrl, boxBgColor, boxBgGradient, boxSpacing, digitsColor, digitsBgColor, labelColor, expireAlignment, expireTitleColor, expireTextColor, } = attributes; const resRequiredProps = { setAttributes, resOption, attributes, objAttributes }; const AlignButtons = ({ value, onChange }) => ( {ALIGN_OPTIONS.map((item) => ( ))} ); return (
{(tab) => tab.name === "general" ? (
{/* ── Timer Settings ── */} setAttributes({ countdownType: v })} /> {countdownType === "due_date" && ( setAttributes({ dueTime: v })} /> )} {countdownType === "evergreen" && ( <> setAttributes({ evergreenHours: parseInt(v || 0, 10) })} /> setAttributes({ evergreenMinutes: parseInt(v || 0, 10) })} /> setAttributes({ evergreenRecurring: v })} /> {evergreenRecurring && ( <> setAttributes({ recurringRestartAfter: parseInt(v || 0, 10) })} /> setAttributes({ recurringStopTime: v })} /> )} )} {/* ── Content Settings ── */} setAttributes({ layout: v })} /> setAttributes({ labelView: v })} /> setAttributes({ alignment: v })} /> setAttributes({ showDays: v })} /> {showDays && ( setAttributes({ daysLabel: v })} /> )} setAttributes({ showHours: v })} /> {showHours && ( setAttributes({ hoursLabel: v })} /> )} setAttributes({ showMinutes: v })} /> {showMinutes && ( setAttributes({ minutesLabel: v })} /> )} setAttributes({ showSeconds: v })} /> {showSeconds && ( setAttributes({ secondsLabel: v })} /> )} setAttributes({ showSeparator: v })} /> {showSeparator && ( setAttributes({ separatorStyle: v })} /> )} {/* ── Expire Action ── */} setAttributes({ expireType: v })} /> {expireType === "text" && ( <> setAttributes({ expiryTitle: v })} /> setAttributes({ expiryText: v })} /> )} {expireType === "url" && ( setAttributes({ redirectUrl: v })} /> )}
) : (
{/* ── Countdown Box ── */} setAttributes({ boxBgColor: v }), label: __("Box Background Color", "notificationx"), }, ]} /> setAttributes({ boxBgGradient: v })} /> setAttributes({ boxSpacing: v })} min={0} max={100} /> {/* ── Color & Typography ── */} setAttributes({ digitsColor: v }), label: __("Digits Color", "notificationx") }, { value: digitsBgColor, onChange: (v) => setAttributes({ digitsBgColor: v }), label: __("Background Color", "notificationx") }, ]} /> setAttributes({ labelColor: v }), label: __("Label Color", "notificationx") }, ]} /> {showSeparator && ( setAttributes({ separatorColor: v }), label: __("Separator Color", "notificationx") }, ]} /> )} {/* ── Individual Box Styling ── */} {UNITS.map((unit) => ( setAttributes({ [`${unit}BgColor`]: v }), label: __("Background Color", "notificationx") }, { value: attributes[`${unit}DigitColor`], onChange: (v) => setAttributes({ [`${unit}DigitColor`]: v }), label: __("Digit Color", "notificationx") }, { value: attributes[`${unit}LabelColor`], onChange: (v) => setAttributes({ [`${unit}LabelColor`]: v }), label: __("Label Color", "notificationx") }, { value: attributes[`${unit}BorderColor`], onChange: (v) => setAttributes({ [`${unit}BorderColor`]: v }), label: __("Border Color", "notificationx") }, ]} /> ))} {/* ── Expire Message ── */} {expireType === "text" && ( setAttributes({ expireAlignment: v })} /> setAttributes({ expireTitleColor: v }), label: __("Title Color", "notificationx") }, { value: expireTextColor, onChange: (v) => setAttributes({ expireTextColor: v }), label: __("Text Color", "notificationx") }, ]} /> )}
) }
); }