/** * External dependencies */ import { Button, Dashicon, Panel, PanelBody, TextareaControl, TextControl, } from '@wordpress/components'; import { Component } from '@wordpress/element'; /** * Internal dependencies */ import './style.scss'; export class Locations extends Component { constructor() { super( ...arguments ); this.state = { selectedCell: null, }; } onDeletePoint = e => { const index = parseInt( e.target.getAttribute( 'data-id' ) ); const { points, onChange } = this.props; const newPoints = points.slice( 0 ); newPoints.splice( index, 1 ); onChange( newPoints ); }; setMarkerField( field, value, index ) { const { points, onChange } = this.props; const newPoints = points.slice( 0 ); newPoints[ index ][ field ] = value; onChange( newPoints ); } render() { const { points } = this.props; const rows = points.map( ( point, index ) => ( this.setMarkerField( 'title', title, index ) } /> this.setMarkerField( 'caption', caption, index ) } /> ) ); return (
{ rows }
); } } Locations.defaultProps = { points: Object.freeze( [] ), onChange: () => {}, }; export default Locations;