@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
23 lines • 1.81 kB
JavaScript
import React, { forwardRef } from "react";
import { useRenameCSS } from "../../../theme/Theme.js";
import { useDateLocale, useI18n } from "../../../util/i18n/i18n.hooks.js";
import { DateTranslationContextProvider, getLocaleFromString, getTranslations, } from "../../Date.locale.js";
import { MonthPickerProvider } from "../MonthPicker.context.js";
import { MonthPickerCaption } from "./MonthPicker.Caption.js";
import { MonthPickerTable } from "./MonthPicker.Table.js";
export const MonthPickerStandalone = forwardRef(({ dropdownCaption = false, fromDate, toDate, disabled = [], selected, className, locale, translations, onMonthSelect, defaultSelected, year, onYearChange, }, ref) => {
const { cn } = useRenameCSS();
const translate = useI18n("DatePicker", translations, getTranslations(locale));
const langProviderLocale = useDateLocale();
if (dropdownCaption && (!fromDate || !toDate)) {
console.warn("Using dropdownCaption required fromDate and toDate");
return null;
}
return (React.createElement("div", { ref: ref, className: cn("navds-date__wrapper", className) },
React.createElement(DateTranslationContextProvider, { translate: translate },
React.createElement(MonthPickerProvider, { dropdownCaption: dropdownCaption, defaultSelected: defaultSelected, selected: selected, disabled: disabled, fromDate: fromDate, toDate: toDate, year: year, onYearChange: onYearChange, onMonthSelect: onMonthSelect, locale: locale ? getLocaleFromString(locale) : langProviderLocale },
React.createElement("div", { className: cn("navds-date rdp-month") },
React.createElement(MonthPickerCaption, null),
React.createElement(MonthPickerTable, null))))));
});
//# sourceMappingURL=MonthPicker.Standalone.js.map