Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@mantine/dates] Showing Week Numbers in Calendar Component #7179

Merged
merged 5 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fix prettier and types issues
  • Loading branch information
MariaBanaszkiewicz committed Nov 27, 2024
commit 4d2690b2f9883a62e1f1922ec25a2d0effd7cbfe
1 change: 1 addition & 0 deletions packages/@docs/styles-api/src/data/Dates.styles-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const MonthStylesApi: StylesApiData<MonthFactory> = {
weekdaysRow: 'Weekdays tr element',
weekday: 'Weekday th element',
day: 'Month day control',
weekNumber: 'Week number td element',
},

vars: {},
Expand Down
2 changes: 1 addition & 1 deletion packages/@mantine/dates/src/components/Month/Month.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import { Day, DayProps, DayStylesNames } from '../Day';
import { WeekdaysRow } from '../WeekdaysRow';
import { getDateInTabOrder } from './get-date-in-tab-order/get-date-in-tab-order';
import { getMonthDays } from './get-month-days/get-month-days';
import { getWeekNumber } from './get-week-number/get-week-number';
import { isAfterMinDate } from './is-after-min-date/is-after-min-date';
import { isBeforeMaxDate } from './is-before-max-date/is-before-max-date';
import { isSameMonth } from './is-same-month/is-same-month';
import classes from './Month.module.css';
import { getWeekNumber } from './get-week-number/get-week-number';

export type MonthStylesNames =
| 'month'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import isoWeek from 'dayjs/plugin/isoWeek.js';

dayjs.extend(isoWeek);

export function getWeekNumber(
week: Date[]): number {
export function getWeekNumber(week: Date[]): number {
const monday = week.find((date) => dayjs(date).day() === 1);
return dayjs(monday).isoWeek();
}