@navikt/ds-react 7.9.0 → 7.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/cjs/alert/Alert.js +2 -2
- package/cjs/alert/Alert.js.map +1 -1
- package/cjs/chips/Removable.js +2 -2
- package/cjs/chips/Removable.js.map +1 -1
- package/cjs/copybutton/CopyButton.js +2 -2
- package/cjs/copybutton/CopyButton.js.map +1 -1
- package/cjs/date/context/useDateTranslationContext.d.ts +1 -1
- package/cjs/date/datepicker/DatePicker.js +3 -3
- package/cjs/date/datepicker/DatePicker.js.map +1 -1
- package/cjs/date/datepicker/DatePickerStandalone.js +3 -3
- package/cjs/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/cjs/date/hooks/useDatepicker.js +2 -2
- package/cjs/date/hooks/useDatepicker.js.map +1 -1
- package/cjs/date/hooks/useMonthPicker.js +2 -2
- package/cjs/date/hooks/useMonthPicker.js.map +1 -1
- package/cjs/date/hooks/useRangeDatepicker.js +2 -2
- package/cjs/date/hooks/useRangeDatepicker.js.map +1 -1
- package/cjs/date/monthpicker/MonthPicker.js +3 -3
- package/cjs/date/monthpicker/MonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/MonthPickerStandalone.js +3 -3
- package/cjs/date/monthpicker/MonthPickerStandalone.js.map +1 -1
- package/cjs/date/parts/DateWrapper.d.ts +1 -1
- package/cjs/date/parts/DateWrapper.js +2 -2
- package/cjs/date/parts/DateWrapper.js.map +1 -1
- package/cjs/expansion-card/ExpansionCardHeader.js +2 -2
- package/cjs/expansion-card/ExpansionCardHeader.js.map +1 -1
- package/cjs/form/ReadOnlyIcon.js +2 -2
- package/cjs/form/ReadOnlyIcon.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/AddNewOption.js +2 -2
- package/cjs/form/combobox/FilteredOptions/AddNewOption.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/LoadingMessage.js +2 -2
- package/cjs/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js +2 -2
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -1
- package/cjs/form/error-summary/ErrorSummary.js +2 -2
- package/cjs/form/error-summary/ErrorSummary.js.map +1 -1
- package/cjs/form/file-upload/parts/dropzone/Dropzone.js +2 -2
- package/cjs/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
- package/cjs/form/file-upload/parts/item/Item.js +2 -2
- package/cjs/form/file-upload/parts/item/Item.js.map +1 -1
- package/cjs/form/form-progress/FormProgress.js +2 -2
- package/cjs/form/form-progress/FormProgress.js.map +1 -1
- package/cjs/form/form-summary/FormSummaryEditLink.js +2 -2
- package/cjs/form/form-summary/FormSummaryEditLink.js.map +1 -1
- package/cjs/form/search/Search.js +2 -2
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/form/search/SearchButton.js +2 -2
- package/cjs/form/search/SearchButton.js.map +1 -1
- package/cjs/form/textarea/TextareaCounter.js +2 -2
- package/cjs/form/textarea/TextareaCounter.js.map +1 -1
- package/cjs/guide-panel/Illustration.darkside.js +2 -2
- package/cjs/guide-panel/Illustration.darkside.js.map +1 -1
- package/cjs/guide-panel/Illustration.js +2 -2
- package/cjs/guide-panel/Illustration.js.map +1 -1
- package/cjs/help-text/HelpText.js +2 -2
- package/cjs/help-text/HelpText.js.map +1 -1
- package/cjs/link/stories/RandomIcon.d.ts +2 -0
- package/cjs/link/stories/RandomIcon.js +39 -0
- package/cjs/link/stories/RandomIcon.js.map +1 -0
- package/cjs/loader/Loader.js +2 -2
- package/cjs/loader/Loader.js.map +1 -1
- package/cjs/modal/ModalHeader.js +2 -2
- package/cjs/modal/ModalHeader.js.map +1 -1
- package/cjs/pagination/Pagination.js +2 -2
- package/cjs/pagination/Pagination.js.map +1 -1
- package/cjs/progress-bar/ProgressBar.js +2 -2
- package/cjs/progress-bar/ProgressBar.js.map +1 -1
- package/cjs/table/ExpandableRow.js +2 -2
- package/cjs/table/ExpandableRow.js.map +1 -1
- package/cjs/timeline/AxisLabels.js +3 -3
- package/cjs/timeline/AxisLabels.js.map +1 -1
- package/cjs/timeline/Pin.js +2 -2
- package/cjs/timeline/Pin.js.map +1 -1
- package/cjs/timeline/TimelineRow.js +2 -2
- package/cjs/timeline/TimelineRow.js.map +1 -1
- package/cjs/timeline/period/ClickablePeriod.js +2 -2
- package/cjs/timeline/period/ClickablePeriod.js.map +1 -1
- package/cjs/timeline/period/NonClickablePeriod.js +2 -2
- package/cjs/timeline/period/NonClickablePeriod.js.map +1 -1
- package/cjs/timeline/utils/period.d.ts +1 -1
- package/cjs/timeline/zoom/ZoomButton.js +2 -2
- package/cjs/timeline/zoom/ZoomButton.js.map +1 -1
- package/cjs/util/i18n/i18n.hooks.d.ts +4 -0
- package/cjs/util/i18n/{i18n.context.js → i18n.hooks.js} +3 -7
- package/cjs/util/i18n/i18n.hooks.js.map +1 -0
- package/cjs/util/i18n/i18n.types.d.ts +4 -0
- package/cjs/util/i18n/locales/nb.d.ts +81 -4
- package/cjs/util/i18n/locales/nb.js +81 -4
- package/cjs/util/i18n/locales/nb.js.map +1 -1
- package/esm/alert/Alert.js +1 -1
- package/esm/alert/Alert.js.map +1 -1
- package/esm/chips/Removable.js +1 -1
- package/esm/chips/Removable.js.map +1 -1
- package/esm/copybutton/CopyButton.js +1 -1
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/context/useDateTranslationContext.d.ts +1 -1
- package/esm/date/datepicker/DatePicker.js +1 -1
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.js +1 -1
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/esm/date/hooks/useDatepicker.js +1 -1
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.js +1 -1
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/hooks/useRangeDatepicker.js +1 -1
- package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.js +1 -1
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/date/monthpicker/MonthPickerStandalone.js +1 -1
- package/esm/date/monthpicker/MonthPickerStandalone.js.map +1 -1
- package/esm/date/parts/DateWrapper.d.ts +1 -1
- package/esm/date/parts/DateWrapper.js +1 -1
- package/esm/date/parts/DateWrapper.js.map +1 -1
- package/esm/expansion-card/ExpansionCardHeader.js +1 -1
- package/esm/expansion-card/ExpansionCardHeader.js.map +1 -1
- package/esm/form/ReadOnlyIcon.js +1 -1
- package/esm/form/ReadOnlyIcon.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/AddNewOption.js +1 -1
- package/esm/form/combobox/FilteredOptions/AddNewOption.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/LoadingMessage.js +1 -1
- package/esm/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js +1 -1
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -1
- package/esm/form/error-summary/ErrorSummary.js +1 -1
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/file-upload/parts/dropzone/Dropzone.js +1 -1
- package/esm/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
- package/esm/form/file-upload/parts/item/Item.js +1 -1
- package/esm/form/file-upload/parts/item/Item.js.map +1 -1
- package/esm/form/form-progress/FormProgress.js +1 -1
- package/esm/form/form-progress/FormProgress.js.map +1 -1
- package/esm/form/form-summary/FormSummaryEditLink.js +1 -1
- package/esm/form/form-summary/FormSummaryEditLink.js.map +1 -1
- package/esm/form/search/Search.js +1 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.js +1 -1
- package/esm/form/search/SearchButton.js.map +1 -1
- package/esm/form/textarea/TextareaCounter.js +1 -1
- package/esm/form/textarea/TextareaCounter.js.map +1 -1
- package/esm/guide-panel/Illustration.darkside.js +1 -1
- package/esm/guide-panel/Illustration.darkside.js.map +1 -1
- package/esm/guide-panel/Illustration.js +1 -1
- package/esm/guide-panel/Illustration.js.map +1 -1
- package/esm/help-text/HelpText.js +1 -1
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/link/stories/RandomIcon.d.ts +2 -0
- package/esm/link/stories/RandomIcon.js +9 -0
- package/esm/link/stories/RandomIcon.js.map +1 -0
- package/esm/loader/Loader.js +1 -1
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/ModalHeader.js +1 -1
- package/esm/modal/ModalHeader.js.map +1 -1
- package/esm/pagination/Pagination.js +1 -1
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/progress-bar/ProgressBar.js +1 -1
- package/esm/progress-bar/ProgressBar.js.map +1 -1
- package/esm/table/ExpandableRow.js +1 -1
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/timeline/AxisLabels.js +1 -1
- package/esm/timeline/AxisLabels.js.map +1 -1
- package/esm/timeline/Pin.js +1 -1
- package/esm/timeline/Pin.js.map +1 -1
- package/esm/timeline/TimelineRow.js +1 -1
- package/esm/timeline/TimelineRow.js.map +1 -1
- package/esm/timeline/period/ClickablePeriod.js +1 -1
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/timeline/period/NonClickablePeriod.js +1 -1
- package/esm/timeline/period/NonClickablePeriod.js.map +1 -1
- package/esm/timeline/utils/period.d.ts +1 -1
- package/esm/timeline/zoom/ZoomButton.js +1 -1
- package/esm/timeline/zoom/ZoomButton.js.map +1 -1
- package/esm/util/i18n/i18n.hooks.d.ts +4 -0
- package/esm/util/i18n/{i18n.context.js → i18n.hooks.js} +3 -7
- package/esm/util/i18n/{i18n.context.js.map → i18n.hooks.js.map} +1 -1
- package/esm/util/i18n/i18n.types.d.ts +4 -0
- package/esm/util/i18n/locales/nb.d.ts +81 -4
- package/esm/util/i18n/locales/nb.js +81 -4
- package/esm/util/i18n/locales/nb.js.map +1 -1
- package/package.json +17 -12
- package/src/alert/Alert.tsx +1 -1
- package/src/chips/Removable.tsx +1 -1
- package/src/copybutton/CopyButton.tsx +1 -1
- package/src/date/context/useDateTranslationContext.ts +1 -1
- package/src/date/datepicker/DatePicker.tsx +1 -1
- package/src/date/datepicker/DatePickerStandalone.tsx +1 -1
- package/src/date/datepicker/datepicker.test.tsx +2 -5
- package/src/date/hooks/useDatepicker.tsx +1 -1
- package/src/date/hooks/useMonthPicker.tsx +1 -1
- package/src/date/hooks/useRangeDatepicker.test.tsx +5 -10
- package/src/date/hooks/useRangeDatepicker.tsx +1 -1
- package/src/date/monthpicker/MonthPicker.tsx +1 -1
- package/src/date/monthpicker/MonthPickerStandalone.tsx +1 -1
- package/src/date/parts/DateWrapper.tsx +2 -1
- package/src/expansion-card/ExpansionCardHeader.tsx +1 -1
- package/src/form/ReadOnlyIcon.tsx +1 -1
- package/src/form/combobox/FilteredOptions/AddNewOption.tsx +1 -1
- package/src/form/combobox/FilteredOptions/LoadingMessage.tsx +1 -1
- package/src/form/combobox/FilteredOptions/MaxSelectedMessage.tsx +1 -1
- package/src/form/error-summary/ErrorSummary.tsx +1 -1
- package/src/form/file-upload/parts/dropzone/Dropzone.tsx +1 -1
- package/src/form/file-upload/parts/item/Item.tsx +1 -1
- package/src/form/form-progress/FormProgress.tsx +1 -1
- package/src/form/form-summary/FormSummaryEditLink.tsx +1 -1
- package/src/form/search/Search.tsx +1 -1
- package/src/form/search/SearchButton.tsx +1 -1
- package/src/form/textarea/TextareaCounter.tsx +1 -1
- package/src/guide-panel/Illustration.darkside.tsx +1 -1
- package/src/guide-panel/Illustration.tsx +1 -1
- package/src/help-text/HelpText.tsx +1 -1
- package/src/loader/Loader.tsx +1 -1
- package/src/modal/ModalHeader.tsx +1 -1
- package/src/pagination/Pagination.tsx +1 -1
- package/src/progress-bar/ProgressBar.tsx +1 -1
- package/src/table/ExpandableRow.tsx +1 -1
- package/src/tabs/Tabs.test.tsx +4 -12
- package/src/timeline/AxisLabels.tsx +2 -1
- package/src/timeline/Pin.tsx +1 -1
- package/src/timeline/TimelineRow.tsx +1 -1
- package/src/timeline/period/ClickablePeriod.tsx +1 -1
- package/src/timeline/period/NonClickablePeriod.tsx +1 -1
- package/src/timeline/utils/period.ts +1 -1
- package/src/timeline/zoom/ZoomButton.tsx +1 -1
- package/src/util/i18n/{i18n.context.test.tsx → i18n.hooks.test.tsx} +62 -3
- package/src/util/i18n/{i18n.context.ts → i18n.hooks.ts} +3 -19
- package/src/util/i18n/i18n.types.ts +12 -0
- package/cjs/modal/types.test-d.d.ts +0 -1
- package/cjs/modal/types.test-d.js +0 -67
- package/cjs/modal/types.test-d.js.map +0 -1
- package/cjs/util/i18n/i18n.context.d.ts +0 -9
- package/cjs/util/i18n/i18n.context.js.map +0 -1
- package/esm/modal/types.test-d.d.ts +0 -1
- package/esm/modal/types.test-d.js +0 -65
- package/esm/modal/types.test-d.js.map +0 -1
- package/esm/util/i18n/i18n.context.d.ts +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.1",
|
|
4
4
|
"description": "React components from the Norwegian Labour and Welfare Administration.",
|
|
5
5
|
"author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -603,10 +603,11 @@
|
|
|
603
603
|
"./package.json": "./package.json"
|
|
604
604
|
},
|
|
605
605
|
"scripts": {
|
|
606
|
-
"docgen": "
|
|
606
|
+
"docgen": "tsx ../../../scripts/docgen.ts",
|
|
607
|
+
"i18n-jsdoc": "tsx ./scripts/addJsdocToLocales.ts",
|
|
607
608
|
"write-packagejson": "echo '{\"type\": \"module\"}' > esm/package.json",
|
|
608
609
|
"clean": "rimraf cjs esm",
|
|
609
|
-
"build": "concurrently \"tsc -p tsconfig.build.json\" \"tsc -p tsconfig.esm.json && tsc-alias -p tsconfig.esm.json && yarn write-packagejson\" ",
|
|
610
|
+
"build": "yarn i18n-jsdoc && concurrently \"tsc -p tsconfig.build.json\" \"tsc -p tsconfig.esm.json && tsc-alias -p tsconfig.esm.json && yarn write-packagejson\" && yarn i18n-jsdoc --cleanup",
|
|
610
611
|
"watch": "tsc --watch -p tsconfig.esm.json",
|
|
611
612
|
"test": "TZ=UTC vitest run -c tests/vitest.config.ts",
|
|
612
613
|
"test:watch": "vitest watch"
|
|
@@ -614,20 +615,23 @@
|
|
|
614
615
|
"dependencies": {
|
|
615
616
|
"@floating-ui/react": "0.25.4",
|
|
616
617
|
"@floating-ui/react-dom": "^2.0.9",
|
|
617
|
-
"@navikt/aksel-icons": "^7.9.
|
|
618
|
-
"@navikt/ds-tokens": "^7.9.
|
|
618
|
+
"@navikt/aksel-icons": "^7.9.1",
|
|
619
|
+
"@navikt/ds-tokens": "^7.9.1",
|
|
619
620
|
"clsx": "^2.1.0",
|
|
620
621
|
"date-fns": "^3.0.0",
|
|
621
622
|
"react-day-picker": "8.10.1"
|
|
622
623
|
},
|
|
623
624
|
"devDependencies": {
|
|
624
|
-
"@testing-library/dom": "
|
|
625
|
-
"@testing-library/jest-dom": "^
|
|
626
|
-
"@testing-library/react": "^
|
|
627
|
-
"@testing-library/user-event": "^14.2
|
|
625
|
+
"@testing-library/dom": "10.4.0",
|
|
626
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
627
|
+
"@testing-library/react": "^16.1.0",
|
|
628
|
+
"@testing-library/user-event": "^14.5.2",
|
|
629
|
+
"@types/jscodeshift": "^0.11.11",
|
|
630
|
+
"aksel": "workspace:^",
|
|
628
631
|
"concurrently": "9.0.1",
|
|
629
632
|
"fast-glob": "3.2.11",
|
|
630
|
-
"
|
|
633
|
+
"jscodeshift": "^0.15.1",
|
|
634
|
+
"jsdom": "25.0.1",
|
|
631
635
|
"react-dom": "^18.0.0",
|
|
632
636
|
"react-router-dom": "^6.3.0",
|
|
633
637
|
"rimraf": "6.0.1",
|
|
@@ -635,7 +639,7 @@
|
|
|
635
639
|
"tsc-alias": "1.8.8",
|
|
636
640
|
"tsx": "^4.19.1",
|
|
637
641
|
"typescript": "5.5.4",
|
|
638
|
-
"vitest": "^1.
|
|
642
|
+
"vitest": "^2.1.8"
|
|
639
643
|
},
|
|
640
644
|
"peerDependencies": {
|
|
641
645
|
"@types/react": ">=17.0.30",
|
|
@@ -645,5 +649,6 @@
|
|
|
645
649
|
"@types/react": {
|
|
646
650
|
"optional": true
|
|
647
651
|
}
|
|
648
|
-
}
|
|
652
|
+
},
|
|
653
|
+
"_comment": "The 'aksel' dependency tells yarn to install the root deps when installing deps for this package. Helps make it possible to contribute without access to GPR."
|
|
649
654
|
}
|
package/src/alert/Alert.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "@navikt/aksel-icons";
|
|
10
10
|
import { Button } from "../button";
|
|
11
11
|
import { BodyLong } from "../typography";
|
|
12
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
12
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
13
13
|
|
|
14
14
|
export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
15
15
|
/**
|
package/src/chips/Removable.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
import { XMarkIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
5
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
5
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
6
6
|
|
|
7
7
|
export interface ChipsRemovableProps
|
|
8
8
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -10,7 +10,7 @@ import { CheckmarkIcon, FilesIcon } from "@navikt/aksel-icons";
|
|
|
10
10
|
import { Label } from "../typography";
|
|
11
11
|
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
12
12
|
import copy from "../util/copy";
|
|
13
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
13
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
14
14
|
|
|
15
15
|
export interface CopyButtonProps
|
|
16
16
|
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
@@ -5,7 +5,7 @@ import { DateRange, DayPicker, isMatch } from "react-day-picker";
|
|
|
5
5
|
import { omit } from "../../util";
|
|
6
6
|
import { useId } from "../../util/hooks";
|
|
7
7
|
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
8
|
-
import { useDateLocale, useI18n } from "../../util/i18n/i18n.
|
|
8
|
+
import { useDateLocale, useI18n } from "../../util/i18n/i18n.hooks";
|
|
9
9
|
import { DateInputContext, DateTranslationContextProvider } from "../context";
|
|
10
10
|
import { DatePickerInput } from "../parts/DateInput";
|
|
11
11
|
import { DateWrapper } from "../parts/DateWrapper";
|
|
@@ -3,7 +3,7 @@ import { isWeekend } from "date-fns";
|
|
|
3
3
|
import React, { forwardRef } from "react";
|
|
4
4
|
import { DateRange, DayPicker, isMatch } from "react-day-picker";
|
|
5
5
|
import { omit } from "../../util";
|
|
6
|
-
import { useDateLocale, useI18n } from "../../util/i18n/i18n.
|
|
6
|
+
import { useDateLocale, useI18n } from "../../util/i18n/i18n.hooks";
|
|
7
7
|
import { DateTranslationContextProvider } from "../context";
|
|
8
8
|
import { getLocaleFromString, getTranslations } from "../utils";
|
|
9
9
|
import Caption from "./parts/Caption";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
2
|
import userEvent from "@testing-library/user-event";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { describe, test } from "vitest";
|
|
@@ -23,9 +23,6 @@ describe("Render datepicker", () => {
|
|
|
23
23
|
test("Should not crash when e.target is window", async () => {
|
|
24
24
|
render(<App />);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
await act(async () => {
|
|
28
|
-
await userEvent.click(screen.getByText("Velg dato"));
|
|
29
|
-
});
|
|
26
|
+
await userEvent.click(screen.getByText("Velg dato"));
|
|
30
27
|
});
|
|
31
28
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { differenceInCalendarDays, isWeekend } from "date-fns";
|
|
2
2
|
import React, { useCallback, useState } from "react";
|
|
3
3
|
import { DayClickEventHandler, isMatch } from "react-day-picker";
|
|
4
|
-
import { useDateLocale } from "../../util/i18n/i18n.
|
|
4
|
+
import { useDateLocale } from "../../util/i18n/i18n.hooks";
|
|
5
5
|
import { DatePickerProps } from "../datepicker/DatePicker";
|
|
6
6
|
import { DateInputProps } from "../parts/DateInput";
|
|
7
7
|
import {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from "react";
|
|
2
|
-
import { useDateLocale } from "../../util/i18n/i18n.
|
|
2
|
+
import { useDateLocale } from "../../util/i18n/i18n.hooks";
|
|
3
3
|
import { MonthPickerProps } from "../monthpicker/types";
|
|
4
4
|
import { DateInputProps } from "../parts/DateInput";
|
|
5
5
|
import {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { act, render, screen } from "@testing-library/react";
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
3
2
|
import userEvent from "@testing-library/user-event";
|
|
4
3
|
import React from "react";
|
|
5
4
|
import { describe, expect, test } from "vitest";
|
|
@@ -29,10 +28,8 @@ describe("Writing in input sets correct values", () => {
|
|
|
29
28
|
|
|
30
29
|
const fraInput = screen.getByRole("textbox", { name: "Fra" });
|
|
31
30
|
const tilInput = screen.getByRole("textbox", { name: "Til" });
|
|
32
|
-
await
|
|
33
|
-
|
|
34
|
-
await userEvent.type(tilInput, "03.08.2022");
|
|
35
|
-
});
|
|
31
|
+
await userEvent.type(fraInput, "03.08.2022");
|
|
32
|
+
await userEvent.type(tilInput, "03.08.2022");
|
|
36
33
|
const res = screen.getByTitle("res");
|
|
37
34
|
expect(res.innerHTML).toEqual(
|
|
38
35
|
JSON.stringify({
|
|
@@ -47,10 +44,8 @@ describe("Writing in input sets correct values", () => {
|
|
|
47
44
|
|
|
48
45
|
const fraInput = screen.getByRole("textbox", { name: "Fra" });
|
|
49
46
|
const tilInput = screen.getByRole("textbox", { name: "Til" });
|
|
50
|
-
await
|
|
51
|
-
|
|
52
|
-
await userEvent.type(tilInput, "02.08.2022");
|
|
53
|
-
});
|
|
47
|
+
await userEvent.type(fraInput, "03.08.2022");
|
|
48
|
+
await userEvent.type(tilInput, "02.08.2022");
|
|
54
49
|
const res = screen.getByTitle("res");
|
|
55
50
|
expect(res.innerHTML).toEqual(
|
|
56
51
|
JSON.stringify({
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "date-fns";
|
|
6
6
|
import React, { useState } from "react";
|
|
7
7
|
import { DateRange, isMatch } from "react-day-picker";
|
|
8
|
-
import { useDateLocale } from "../../util/i18n/i18n.
|
|
8
|
+
import { useDateLocale } from "../../util/i18n/i18n.hooks";
|
|
9
9
|
import { DatePickerProps } from "../datepicker/DatePicker";
|
|
10
10
|
import { DateInputProps } from "../parts/DateInput";
|
|
11
11
|
import {
|
|
@@ -3,7 +3,7 @@ import React, { forwardRef, useState } from "react";
|
|
|
3
3
|
import { DayPickerProvider } from "react-day-picker";
|
|
4
4
|
import { useId } from "../../util/hooks";
|
|
5
5
|
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
6
|
-
import { useDateLocale, useI18n } from "../../util/i18n/i18n.
|
|
6
|
+
import { useDateLocale, useI18n } from "../../util/i18n/i18n.hooks";
|
|
7
7
|
import {
|
|
8
8
|
DateInputContext,
|
|
9
9
|
DateTranslationContextProvider,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef, useState } from "react";
|
|
3
3
|
import { DayPickerProvider } from "react-day-picker";
|
|
4
|
-
import { useDateLocale, useI18n } from "../../util/i18n/i18n.
|
|
4
|
+
import { useDateLocale, useI18n } from "../../util/i18n/i18n.hooks";
|
|
5
5
|
import {
|
|
6
6
|
DateTranslationContextProvider,
|
|
7
7
|
SharedMonthProvider,
|
|
@@ -5,7 +5,8 @@ import { Modal } from "../../modal";
|
|
|
5
5
|
import { useModalContext } from "../../modal/Modal.context";
|
|
6
6
|
import { Popover } from "../../popover";
|
|
7
7
|
import { useMedia } from "../../util/hooks";
|
|
8
|
-
import {
|
|
8
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
9
|
+
import { TFunction } from "../../util/i18n/i18n.types";
|
|
9
10
|
import { getGlobalTranslations } from "../utils";
|
|
10
11
|
|
|
11
12
|
const variantToLabel = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef, useContext } from "react";
|
|
3
3
|
import { ChevronDownIcon } from "@navikt/aksel-icons";
|
|
4
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
4
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
5
5
|
import { ExpansionCardContext } from "./context";
|
|
6
6
|
|
|
7
7
|
export interface ExpansionCardHeaderProps
|
|
@@ -2,7 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { PlusIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { BodyShort, Label } from "../../../typography";
|
|
5
|
-
import { useI18n } from "../../../util/i18n/i18n.
|
|
5
|
+
import { useI18n } from "../../../util/i18n/i18n.hooks";
|
|
6
6
|
import { useInputContext } from "../Input/Input.context";
|
|
7
7
|
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
8
8
|
import { isInList, toComboboxOption } from "../combobox-utils";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Loader } from "../../../loader";
|
|
3
|
-
import { useI18n } from "../../../util/i18n/i18n.
|
|
3
|
+
import { useI18n } from "../../../util/i18n/i18n.hooks";
|
|
4
4
|
import { useInputContext } from "../Input/Input.context";
|
|
5
5
|
import filteredOptionsUtil from "./filtered-options-util";
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { useI18n } from "../../../util/i18n/i18n.
|
|
2
|
+
import { useI18n } from "../../../util/i18n/i18n.hooks";
|
|
3
3
|
import { useInputContext } from "../Input/Input.context";
|
|
4
4
|
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
5
5
|
import filteredOptionsUtil from "./filtered-options-util";
|
|
@@ -3,7 +3,7 @@ import React, { HTMLAttributes, forwardRef, useRef } from "react";
|
|
|
3
3
|
import { BodyShort, Heading } from "../../typography";
|
|
4
4
|
import { composeEventHandlers } from "../../util/composeEventHandlers";
|
|
5
5
|
import { useMergeRefs } from "../../util/hooks";
|
|
6
|
-
import { useI18n } from "../../util/i18n/i18n.
|
|
6
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
7
7
|
import ErrorSummaryItem from "./ErrorSummaryItem";
|
|
8
8
|
|
|
9
9
|
export interface ErrorSummaryProps
|
|
@@ -5,7 +5,7 @@ import { Button } from "../../../../button";
|
|
|
5
5
|
import { BodyShort, ErrorMessage, Label } from "../../../../typography";
|
|
6
6
|
import { composeEventHandlers } from "../../../../util/composeEventHandlers";
|
|
7
7
|
import { useId } from "../../../../util/hooks";
|
|
8
|
-
import { useI18n } from "../../../../util/i18n/i18n.
|
|
8
|
+
import { useI18n } from "../../../../util/i18n/i18n.hooks";
|
|
9
9
|
import { omit } from "../../../../util/omit";
|
|
10
10
|
import { useFormField } from "../../../useFormField";
|
|
11
11
|
import { useFileUploadTranslation } from "../../FileUpload.context";
|
|
@@ -3,7 +3,7 @@ import React, { MouseEvent, forwardRef } from "react";
|
|
|
3
3
|
import { ExclamationmarkTriangleIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { BodyShort } from "../../../../typography";
|
|
5
5
|
import { OverridableComponent } from "../../../../util";
|
|
6
|
-
import { useI18n } from "../../../../util/i18n/i18n.
|
|
6
|
+
import { useI18n } from "../../../../util/i18n/i18n.hooks";
|
|
7
7
|
import { ComponentTranslation } from "../../../../util/i18n/i18n.types";
|
|
8
8
|
import { useFileUploadTranslation } from "../../FileUpload.context";
|
|
9
9
|
import { FileItem } from "./Item.types";
|
|
@@ -6,7 +6,7 @@ import { HStack } from "../../layout/stack";
|
|
|
6
6
|
import { ProgressBar } from "../../progress-bar";
|
|
7
7
|
import { Stepper, StepperStepProps } from "../../stepper";
|
|
8
8
|
import { BodyShort } from "../../typography";
|
|
9
|
-
import { useI18n } from "../../util/i18n/i18n.
|
|
9
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
10
10
|
import { ComponentTranslation } from "../../util/i18n/i18n.types";
|
|
11
11
|
|
|
12
12
|
export interface FormProgressProps
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
import { Link } from "../../link";
|
|
4
|
-
import { useI18n } from "../../util/i18n/i18n.
|
|
4
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
5
5
|
import { OverridableComponent } from "../../util/types";
|
|
6
6
|
|
|
7
7
|
export interface FormSummaryEditProps
|
|
@@ -11,7 +11,7 @@ import { useThemeInternal } from "../../theme/Theme";
|
|
|
11
11
|
import { BodyShort, ErrorMessage, Label } from "../../typography";
|
|
12
12
|
import { omit } from "../../util";
|
|
13
13
|
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
14
|
-
import { useI18n } from "../../util/i18n/i18n.
|
|
14
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
15
15
|
import { FormFieldProps, useFormField } from "../useFormField";
|
|
16
16
|
import SearchButton, { SearchButtonType } from "./SearchButton";
|
|
17
17
|
import { SearchContext } from "./context";
|
|
@@ -3,7 +3,7 @@ import React, { forwardRef, useContext } from "react";
|
|
|
3
3
|
import { MagnifyingGlassIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { Button, ButtonProps } from "../../button";
|
|
5
5
|
import { composeEventHandlers } from "../../util/composeEventHandlers";
|
|
6
|
-
import { useI18n } from "../../util/i18n/i18n.
|
|
6
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
7
7
|
import { SearchContext } from "./context";
|
|
8
8
|
|
|
9
9
|
export interface SearchButtonProps
|
|
@@ -2,7 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
3
|
import { BodyShort } from "../../typography";
|
|
4
4
|
import debounce from "../../util/debounce";
|
|
5
|
-
import { useI18n } from "../../util/i18n/i18n.
|
|
5
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
6
6
|
import type { TextareaProps } from "./Textarea";
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
@@ -4,7 +4,7 @@ import { Popover, PopoverProps } from "../popover";
|
|
|
4
4
|
import { useThemeInternal } from "../theme/Theme";
|
|
5
5
|
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
6
6
|
import { useMergeRefs } from "../util/hooks/useMergeRefs";
|
|
7
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
7
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
8
8
|
import { HelpTextIcon } from "./HelpTextIcon";
|
|
9
9
|
|
|
10
10
|
export interface HelpTextProps
|
package/src/loader/Loader.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import React, { SVGProps, forwardRef } from "react";
|
|
3
3
|
import { omit } from "../util";
|
|
4
4
|
import { useId } from "../util/hooks";
|
|
5
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
5
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
6
6
|
|
|
7
7
|
export interface LoaderProps extends Omit<SVGProps<SVGSVGElement>, "ref"> {
|
|
8
8
|
/**
|
|
@@ -2,7 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
import { XMarkIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { Button } from "../button";
|
|
5
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
5
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
6
6
|
import { useModalContext } from "./Modal.context";
|
|
7
7
|
|
|
8
8
|
export interface ModalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -3,7 +3,7 @@ import React, { forwardRef } from "react";
|
|
|
3
3
|
import { ChevronLeftIcon, ChevronRightIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { BodyShort, Heading } from "../typography";
|
|
5
5
|
import { useId } from "../util";
|
|
6
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
6
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
7
7
|
import PaginationItem, {
|
|
8
8
|
PaginationItemProps,
|
|
9
9
|
PaginationItemType,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { HTMLAttributes, forwardRef, useEffect, useRef } from "react";
|
|
3
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
3
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
4
4
|
|
|
5
5
|
interface ProgressBarPropsBase
|
|
6
6
|
extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
|
|
@@ -4,7 +4,7 @@ import { ChevronDownIcon } from "@navikt/aksel-icons";
|
|
|
4
4
|
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
5
5
|
import { useId } from "../util/hooks";
|
|
6
6
|
import { useControllableState } from "../util/hooks/useControllableState";
|
|
7
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
7
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
8
8
|
import AnimateHeight from "./AnimateHeight";
|
|
9
9
|
import DataCell from "./DataCell";
|
|
10
10
|
import Row, { RowProps } from "./Row";
|
package/src/tabs/Tabs.test.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
2
|
import userEvent from "@testing-library/user-event";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { describe, expect, test } from "vitest";
|
|
@@ -154,19 +154,11 @@ describe("Tabs", () => {
|
|
|
154
154
|
expect(screen.getByTestId("tab2")).toHaveFocus();
|
|
155
155
|
|
|
156
156
|
/* Move focus to tabPanel */
|
|
157
|
-
|
|
158
|
-
await act(async () => {
|
|
159
|
-
/* Tablist handles tabbing with setTimeout, so we need to use act */
|
|
160
|
-
await userEvent.tab();
|
|
161
|
-
});
|
|
162
|
-
|
|
157
|
+
await userEvent.tab();
|
|
163
158
|
expect(screen.getByTestId("tabpanel1")).toHaveFocus();
|
|
164
|
-
/* Move focus back to tablist, now tab1 should have focus */
|
|
165
159
|
|
|
166
|
-
|
|
167
|
-
await
|
|
168
|
-
await userEvent.tab({ shift: true });
|
|
169
|
-
});
|
|
160
|
+
/* Move focus back to tablist, now tab1 should have focus */
|
|
161
|
+
await userEvent.tab({ shift: true });
|
|
170
162
|
expect(screen.getByTestId("tab1")).toHaveFocus();
|
|
171
163
|
});
|
|
172
164
|
});
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
} from "date-fns";
|
|
17
17
|
import React from "react";
|
|
18
18
|
import { Detail } from "../typography/Detail";
|
|
19
|
-
import {
|
|
19
|
+
import { useDateLocale, useI18n } from "../util/i18n/i18n.hooks";
|
|
20
|
+
import { TFunction } from "../util/i18n/i18n.types";
|
|
20
21
|
import { useTimelineContext } from "./hooks/useTimelineContext";
|
|
21
22
|
import { isVisible } from "./utils";
|
|
22
23
|
import { horizontalPositionAndWidth } from "./utils/calc";
|
package/src/timeline/Pin.tsx
CHANGED
|
@@ -17,7 +17,7 @@ import { format } from "date-fns";
|
|
|
17
17
|
import React, { forwardRef, useRef, useState } from "react";
|
|
18
18
|
import { useThemeInternal } from "../theme/Theme";
|
|
19
19
|
import { useMergeRefs } from "../util/hooks/useMergeRefs";
|
|
20
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
20
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
21
21
|
import { useTimelineContext } from "./hooks/useTimelineContext";
|
|
22
22
|
import { position } from "./utils/calc";
|
|
23
23
|
import { TimelineComponentTypes } from "./utils/types.internal";
|
|
@@ -2,7 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import { format } from "date-fns";
|
|
3
3
|
import React, { forwardRef } from "react";
|
|
4
4
|
import { BodyShort } from "../typography/BodyShort";
|
|
5
|
-
import { useI18n } from "../util/i18n/i18n.
|
|
5
|
+
import { useI18n } from "../util/i18n/i18n.hooks";
|
|
6
6
|
import { PeriodContext } from "./hooks/usePeriodContext";
|
|
7
7
|
import { useRowContext } from "./hooks/useRowContext";
|
|
8
8
|
import { useTimelineContext } from "./hooks/useTimelineContext";
|
|
@@ -17,7 +17,7 @@ import cl from "clsx";
|
|
|
17
17
|
import React, { useRef, useState } from "react";
|
|
18
18
|
import { useThemeInternal } from "../../theme/Theme";
|
|
19
19
|
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
20
|
-
import { useI18n } from "../../util/i18n/i18n.
|
|
20
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
21
21
|
import { usePeriodContext } from "../hooks/usePeriodContext";
|
|
22
22
|
import { useRowContext } from "../hooks/useRowContext";
|
|
23
23
|
import { useTimelineContext } from "../hooks/useTimelineContext";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { useI18n } from "../../util/i18n/i18n.
|
|
3
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
4
4
|
import { ariaLabel, getConditionalClasses } from "../utils/period";
|
|
5
5
|
import type { PeriodProps } from "./types";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import { format } from "date-fns";
|
|
3
|
-
import type { TFunction } from "../../util/i18n/i18n.
|
|
3
|
+
import type { TFunction } from "../../util/i18n/i18n.types";
|
|
4
4
|
import type { PeriodProps } from "../period/types";
|
|
5
5
|
|
|
6
6
|
export const getConditionalClasses = (
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "date-fns";
|
|
9
9
|
import React, { forwardRef } from "react";
|
|
10
10
|
import { Detail } from "../../typography/Detail";
|
|
11
|
-
import { useI18n } from "../../util/i18n/i18n.
|
|
11
|
+
import { useI18n } from "../../util/i18n/i18n.hooks";
|
|
12
12
|
import { useTimelineContext } from "../hooks/useTimelineContext";
|
|
13
13
|
|
|
14
14
|
export interface TimelineZoomButtonProps {
|
|
@@ -2,9 +2,8 @@ import { renderHook } from "@testing-library/react";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { describe, expect, test } from "vitest";
|
|
4
4
|
import { Provider } from "../../provider";
|
|
5
|
-
import { useI18n } from "./i18n.
|
|
6
|
-
import en from "./locales
|
|
7
|
-
import nb from "./locales/nb";
|
|
5
|
+
import { useDateLocale, useI18n } from "./i18n.hooks";
|
|
6
|
+
import { en, nb, nn } from "./locales";
|
|
8
7
|
|
|
9
8
|
describe("useI18n", () => {
|
|
10
9
|
test("should throw error if key is not found", () => {
|
|
@@ -112,3 +111,63 @@ describe("useI18n", () => {
|
|
|
112
111
|
expect(() => translate("item.uploading", { other: "John" })).toThrowError();
|
|
113
112
|
});
|
|
114
113
|
});
|
|
114
|
+
|
|
115
|
+
describe("useDateLocale", () => {
|
|
116
|
+
test("should return the default NB date locale when Provider is not used", () => {
|
|
117
|
+
const { result } = renderHook(() => useDateLocale());
|
|
118
|
+
const dateLocale = result.current;
|
|
119
|
+
expect(dateLocale).toBe(nb.global.dateLocale);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("should return the default NB date locale when Provider is used without the locale prop", () => {
|
|
123
|
+
const { result } = renderHook(() => useDateLocale(), {
|
|
124
|
+
wrapper: ({ children }) => <Provider>{children}</Provider>,
|
|
125
|
+
});
|
|
126
|
+
const dateLocale = result.current;
|
|
127
|
+
expect(dateLocale).toBe(nb.global.dateLocale);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("should return date locale from context.locale when using Provider with just locale prop", () => {
|
|
131
|
+
const { result } = renderHook(() => useDateLocale(), {
|
|
132
|
+
wrapper: ({ children }) => <Provider locale={en}>{children}</Provider>,
|
|
133
|
+
});
|
|
134
|
+
const dateLocale = result.current;
|
|
135
|
+
expect(dateLocale).toBe(en.global.dateLocale);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("should return date locale from context.locale when it does not exist in translations", () => {
|
|
139
|
+
const { result } = renderHook(() => useDateLocale(), {
|
|
140
|
+
wrapper: ({ children }) => (
|
|
141
|
+
<Provider locale={en} translations={{ global: {} }}>
|
|
142
|
+
{children}
|
|
143
|
+
</Provider>
|
|
144
|
+
),
|
|
145
|
+
});
|
|
146
|
+
const dateLocale = result.current;
|
|
147
|
+
expect(dateLocale).toBe(en.global.dateLocale);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("should return date locale from context.translations", () => {
|
|
151
|
+
const { result } = renderHook(() => useDateLocale(), {
|
|
152
|
+
wrapper: ({ children }) => (
|
|
153
|
+
<Provider locale={en} translations={nn}>
|
|
154
|
+
{children}
|
|
155
|
+
</Provider>
|
|
156
|
+
),
|
|
157
|
+
});
|
|
158
|
+
const dateLocale = result.current;
|
|
159
|
+
expect(dateLocale).toBe(nn.global.dateLocale);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("should return date locale from second object in context.translations", () => {
|
|
163
|
+
const { result } = renderHook(() => useDateLocale(), {
|
|
164
|
+
wrapper: ({ children }) => (
|
|
165
|
+
<Provider locale={nb} translations={[{}, nn, en]}>
|
|
166
|
+
{children}
|
|
167
|
+
</Provider>
|
|
168
|
+
),
|
|
169
|
+
});
|
|
170
|
+
const dateLocale = result.current;
|
|
171
|
+
expect(dateLocale).toBe(nn.global.dateLocale);
|
|
172
|
+
});
|
|
173
|
+
});
|