Jake Vanderwerf
2026-09-06 3e4e3db64b366028845cfd610c5b17f26bd062ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { useState } from 'react';
import { DatePicker } from '@wordpress/components';
 
const DateField = ({field, value, onChange}) => {
    const [ date, setDate ] = useState( new Date() );
    return (
        <div className="components-base-control" id={field.name}>
            <label className="components-base-control__label">
                { field.label }
            </label>
            <DatePicker
                currentDate={ date }
                onChange={ onChange }
                help={ field.description }
                value={value??''}
            />
            { getDescription(field) }
        </div>
    );
};
const getDescription = (field) => {
    if (!field.description || field.description.length === 0) return;
    return (
        <p className="hint">{field.description}</p>
    )
};
 
export default DateField;