@aoctech/ui 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,6 @@ interface CalendarProps {
|
|
|
5
5
|
disabled?: Matcher | Matcher[];
|
|
6
6
|
className?: string;
|
|
7
7
|
}
|
|
8
|
-
/** An inline, keyboard-operable calendar. Use DatePicker for a field trigger. */
|
|
9
8
|
declare function Calendar({ selected, onSelect, disabled, className }: CalendarProps): import("react").JSX.Element;
|
|
10
9
|
interface DatePickerProps {
|
|
11
10
|
value?: Date;
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Popover } from "@base-ui/react/popover";
|
|
4
|
+
import { format } from "date-fns";
|
|
4
5
|
import { ptBR } from "date-fns/locale/pt-BR";
|
|
5
6
|
import { useState } from "react";
|
|
6
7
|
import { DayPicker } from "react-day-picker";
|
|
7
8
|
import { cn } from "../lib/cn";
|
|
8
9
|
import { useThemeScope } from "./theme-provider";
|
|
9
10
|
/** An inline, keyboard-operable calendar. Use DatePicker for a field trigger. */
|
|
11
|
+
// react-day-picker's default labels are English ("Go to the Previous Month",
|
|
12
|
+
// "Today, …"): a screen reader in a pt-BR product read half its calendar in
|
|
13
|
+
// another language.
|
|
14
|
+
const LABELS = {
|
|
15
|
+
labelPrevious: () => "Mês anterior",
|
|
16
|
+
labelNext: () => "Próximo mês",
|
|
17
|
+
labelDayButton: (date, modifiers) => `${modifiers.today ? "Hoje, " : ""}${format(date, "PPPP", { locale: ptBR })}${modifiers.selected ? ", selecionado" : ""}`,
|
|
18
|
+
};
|
|
10
19
|
function Calendar({ selected, onSelect, disabled, className }) {
|
|
11
|
-
return (_jsx(DayPicker, { mode: "single",
|
|
20
|
+
return (_jsx(DayPicker, { mode: "single",
|
|
21
|
+
// Open on the selected date's month, not today's: editing a date months
|
|
22
|
+
// away otherwise starts by paging back to it.
|
|
23
|
+
defaultMonth: selected, labels: LABELS, selected: selected, onSelect: onSelect, disabled: disabled, locale: ptBR, classNames: {
|
|
12
24
|
month_caption: "calendar-month-caption",
|
|
13
25
|
caption_label: "calendar-caption-label",
|
|
14
26
|
nav: "calendar-nav",
|
package/package.json
CHANGED