feat(date-picker): support configurable week starts

This commit is contained in:
2026-03-23 11:28:53 +08:00
parent 4d67f4ad76
commit c570431dba
5 changed files with 226 additions and 156 deletions
@@ -86,6 +86,39 @@ describe("DatePicker", () => {
expect(screen.getByText("April 2028")).toBeInTheDocument();
});
it("defaults to a monday-first calendar grid", () => {
render(
<DatePicker
aria-label="Monday-first date"
defaultMonth={new Date(2026, 2, 1)}
defaultOpen
locale="en-US"
/>
);
const firstDay = within(screen.getByRole("grid")).getAllByRole("gridcell")[0];
expect(firstDay).toHaveAccessibleName("Feb 23, 2026");
expect(screen.getByText("Mon")).toBeInTheDocument();
});
it("supports sunday-first calendar grids when requested", () => {
render(
<DatePicker
aria-label="Sunday-first date"
defaultMonth={new Date(2026, 2, 1)}
defaultOpen
locale="en-US"
weekStartsOn="sunday"
/>
);
const firstDay = within(screen.getByRole("grid")).getAllByRole("gridcell")[0];
expect(firstDay).toHaveAccessibleName("Mar 1, 2026");
expect(screen.getByText("Sun")).toBeInTheDocument();
});
it("respects min and max dates", async () => {
render(
<DatePicker