Skip to content

Commit

Permalink
docs: update for formatters, labels
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl committed Jul 16, 2024
1 parent 7e76758 commit 9857d94
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/formatters/formatCaption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { FormatOptions, dateLib as defaultDateLib } from "../lib/index.js";
import type { DateLib } from "../types/index.js";

/**
* The default formatter for the caption element. As default, it returns the
* month and year.
* Format the caption of the month.
*
* @defaultValue `LLLL y` (e.g. "November 2022")
* @group Formatters
* @see https://daypicker.dev/next/docs/translation#custom-formatters
*/
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/formatDay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { dateLib as defaultDateLib } from "../lib/index.js";
import type { DateLib } from "../types/index.js";

/**
* The default formatter for the day grid cell element. As default, it returns
* the date of the day.
* Format the day date shown in the day cell.
*
* @defaultValue `d` (e.g. "1")
* @group Formatters
* @see https://daypicker.dev/next/docs/translation#custom-formatters
*/
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/formatMonthDropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { DateFnsMonth } from "../lib/dateLib.js";
import { enUS } from "../lib/locales.js";

/**
* The default formatter for the month dropdown option. As default, it returns
* the month name.
* Format the month number for the dropdown option label.
*
* @defaultValue `monthNumber.toString()`
* @group Formatters
* @see https://daypicker.dev/next/docs/translation#custom-formatters
*/
Expand Down
5 changes: 2 additions & 3 deletions src/formatters/formatWeekNumber.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/**
* The default formatter for the week numbers. As default, it returns the week
* number with a leading zero if the week number is less than 10.
* Format the week number.
*
* @param weekNumber - The week number to format.
* @defaultValue `weekNumber.toLocaleString()` with a leading zero for single-digit numbers
* @group Formatters
* @see https://daypicker.dev/next/docs/translation#custom-formatters
*/
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/formatWeekNumberHeader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The default formatter for the week numbers header. As default, it returns an
* empty string.
* Format the week number header.
*
* @defaultValue `""`
* @group Formatters
* @see https://daypicker.dev/next/docs/translation#custom-formatters
*/
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/formatWeekdayName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { dateLib as defaultDateLib } from "../lib/index.js";
import type { DateLib } from "../types/index.js";

/**
* The default formatter for the name of the weekday. As default, it returns the
* short name of the weekday (e.g. "Mo").
* Format the weekday name to be displayed in the weekdays header.
*
* @defaultValue `cccccc` (e.g. "Mo" for Monday)
* @group Formatters
* @see https://daypicker.dev/next/docs/translation#custom-formatters
*/
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/formatYearDropdown.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The default formatter for the Year dropdown option. As default, it returns
* the year.
* Format the years for the dropdown option label.
*
* @defaultValue `year.toString()`
* @group Formatters
* @see https://daypicker.dev/next/docs/translation#custom-formatters
*/
Expand Down
3 changes: 2 additions & 1 deletion src/labels/labelDayButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { dateLib as defaultDateLib } from "../lib/index.js";
import type { Modifiers } from "../types/index.js";

/**
* Return an ARIA label for the day button.
* The ARIA label for the day button.
*
* Use the `modifiers` argument to add additional context to the label, e.g.
* when a day is selected or is today.
*
* @defaultValue The formatted date.
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
1 change: 1 addition & 0 deletions src/labels/labelGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DateLib } from "../types/index.js";
* Return an ARIA label for the month grid, that will be announced when entering
* the grid.
*
* @defaultValue `LLLL y` (e.g. "November 2022")
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
3 changes: 2 additions & 1 deletion src/labels/labelMonthDropdown.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { LabelOptions } from "../lib/dateLib.js";

/**
* Return the default ARIA label for the months dropdown element.
* The ARIA label for the months dropdown.
*
* @defaultValue `"Choose the Month"`
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
4 changes: 2 additions & 2 deletions src/labels/labelNav.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Return an ARIA label for the navigation toolbar, that will be announced when
* entering it (optional).
* The ARIA label for the navigation toolbar.
*
* @defaultValue `""`
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
3 changes: 2 additions & 1 deletion src/labels/labelNext.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { LabelOptions } from "../lib/dateLib.js";

/**
* Return the default ARIA label for next month button.
* The ARIA label for next month button.
*
* @defaultValue `"Go to the Next Month"`
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
3 changes: 2 additions & 1 deletion src/labels/labelPrevious.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { LabelOptions } from "../lib/dateLib.js";

/**
* Return the default ARIA label for next month button.
* The ARIA label for previous month button.
*
* @defaultValue `"Go to the Previous Month"`
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
3 changes: 2 additions & 1 deletion src/labels/labelWeekNumber.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { LabelOptions } from "../lib/dateLib.js";

/**
* Return the default ARIA label for the week number element.
* The ARIA label for the week number cell (the first cell in the row).
*
* @defaultValue `Week ${weekNumber}`
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
3 changes: 2 additions & 1 deletion src/labels/labelWeekNumberHeader.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { LabelOptions } from "../lib/dateLib.js";

/**
* Return the default ARIA label for the week number header element.
* The ARIA label for the week number header element.
*
* @defaultValue `"Week Number"`
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
3 changes: 2 additions & 1 deletion src/labels/labelWeekday.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { dateLib as defaultDateLib } from "../lib/index.js";
import type { DateLib } from "../types/index.js";

/**
* Return he default ARIA label for the Weekday colum header.
* The ARIA label for the Weekday column header.
*
* @defaultValue `"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"`
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
3 changes: 2 additions & 1 deletion src/labels/labelYearDropdown.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { LabelOptions } from "../lib/dateLib.js";

/**
* Return the default ARIA label for the years dropdown.
* The ARIA label for the years dropdown.
*
* @defaultValue `"Choose the Year"`
* @group Labels
* @see http://daypicker.dev/next/docs/translation#aria-labels
*/
Expand Down
50 changes: 25 additions & 25 deletions website/docs/docs/translation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,27 @@ function ItalianLabels() {

The following labels are required to be translated, as they default to English:

| Function | Description |
| -------------------------------------------------------------- | -------------------------------------- |
| [`labelDayButton`](../api/functions/labelDayButton.md) | The label for the day button. |
| [`labelWeekNumber`](../api/functions/labelWeekNumber.md) | The label for the week number element. |
| [`labelNext`](../api/functions/labelNext.md) | The label for next month button. |
| [`labelPrevious`](../api/functions/labelPrevious.md) | The label for next month button. |
| [`labelMonthDropdown`](../api/functions/labelMonthDropdown.md) | The label for the months dropdown. |
| [`labelYearDropdown`](../api/functions/labelYearDropdown.md) | The label for the years dropdown. |
| Function | Description |
| -------------------------------------------------------------- | -------------------------------------------------------------------- |
| [`labelDayButton`](../api/functions/labelDayButton.md) | The ARIA label for the day button. |
| [`labelMonthDropdown`](../api/functions/labelMonthDropdown.md) | The ARIA label for the months dropdown. |
| [`labelNext`](../api/functions/labelNext.md) | The ARIA label for next month button. |
| [`labelPrevious`](../api/functions/labelPrevious.md) | The ARIA label for previous month button. |
| [`labelWeekNumber`](../api/functions/labelWeekNumber.md) | The ARIA label for the week number cell (the first cell in the row). |
| [`labelYearDropdown`](../api/functions/labelYearDropdown.md) | The ARIA label for the years dropdown. |

### Optional labels

The following labels are optional and should work out of the box in most languages:

| Function | Description |
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| [`labelWeekday`](../api/functions/labelWeekday.md) | The label for the Weekday element. |
| [`labelDay`](../api/functions/labelDay.md) | The label for the day button. |
| [`labelGrid`](../api/functions/labelGrid.md) | The label for the month grid, that will be announced when entering the grid. |
| [`labelGridcell`](../api/functions/labelGridcell.md) | The label for the day gridcell when the calendar is not interactive. |
| [`labelNav`](../api/functions/labelNav.md) | The label for the navigation toolbar, that will be announced when entering it. |
| [`labelWeekNumberHeader`](../api/functions/labelWeekNumberHeader.md) | The label for the week number header element. |
| Function | Description |
| -------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| [`labelDay`](../api/functions/labelDay.md) | The ARIA label for the day button. |
| [`labelGrid`](../api/functions/labelGrid.md) | Return an ARIA label for the month grid, that will be announced when entering the grid. |
| [`labelGridcell`](../api/functions/labelGridcell.md) | The label for the day gridcell when the calendar is not interactive. |
| [`labelNav`](../api/functions/labelNav.md) | The ARIA label for the navigation toolbar. |
| [`labelWeekNumberHeader`](../api/functions/labelWeekNumberHeader.md) | The ARIA label for the week number header element. |
| [`labelWeekday`](../api/functions/labelWeekday.md) | The ARIA label for the Weekday column header. |

## RTL Text Direction

Expand Down Expand Up @@ -118,15 +118,15 @@ import { format } from "date-fns";
/>;
```

| Function | Description |
| ---------------------------------------------------------------------- | ---------------------------------------------------- |
| [`formatCaption`](../api/functions/formatCaption.md) | The default formatter for the caption element. |
| [`formatDay`](../api/functions/formatDay.md) | The default formatter for the day grid cell element. |
| [`formatMonthDropdown`](../api/functions/formatMonthDropdown.md) | The default formatter for the month dropdown value. |
| [`formatWeekNumber`](../api/functions/formatWeekNumber.md) | The default formatter for the week numbers. |
| [`formatWeekNumberHeader`](../api/functions/formatWeekNumberHeader.md) | The default formatter for the week numbers header. |
| [`formatWeekdayName`](../api/functions/formatWeekdayName.md) | The default formatter for the name of the weekday. |
| [`formatYearDropdown`](../api/functions/formatYearDropdown.md) | The default formatter for the Year caption. |
| Function | Description |
| ---------------------------------------------------------------------- | --------------------------------------------------------------- |
| [`formatCaption`](../api/functions/formatCaption.md) | Format the caption of the month. |
| [`formatDay`](../api/functions/formatDay.md) | Format the day date shown in the day cell. |
| [`formatMonthDropdown`](../api/functions/formatMonthDropdown.md) | Format the month number for the dropdown option label. |
| [`formatWeekNumber`](../api/functions/formatWeekNumber.md) | Format the week number. |
| [`formatWeekNumberHeader`](../api/functions/formatWeekNumberHeader.md) | Format the week number header. |
| [`formatWeekdayName`](../api/functions/formatWeekdayName.md) | Format the weekday name to be displayed in the weekdays header. |
| [`formatYearDropdown`](../api/functions/formatYearDropdown.md) | Format the years for the dropdown option label. |

### Numbering System

Expand Down

0 comments on commit 9857d94

Please sign in to comment.