@navikt/ds-react 7.6.0 → 7.8.0
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/cjs/chips/Removable.d.ts +0 -5
- package/cjs/chips/Removable.js +2 -2
- package/cjs/chips/Removable.js.map +1 -1
- package/cjs/copybutton/CopyButton.d.ts +1 -6
- package/cjs/copybutton/CopyButton.js +8 -6
- package/cjs/copybutton/CopyButton.js.map +1 -1
- package/cjs/date/context/index.d.ts +2 -1
- package/cjs/date/context/index.js +5 -2
- package/cjs/date/context/index.js.map +1 -1
- package/cjs/date/context/useDateInputContext.d.ts +3 -3
- package/cjs/date/context/useDateInputContext.js +4 -4
- package/cjs/date/context/useDateInputContext.js.map +1 -1
- package/cjs/date/context/useDateTranslationContext.d.ts +8 -0
- package/cjs/date/context/useDateTranslationContext.js +7 -0
- package/cjs/date/context/useDateTranslationContext.js.map +1 -0
- package/cjs/date/datepicker/DatePicker.js +18 -16
- package/cjs/date/datepicker/DatePicker.js.map +1 -1
- package/cjs/date/datepicker/DatePickerStandalone.js +17 -14
- package/cjs/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/cjs/date/datepicker/parts/Caption.js +2 -3
- package/cjs/date/datepicker/parts/Caption.js.map +1 -1
- package/cjs/date/datepicker/parts/DropdownCaption.js +2 -2
- package/cjs/date/datepicker/parts/DropdownCaption.js.map +1 -1
- package/cjs/date/datepicker/parts/WeekNumber.js +14 -6
- package/cjs/date/datepicker/parts/WeekNumber.js.map +1 -1
- package/cjs/date/datepicker/parts/WeekRow.js +2 -3
- package/cjs/date/datepicker/parts/WeekRow.js.map +1 -1
- package/cjs/date/datepicker/types.d.ts +8 -0
- package/cjs/date/monthpicker/MonthCaption.js +1 -3
- package/cjs/date/monthpicker/MonthCaption.js.map +1 -1
- package/cjs/date/monthpicker/MonthPicker.js +30 -28
- package/cjs/date/monthpicker/MonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/MonthPickerStandalone.js +16 -12
- package/cjs/date/monthpicker/MonthPickerStandalone.js.map +1 -1
- package/cjs/date/monthpicker/types.d.ts +8 -0
- package/cjs/date/parts/DateInput.js +1 -2
- package/cjs/date/parts/DateInput.js.map +1 -1
- package/cjs/date/parts/DateWrapper.d.ts +3 -1
- package/cjs/date/parts/DateWrapper.js +3 -3
- package/cjs/date/parts/DateWrapper.js.map +1 -1
- package/cjs/date/utils/index.d.ts +1 -1
- package/cjs/date/utils/index.js +2 -1
- package/cjs/date/utils/index.js.map +1 -1
- package/cjs/date/utils/locale.d.ts +12 -2
- package/cjs/date/utils/locale.js +18 -2
- package/cjs/date/utils/locale.js.map +1 -1
- package/cjs/form/combobox/Combobox.d.ts +1 -1
- package/cjs/form/combobox/ComboboxWrapper.js +6 -6
- package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/AddNewOption.js +3 -1
- package/cjs/form/combobox/FilteredOptions/AddNewOption.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptionsItem.js +1 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptionsItem.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/LoadingMessage.js +3 -1
- package/cjs/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.d.ts +1 -1
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js +6 -5
- package/cjs/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +4 -4
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/cjs/form/combobox/Input/Input.context.d.ts +1 -1
- package/cjs/form/combobox/Input/Input.context.js.map +1 -1
- package/cjs/form/combobox/Input/Input.js +1 -1
- package/cjs/form/combobox/Input/Input.js.map +1 -1
- package/cjs/form/combobox/Input/InputController.d.ts +1 -1
- package/cjs/form/combobox/Input/InputController.js +10 -10
- package/cjs/form/combobox/Input/InputController.js.map +1 -1
- package/cjs/form/combobox/Input/ToggleListButton.d.ts +1 -4
- package/cjs/form/combobox/Input/ToggleListButton.js +3 -5
- package/cjs/form/combobox/Input/ToggleListButton.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +8 -6
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +2 -1
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +9 -5
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/cjs/form/combobox/types.d.ts +7 -22
- package/cjs/form/form-summary/FormSummaryEditLink.js +4 -2
- package/cjs/form/form-summary/FormSummaryEditLink.js.map +1 -1
- package/cjs/form/search/Search.d.ts +2 -1
- package/cjs/form/search/Search.js +8 -3
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/form/textarea/Textarea.d.ts +1 -0
- package/cjs/form/textarea/Textarea.js.map +1 -1
- package/cjs/guide-panel/GuidePanel.js +11 -3
- package/cjs/guide-panel/GuidePanel.js.map +1 -1
- package/cjs/guide-panel/Illustration.d.ts +2 -8
- package/cjs/guide-panel/Illustration.darkside.d.ts +2 -0
- package/cjs/guide-panel/Illustration.darkside.js +30 -0
- package/cjs/guide-panel/Illustration.darkside.js.map +1 -0
- package/cjs/guide-panel/Illustration.js +4 -18
- package/cjs/guide-panel/Illustration.js.map +1 -1
- package/cjs/guide-panel/index.d.ts +0 -1
- package/cjs/guide-panel/index.js +1 -3
- package/cjs/guide-panel/index.js.map +1 -1
- package/cjs/help-text/HelpText.d.ts +1 -1
- package/cjs/help-text/HelpText.js +6 -3
- package/cjs/help-text/HelpText.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +2 -3
- package/cjs/index.js.map +1 -1
- package/cjs/internal-header/InternalHeaderButton.d.ts +1 -1
- package/cjs/internal-header/InternalHeaderUserButton.d.ts +1 -1
- package/cjs/internal-header/InternalHeaderUserButton.js +1 -1
- package/cjs/internal-header/InternalHeaderUserButton.js.map +1 -1
- package/cjs/layout/base/BasePrimitive.js +4 -1
- package/cjs/layout/base/BasePrimitive.js.map +1 -1
- package/cjs/layout/bleed/Bleed.js +5 -2
- package/cjs/layout/bleed/Bleed.js.map +1 -1
- package/cjs/layout/box/Box.d.ts +6 -1
- package/cjs/layout/box/Box.darkside.d.ts +70 -0
- package/cjs/layout/box/Box.darkside.js +98 -0
- package/cjs/layout/box/Box.darkside.js.map +1 -0
- package/cjs/layout/box/Box.js +19 -6
- package/cjs/layout/box/Box.js.map +1 -1
- package/cjs/layout/box/index.js +2 -0
- package/cjs/layout/box/index.js.map +1 -1
- package/cjs/layout/grid/HGrid.js +4 -1
- package/cjs/layout/grid/HGrid.js.map +1 -1
- package/cjs/layout/page/Page.d.ts +1 -0
- package/cjs/layout/page/Page.js +5 -0
- package/cjs/layout/page/Page.js.map +1 -1
- package/cjs/layout/stack/Stack.js +4 -1
- package/cjs/layout/stack/Stack.js.map +1 -1
- package/cjs/layout/utilities/css.d.ts +2 -2
- package/cjs/layout/utilities/css.js +8 -9
- package/cjs/layout/utilities/css.js.map +1 -1
- package/cjs/layout/utilities/types.d.ts +10 -0
- package/cjs/modal/Modal.js +1 -1
- package/cjs/modal/Modal.js.map +1 -1
- package/cjs/modal/ModalHeader.js +1 -1
- package/cjs/modal/ModalHeader.js.map +1 -1
- package/cjs/popover/Popover.js +1 -1
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/provider/Provider.d.ts +35 -10
- package/cjs/provider/Provider.js +13 -14
- package/cjs/provider/Provider.js.map +1 -1
- package/cjs/table/ExpandableRow.js +3 -3
- package/cjs/table/ExpandableRow.js.map +1 -1
- package/cjs/tabs/Tabs.context.d.ts +1 -1
- package/cjs/timeline/Timeline.d.ts +1 -0
- package/cjs/timeline/Timeline.js.map +1 -1
- package/cjs/util/i18n/i18n.context.d.ts +1 -1
- package/cjs/util/i18n/i18n.context.js +15 -14
- package/cjs/util/i18n/i18n.context.js.map +1 -1
- package/cjs/util/i18n/locales/en.d.ts +51 -36
- package/cjs/util/i18n/locales/en.js +52 -37
- package/cjs/util/i18n/locales/en.js.map +1 -1
- package/cjs/util/i18n/locales/index.d.ts +3 -0
- package/cjs/util/i18n/locales/index.js +14 -0
- package/cjs/util/i18n/locales/index.js.map +1 -0
- package/cjs/util/i18n/locales/nb.d.ts +54 -37
- package/cjs/util/i18n/locales/nb.js +56 -39
- package/cjs/util/i18n/locales/nb.js.map +1 -1
- package/cjs/util/i18n/locales/nn.d.ts +51 -36
- package/cjs/util/i18n/locales/nn.js +52 -37
- package/cjs/util/i18n/locales/nn.js.map +1 -1
- package/esm/chips/Removable.d.ts +0 -5
- package/esm/chips/Removable.js +2 -2
- package/esm/chips/Removable.js.map +1 -1
- package/esm/copybutton/CopyButton.d.ts +1 -6
- package/esm/copybutton/CopyButton.js +8 -6
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/context/index.d.ts +2 -1
- package/esm/date/context/index.js +2 -1
- package/esm/date/context/index.js.map +1 -1
- package/esm/date/context/useDateInputContext.d.ts +3 -3
- package/esm/date/context/useDateInputContext.js +3 -3
- package/esm/date/context/useDateInputContext.js.map +1 -1
- package/esm/date/context/useDateTranslationContext.d.ts +8 -0
- package/esm/date/context/useDateTranslationContext.js +3 -0
- package/esm/date/context/useDateTranslationContext.js.map +1 -0
- package/esm/date/datepicker/DatePicker.js +21 -19
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.js +19 -16
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/esm/date/datepicker/parts/Caption.js +2 -3
- package/esm/date/datepicker/parts/Caption.js.map +1 -1
- package/esm/date/datepicker/parts/DropdownCaption.js +3 -3
- package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
- package/esm/date/datepicker/parts/WeekNumber.js +15 -7
- package/esm/date/datepicker/parts/WeekNumber.js.map +1 -1
- package/esm/date/datepicker/parts/WeekRow.js +2 -3
- package/esm/date/datepicker/parts/WeekRow.js.map +1 -1
- package/esm/date/datepicker/types.d.ts +8 -0
- package/esm/date/monthpicker/MonthCaption.js +2 -4
- package/esm/date/monthpicker/MonthCaption.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.js +33 -31
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/date/monthpicker/MonthPickerStandalone.js +18 -14
- package/esm/date/monthpicker/MonthPickerStandalone.js.map +1 -1
- package/esm/date/monthpicker/types.d.ts +8 -0
- package/esm/date/parts/DateInput.js +2 -3
- package/esm/date/parts/DateInput.js.map +1 -1
- package/esm/date/parts/DateWrapper.d.ts +3 -1
- package/esm/date/parts/DateWrapper.js +4 -4
- package/esm/date/parts/DateWrapper.js.map +1 -1
- package/esm/date/utils/index.d.ts +1 -1
- package/esm/date/utils/index.js +1 -1
- package/esm/date/utils/index.js.map +1 -1
- package/esm/date/utils/locale.d.ts +12 -2
- package/esm/date/utils/locale.js +16 -1
- package/esm/date/utils/locale.js.map +1 -1
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/ComboboxWrapper.js +6 -6
- package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/AddNewOption.js +3 -1
- package/esm/form/combobox/FilteredOptions/AddNewOption.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptionsItem.js +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptionsItem.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/LoadingMessage.js +3 -1
- package/esm/form/combobox/FilteredOptions/LoadingMessage.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.d.ts +1 -1
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js +6 -5
- package/esm/form/combobox/FilteredOptions/MaxSelectedMessage.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +4 -4
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/esm/form/combobox/Input/Input.context.d.ts +1 -1
- package/esm/form/combobox/Input/Input.context.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +1 -1
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/combobox/Input/InputController.d.ts +1 -1
- package/esm/form/combobox/Input/InputController.js +10 -10
- package/esm/form/combobox/Input/InputController.js.map +1 -1
- package/esm/form/combobox/Input/ToggleListButton.d.ts +1 -4
- package/esm/form/combobox/Input/ToggleListButton.js +3 -5
- package/esm/form/combobox/Input/ToggleListButton.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js +8 -6
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +2 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +9 -5
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/esm/form/combobox/types.d.ts +7 -22
- package/esm/form/form-summary/FormSummaryEditLink.js +4 -2
- package/esm/form/form-summary/FormSummaryEditLink.js.map +1 -1
- package/esm/form/search/Search.d.ts +2 -1
- package/esm/form/search/Search.js +8 -3
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/textarea/Textarea.d.ts +1 -0
- package/esm/form/textarea/Textarea.js.map +1 -1
- package/esm/guide-panel/GuidePanel.js +11 -3
- package/esm/guide-panel/GuidePanel.js.map +1 -1
- package/esm/guide-panel/Illustration.d.ts +2 -8
- package/esm/guide-panel/Illustration.darkside.d.ts +2 -0
- package/esm/guide-panel/Illustration.darkside.js +23 -0
- package/esm/guide-panel/Illustration.darkside.js.map +1 -0
- package/esm/guide-panel/Illustration.js +4 -18
- package/esm/guide-panel/Illustration.js.map +1 -1
- package/esm/guide-panel/index.d.ts +0 -1
- package/esm/guide-panel/index.js +0 -1
- package/esm/guide-panel/index.js.map +1 -1
- package/esm/help-text/HelpText.d.ts +1 -1
- package/esm/help-text/HelpText.js +6 -3
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/internal-header/InternalHeaderButton.d.ts +1 -1
- package/esm/internal-header/InternalHeaderUserButton.d.ts +1 -1
- package/esm/internal-header/InternalHeaderUserButton.js +1 -1
- package/esm/internal-header/InternalHeaderUserButton.js.map +1 -1
- package/esm/layout/base/BasePrimitive.js +4 -1
- package/esm/layout/base/BasePrimitive.js.map +1 -1
- package/esm/layout/bleed/Bleed.js +5 -2
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/box/Box.d.ts +6 -1
- package/esm/layout/box/Box.darkside.d.ts +70 -0
- package/esm/layout/box/Box.darkside.js +69 -0
- package/esm/layout/box/Box.darkside.js.map +1 -0
- package/esm/layout/box/Box.js +18 -5
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/grid/HGrid.js +4 -1
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.d.ts +1 -0
- package/esm/layout/page/Page.js +5 -0
- package/esm/layout/page/Page.js.map +1 -1
- package/esm/layout/stack/Stack.js +4 -1
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/layout/utilities/css.d.ts +2 -2
- package/esm/layout/utilities/css.js +8 -9
- package/esm/layout/utilities/css.js.map +1 -1
- package/esm/layout/utilities/types.d.ts +10 -0
- package/esm/modal/Modal.js +2 -2
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalHeader.js +1 -1
- package/esm/modal/ModalHeader.js.map +1 -1
- package/esm/popover/Popover.js +2 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/provider/Provider.d.ts +35 -10
- package/esm/provider/Provider.js +11 -15
- package/esm/provider/Provider.js.map +1 -1
- package/esm/table/ExpandableRow.js +3 -3
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/tabs/Tabs.context.d.ts +1 -1
- package/esm/timeline/Timeline.d.ts +1 -0
- package/esm/timeline/Timeline.js.map +1 -1
- package/esm/util/i18n/i18n.context.d.ts +1 -1
- package/esm/util/i18n/i18n.context.js +15 -14
- package/esm/util/i18n/i18n.context.js.map +1 -1
- package/esm/util/i18n/locales/en.d.ts +51 -36
- package/esm/util/i18n/locales/en.js +52 -37
- package/esm/util/i18n/locales/en.js.map +1 -1
- package/esm/util/i18n/locales/index.d.ts +3 -0
- package/esm/util/i18n/locales/index.js +5 -0
- package/esm/util/i18n/locales/index.js.map +1 -0
- package/esm/util/i18n/locales/nb.d.ts +54 -37
- package/esm/util/i18n/locales/nb.js +56 -39
- package/esm/util/i18n/locales/nb.js.map +1 -1
- package/esm/util/i18n/locales/nn.d.ts +51 -36
- package/esm/util/i18n/locales/nn.js +52 -37
- package/esm/util/i18n/locales/nn.js.map +1 -1
- package/package.json +13 -3
- package/src/chips/Removable.tsx +1 -9
- package/src/copybutton/CopyButton.tsx +14 -30
- package/src/date/context/index.ts +5 -1
- package/src/date/context/useDateInputContext.tsx +6 -4
- package/src/date/context/useDateTranslationContext.ts +9 -0
- package/src/date/datepicker/DatePicker.tsx +41 -32
- package/src/date/datepicker/DatePickerStandalone.tsx +46 -37
- package/src/date/datepicker/parts/Caption.tsx +2 -3
- package/src/date/datepicker/parts/DropdownCaption.tsx +3 -3
- package/src/date/datepicker/parts/WeekNumber.tsx +34 -15
- package/src/date/datepicker/parts/WeekRow.tsx +2 -3
- package/src/date/datepicker/types.ts +8 -0
- package/src/date/monthpicker/MonthCaption.tsx +2 -4
- package/src/date/monthpicker/MonthPicker.tsx +67 -54
- package/src/date/monthpicker/MonthPickerStandalone.tsx +39 -26
- package/src/date/monthpicker/types.ts +8 -0
- package/src/date/parts/DateInput.tsx +2 -3
- package/src/date/parts/DateWrapper.tsx +6 -4
- package/src/date/utils/index.ts +5 -1
- package/src/date/utils/locale.ts +17 -1
- package/src/form/combobox/ComboboxWrapper.tsx +6 -6
- package/src/form/combobox/FilteredOptions/AddNewOption.tsx +3 -1
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +4 -4
- package/src/form/combobox/FilteredOptions/FilteredOptionsItem.tsx +1 -1
- package/src/form/combobox/FilteredOptions/LoadingMessage.tsx +3 -1
- package/src/form/combobox/FilteredOptions/MaxSelectedMessage.tsx +6 -6
- package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +4 -4
- package/src/form/combobox/Input/Input.context.tsx +3 -3
- package/src/form/combobox/Input/Input.tsx +1 -1
- package/src/form/combobox/Input/InputController.tsx +5 -27
- package/src/form/combobox/Input/ToggleListButton.tsx +8 -24
- package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +17 -11
- package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +10 -7
- package/src/form/combobox/__tests__/combobox.test.tsx +2 -1
- package/src/form/combobox/types.ts +11 -24
- package/src/form/form-summary/FormSummaryEditLink.tsx +7 -6
- package/src/form/search/Search.tsx +35 -13
- package/src/form/textarea/Textarea.tsx +1 -0
- package/src/guide-panel/GuidePanel.tsx +59 -15
- package/src/guide-panel/Illustration.darkside.tsx +96 -0
- package/src/guide-panel/Illustration.tsx +5 -22
- package/src/guide-panel/index.ts +0 -1
- package/src/help-text/HelpText.tsx +8 -6
- package/src/index.ts +1 -5
- package/src/internal-header/InternalHeaderButton.tsx +1 -1
- package/src/internal-header/InternalHeaderUserButton.tsx +2 -2
- package/src/layout/base/BasePrimitive.tsx +29 -25
- package/src/layout/bleed/Bleed.tsx +8 -0
- package/src/layout/box/Box.darkside.tsx +154 -0
- package/src/layout/box/Box.tsx +90 -61
- package/src/layout/box/index.ts +3 -0
- package/src/layout/grid/HGrid.tsx +7 -3
- package/src/layout/page/Page.tsx +10 -0
- package/src/layout/stack/Stack.tsx +8 -4
- package/src/layout/utilities/css.ts +18 -12
- package/src/layout/utilities/types.ts +24 -0
- package/src/modal/Modal.tsx +2 -2
- package/src/modal/ModalHeader.tsx +1 -1
- package/src/popover/Popover.tsx +2 -2
- package/src/provider/Provider.tsx +56 -13
- package/src/table/ExpandableRow.tsx +10 -3
- package/src/timeline/Timeline.tsx +1 -0
- package/src/util/i18n/i18n.context.test.tsx +29 -8
- package/src/util/i18n/i18n.context.ts +15 -14
- package/src/util/i18n/locales/en.ts +52 -37
- package/src/util/i18n/locales/index.ts +4 -0
- package/src/util/i18n/locales/nb.ts +56 -39
- package/src/util/i18n/locales/nn.ts +52 -37
- package/cjs/provider/i18n/LanguageProvider.d.ts +0 -26
- package/cjs/provider/i18n/LanguageProvider.js +0 -54
- package/cjs/provider/i18n/LanguageProvider.js.map +0 -1
- package/esm/provider/i18n/LanguageProvider.d.ts +0 -26
- package/esm/provider/i18n/LanguageProvider.js +0 -23
- package/esm/provider/i18n/LanguageProvider.js.map +0 -1
- package/src/provider/i18n/LanguageProvider.tsx +0 -49
package/src/layout/box/Box.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
+
import { UNSAFE_useAkselTheme } from "../../provider";
|
|
3
4
|
import { Slot } from "../../slot/Slot";
|
|
4
5
|
import { omit } from "../../util";
|
|
5
6
|
import { OverridableComponent } from "../../util/types";
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
SpaceDelimitedAttribute,
|
|
19
20
|
SurfaceColorToken,
|
|
20
21
|
} from "../utilities/types";
|
|
22
|
+
import BoxNew from "./Box.darkside";
|
|
21
23
|
|
|
22
24
|
export type BoxProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
23
25
|
/**
|
|
@@ -55,6 +57,11 @@ export type BoxProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
55
57
|
} & PrimitiveProps &
|
|
56
58
|
PrimitiveAsChildProps;
|
|
57
59
|
|
|
60
|
+
interface BoxComponentType
|
|
61
|
+
extends OverridableComponent<BoxProps, HTMLDivElement> {
|
|
62
|
+
New: typeof BoxNew;
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
/**
|
|
59
66
|
* Foundational Layout-primitive for generic encapsulation & styling.
|
|
60
67
|
*
|
|
@@ -82,69 +89,91 @@ export type BoxProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
82
89
|
* </Box>
|
|
83
90
|
* </VStack>
|
|
84
91
|
*/
|
|
85
|
-
export const
|
|
86
|
-
(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
shadow,
|
|
96
|
-
style: _style,
|
|
97
|
-
asChild,
|
|
98
|
-
...rest
|
|
99
|
-
},
|
|
100
|
-
ref,
|
|
101
|
-
) => {
|
|
102
|
-
const style: React.CSSProperties = {
|
|
103
|
-
..._style,
|
|
104
|
-
"--__ac-box-background": background
|
|
105
|
-
? `var(--a-${background})`
|
|
106
|
-
: undefined,
|
|
107
|
-
"--__ac-box-shadow": shadow ? `var(--a-shadow-${shadow})` : undefined,
|
|
108
|
-
"--__ac-box-border-color": borderColor
|
|
109
|
-
? `var(--a-${borderColor})`
|
|
110
|
-
: undefined,
|
|
111
|
-
"--__ac-box-border-width": borderWidth
|
|
112
|
-
? borderWidth
|
|
113
|
-
.split(" ")
|
|
114
|
-
.map((x) => `${x}px`)
|
|
115
|
-
.join(" ")
|
|
116
|
-
: undefined,
|
|
117
|
-
...getResponsiveProps(
|
|
118
|
-
"box",
|
|
119
|
-
"border-radius",
|
|
120
|
-
"border-radius",
|
|
92
|
+
export const BoxComponent: OverridableComponent<BoxProps, HTMLDivElement> =
|
|
93
|
+
forwardRef(
|
|
94
|
+
(
|
|
95
|
+
{
|
|
96
|
+
children,
|
|
97
|
+
className,
|
|
98
|
+
as: Component = "div",
|
|
99
|
+
background,
|
|
100
|
+
borderColor,
|
|
101
|
+
borderWidth,
|
|
121
102
|
borderRadius,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
103
|
+
shadow,
|
|
104
|
+
style: _style,
|
|
105
|
+
asChild,
|
|
106
|
+
...rest
|
|
107
|
+
},
|
|
108
|
+
ref,
|
|
109
|
+
) => {
|
|
110
|
+
const themeContext = UNSAFE_useAkselTheme(false);
|
|
111
|
+
|
|
112
|
+
if (
|
|
113
|
+
process.env.NODE_ENV !== "production" &&
|
|
114
|
+
themeContext &&
|
|
115
|
+
(background || borderColor || shadow)
|
|
116
|
+
) {
|
|
117
|
+
console.warn(
|
|
118
|
+
`<Box /> with properties 'background', 'borderColor' or 'shadow' cannot be used with AkselTheme (darkmode-support). To continue using these properties, migrate to '<Box.New>'`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const prefix = themeContext ? "ax" : "a";
|
|
123
|
+
|
|
124
|
+
const style: React.CSSProperties = {
|
|
125
|
+
..._style,
|
|
126
|
+
[`--__${prefix}c-box-background`]: background
|
|
127
|
+
? `var(--a-${background})`
|
|
128
|
+
: undefined,
|
|
129
|
+
[`--__${prefix}c-box-shadow`]: shadow
|
|
130
|
+
? `var(--a-shadow-${shadow})`
|
|
131
|
+
: undefined,
|
|
132
|
+
[`--__${prefix}c-box-border-color`]: borderColor
|
|
133
|
+
? `var(--a-${borderColor})`
|
|
134
|
+
: undefined,
|
|
135
|
+
[`--__${prefix}c-box-border-width`]: borderWidth
|
|
136
|
+
? borderWidth
|
|
137
|
+
.split(" ")
|
|
138
|
+
.map((x) => `${x}px`)
|
|
139
|
+
.join(" ")
|
|
140
|
+
: undefined,
|
|
141
|
+
...getResponsiveProps(
|
|
142
|
+
prefix,
|
|
143
|
+
"box",
|
|
144
|
+
"border-radius",
|
|
145
|
+
"border-radius",
|
|
146
|
+
borderRadius,
|
|
147
|
+
false,
|
|
148
|
+
["0"],
|
|
149
|
+
),
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const Comp = asChild ? Slot : Component;
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<BasePrimitive {...rest}>
|
|
156
|
+
<Comp
|
|
157
|
+
{...omit(rest, PRIMITIVE_PROPS)}
|
|
158
|
+
ref={ref}
|
|
159
|
+
style={style}
|
|
160
|
+
className={cl("navds-box", className, {
|
|
161
|
+
"navds-box-bg": background,
|
|
162
|
+
"navds-box-border-color": borderColor,
|
|
163
|
+
"navds-box-border-width": borderWidth,
|
|
164
|
+
"navds-box-border-radius": borderRadius,
|
|
165
|
+
"navds-box-shadow": shadow,
|
|
166
|
+
})}
|
|
167
|
+
>
|
|
168
|
+
{children}
|
|
169
|
+
</Comp>
|
|
170
|
+
</BasePrimitive>
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
);
|
|
126
174
|
|
|
127
|
-
|
|
175
|
+
export const Box = BoxComponent as BoxComponentType;
|
|
128
176
|
|
|
129
|
-
|
|
130
|
-
<BasePrimitive {...rest}>
|
|
131
|
-
<Comp
|
|
132
|
-
{...omit(rest, PRIMITIVE_PROPS)}
|
|
133
|
-
ref={ref}
|
|
134
|
-
style={style}
|
|
135
|
-
className={cl("navds-box", className, {
|
|
136
|
-
"navds-box-bg": background,
|
|
137
|
-
"navds-box-border-color": borderColor,
|
|
138
|
-
"navds-box-border-width": borderWidth,
|
|
139
|
-
"navds-box-border-radius": borderRadius,
|
|
140
|
-
"navds-box-shadow": shadow,
|
|
141
|
-
})}
|
|
142
|
-
>
|
|
143
|
-
{children}
|
|
144
|
-
</Comp>
|
|
145
|
-
</BasePrimitive>
|
|
146
|
-
);
|
|
147
|
-
},
|
|
148
|
-
);
|
|
177
|
+
Box.New = BoxNew;
|
|
149
178
|
|
|
150
179
|
export default Box;
|
package/src/layout/box/index.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
export { default as Box, type BoxProps } from "./Box";
|
|
3
|
+
|
|
4
|
+
/* TODO: Uncomment this when ready to expose darkmode-support. Remember to update top-level `index.ts` at the same time. */
|
|
5
|
+
/* export { default as BoxNew, type BoxNewProps } from "./Box.darkside"; */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
+
import { UNSAFE_useAkselTheme } from "../../provider";
|
|
3
4
|
import { Slot } from "../../slot/Slot";
|
|
4
5
|
import { OverridableComponent, omit } from "../../util";
|
|
5
6
|
import BasePrimitive, {
|
|
@@ -77,11 +78,14 @@ export const HGrid: OverridableComponent<HGridProps, HTMLDivElement> =
|
|
|
77
78
|
},
|
|
78
79
|
ref,
|
|
79
80
|
) => {
|
|
81
|
+
const themeContext = UNSAFE_useAkselTheme(false);
|
|
82
|
+
const prefix = themeContext ? "ax" : "a";
|
|
83
|
+
|
|
80
84
|
const styles: React.CSSProperties = {
|
|
81
85
|
...style,
|
|
82
|
-
|
|
83
|
-
...getResponsiveProps(`hgrid`, "gap", "spacing", gap),
|
|
84
|
-
...getResponsiveValue(`hgrid`, "columns", formatGrid(columns)),
|
|
86
|
+
[`--__${prefix}c-hgrid-align`]: align,
|
|
87
|
+
...getResponsiveProps(prefix, `hgrid`, "gap", "spacing", gap),
|
|
88
|
+
...getResponsiveValue(prefix, `hgrid`, "columns", formatGrid(columns)),
|
|
85
89
|
};
|
|
86
90
|
|
|
87
91
|
const Comp = asChild ? Slot : Component;
|
package/src/layout/page/Page.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
+
import { UNSAFE_useAkselTheme } from "../../provider";
|
|
3
4
|
import { OverridableComponent } from "../../util";
|
|
4
5
|
import { BackgroundColorToken } from "../utilities/types";
|
|
5
6
|
import { PageBlock } from "./parts/PageBlock";
|
|
@@ -14,6 +15,7 @@ export interface PageProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
14
15
|
* Background color.
|
|
15
16
|
* Accepts a [background color token](https://aksel.nav.no/grunnleggende/styling/design-tokens#753d1cf4d1d6).
|
|
16
17
|
* @default "bg-default"
|
|
18
|
+
* @deprecated 'background'-prop will be removed in future major-versions. Use `<Box asChild background="...">` wrapped around `<Page>`.
|
|
17
19
|
*/
|
|
18
20
|
background?: BackgroundColorToken;
|
|
19
21
|
/**
|
|
@@ -52,6 +54,14 @@ export const PageComponent: OverridableComponent<PageProps, HTMLElement> =
|
|
|
52
54
|
},
|
|
53
55
|
ref,
|
|
54
56
|
) => {
|
|
57
|
+
const themeContext = UNSAFE_useAkselTheme(false);
|
|
58
|
+
|
|
59
|
+
if (process.env.NODE_ENV !== "production" && themeContext && background) {
|
|
60
|
+
console.warn(
|
|
61
|
+
`Prop \`background\` is deprecated and cannot be used with theme-support. Instead wrap component with \`<Box asChild background>\``,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
const style: React.CSSProperties = {
|
|
56
66
|
..._style,
|
|
57
67
|
"--__ac-page-background": `var(--a-${background})`,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { HTMLAttributes, forwardRef } from "react";
|
|
3
|
+
import { UNSAFE_useAkselTheme } from "../../provider";
|
|
3
4
|
import { Slot } from "../../slot/Slot";
|
|
4
5
|
import { omit } from "../../util";
|
|
5
6
|
import { OverridableComponent } from "../../util/types";
|
|
@@ -83,12 +84,15 @@ export const Stack: OverridableComponent<StackProps, HTMLDivElement> =
|
|
|
83
84
|
},
|
|
84
85
|
ref,
|
|
85
86
|
) => {
|
|
87
|
+
const themeContext = UNSAFE_useAkselTheme(false);
|
|
88
|
+
const prefix = themeContext ? "ax" : "a";
|
|
89
|
+
|
|
86
90
|
const style: React.CSSProperties = {
|
|
87
91
|
..._style,
|
|
88
|
-
...getResponsiveProps(`stack`, "gap", "spacing", gap),
|
|
89
|
-
...getResponsiveValue(`stack`, "direction", direction),
|
|
90
|
-
...getResponsiveValue(`stack`, "align", align),
|
|
91
|
-
...getResponsiveValue(`stack`, "justify", justify),
|
|
92
|
+
...getResponsiveProps(prefix, `stack`, "gap", "spacing", gap),
|
|
93
|
+
...getResponsiveValue(prefix, `stack`, "direction", direction),
|
|
94
|
+
...getResponsiveValue(prefix, `stack`, "align", align),
|
|
95
|
+
...getResponsiveValue(prefix, `stack`, "justify", justify),
|
|
92
96
|
};
|
|
93
97
|
|
|
94
98
|
const Comp = asChild ? Slot : Component;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ResponsiveProp } from "./types";
|
|
2
2
|
|
|
3
3
|
export function getResponsiveValue<T = string>(
|
|
4
|
+
prefix: string,
|
|
4
5
|
componentName: string,
|
|
5
6
|
componentProp: string,
|
|
6
7
|
responsiveProp?: ResponsiveProp<T>,
|
|
@@ -11,13 +12,13 @@ export function getResponsiveValue<T = string>(
|
|
|
11
12
|
|
|
12
13
|
if (typeof responsiveProp === "string") {
|
|
13
14
|
return {
|
|
14
|
-
[`--
|
|
15
|
+
[`--__${prefix}c-${componentName}-${componentProp}-xs`]: responsiveProp,
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
return Object.fromEntries(
|
|
19
20
|
Object.entries(responsiveProp).map(([breakpointAlias, responsiveValue]) => [
|
|
20
|
-
`--
|
|
21
|
+
`--__${prefix}c-${componentName}-${componentProp}-${breakpointAlias}`,
|
|
21
22
|
responsiveValue,
|
|
22
23
|
]),
|
|
23
24
|
);
|
|
@@ -37,6 +38,7 @@ const translateTokenStringToCSS = (
|
|
|
37
38
|
tokenSubgroup: string,
|
|
38
39
|
tokenExceptions: string[],
|
|
39
40
|
invert: boolean,
|
|
41
|
+
prefix: string,
|
|
40
42
|
) => {
|
|
41
43
|
return tokenString
|
|
42
44
|
.split(" ")
|
|
@@ -54,7 +56,7 @@ const translateTokenStringToCSS = (
|
|
|
54
56
|
return "auto";
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
let output = `var(
|
|
59
|
+
let output = `var(--${prefix}-${tokenSubgroup}-${x})`;
|
|
58
60
|
if (tokenExceptions.includes(x)) {
|
|
59
61
|
output = translateExceptionToCSS(x);
|
|
60
62
|
}
|
|
@@ -70,6 +72,7 @@ const translateTokenStringToCSS = (
|
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
export function getResponsiveProps<T extends string>(
|
|
75
|
+
prefix: string,
|
|
73
76
|
componentName: string,
|
|
74
77
|
componentProp: string,
|
|
75
78
|
tokenSubgroup: string,
|
|
@@ -83,27 +86,30 @@ export function getResponsiveProps<T extends string>(
|
|
|
83
86
|
|
|
84
87
|
if (typeof responsiveProp === "string") {
|
|
85
88
|
return {
|
|
86
|
-
[`--
|
|
89
|
+
[`--__${prefix}c-${componentName}-${componentProp}-xs`]:
|
|
87
90
|
translateTokenStringToCSS(
|
|
88
91
|
componentProp,
|
|
89
92
|
responsiveProp,
|
|
90
93
|
tokenSubgroup,
|
|
91
94
|
tokenExceptions,
|
|
92
95
|
invert,
|
|
96
|
+
prefix,
|
|
93
97
|
),
|
|
94
98
|
};
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
const styleProps = {};
|
|
98
102
|
Object.entries(responsiveProp).forEach(([breakpointAlias, aliasOrScale]) => {
|
|
99
|
-
styleProps[
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
styleProps[
|
|
104
|
+
`--__${prefix}c-${componentName}-${componentProp}-${breakpointAlias}`
|
|
105
|
+
] = translateTokenStringToCSS(
|
|
106
|
+
componentProp,
|
|
107
|
+
aliasOrScale,
|
|
108
|
+
tokenSubgroup,
|
|
109
|
+
tokenExceptions,
|
|
110
|
+
invert,
|
|
111
|
+
prefix,
|
|
112
|
+
);
|
|
107
113
|
});
|
|
108
114
|
return styleProps;
|
|
109
115
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/* Darkside tokens */
|
|
2
|
+
import { semanticTokenConfig } from "@navikt/ds-tokens/darkside/tokens/semantic";
|
|
3
|
+
import { SemanticTokensForAllRolesConfigT } from "@navikt/ds-tokens/darkside/tokens/semantic-roles";
|
|
4
|
+
import { shadowTokenConfig } from "@navikt/ds-tokens/darkside/tokens/shadow";
|
|
5
|
+
|
|
6
|
+
/* Old */
|
|
1
7
|
import borderRadii from "@navikt/ds-tokens/src/border.json";
|
|
2
8
|
import bgColors from "@navikt/ds-tokens/src/colors-bg.json";
|
|
3
9
|
import borderColors from "@navikt/ds-tokens/src/colors-border.json";
|
|
@@ -27,3 +33,21 @@ type FixedResponsiveT<T> = {
|
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
export type ResponsiveProp<T> = T | FixedResponsiveT<T>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Darkside tokens
|
|
39
|
+
*/
|
|
40
|
+
export type SemanticShadowTokens = keyof ReturnType<
|
|
41
|
+
typeof shadowTokenConfig
|
|
42
|
+
>["shadow"];
|
|
43
|
+
|
|
44
|
+
export type SemanticStaticBgDarkside = keyof ReturnType<
|
|
45
|
+
typeof semanticTokenConfig
|
|
46
|
+
>["bg"];
|
|
47
|
+
|
|
48
|
+
export type SemanticRoleBgDarkside =
|
|
49
|
+
keyof SemanticTokensForAllRolesConfigT<"color">["bg"];
|
|
50
|
+
|
|
51
|
+
export type SemanticStaticBorderDarkside = keyof ReturnType<
|
|
52
|
+
typeof semanticTokenConfig
|
|
53
|
+
>["border"];
|
package/src/modal/Modal.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { useFloatingPortalNode } from "@floating-ui/react";
|
|
|
2
2
|
import cl from "clsx";
|
|
3
3
|
import React, { forwardRef, useContext, useEffect, useRef } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
-
import {
|
|
5
|
+
import { DateInputContext } from "../date/context";
|
|
6
6
|
import { useProvider } from "../provider/Provider";
|
|
7
7
|
import { Detail, Heading } from "../typography";
|
|
8
8
|
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
@@ -106,7 +106,7 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
|
|
|
106
106
|
const rootElement = useProvider()?.rootElement;
|
|
107
107
|
const portalNode = useFloatingPortalNode({ root: rootElement });
|
|
108
108
|
|
|
109
|
-
const dateContext = useContext(
|
|
109
|
+
const dateContext = useContext(DateInputContext);
|
|
110
110
|
const isNested = useModalContext(false) !== undefined;
|
|
111
111
|
if (isNested && !dateContext) {
|
|
112
112
|
console.error("Modals should not be nested");
|
|
@@ -17,7 +17,7 @@ export interface ModalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
17
17
|
const ModalHeader = forwardRef<HTMLDivElement, ModalHeaderProps>(
|
|
18
18
|
({ children, className, closeButton = true, ...rest }, ref) => {
|
|
19
19
|
const context = useModalContext();
|
|
20
|
-
const translate = useI18n("
|
|
20
|
+
const translate = useI18n("global");
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
23
|
<div {...rest} ref={ref} className={cl("navds-modal__header", className)}>
|
package/src/popover/Popover.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "@floating-ui/react";
|
|
9
9
|
import cl from "clsx";
|
|
10
10
|
import React, { HTMLAttributes, forwardRef, useContext, useRef } from "react";
|
|
11
|
-
import {
|
|
11
|
+
import { DateInputContext } from "../date/context";
|
|
12
12
|
import { useModalContext } from "../modal/Modal.context";
|
|
13
13
|
import { DismissableLayer } from "../overlays/dismissablelayer/DismissableLayer";
|
|
14
14
|
import { UNSAFE_useAkselTheme } from "../provider";
|
|
@@ -121,7 +121,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
|
|
121
121
|
) => {
|
|
122
122
|
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
123
123
|
const isInModal = useModalContext(false) !== undefined;
|
|
124
|
-
const isInDatepicker = useContext(
|
|
124
|
+
const isInDatepicker = useContext(DateInputContext) !== null;
|
|
125
125
|
const chosenStrategy = userStrategy ?? (isInModal ? "fixed" : "absolute");
|
|
126
126
|
const chosenFlip = isInDatepicker ? false : _flip;
|
|
127
127
|
|
|
@@ -1,20 +1,49 @@
|
|
|
1
1
|
import React, { createContext, useContext } from "react";
|
|
2
|
+
import { PartialTranslations, Translations } from "../util/i18n/i18n.types";
|
|
3
|
+
import nb from "../util/i18n/locales/nb";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Global root-element to attach portals to (Tooltip)
|
|
6
|
-
*/
|
|
5
|
+
type ProviderContextType = {
|
|
7
6
|
rootElement?: HTMLElement;
|
|
8
|
-
|
|
7
|
+
locale: Translations;
|
|
8
|
+
translations?: PartialTranslations | PartialTranslations[];
|
|
9
|
+
};
|
|
9
10
|
|
|
10
|
-
export const ProviderContext = createContext<ProviderContextType
|
|
11
|
-
|
|
12
|
-
);
|
|
11
|
+
export const ProviderContext = createContext<ProviderContextType>({
|
|
12
|
+
locale: nb,
|
|
13
|
+
});
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
-
children
|
|
15
|
+
export type ProviderProps = {
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Global root-element to attach portals to. Used by Tooltip, Modal (optionally) and ActionMenu.
|
|
19
|
+
*/
|
|
16
20
|
rootElement?: HTMLElement;
|
|
17
|
-
}
|
|
21
|
+
} & (
|
|
22
|
+
| {
|
|
23
|
+
/**
|
|
24
|
+
* Aksel locale
|
|
25
|
+
* @default nb
|
|
26
|
+
* @example
|
|
27
|
+
* ```jsx
|
|
28
|
+
* import { en } from "@navikt/ds-react/locales";
|
|
29
|
+
* <Provider locale={en}>
|
|
30
|
+
* {app}
|
|
31
|
+
* </Provider>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
locale: Translations;
|
|
35
|
+
/**
|
|
36
|
+
* Use this if you need to override some of the default translations.
|
|
37
|
+
* Can be a single object or an array of objects.
|
|
38
|
+
* Must be used together with the `locale` prop.
|
|
39
|
+
*/
|
|
40
|
+
translations?: PartialTranslations | PartialTranslations[];
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
locale?: never;
|
|
44
|
+
translations?: never;
|
|
45
|
+
}
|
|
46
|
+
);
|
|
18
47
|
|
|
19
48
|
export const useProvider = () => useContext(ProviderContext);
|
|
20
49
|
|
|
@@ -31,9 +60,23 @@ export const useProvider = () => useContext(ProviderContext);
|
|
|
31
60
|
* </Provider>
|
|
32
61
|
* ```
|
|
33
62
|
*/
|
|
34
|
-
export const Provider = ({
|
|
63
|
+
export const Provider = ({
|
|
64
|
+
children,
|
|
65
|
+
rootElement,
|
|
66
|
+
locale,
|
|
67
|
+
translations,
|
|
68
|
+
}: ProviderProps) => {
|
|
69
|
+
const parentContext = useProvider();
|
|
35
70
|
return (
|
|
36
|
-
<ProviderContext.Provider
|
|
71
|
+
<ProviderContext.Provider
|
|
72
|
+
value={{
|
|
73
|
+
rootElement: rootElement || parentContext.rootElement,
|
|
74
|
+
locale: locale || parentContext.locale || nb,
|
|
75
|
+
translations: translations || parentContext.translations,
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</ProviderContext.Provider>
|
|
37
80
|
);
|
|
38
81
|
};
|
|
39
82
|
|
|
@@ -78,6 +78,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
|
|
|
78
78
|
onChange: onOpenChange,
|
|
79
79
|
});
|
|
80
80
|
const translate = useI18n("global");
|
|
81
|
+
|
|
81
82
|
const id = useId();
|
|
82
83
|
|
|
83
84
|
const expansionHandler = (event: React.MouseEvent<HTMLElement>) => {
|
|
@@ -110,7 +111,7 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
|
|
|
110
111
|
className={cl("navds-table__toggle-expand-cell", {
|
|
111
112
|
"navds-table__toggle-expand-cell--open": _open,
|
|
112
113
|
})}
|
|
113
|
-
onClick={expansionHandler}
|
|
114
|
+
onClick={!expansionDisabled ? expansionHandler : () => null}
|
|
114
115
|
>
|
|
115
116
|
{!expansionDisabled && (
|
|
116
117
|
<button
|
|
@@ -129,13 +130,19 @@ export const ExpandableRow: ExpandableRowType = forwardRef(
|
|
|
129
130
|
</DataCell>
|
|
130
131
|
{togglePlacement === "left" && children}
|
|
131
132
|
</Row>
|
|
132
|
-
<tr
|
|
133
|
+
<tr
|
|
134
|
+
data-state={_open ? "open" : "closed"}
|
|
135
|
+
className="navds-table__expanded-row"
|
|
136
|
+
aria-hidden={!_open}
|
|
137
|
+
id={id}
|
|
138
|
+
>
|
|
133
139
|
<td colSpan={colSpan} className="navds-table__expanded-row-cell">
|
|
134
140
|
<AnimateHeight
|
|
135
141
|
className="navds-table__expanded-row-collapse"
|
|
136
142
|
innerClassName="navds-table__expanded-row-content"
|
|
137
143
|
height={_open ? "auto" : 0}
|
|
138
|
-
duration={
|
|
144
|
+
duration={150}
|
|
145
|
+
easing="cubic-bezier(0.39,0.57,0.56,1)"
|
|
139
146
|
>
|
|
140
147
|
{content}
|
|
141
148
|
</AnimateHeight>
|
|
@@ -39,6 +39,7 @@ export interface TimelineProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
39
39
|
/**
|
|
40
40
|
* Templates for label texts. The templates are passed to the date-fns `format` function.
|
|
41
41
|
* Defaults to { day: "dd.MM", month: "MMM yy", year: "yyyy" }.
|
|
42
|
+
* @deprecated Use `<Provider />`-component
|
|
42
43
|
*/
|
|
43
44
|
axisLabelTemplates?: AxisLabelTemplates;
|
|
44
45
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { renderHook } from "@testing-library/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { describe, expect, test } from "vitest";
|
|
4
|
-
import
|
|
4
|
+
import { Provider } from "../../provider";
|
|
5
5
|
import { useI18n } from "./i18n.context";
|
|
6
|
+
import en from "./locales/en";
|
|
7
|
+
import nb from "./locales/nb";
|
|
6
8
|
|
|
7
9
|
describe("useI18n", () => {
|
|
8
10
|
test("should throw error if key is not found", () => {
|
|
@@ -12,13 +14,32 @@ describe("useI18n", () => {
|
|
|
12
14
|
expect(() => translate("item.nonexistentKey")).toThrowError();
|
|
13
15
|
});
|
|
14
16
|
|
|
15
|
-
test("should return the
|
|
17
|
+
test("should return the default NB translation when Provider is not used", () => {
|
|
18
|
+
const { result } = renderHook(() => useI18n("FileUpload"));
|
|
19
|
+
const translate = result.current;
|
|
20
|
+
expect(translate("item.uploading")).toBe(nb.FileUpload.item.uploading);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("should return the default translation when key is not in context object", () => {
|
|
24
|
+
const i18n = { FileUpload: { item: { downloading: "Test translation" } } };
|
|
25
|
+
const { result } = renderHook(() => useI18n("FileUpload"), {
|
|
26
|
+
wrapper: ({ children }) => (
|
|
27
|
+
<Provider locale={en} translations={i18n}>
|
|
28
|
+
{children}
|
|
29
|
+
</Provider>
|
|
30
|
+
),
|
|
31
|
+
});
|
|
32
|
+
const translate = result.current;
|
|
33
|
+
expect(translate("item.uploading")).toBe(en.FileUpload.item.uploading);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("should return the translated text from the context object", () => {
|
|
16
37
|
const i18n = { FileUpload: { item: { uploading: "Test translation" } } };
|
|
17
38
|
const { result } = renderHook(() => useI18n("FileUpload"), {
|
|
18
39
|
wrapper: ({ children }) => (
|
|
19
|
-
<
|
|
40
|
+
<Provider locale={en} translations={i18n}>
|
|
20
41
|
{children}
|
|
21
|
-
</
|
|
42
|
+
</Provider>
|
|
22
43
|
),
|
|
23
44
|
});
|
|
24
45
|
const translate = result.current;
|
|
@@ -32,9 +53,9 @@ describe("useI18n", () => {
|
|
|
32
53
|
const i18n2 = { FileUpload: { item: { uploading: "Wrong translation" } } };
|
|
33
54
|
const { result } = renderHook(() => useI18n("FileUpload"), {
|
|
34
55
|
wrapper: ({ children }) => (
|
|
35
|
-
<
|
|
56
|
+
<Provider locale={en} translations={[i18n1, i18n2]}>
|
|
36
57
|
{children}
|
|
37
|
-
</
|
|
58
|
+
</Provider>
|
|
38
59
|
),
|
|
39
60
|
});
|
|
40
61
|
const translate = result.current;
|
|
@@ -48,9 +69,9 @@ describe("useI18n", () => {
|
|
|
48
69
|
};
|
|
49
70
|
const { result } = renderHook(() => useI18n("FileUpload"), {
|
|
50
71
|
wrapper: ({ children }) => (
|
|
51
|
-
<
|
|
72
|
+
<Provider locale={en} translations={[i18n1, i18n2]}>
|
|
52
73
|
{children}
|
|
53
|
-
</
|
|
74
|
+
</Provider>
|
|
54
75
|
),
|
|
55
76
|
});
|
|
56
77
|
const translate = result.current;
|