import React, { useState, useEffect } from 'react'; import { Button, Icon, PanelBody, ToggleControl } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import LCPDimensionControl from './LCPDimensionControl'; import LCPHTMLModal from './LCPHTMLModal.js'; const LCPChartBlockSettings = ({ attributes, setAttributes }) => { // Use `legendAlignment` from props (block attributes) const { renderLegend, legendLocation, legendAlignment, allowDownloadImage, downloadImageMaxWidth, allowDownloadCsv, allowDownloadJson, allowSorting, allowFiltering, footerContent, chartTitle, chartSubtitle, toolbarLocation, toolbarAlignment } = attributes; // Set local state for legend location (for UI updates) const [selectedLegendLocation, setSelectedLegendLocation] = useState(legendLocation); // Update block attribute when location changes useEffect(() => { setAttributes({ legendLocation: selectedLegendLocation }); }, [selectedLegendLocation, setAttributes]); // Set local state for alignment (for UI updates) const [selectedLegendAlignment, setSelectedLegendAlignment] = useState(legendAlignment); // Update block attribute when alignment changes useEffect(() => { setAttributes({ legendAlignment: selectedLegendAlignment }); }, [selectedLegendAlignment, setAttributes]); // Set local state for alignment (for UI updates) const [selectedToolbarAlignment, setSelectedToolbarAlignment] = useState(toolbarAlignment); // Update block attribute when alignment changes useEffect(() => { setAttributes({ toolbarAlignment: selectedToolbarAlignment }); }, [selectedToolbarAlignment, setAttributes]); // Render the component return (