@navikt/ds-react 7.8.1 → 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/accordion/AccordionContent.js +2 -2
- package/cjs/accordion/AccordionContent.js.map +1 -1
- package/cjs/accordion/AccordionHeader.js +2 -2
- package/cjs/accordion/AccordionHeader.js.map +1 -1
- package/cjs/alert/Alert.js +2 -2
- package/cjs/alert/Alert.js.map +1 -1
- package/cjs/button/Button.js +9 -25
- package/cjs/button/Button.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/datepicker/parts/WeekNumber.js +2 -2
- package/cjs/date/datepicker/parts/WeekNumber.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/DateInput.js +1 -1
- package/cjs/date/parts/DateInput.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/Combobox.d.ts +1 -1
- package/cjs/form/combobox/Combobox.js +1 -1
- package/cjs/form/combobox/Combobox.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/combobox/Input/InputController.d.ts +1 -1
- package/cjs/form/confirmation-panel/ConfirmationPanel.js +1 -1
- package/cjs/form/confirmation-panel/ConfirmationPanel.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/fieldset/Fieldset.js +1 -1
- package/cjs/form/fieldset/Fieldset.js.map +1 -1
- package/cjs/form/file-upload/parts/dropzone/Dropzone.js +3 -3
- 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 +5 -5
- 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/select/Select.js +1 -1
- package/cjs/form/select/Select.js.map +1 -1
- package/cjs/form/switch/Switch.js +1 -7
- package/cjs/form/switch/Switch.js.map +1 -1
- package/cjs/form/textarea/Textarea.js +1 -1
- package/cjs/form/textarea/Textarea.js.map +1 -1
- package/cjs/form/textarea/TextareaCounter.js +2 -2
- package/cjs/form/textarea/TextareaCounter.js.map +1 -1
- package/cjs/form/textfield/TextField.js +1 -1
- package/cjs/form/textfield/TextField.js.map +1 -1
- package/cjs/guide-panel/GuidePanel.js +2 -2
- package/cjs/guide-panel/GuidePanel.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 +4 -4
- package/cjs/help-text/HelpText.js.map +1 -1
- package/cjs/internal-header/InternalHeader.js +3 -3
- package/cjs/internal-header/InternalHeader.js.map +1 -1
- package/cjs/layout/base/BasePrimitive.js +2 -2
- package/cjs/layout/base/BasePrimitive.js.map +1 -1
- package/cjs/layout/bleed/Bleed.js +2 -2
- package/cjs/layout/bleed/Bleed.js.map +1 -1
- package/cjs/layout/box/Box.js +2 -2
- package/cjs/layout/box/Box.js.map +1 -1
- package/cjs/layout/grid/HGrid.js +2 -2
- package/cjs/layout/grid/HGrid.js.map +1 -1
- package/cjs/layout/page/Page.js +2 -2
- package/cjs/layout/page/Page.js.map +1 -1
- package/cjs/layout/stack/Stack.js +2 -2
- package/cjs/layout/stack/Stack.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/overlays/action-menu/ActionMenu.js +2 -2
- package/cjs/overlays/action-menu/ActionMenu.js.map +1 -1
- package/cjs/pagination/Pagination.js +2 -2
- package/cjs/pagination/Pagination.js.map +1 -1
- package/cjs/pagination/PaginationItem.js +2 -2
- package/cjs/pagination/PaginationItem.js.map +1 -1
- package/cjs/popover/Popover.js +2 -2
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/portal/Portal.js +12 -0
- package/cjs/portal/Portal.js.map +1 -1
- package/cjs/progress-bar/ProgressBar.js +2 -2
- package/cjs/progress-bar/ProgressBar.js.map +1 -1
- package/cjs/provider/index.d.ts +0 -1
- package/cjs/provider/index.js +1 -4
- package/cjs/provider/index.js.map +1 -1
- package/cjs/read-more/ReadMore.js +1 -3
- package/cjs/read-more/ReadMore.js.map +1 -1
- package/cjs/table/ExpandableRow.js +2 -2
- package/cjs/table/ExpandableRow.js.map +1 -1
- package/cjs/tabs/Tabs.context.d.ts +1 -1
- package/cjs/tabs/parts/tablist/useScrollButtons.d.ts +1 -1
- package/cjs/theme/Theme.d.ts +16 -0
- package/cjs/{provider/theme/AkselTheme.js → theme/Theme.js} +17 -18
- package/cjs/theme/Theme.js.map +1 -0
- package/cjs/theme/index.d.ts +1 -0
- package/cjs/theme/index.js +7 -0
- package/cjs/theme/index.js.map +1 -0
- package/cjs/timeline/AxisLabels.js +3 -3
- package/cjs/timeline/AxisLabels.js.map +1 -1
- package/cjs/timeline/Pin.js +4 -4
- 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 +4 -4
- 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/toggle-group/parts/ToggleItem.js +1 -1
- package/cjs/toggle-group/parts/ToggleItem.js.map +1 -1
- package/cjs/tooltip/Tooltip.js +2 -2
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/cjs/typography/ErrorMessage.d.ts +4 -0
- package/cjs/typography/ErrorMessage.js +6 -2
- package/cjs/typography/ErrorMessage.js.map +1 -1
- package/cjs/util/TextareaAutoSize.js +1 -1
- package/cjs/util/TextareaAutoSize.js.map +1 -1
- package/cjs/util/debounce.d.ts +2 -2
- package/cjs/util/debounce.js +5 -1
- package/cjs/util/debounce.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/accordion/AccordionContent.js +2 -2
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +2 -2
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/alert/Alert.js +1 -1
- package/esm/alert/Alert.js.map +1 -1
- package/esm/button/Button.js +10 -26
- package/esm/button/Button.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/datepicker/parts/WeekNumber.js +2 -2
- package/esm/date/datepicker/parts/WeekNumber.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/DateInput.js +1 -1
- package/esm/date/parts/DateInput.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/Combobox.d.ts +1 -1
- package/esm/form/combobox/Combobox.js +1 -1
- package/esm/form/combobox/Combobox.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/combobox/Input/InputController.d.ts +1 -1
- package/esm/form/confirmation-panel/ConfirmationPanel.js +1 -1
- package/esm/form/confirmation-panel/ConfirmationPanel.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/fieldset/Fieldset.js +1 -1
- package/esm/form/fieldset/Fieldset.js.map +1 -1
- package/esm/form/file-upload/parts/dropzone/Dropzone.js +2 -2
- 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 +4 -4
- 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/select/Select.js +1 -1
- package/esm/form/select/Select.js.map +1 -1
- package/esm/form/switch/Switch.js +1 -7
- package/esm/form/switch/Switch.js.map +1 -1
- package/esm/form/textarea/Textarea.js +1 -1
- package/esm/form/textarea/Textarea.js.map +1 -1
- package/esm/form/textarea/TextareaCounter.js +1 -1
- package/esm/form/textarea/TextareaCounter.js.map +1 -1
- package/esm/form/textfield/TextField.js +1 -1
- package/esm/form/textfield/TextField.js.map +1 -1
- package/esm/guide-panel/GuidePanel.js +2 -2
- package/esm/guide-panel/GuidePanel.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 +3 -3
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/internal-header/InternalHeader.js +3 -3
- package/esm/internal-header/InternalHeader.js.map +1 -1
- package/esm/layout/base/BasePrimitive.js +2 -2
- package/esm/layout/base/BasePrimitive.js.map +1 -1
- package/esm/layout/bleed/Bleed.js +2 -2
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/box/Box.js +2 -2
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/grid/HGrid.js +2 -2
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.js +2 -2
- package/esm/layout/page/Page.js.map +1 -1
- package/esm/layout/stack/Stack.js +2 -2
- package/esm/layout/stack/Stack.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/overlays/action-menu/ActionMenu.js +2 -2
- package/esm/overlays/action-menu/ActionMenu.js.map +1 -1
- package/esm/pagination/Pagination.js +1 -1
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.js +2 -2
- package/esm/pagination/PaginationItem.js.map +1 -1
- package/esm/popover/Popover.js +2 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/portal/Portal.js +12 -0
- package/esm/portal/Portal.js.map +1 -1
- package/esm/progress-bar/ProgressBar.js +1 -1
- package/esm/progress-bar/ProgressBar.js.map +1 -1
- package/esm/provider/index.d.ts +0 -1
- package/esm/provider/index.js +0 -1
- package/esm/provider/index.js.map +1 -1
- package/esm/read-more/ReadMore.js +1 -3
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/table/ExpandableRow.js +1 -1
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/tabs/Tabs.context.d.ts +1 -1
- package/esm/tabs/parts/tablist/useScrollButtons.d.ts +1 -1
- package/esm/theme/Theme.d.ts +16 -0
- package/esm/theme/Theme.js +21 -0
- package/esm/theme/Theme.js.map +1 -0
- package/esm/theme/index.d.ts +1 -0
- package/esm/theme/index.js +3 -0
- package/esm/theme/index.js.map +1 -0
- package/esm/timeline/AxisLabels.js +1 -1
- package/esm/timeline/AxisLabels.js.map +1 -1
- package/esm/timeline/Pin.js +3 -3
- 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 +3 -3
- 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/toggle-group/parts/ToggleItem.js +1 -1
- package/esm/toggle-group/parts/ToggleItem.js.map +1 -1
- package/esm/tooltip/Tooltip.js +2 -2
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/ErrorMessage.d.ts +4 -0
- package/esm/typography/ErrorMessage.js +6 -2
- package/esm/typography/ErrorMessage.js.map +1 -1
- package/esm/util/TextareaAutoSize.js +1 -1
- package/esm/util/TextareaAutoSize.js.map +1 -1
- package/esm/util/debounce.d.ts +2 -2
- package/esm/util/debounce.js +5 -1
- package/esm/util/debounce.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/accordion/AccordionContent.tsx +2 -2
- package/src/accordion/AccordionHeader.tsx +2 -2
- package/src/alert/Alert.tsx +1 -1
- package/src/button/Button.tsx +20 -50
- 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/datepicker/parts/WeekNumber.tsx +2 -2
- 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/DateInput.tsx +5 -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/Combobox.tsx +5 -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/confirmation-panel/ConfirmationPanel.tsx +5 -1
- package/src/form/error-summary/ErrorSummary.tsx +1 -1
- package/src/form/fieldset/Fieldset.tsx +3 -1
- package/src/form/file-upload/parts/dropzone/Dropzone.tsx +2 -2
- 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 +6 -4
- package/src/form/search/SearchButton.tsx +1 -1
- package/src/form/select/Select.tsx +3 -1
- package/src/form/switch/Switch.tsx +1 -10
- package/src/form/textarea/Textarea.tsx +3 -1
- package/src/form/textarea/TextareaCounter.tsx +1 -1
- package/src/form/textfield/TextField.tsx +3 -1
- package/src/guide-panel/GuidePanel.tsx +2 -2
- package/src/guide-panel/Illustration.darkside.tsx +1 -1
- package/src/guide-panel/Illustration.tsx +1 -1
- package/src/help-text/HelpText.tsx +3 -3
- package/src/internal-header/InternalHeader.tsx +4 -4
- package/src/layout/base/BasePrimitive.tsx +2 -2
- package/src/layout/bleed/Bleed.tsx +2 -2
- package/src/layout/box/Box.tsx +2 -2
- package/src/layout/grid/HGrid.tsx +2 -2
- package/src/layout/page/Page.tsx +2 -2
- package/src/layout/stack/Stack.tsx +2 -2
- package/src/loader/Loader.tsx +1 -1
- package/src/modal/ModalHeader.tsx +1 -1
- package/src/overlays/action-menu/ActionMenu.tsx +2 -2
- package/src/pagination/Pagination.tsx +1 -1
- package/src/pagination/PaginationItem.tsx +2 -2
- package/src/popover/Popover.tsx +2 -2
- package/src/portal/Portal.tsx +17 -0
- package/src/progress-bar/ProgressBar.tsx +1 -1
- package/src/provider/index.ts +0 -4
- package/src/read-more/ReadMore.tsx +1 -4
- package/src/table/ExpandableRow.tsx +1 -1
- package/src/tabs/Tabs.test.tsx +4 -12
- package/src/theme/Theme.tsx +60 -0
- package/src/theme/index.ts +2 -0
- package/src/timeline/AxisLabels.tsx +2 -1
- package/src/timeline/Pin.tsx +3 -3
- package/src/timeline/TimelineRow.tsx +1 -1
- package/src/timeline/period/ClickablePeriod.tsx +3 -3
- 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/toggle-group/parts/ToggleItem.tsx +1 -0
- package/src/tooltip/Tooltip.tsx +2 -2
- package/src/typography/ErrorMessage.tsx +36 -2
- package/src/util/TextareaAutoSize.tsx +15 -11
- package/src/util/debounce.ts +11 -3
- 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/provider/theme/AkselTheme.d.ts +0 -22
- package/cjs/provider/theme/AkselTheme.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/provider/theme/AkselTheme.d.ts +0 -22
- package/esm/provider/theme/AkselTheme.js +0 -22
- package/esm/provider/theme/AkselTheme.js.map +0 -1
- package/esm/util/i18n/i18n.context.d.ts +0 -9
- package/src/provider/theme/AkselTheme.tsx +0 -70
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
import { ChevronDownIcon } from "@navikt/aksel-icons";
|
|
4
|
-
import { UNSAFE_useAkselTheme } from "../provider";
|
|
5
4
|
import { BodyLong } from "../typography";
|
|
6
5
|
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
7
6
|
import { useControllableState } from "../util/hooks/useControllableState";
|
|
@@ -75,8 +74,6 @@ export const ReadMore = forwardRef<HTMLButtonElement, ReadMoreProps>(
|
|
|
75
74
|
onChange: onOpenChange,
|
|
76
75
|
});
|
|
77
76
|
|
|
78
|
-
const themeContext = UNSAFE_useAkselTheme(false);
|
|
79
|
-
|
|
80
77
|
const typoSize = size === "small" ? "small" : "medium";
|
|
81
78
|
|
|
82
79
|
return (
|
|
@@ -87,7 +84,7 @@ export const ReadMore = forwardRef<HTMLButtonElement, ReadMoreProps>(
|
|
|
87
84
|
className,
|
|
88
85
|
{ "navds-read-more--open": _open },
|
|
89
86
|
)}
|
|
90
|
-
data-volume=
|
|
87
|
+
data-volume="low"
|
|
91
88
|
>
|
|
92
89
|
<button
|
|
93
90
|
{...rest}
|
|
@@ -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
|
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { Slot } from "../slot/Slot";
|
|
4
|
+
import { createContext } from "../util/create-context";
|
|
5
|
+
import { AsChildProps } from "../util/types";
|
|
6
|
+
|
|
7
|
+
type ThemeContext = {
|
|
8
|
+
/**
|
|
9
|
+
* Color theme
|
|
10
|
+
* @default "light"
|
|
11
|
+
*/
|
|
12
|
+
theme: "light" | "dark";
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const [ThemeProvider, useThemeInternal] = createContext<ThemeContext>({
|
|
16
|
+
hookName: "useTheme",
|
|
17
|
+
name: "ThemeProvider",
|
|
18
|
+
providerName: "ThemeProvider",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
type ThemeProps = {
|
|
22
|
+
className?: string;
|
|
23
|
+
hasBackground?: boolean;
|
|
24
|
+
} & ThemeContext &
|
|
25
|
+
AsChildProps;
|
|
26
|
+
|
|
27
|
+
const Theme = forwardRef<HTMLDivElement, ThemeProps>(
|
|
28
|
+
(props: ThemeProps, ref) => {
|
|
29
|
+
const context = useThemeInternal(false);
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
children,
|
|
33
|
+
className,
|
|
34
|
+
asChild = false,
|
|
35
|
+
theme = context?.theme ?? "light",
|
|
36
|
+
hasBackground: hasBackgroundProp = true,
|
|
37
|
+
} = props;
|
|
38
|
+
|
|
39
|
+
const isRoot = context === undefined;
|
|
40
|
+
|
|
41
|
+
const hasBackground =
|
|
42
|
+
hasBackgroundProp ?? (isRoot && props.theme !== undefined);
|
|
43
|
+
|
|
44
|
+
const SlotElement = asChild ? Slot : "div";
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<ThemeProvider theme={theme}>
|
|
48
|
+
<SlotElement
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cl("navds-theme", className, theme)}
|
|
51
|
+
data-background={hasBackground}
|
|
52
|
+
>
|
|
53
|
+
{children}
|
|
54
|
+
</SlotElement>
|
|
55
|
+
</ThemeProvider>
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
export { Theme, useThemeInternal };
|
|
@@ -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
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
} from "@floating-ui/react";
|
|
16
16
|
import { format } from "date-fns";
|
|
17
17
|
import React, { forwardRef, useRef, useState } from "react";
|
|
18
|
-
import {
|
|
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";
|
|
@@ -48,7 +48,7 @@ export const Pin = forwardRef<HTMLButtonElement, TimelinePinProps>(
|
|
|
48
48
|
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
49
49
|
const translate = useI18n("Timeline");
|
|
50
50
|
|
|
51
|
-
const themeContext =
|
|
51
|
+
const themeContext = useThemeInternal(false);
|
|
52
52
|
const showArrow = !themeContext;
|
|
53
53
|
|
|
54
54
|
const {
|
|
@@ -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";
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
} from "@floating-ui/react";
|
|
16
16
|
import cl from "clsx";
|
|
17
17
|
import React, { useRef, useState } from "react";
|
|
18
|
-
import {
|
|
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";
|
|
@@ -56,7 +56,7 @@ const ClickablePeriod = React.memo(
|
|
|
56
56
|
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
57
57
|
const translate = useI18n("Timeline");
|
|
58
58
|
|
|
59
|
-
const themeContext =
|
|
59
|
+
const themeContext = useThemeInternal(false);
|
|
60
60
|
const showArrow = !themeContext;
|
|
61
61
|
|
|
62
62
|
const {
|
|
@@ -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 {
|
|
@@ -76,6 +76,7 @@ const ToggleItem = forwardRef<HTMLButtonElement, ToggleGroupItemProps>(
|
|
|
76
76
|
type="button"
|
|
77
77
|
role="radio"
|
|
78
78
|
aria-checked={itemCtx.isSelected}
|
|
79
|
+
data-selected={itemCtx.isSelected}
|
|
79
80
|
tabIndex={itemCtx.isFocused ? 0 : -1}
|
|
80
81
|
onClick={itemCtx.onClick}
|
|
81
82
|
onFocus={itemCtx.onFocus}
|
package/src/tooltip/Tooltip.tsx
CHANGED
|
@@ -15,8 +15,8 @@ import cl from "clsx";
|
|
|
15
15
|
import React, { HTMLAttributes, forwardRef, useRef } from "react";
|
|
16
16
|
import { useModalContext } from "../modal/Modal.context";
|
|
17
17
|
import { Portal } from "../portal";
|
|
18
|
-
import { UNSAFE_useAkselTheme } from "../provider";
|
|
19
18
|
import { Slot } from "../slot/Slot";
|
|
19
|
+
import { useThemeInternal } from "../theme/Theme";
|
|
20
20
|
import { Detail } from "../typography";
|
|
21
21
|
import { useId } from "../util/hooks";
|
|
22
22
|
import { useControllableState } from "../util/hooks/useControllableState";
|
|
@@ -124,7 +124,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
124
124
|
},
|
|
125
125
|
ref,
|
|
126
126
|
) => {
|
|
127
|
-
const themeContext =
|
|
127
|
+
const themeContext = useThemeInternal(false);
|
|
128
128
|
const showArrow = _arrow && !themeContext;
|
|
129
129
|
|
|
130
130
|
const [_open, _setOpen] = useControllableState({
|
|
@@ -16,6 +16,10 @@ export interface ErrorMessageProps
|
|
|
16
16
|
* Error text.
|
|
17
17
|
*/
|
|
18
18
|
children: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Render a triangular warning icon.
|
|
21
|
+
*/
|
|
22
|
+
showIcon?: boolean;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
/**
|
|
@@ -36,7 +40,18 @@ export const ErrorMessage: OverridableComponent<
|
|
|
36
40
|
ErrorMessageProps,
|
|
37
41
|
HTMLParagraphElement
|
|
38
42
|
> = forwardRef(
|
|
39
|
-
(
|
|
43
|
+
(
|
|
44
|
+
{
|
|
45
|
+
children,
|
|
46
|
+
className,
|
|
47
|
+
size,
|
|
48
|
+
spacing,
|
|
49
|
+
as: Component = "p",
|
|
50
|
+
showIcon = false,
|
|
51
|
+
...rest
|
|
52
|
+
},
|
|
53
|
+
ref,
|
|
54
|
+
) => (
|
|
40
55
|
<Component
|
|
41
56
|
{...rest}
|
|
42
57
|
ref={ref}
|
|
@@ -49,9 +64,28 @@ export const ErrorMessage: OverridableComponent<
|
|
|
49
64
|
}),
|
|
50
65
|
{
|
|
51
66
|
"navds-label--small": size === "small",
|
|
67
|
+
"navds-error-message--show-icon": showIcon,
|
|
52
68
|
},
|
|
53
69
|
)}
|
|
54
|
-
|
|
70
|
+
>
|
|
71
|
+
{showIcon && (
|
|
72
|
+
<svg
|
|
73
|
+
viewBox="0 0 17 16"
|
|
74
|
+
fill="none"
|
|
75
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
76
|
+
focusable={false}
|
|
77
|
+
aria-hidden
|
|
78
|
+
>
|
|
79
|
+
<path
|
|
80
|
+
fillRule="evenodd"
|
|
81
|
+
clipRule="evenodd"
|
|
82
|
+
d="M3.49209 11.534L8.11398 2.7594C8.48895 2.04752 9.50833 2.04743 9.88343 2.75924L14.5073 11.5339C14.8582 12.1998 14.3753 13 13.6226 13H4.37685C3.6242 13 3.14132 12.1999 3.49209 11.534ZM9.74855 10.495C9.74855 10.9092 9.41276 11.245 8.99855 11.245C8.58433 11.245 8.24855 10.9092 8.24855 10.495C8.24855 10.0808 8.58433 9.74497 8.99855 9.74497C9.41276 9.74497 9.74855 10.0808 9.74855 10.495ZM9.49988 5.49997C9.49988 5.22383 9.27602 4.99997 8.99988 4.99997C8.72373 4.99997 8.49988 5.22383 8.49988 5.49997V7.99997C8.49988 8.27611 8.72373 8.49997 8.99988 8.49997C9.27602 8.49997 9.49988 8.27611 9.49988 7.99997V5.49997Z"
|
|
83
|
+
fill="currentColor"
|
|
84
|
+
/>
|
|
85
|
+
</svg>
|
|
86
|
+
)}
|
|
87
|
+
{children}
|
|
88
|
+
</Component>
|
|
55
89
|
),
|
|
56
90
|
);
|
|
57
91
|
|
|
@@ -167,19 +167,23 @@ const TextareaAutosize = forwardRef<HTMLTextAreaElement, TextareaAutosizeProps>(
|
|
|
167
167
|
});
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
const handleResize = debounce(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
const handleResize = debounce(
|
|
171
|
+
() => {
|
|
172
|
+
renders.current = 0;
|
|
173
|
+
|
|
174
|
+
if (inputRef.current?.style.height || inputRef.current?.style.width) {
|
|
175
|
+
// User has resized manually
|
|
176
|
+
if (inputRef.current?.style.overflow === "hidden") {
|
|
177
|
+
setState((oldState) => ({ ...oldState, overflow: false })); // The state update isn't important, we just need to trigger a rerender
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
177
180
|
}
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
181
|
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
syncHeightWithFlushSync();
|
|
183
|
+
},
|
|
184
|
+
166,
|
|
185
|
+
true,
|
|
186
|
+
);
|
|
183
187
|
|
|
184
188
|
const input = inputRef.current!;
|
|
185
189
|
const containerWindow = ownerWindow(input);
|
package/src/util/debounce.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
// https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/debounce.js
|
|
3
|
-
export default function debounce
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export default function debounce<T extends unknown[]>(
|
|
4
|
+
func: (...args: T) => void,
|
|
5
|
+
wait = 166,
|
|
6
|
+
leading = false,
|
|
7
|
+
) {
|
|
8
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
9
|
+
function debounced(this: any, ...args: T) {
|
|
6
10
|
const later = () => {
|
|
11
|
+
timeout = undefined;
|
|
7
12
|
func.apply(this, args);
|
|
8
13
|
};
|
|
14
|
+
if (!timeout && leading) {
|
|
15
|
+
later();
|
|
16
|
+
}
|
|
9
17
|
clearTimeout(timeout);
|
|
10
18
|
timeout = setTimeout(later, wait);
|
|
11
19
|
}
|
|
@@ -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
|
+
});
|
|
@@ -5,26 +5,12 @@ import {
|
|
|
5
5
|
Component,
|
|
6
6
|
ComponentTranslation,
|
|
7
7
|
PartialTranslations,
|
|
8
|
-
|
|
8
|
+
TFunction,
|
|
9
9
|
} from "./i18n.types";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
* https://regex101.com/r/LYKWi3/1
|
|
13
|
-
*/
|
|
11
|
+
/* https://regex101.com/r/LYKWi3/1 */
|
|
14
12
|
const REPLACE_REGEX = /{[^}]*}/g;
|
|
15
13
|
|
|
16
|
-
/* https://dev.to/pffigueiredo/typescript-utility-keyof-nested-object-2pa3 */
|
|
17
|
-
type NestedKeyOf<ObjectType extends object> = {
|
|
18
|
-
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
|
|
19
|
-
? `${Key}.${NestedKeyOf<ObjectType[Key]>}`
|
|
20
|
-
: `${Key}`;
|
|
21
|
-
}[keyof ObjectType & (string | number)];
|
|
22
|
-
|
|
23
|
-
export type TFunction<T extends Component> = (
|
|
24
|
-
keypath: NestedKeyOf<Translations[T]>,
|
|
25
|
-
replacements?: Record<string, string | number>,
|
|
26
|
-
) => string;
|
|
27
|
-
|
|
28
14
|
export function useI18n<T extends Component>(
|
|
29
15
|
componentName: T,
|
|
30
16
|
...localTranslations: (ComponentTranslation<T> | undefined)[]
|
|
@@ -39,9 +25,7 @@ export function useI18n<T extends Component>(
|
|
|
39
25
|
context.locale[componentName],
|
|
40
26
|
];
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
* https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24
|
|
44
|
-
*/
|
|
28
|
+
/* https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24 */
|
|
45
29
|
const translate: TFunction<T> = (keypath, replacements) => {
|
|
46
30
|
const text = get(keypath, i18nObjects);
|
|
47
31
|
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type nb from "./locales/nb";
|
|
2
2
|
|
|
3
|
+
/* https://dev.to/pffigueiredo/typescript-utility-keyof-nested-object-2pa3 */
|
|
4
|
+
type NestedKeyOf<ObjectType extends object> = {
|
|
5
|
+
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object
|
|
6
|
+
? `${Key}.${NestedKeyOf<ObjectType[Key]>}`
|
|
7
|
+
: `${Key}`;
|
|
8
|
+
}[keyof ObjectType & (string | number)];
|
|
9
|
+
|
|
10
|
+
export type TFunction<T extends Component> = (
|
|
11
|
+
keypath: NestedKeyOf<Translations[T]>,
|
|
12
|
+
replacements?: Record<string, string | number>,
|
|
13
|
+
) => string;
|
|
14
|
+
|
|
3
15
|
/* https://stackoverflow.com/questions/47914536/use-partial-in-nested-property-with-typescripts */
|
|
4
16
|
type RecursivePartial<T> = {
|
|
5
17
|
[P in keyof T]?: RecursivePartial<T[P]>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
test("ModalProps works as intended", () => {
|
|
5
|
-
(0, vitest_1.expectTypeOf)({
|
|
6
|
-
header: { heading: "Label" },
|
|
7
|
-
children: "OK",
|
|
8
|
-
}).toMatchTypeOf();
|
|
9
|
-
(0, vitest_1.expectTypeOf)({
|
|
10
|
-
header: { heading: "Label" },
|
|
11
|
-
"aria-label": "Label",
|
|
12
|
-
children: "OK",
|
|
13
|
-
}).toMatchTypeOf();
|
|
14
|
-
(0, vitest_1.expectTypeOf)({
|
|
15
|
-
header: { heading: "Label" },
|
|
16
|
-
"aria-labelledby": "Label",
|
|
17
|
-
children: "OK",
|
|
18
|
-
}).toMatchTypeOf();
|
|
19
|
-
(0, vitest_1.expectTypeOf)({
|
|
20
|
-
"aria-label": "Label",
|
|
21
|
-
children: "OK",
|
|
22
|
-
}).toMatchTypeOf();
|
|
23
|
-
(0, vitest_1.expectTypeOf)({
|
|
24
|
-
"aria-labelledby": "Label",
|
|
25
|
-
children: "OK",
|
|
26
|
-
}).toMatchTypeOf();
|
|
27
|
-
(0, vitest_1.expectTypeOf)({
|
|
28
|
-
"aria-label": "Label",
|
|
29
|
-
open: true,
|
|
30
|
-
onClose: () => null,
|
|
31
|
-
children: "OK",
|
|
32
|
-
}).toMatchTypeOf();
|
|
33
|
-
(0, vitest_1.expectTypeOf)({
|
|
34
|
-
children: "Mangler label",
|
|
35
|
-
}).not.toMatchTypeOf();
|
|
36
|
-
(0, vitest_1.expectTypeOf)({
|
|
37
|
-
open: true,
|
|
38
|
-
children: "Mangler onClose eller label",
|
|
39
|
-
}).not.toMatchTypeOf();
|
|
40
|
-
(0, vitest_1.expectTypeOf)({
|
|
41
|
-
open: true,
|
|
42
|
-
"aria-label": "Label",
|
|
43
|
-
children: "Mangler onClose",
|
|
44
|
-
}).not.toMatchTypeOf();
|
|
45
|
-
(0, vitest_1.expectTypeOf)({
|
|
46
|
-
open: true,
|
|
47
|
-
onClose: () => null,
|
|
48
|
-
children: "Mangler label",
|
|
49
|
-
}).not.toMatchTypeOf();
|
|
50
|
-
(0, vitest_1.expectTypeOf)({
|
|
51
|
-
header: { heading: "Label" },
|
|
52
|
-
open: true,
|
|
53
|
-
children: "Mangler onClose",
|
|
54
|
-
}).not.toMatchTypeOf();
|
|
55
|
-
(0, vitest_1.expectTypeOf)({
|
|
56
|
-
header: { heading: "Label" },
|
|
57
|
-
"aria-label": "Label",
|
|
58
|
-
"aria-labelledby": "Label",
|
|
59
|
-
children: "For mange labels",
|
|
60
|
-
}).not.toMatchTypeOf();
|
|
61
|
-
(0, vitest_1.expectTypeOf)({
|
|
62
|
-
"aria-label": "Label",
|
|
63
|
-
"aria-labelledby": "Label",
|
|
64
|
-
children: "For mange labels",
|
|
65
|
-
}).not.toMatchTypeOf();
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=types.test-d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.test-d.js","sourceRoot":"","sources":["../../src/modal/types.test-d.ts"],"names":[],"mappings":";;AAAA,mCAAsC;AAGtC,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;IACxC,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,YAAY,EAAE,OAAO;QACrB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,aAAa,EAAc,CAAC;IAE/B,IAAA,qBAAY,EAAC;QACX,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,6BAA6B;KACxC,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,IAAI,EAAE,IAAI;QACV,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QAC5B,YAAY,EAAE,OAAO;QACrB,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;IAEnC,IAAA,qBAAY,EAAC;QACX,YAAY,EAAE,OAAO;QACrB,iBAAiB,EAAE,OAAO;QAC1B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAC,GAAG,CAAC,aAAa,EAAc,CAAC;AACrC,CAAC,CAAC,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
type AkselThemeContext = {
|
|
3
|
-
/**
|
|
4
|
-
* Color theme
|
|
5
|
-
* @default "light"
|
|
6
|
-
*/
|
|
7
|
-
theme?: "light" | "dark";
|
|
8
|
-
/**
|
|
9
|
-
* Brand volume
|
|
10
|
-
* @default "low"
|
|
11
|
-
* This is experimental and subject to changes
|
|
12
|
-
*/
|
|
13
|
-
volume?: "high" | "low";
|
|
14
|
-
};
|
|
15
|
-
declare const useAkselTheme: <S extends boolean = true>(strict?: S) => S extends true ? AkselThemeContext : AkselThemeContext | undefined;
|
|
16
|
-
declare const AkselTheme: React.ForwardRefExoticComponent<{
|
|
17
|
-
children: React.ReactNode;
|
|
18
|
-
className?: string;
|
|
19
|
-
hasBackground?: boolean;
|
|
20
|
-
asChild?: boolean;
|
|
21
|
-
} & AkselThemeContext & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
-
export { AkselTheme, useAkselTheme };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AkselTheme.js","sourceRoot":"","sources":["../../../src/provider/theme/AkselTheme.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAsB;AACtB,+CAA0C;AAC1C,0CAAuC;AACvC,8DAA0D;AAgB1D,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,GAAG,IAAA,8BAAa,EAAoB;IACtE,YAAY,EAAE,sDAAsD;IACpE,QAAQ,EAAE,eAAe;IACzB,IAAI,EAAE,oBAAoB;IAC1B,YAAY,EAAE,oBAAoB;CACnC,CAAC,CAAC;AA6CkB,sCAAa;AAnClC,MAAM,UAAU,GAAG,IAAA,kBAAU,EAC3B,CAAC,KAAsB,EAAE,GAAG,EAAE,EAAE;;IAC9B,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAErC,MAAM,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,GAAG,KAAK,EACf,KAAK,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,mCAAI,OAAO,EACjC,MAAM,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,KAAK,EACjC,aAAa,EAAE,iBAAiB,GAAG,IAAI,GACxC,GAAG,KAAK,CAAC;IAEV,MAAM,MAAM,GAAG,OAAO,KAAK,SAAS,CAAC;IAErC,MAAM,aAAa,GACjB,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAE7D,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,WAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAE3C,OAAO,CACL,8BAAC,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;QACzC,8BAAC,WAAW,IACV,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAA,cAAE,EAAC,aAAa,EAAE,SAAS,EAAE,KAAK,CAAC,qBAC7B,aAAa,iBACjB,MAAM,IAElB,QAAQ,CACG,CACA,CACjB,CAAC;AACJ,CAAC,CACF,CAAC;AAEO,gCAAU"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Locale } from "date-fns";
|
|
2
|
-
import { Component, ComponentTranslation, Translations } from "./i18n.types";
|
|
3
|
-
type NestedKeyOf<ObjectType extends object> = {
|
|
4
|
-
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
|
|
5
|
-
}[keyof ObjectType & (string | number)];
|
|
6
|
-
export type TFunction<T extends Component> = (keypath: NestedKeyOf<Translations[T]>, replacements?: Record<string, string | number>) => string;
|
|
7
|
-
export declare function useI18n<T extends Component>(componentName: T, ...localTranslations: (ComponentTranslation<T> | undefined)[]): TFunction<T>;
|
|
8
|
-
export declare function useDateLocale(): Locale;
|
|
9
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.context.js","sourceRoot":"","sources":["../../../src/util/i18n/i18n.context.ts"],"names":[],"mappings":";;AA2BA,0BAuCC;AAED,sCAcC;AAjFD,sDAAsD;AACtD,+BAA4B;AAQ5B;;GAEG;AACH,MAAM,aAAa,GAAG,UAAU,CAAC;AAcjC,SAAgB,OAAO,CACrB,aAAgB,EAChB,GAAG,iBAA0D;IAE7D,MAAM,OAAO,GAAG,IAAA,sBAAW,GAAE,CAAC;IAC9B,MAAM,mBAAmB,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;IACvD,MAAM,WAAW,GAAwC;QACvD,GAAG,iBAAiB;QACpB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;YACpC,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;KAC9B,CAAC;IAEF;;OAEG;IACH,MAAM,SAAS,GAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE;QACxD,MAAM,IAAI,GAAG,IAAA,SAAG,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAEvC,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC3C,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAEzD,IAAI,YAAY,CAAC,WAAW,CAAC,KAAK,SAAS,EAAE,CAAC;oBAC5C,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;oBACrD,MAAM,IAAI,KAAK,CACb,0BAA0B,OAAO,gDAAgD,WAAW,+CAA+C,eAAe,GAAG,CAC9J,CAAC;gBACJ,CAAC;gBAED,OAAO,YAAY,CAAC,WAAW,CAAW,CAAC,CAAC,+CAA+C;YAC7F,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,aAAa;IAC3B,MAAM,OAAO,GAAG,IAAA,sBAAW,GAAE,CAAC;IAC9B,MAAM,mBAAmB,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;IACvD,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACpD,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QAC1C,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAExC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,EAAE,CAAC;YACpB,OAAO,GAAG,CAAC,UAAoB,CAAC;QAClC,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|