Skip to content

Commit

Permalink
i18n: rename some files, add tests for useDateLocale (#3481)
Browse files Browse the repository at this point in the history
  • Loading branch information
HalvorHaugan authored Dec 28, 2024
1 parent fa15677 commit ef5e671
Show file tree
Hide file tree
Showing 43 changed files with 119 additions and 62 deletions.
2 changes: 1 addition & 1 deletion @navikt/core/react/src/alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@navikt/aksel-icons";
import { Button } from "../button";
import { BodyLong } from "../typography";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";

export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
/**
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/chips/Removable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cl from "clsx";
import React, { forwardRef } from "react";
import { XMarkIcon } from "@navikt/aksel-icons";
import { composeEventHandlers } from "../util/composeEventHandlers";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";

export interface ChipsRemovableProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/copybutton/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CheckmarkIcon, FilesIcon } from "@navikt/aksel-icons";
import { Label } from "../typography";
import { composeEventHandlers } from "../util/composeEventHandlers";
import copy from "../util/copy";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";

export interface CopyButtonProps
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext } from "../../util/create-context";
import { TFunction } from "../../util/i18n/i18n.context";
import { TFunction } from "../../util/i18n/i18n.types";

interface DateTranslationContextProps {
translate: TFunction<"DatePicker">;
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/date/datepicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DateRange, DayPicker, isMatch } from "react-day-picker";
import { omit } from "../../util";
import { useId } from "../../util/hooks";
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
import { useDateLocale, useI18n } from "../../util/i18n/i18n.context";
import { useDateLocale, useI18n } from "../../util/i18n/i18n.hooks";
import { DateInputContext, DateTranslationContextProvider } from "../context";
import { DatePickerInput } from "../parts/DateInput";
import { DateWrapper } from "../parts/DateWrapper";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isWeekend } from "date-fns";
import React, { forwardRef } from "react";
import { DateRange, DayPicker, isMatch } from "react-day-picker";
import { omit } from "../../util";
import { useDateLocale, useI18n } from "../../util/i18n/i18n.context";
import { useDateLocale, useI18n } from "../../util/i18n/i18n.hooks";
import { DateTranslationContextProvider } from "../context";
import { getLocaleFromString, getTranslations } from "../utils";
import Caption from "./parts/Caption";
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/date/hooks/useDatepicker.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { differenceInCalendarDays, isWeekend } from "date-fns";
import React, { useCallback, useState } from "react";
import { DayClickEventHandler, isMatch } from "react-day-picker";
import { useDateLocale } from "../../util/i18n/i18n.context";
import { useDateLocale } from "../../util/i18n/i18n.hooks";
import { DatePickerProps } from "../datepicker/DatePicker";
import { DateInputProps } from "../parts/DateInput";
import {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/date/hooks/useMonthPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useMemo, useState } from "react";
import { useDateLocale } from "../../util/i18n/i18n.context";
import { useDateLocale } from "../../util/i18n/i18n.hooks";
import { MonthPickerProps } from "../monthpicker/types";
import { DateInputProps } from "../parts/DateInput";
import {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/date/hooks/useRangeDatepicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "date-fns";
import React, { useState } from "react";
import { DateRange, isMatch } from "react-day-picker";
import { useDateLocale } from "../../util/i18n/i18n.context";
import { useDateLocale } from "../../util/i18n/i18n.hooks";
import { DatePickerProps } from "../datepicker/DatePicker";
import { DateInputProps } from "../parts/DateInput";
import {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/date/monthpicker/MonthPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { forwardRef, useState } from "react";
import { DayPickerProvider } from "react-day-picker";
import { useId } from "../../util/hooks";
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
import { useDateLocale, useI18n } from "../../util/i18n/i18n.context";
import { useDateLocale, useI18n } from "../../util/i18n/i18n.hooks";
import {
DateInputContext,
DateTranslationContextProvider,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cl from "clsx";
import React, { forwardRef, useState } from "react";
import { DayPickerProvider } from "react-day-picker";
import { useDateLocale, useI18n } from "../../util/i18n/i18n.context";
import { useDateLocale, useI18n } from "../../util/i18n/i18n.hooks";
import {
DateTranslationContextProvider,
SharedMonthProvider,
Expand Down
3 changes: 2 additions & 1 deletion @navikt/core/react/src/date/parts/DateWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Modal } from "../../modal";
import { useModalContext } from "../../modal/Modal.context";
import { Popover } from "../../popover";
import { useMedia } from "../../util/hooks";
import { TFunction, useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import { TFunction } from "../../util/i18n/i18n.types";
import { getGlobalTranslations } from "../utils";

const variantToLabel = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cl from "clsx";
import React, { forwardRef, useContext } from "react";
import { ChevronDownIcon } from "@navikt/aksel-icons";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";
import { ExpansionCardContext } from "./context";

export interface ExpansionCardHeaderProps
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/form/ReadOnlyIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { PadlockLockedFillIcon } from "@navikt/aksel-icons";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";

export const ReadOnlyIcon = () => (
<PadlockLockedFillIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cl from "clsx";
import React from "react";
import { PlusIcon } from "@navikt/aksel-icons";
import { BodyShort, Label } from "../../../typography";
import { useI18n } from "../../../util/i18n/i18n.context";
import { useI18n } from "../../../util/i18n/i18n.hooks";
import { useInputContext } from "../Input/Input.context";
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
import { isInList, toComboboxOption } from "../combobox-utils";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Loader } from "../../../loader";
import { useI18n } from "../../../util/i18n/i18n.context";
import { useI18n } from "../../../util/i18n/i18n.hooks";
import { useInputContext } from "../Input/Input.context";
import filteredOptionsUtil from "./filtered-options-util";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { useI18n } from "../../../util/i18n/i18n.context";
import { useI18n } from "../../../util/i18n/i18n.hooks";
import { useInputContext } from "../Input/Input.context";
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
import filteredOptionsUtil from "./filtered-options-util";
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/form/error-summary/ErrorSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { HTMLAttributes, forwardRef, useRef } from "react";
import { BodyShort, Heading } from "../../typography";
import { composeEventHandlers } from "../../util/composeEventHandlers";
import { useMergeRefs } from "../../util/hooks";
import { useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import ErrorSummaryItem from "./ErrorSummaryItem";

export interface ErrorSummaryProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Button } from "../../../../button";
import { BodyShort, ErrorMessage, Label } from "../../../../typography";
import { composeEventHandlers } from "../../../../util/composeEventHandlers";
import { useId } from "../../../../util/hooks";
import { useI18n } from "../../../../util/i18n/i18n.context";
import { useI18n } from "../../../../util/i18n/i18n.hooks";
import { omit } from "../../../../util/omit";
import { useFormField } from "../../../useFormField";
import { useFileUploadTranslation } from "../../FileUpload.context";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { MouseEvent, forwardRef } from "react";
import { ExclamationmarkTriangleIcon } from "@navikt/aksel-icons";
import { BodyShort } from "../../../../typography";
import { OverridableComponent } from "../../../../util";
import { useI18n } from "../../../../util/i18n/i18n.context";
import { useI18n } from "../../../../util/i18n/i18n.hooks";
import { ComponentTranslation } from "../../../../util/i18n/i18n.types";
import { useFileUploadTranslation } from "../../FileUpload.context";
import { FileItem } from "./Item.types";
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/form/form-progress/FormProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HStack } from "../../layout/stack";
import { ProgressBar } from "../../progress-bar";
import { Stepper, StepperStepProps } from "../../stepper";
import { BodyShort } from "../../typography";
import { useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import { ComponentTranslation } from "../../util/i18n/i18n.types";

export interface FormProgressProps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cl from "clsx";
import React, { forwardRef } from "react";
import { Link } from "../../link";
import { useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import { OverridableComponent } from "../../util/types";

export interface FormSummaryEditProps
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/form/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useThemeInternal } from "../../theme/Theme";
import { BodyShort, ErrorMessage, Label } from "../../typography";
import { omit } from "../../util";
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
import { useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import { FormFieldProps, useFormField } from "../useFormField";
import SearchButton, { SearchButtonType } from "./SearchButton";
import { SearchContext } from "./context";
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/form/search/SearchButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { forwardRef, useContext } from "react";
import { MagnifyingGlassIcon } from "@navikt/aksel-icons";
import { Button, ButtonProps } from "../../button";
import { composeEventHandlers } from "../../util/composeEventHandlers";
import { useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import { SearchContext } from "./context";

export interface SearchButtonProps
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/form/textarea/TextareaCounter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cl from "clsx";
import React, { useEffect, useState } from "react";
import { BodyShort } from "../../typography";
import debounce from "../../util/debounce";
import { useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import type { TextareaProps } from "./Textarea";

interface Props {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";

export const DarksideGudiepanelIllustration = () => {
const translate = useI18n("GuidePanel");
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/guide-panel/Illustration.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";

export const DefaultIllustration = () => {
const translate = useI18n("GuidePanel");
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/help-text/HelpText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Popover, PopoverProps } from "../popover";
import { useThemeInternal } from "../theme/Theme";
import { composeEventHandlers } from "../util/composeEventHandlers";
import { useMergeRefs } from "../util/hooks/useMergeRefs";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";
import { HelpTextIcon } from "./HelpTextIcon";

export interface HelpTextProps
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/loader/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cl from "clsx";
import React, { SVGProps, forwardRef } from "react";
import { omit } from "../util";
import { useId } from "../util/hooks";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";

export interface LoaderProps extends Omit<SVGProps<SVGSVGElement>, "ref"> {
/**
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/modal/ModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cl from "clsx";
import React, { forwardRef } from "react";
import { XMarkIcon } from "@navikt/aksel-icons";
import { Button } from "../button";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";
import { useModalContext } from "./Modal.context";

export interface ModalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { forwardRef } from "react";
import { ChevronLeftIcon, ChevronRightIcon } from "@navikt/aksel-icons";
import { BodyShort, Heading } from "../typography";
import { useId } from "../util";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";
import PaginationItem, {
PaginationItemProps,
PaginationItemType,
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/progress-bar/ProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cl from "clsx";
import React, { HTMLAttributes, forwardRef, useEffect, useRef } from "react";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";

interface ProgressBarPropsBase
extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/table/ExpandableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ChevronDownIcon } from "@navikt/aksel-icons";
import { composeEventHandlers } from "../util/composeEventHandlers";
import { useId } from "../util/hooks";
import { useControllableState } from "../util/hooks/useControllableState";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";
import AnimateHeight from "./AnimateHeight";
import DataCell from "./DataCell";
import Row, { RowProps } from "./Row";
Expand Down
3 changes: 2 additions & 1 deletion @navikt/core/react/src/timeline/AxisLabels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
} from "date-fns";
import React from "react";
import { Detail } from "../typography/Detail";
import { TFunction, useDateLocale, useI18n } from "../util/i18n/i18n.context";
import { useDateLocale, useI18n } from "../util/i18n/i18n.hooks";
import { TFunction } from "../util/i18n/i18n.types";
import { useTimelineContext } from "./hooks/useTimelineContext";
import { isVisible } from "./utils";
import { horizontalPositionAndWidth } from "./utils/calc";
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/timeline/Pin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { format } from "date-fns";
import React, { forwardRef, useRef, useState } from "react";
import { useThemeInternal } from "../theme/Theme";
import { useMergeRefs } from "../util/hooks/useMergeRefs";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";
import { useTimelineContext } from "./hooks/useTimelineContext";
import { position } from "./utils/calc";
import { TimelineComponentTypes } from "./utils/types.internal";
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/timeline/TimelineRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cl from "clsx";
import { format } from "date-fns";
import React, { forwardRef } from "react";
import { BodyShort } from "../typography/BodyShort";
import { useI18n } from "../util/i18n/i18n.context";
import { useI18n } from "../util/i18n/i18n.hooks";
import { PeriodContext } from "./hooks/usePeriodContext";
import { useRowContext } from "./hooks/useRowContext";
import { useTimelineContext } from "./hooks/useTimelineContext";
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/timeline/period/ClickablePeriod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import cl from "clsx";
import React, { useRef, useState } from "react";
import { useThemeInternal } from "../../theme/Theme";
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
import { useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import { usePeriodContext } from "../hooks/usePeriodContext";
import { useRowContext } from "../hooks/useRowContext";
import { useTimelineContext } from "../hooks/useTimelineContext";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cl from "clsx";
import React from "react";
import { useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import { ariaLabel, getConditionalClasses } from "../utils/period";
import type { PeriodProps } from "./types";

Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/timeline/utils/period.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cl from "clsx";
import { format } from "date-fns";
import type { TFunction } from "../../util/i18n/i18n.context";
import type { TFunction } from "../../util/i18n/i18n.types";
import type { PeriodProps } from "../period/types";

export const getConditionalClasses = (
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/timeline/zoom/ZoomButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "date-fns";
import React, { forwardRef } from "react";
import { Detail } from "../../typography/Detail";
import { useI18n } from "../../util/i18n/i18n.context";
import { useI18n } from "../../util/i18n/i18n.hooks";
import { useTimelineContext } from "../hooks/useTimelineContext";

export interface TimelineZoomButtonProps {
Expand Down
Loading

0 comments on commit ef5e671

Please sign in to comment.