Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0865aba
docs: add readme for DatePicker component
Jun 9, 2025
880f337
docs: add readme for TimePicker component
Jun 9, 2025
a85eb1f
chore: update manifest.json for docs
Jun 9, 2025
96574ed
chore: update changelog
shrivastavanolo Jul 16, 2025
e70ffe1
chore: npm run docs:build command
shrivastavanolo Apr 9, 2026
587d085
Update packages/components/src/date-time/time/README.md
shrivastavanolo Apr 10, 2026
9ea4a99
docs: semantic/markup issues
shrivastavanolo Apr 10, 2026
8a02f16
docs: update manifest titles to DatePicker and TimePicker for consist…
shrivastavanolo Apr 10, 2026
c0e8cac
chore: run docs build and include generated updates
shrivastavanolo Apr 10, 2026
d1e894d
docs: address review feedback for DatePicker and TimePicker README
shrivastavanolo Apr 13, 2026
36cc539
refactor: rename date/time folders to date-picker/time-picker and upd…
shrivastavanolo Apr 13, 2026
b381ff2
chore: run docs build and use tabs for indentation in README
shrivastavanolo Apr 13, 2026
33052f9
Update packages/components/src/date-time/time-picker/README.md
shrivastavanolo Apr 14, 2026
77c3654
docs: expand TimePicker.TimeInput docs and align JSDoc with README
shrivastavanolo Apr 14, 2026
26f1711
chore: fix docs build failure
shrivastavanolo Apr 14, 2026
e1480a9
Update packages/components/src/date-time/time-picker/README.md
ciampo Apr 14, 2026
986d40b
Update packages/components/src/date-time/time-picker/README.md
ciampo Apr 14, 2026
c04de39
Update packages/components/src/date-time/time-picker/README.md
ciampo Apr 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,12 +857,24 @@
"markdown_source": "../packages/components/src/dashicon/README.md",
"parent": "components"
},
{
"title": "DatePicker",
"slug": "date-picker",
"markdown_source": "../packages/components/src/date-time/date-picker/README.md",
"parent": "components"
},
{
"title": "DateTime",
"slug": "date-time",
"markdown_source": "../packages/components/src/date-time/README.md",
"parent": "components"
},
{
"title": "TimePicker",
"slug": "time-picker",
"markdown_source": "../packages/components/src/date-time/time-picker/README.md",
"parent": "components"
},
{
"title": "Disabled",
"slug": "disabled",
Expand Down
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Documentation

- Add README.md files for `DatePicker` and `TimePicker` components ([#70365](https://github.com/WordPress/gutenberg/pull/70365)).

### Bug Fixes

- `CheckboxControl`: Fix disabled styles [#77132](https://github.com/WordPress/gutenberg/pull/77132).
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/date-time/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ A callback function which receives a Date object representing a day as an argume

- Required: No

### `onMonthPreviewed`: `( date: Date ) => void`
### `onMonthPreviewed`: `( date: string ) => void`

A callback invoked when selecting the previous/next month in the date picker. The callback receives the new month date in the ISO format as an argument.

Expand All @@ -87,5 +87,5 @@ List of events to show in the date picker. Each event will appear as a dot on th

The day that the week should start on. 0 for Sunday, 1 for Monday, etc.

- Required: No
- Default: 0
- Required: No
- Default: 0
65 changes: 65 additions & 0 deletions packages/components/src/date-time/date-picker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# DatePicker

DatePicker is a React component that renders a calendar for date selection. It can be used independently or as part of the `DateTimePicker` component.

## Usage

Render a DatePicker.

```jsx
import { useState } from 'react';
import { DatePicker } from '@wordpress/components';

const MyDatePicker = () => {
const [ date, setDate ] = useState( new Date() );

return (
<DatePicker
currentDate={ date }
onChange={ ( newDate ) => setDate( newDate ) }
/>
);
};
```
Comment thread
ciampo marked this conversation as resolved.

## Props

The component accepts the following props:

### `currentDate`: `Date | string | number | null`

The current date at initialization. Optionally pass in a `null` value to specify no date is currently selected.

- Required: No
- Default: today's date

### `onChange`: `( date: string ) => void`

The function called when a new date has been selected. It is passed the `currentDate` as an argument.

- Required: No

### `events`: `{ date: Date }[]`

List of events to show in the date picker. Each event will appear as a dot on the day of the event.

- Required: No

### `isInvalidDate`: `( date: Date ) => boolean`

A callback function which receives a Date object representing a day as an argument, and should return a Boolean to signify if the day is valid or not.

- Required: No

### `onMonthPreviewed`: `( date: string ) => void`

A callback invoked when selecting the previous/next month in the date picker. The callback receives the new month date in the ISO format as an argument.

- Required: No

### `startOfWeek`: `0 | 1 | 2 | 3 | 4 | 5 | 6`

The day that the week should start on. 0 for Sunday, 1 for Monday, etc.

- Required: No
- Default: 0
4 changes: 2 additions & 2 deletions packages/components/src/date-time/date-time/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import { default as DatePicker } from '../date';
import { default as TimePicker } from '../time';
import { default as DatePicker } from '../date-picker';
import { default as TimePicker } from '../time-picker';
import type { DateTimePickerProps } from '../types';
import { Wrapper } from './styles';

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/date-time/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Internal dependencies
*/
import { default as DatePicker } from './date';
import { default as TimePicker } from './time';
import { default as DatePicker } from './date-picker';
import { default as TimePicker } from './time-picker';
import { default as DateTimePicker } from './date-time';

export { DatePicker, TimePicker };
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/date-time/stories/date.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useState, useEffect } from '@wordpress/element';
/**
* Internal dependencies
*/
import DatePicker from '../date';
import DatePicker from '../date-picker';
import { daysFromNow, isWeekend } from './utils';

const meta: Meta< typeof DatePicker > = {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/date-time/stories/time.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useState, useEffect } from '@wordpress/element';
/**
* Internal dependencies
*/
import TimePicker from '../time';
import TimePicker from '../time-picker';

const meta: Meta< typeof TimePicker > = {
title: 'Components/Selection & Input/Time & Date/TimePicker',
Expand Down
119 changes: 119 additions & 0 deletions packages/components/src/date-time/time-picker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# TimePicker

TimePicker is a React component that renders form inputs for time and date selection. It can be used independently or as part of the `DateTimePicker` component.

**Note:** `TimePicker` also exposes a compound sub-component, `TimePicker.TimeInput`, which can be used independently to render a time input field without the full picker UI.
Comment thread
ciampo marked this conversation as resolved.

## Usage

Render a TimePicker.

```jsx
import { useState } from 'react';
import { TimePicker } from '@wordpress/components';

const MyTimePicker = () => {
const [ time, setTime ] = useState( new Date() );

return (
<TimePicker
currentTime={ time }
onChange={ ( newTime ) => setTime( newTime ) }
is12Hour
/>
);
};
```
Comment thread
ciampo marked this conversation as resolved.

## Props

The component accepts the following props:

### `currentTime`: `Date | string | number | null`

The current time at initialization. Optionally pass in a `null` value to specify no time is currently selected.

- Required: No
- Default: current time

### `onChange`: `( time: string ) => void`

The function called when a new time has been selected. It is passed the time as an ISO-formatted string.

- Required: No

### `is12Hour`: `boolean`

Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed.

Comment thread
ciampo marked this conversation as resolved.
- Required: No
- Default: false

### `dateOrder`: `'dmy' | 'mdy' | 'ymd'`

The order of day, month, and year. This prop overrides the time format determined by `is12Hour` prop.

- Required: No
- Default: `'dmy'` (or `'mdy'` when `is12Hour` is `true`)

### `hideLabelFromVision`: `boolean`

Whether to visually hide field labels while keeping them accessible to screen readers.

- Required: No
- Default: false

## TimePicker.TimeInput

A standalone time input component. Values are passed as an object in 24-hour format (`{ hours: number, minutes: number }`).

### Usage

```jsx
import { useState } from 'react';
import { TimePicker } from '@wordpress/components';

const MyTimeInput = () => {
const [ time, setTime ] = useState( { hours: 13, minutes: 30 } );

return (
<TimePicker.TimeInput
value={ time }
onChange={ setTime }
label="Time"
/>
);
};
Comment thread
ciampo marked this conversation as resolved.
```

### Props

#### `value`: `{ hours: number, minutes: number }`

The time input value in 24-hour format.

- Required: No

#### `defaultValue`: `{ hours: number, minutes: number }`

An optional default value for the control when used in uncontrolled mode. If left `undefined`, the current time will be used.

- Required: No

#### `onChange`: `( time: { hours: number, minutes: number } ) => void`

Called when the time changes. Receives the new value as an object with `hours` and `minutes`.

- Required: No

#### `is12Hour`: `boolean`

Whether to use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed.

- Required: No

#### `label`: `string`

The label for the time input.

- Required: No
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { TimeInput } from './time-input';
const VALID_DATE_ORDERS = [ 'dmy', 'mdy', 'ymd' ];

/**
* TimePicker is a React component that renders a clock for time selection.
* TimePicker is a React component that renders form inputs for time and date selection. It can be used independently or as part of the `DateTimePicker` component.
*
* ```jsx
* import { TimePicker } from '@wordpress/components';
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/date-time/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import type { MinutesInput } from './time/styles';
import type { MinutesInput } from './time-picker/styles';

export type TimePickerProps = {
/**
Expand Down
Loading