UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

54 lines (53 loc) 1.58 kB
import React from "react"; import { PartialTranslations, Translations } from "../util/i18n/i18n.types"; type ProviderContextType = { rootElement?: HTMLElement; locale: Translations; translations?: PartialTranslations | PartialTranslations[]; }; export declare const ProviderContext: React.Context<ProviderContextType>; export type ProviderProps = { children: React.ReactNode; /** * Global root-element to attach portals to. Used by Tooltip, Modal (optionally) and ActionMenu. */ rootElement?: HTMLElement; } & ({ /** * Aksel locale * @default nb * @example * ```jsx * import { en } from "@navikt/ds-react/locales"; * <Provider locale={en}> * {app} * </Provider> * ``` */ locale: Translations; /** * Use this if you need to override some of the default translations. * Can be a single object or an array of objects. * Must be used together with the `locale` prop. */ translations?: PartialTranslations | PartialTranslations[]; } | { locale?: never; translations?: never; }); export declare const useProvider: () => ProviderContextType; /** * Provides added context to the component tree. * * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/provider) * @see 🏷️ {@link ProviderProps} * * @example * ```jsx * <Provider rootElement={rootElement}> * {app} * </Provider> * ``` */ export declare const Provider: ({ children, rootElement, locale, translations, }: ProviderProps) => React.JSX.Element; export default Provider;