1 | import type { DayPickerProps } from "../types/index.js";
|
2 |
|
3 |
|
4 | export function getDataAttributes(
|
5 | props: DayPickerProps
|
6 | ): Record<string, unknown> {
|
7 | const dataAttributes: Record<string, unknown> = {
|
8 | "data-mode": props.mode ?? undefined,
|
9 | "data-required": "required" in props ? props.required : undefined,
|
10 | "data-multiple-months":
|
11 | (props.numberOfMonths && props.numberOfMonths > 1) || undefined,
|
12 | "data-week-numbers": props.showWeekNumber || undefined
|
13 | };
|
14 | Object.entries(props).forEach(([key, val]) => {
|
15 | if (key.startsWith("data-")) {
|
16 | dataAttributes[key] = val;
|
17 | }
|
18 | });
|
19 | return dataAttributes;
|
20 | }
|