Jake Vanderwerf
2026-09-09 8318f60480aedd4aa1e64dc35468247dfbba9316
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
29
30
31
32
33
import { useState } from 'react';
import { DateTimePicker } from '@wordpress/components';
 
const DateTimeField = ({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>
            <DateTimePicker
                currentDate={ date }
                onChange={ onChange }
                label={ field.label }
                help={ field.description }
                value={value??''}
                is12Hour={ true }
            />
            { getDescription(field) }
        </div>
    );
};
 
const getDescription = (field) => {
    if (!field.description || field.description.length === 0) return;
    return (
        <p className="hint">{field.description}</p>
    )
};
 
export default DateTimeField;