@navikt/ds-react 5.13.0 → 5.15.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/_docs.json +206 -135
- package/cjs/accordion/AccordionHeader.js +2 -4
- package/cjs/button/Button.js +11 -12
- package/cjs/chips/Removable.js +3 -6
- package/cjs/copybutton/CopyButton.js +4 -5
- package/cjs/date/datepicker/DatePicker.js +4 -2
- package/cjs/date/datepicker/parts/WeekRow.js +2 -2
- package/cjs/date/monthpicker/MonthPicker.js +4 -3
- package/cjs/date/parts/DateWrapper.js +2 -2
- package/cjs/dropdown/Menu/GroupedList/GroupedItem.js +3 -6
- package/cjs/dropdown/Menu/List/Item.js +3 -6
- package/cjs/dropdown/Toggle.js +6 -5
- package/cjs/form/ConfirmationPanel.js +2 -2
- package/cjs/form/Textarea.js +2 -1
- package/cjs/form/checkbox/Checkbox.js +3 -2
- package/cjs/form/combobox/Combobox.js +2 -2
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +3 -4
- package/cjs/form/combobox/Input/inputContext.js +2 -2
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +2 -5
- package/cjs/form/error-summary/ErrorSummary.js +2 -2
- package/cjs/form/radio/Radio.js +3 -2
- package/cjs/form/radio/RadioGroup.js +2 -2
- package/cjs/form/search/Search.js +2 -1
- package/cjs/form/search/SearchButton.js +2 -4
- package/cjs/form/useFormField.js +2 -2
- package/cjs/guide-panel/Illustration.js +2 -2
- package/cjs/help-text/HelpText.js +5 -7
- package/cjs/help-text/HelpTextIcon.js +2 -2
- package/cjs/list/List.js +2 -2
- package/cjs/loader/Loader.js +2 -1
- package/cjs/modal/Modal.js +21 -18
- package/cjs/modal/dialog-polyfill.js +2 -2
- package/cjs/popover/Popover.js +6 -5
- package/cjs/read-more/ReadMore.js +2 -4
- package/cjs/stepper/Step.js +6 -6
- package/cjs/{util → table}/AnimateHeight.js +4 -5
- package/cjs/table/DataCell.js +2 -2
- package/cjs/table/ExpandableRow.js +9 -9
- package/cjs/table/HeaderCell.js +2 -1
- package/cjs/tabs/TabList.js +2 -1
- package/cjs/tag/Tag.js +4 -2
- package/cjs/timeline/Pin.js +2 -2
- package/cjs/timeline/period/ClickablePeriod.js +2 -2
- package/cjs/toggle-group/ToggleGroup.js +2 -2
- package/cjs/tooltip/Tooltip.js +6 -5
- package/cjs/util/Slot.js +2 -5
- package/cjs/util/TextareaAutoSize.js +7 -5
- package/cjs/util/composeEventHandlers.js +17 -0
- package/cjs/util/hooks/index.js +19 -0
- package/cjs/util/hooks/package.json +6 -0
- package/cjs/util/hooks/useClientLayoutEffect.js +7 -0
- package/cjs/util/hooks/useMergeRefs.js +37 -0
- package/cjs/util/{usePrevious.js → hooks/usePrevious.js} +2 -1
- package/cjs/util/index.js +7 -7
- package/cjs/util/types/index.js +2 -0
- package/cjs/util/types/package.json +6 -0
- package/esm/accordion/AccordionHeader.js +2 -4
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/button/Button.d.ts +1 -1
- package/esm/button/Button.js +12 -13
- package/esm/button/Button.js.map +1 -1
- package/esm/chips/Chips.d.ts +1 -1
- package/esm/chips/Removable.js +3 -6
- package/esm/chips/Removable.js.map +1 -1
- package/esm/chips/Toggle.d.ts +1 -1
- package/esm/copybutton/CopyButton.js +4 -5
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/datepicker/DatePicker.js +5 -3
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/parts/WeekRow.js +1 -1
- package/esm/date/datepicker/parts/WeekRow.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.js +4 -3
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/date/parts/DateWrapper.js +1 -1
- package/esm/date/parts/DateWrapper.js.map +1 -1
- package/esm/date/utils/dates-disabled.d.ts +1 -1
- package/esm/date/utils/dates-disabled.js.map +1 -1
- package/esm/dropdown/Menu/GroupedList/GroupedItem.d.ts +1 -1
- package/esm/dropdown/Menu/GroupedList/GroupedItem.js +3 -6
- package/esm/dropdown/Menu/GroupedList/GroupedItem.js.map +1 -1
- package/esm/dropdown/Menu/GroupedList/index.d.ts +1 -1
- package/esm/dropdown/Menu/List/Item.d.ts +1 -1
- package/esm/dropdown/Menu/List/Item.js +3 -6
- package/esm/dropdown/Menu/List/Item.js.map +1 -1
- package/esm/dropdown/Menu/List/index.d.ts +1 -1
- package/esm/dropdown/Toggle.js +6 -5
- package/esm/dropdown/Toggle.js.map +1 -1
- package/esm/expansion-card/ExpansionCard.d.ts +1 -1
- package/esm/expansion-card/ExpansionCardTitle.d.ts +1 -1
- package/esm/form/ConfirmationPanel.js +1 -1
- package/esm/form/ConfirmationPanel.js.map +1 -1
- package/esm/form/Textarea.js +2 -1
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +2 -1
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/combobox/Combobox.js +3 -3
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +1 -2
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
- package/esm/form/combobox/Input/inputContext.js +1 -1
- package/esm/form/combobox/Input/inputContext.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +1 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.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/error-summary/ErrorSummaryItem.d.ts +1 -1
- package/esm/form/radio/Radio.js +2 -1
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/RadioGroup.js +1 -1
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/form/search/Search.js +4 -3
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.js +2 -4
- package/esm/form/search/SearchButton.js.map +1 -1
- package/esm/form/useFormField.js +1 -1
- package/esm/form/useFormField.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.d.ts +0 -5
- package/esm/help-text/HelpText.js +6 -8
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/help-text/HelpTextIcon.js +1 -1
- package/esm/internal-header/InternalHeader.d.ts +1 -1
- package/esm/internal-header/InternalHeaderButton.d.ts +1 -1
- package/esm/internal-header/InternalHeaderTitle.d.ts +1 -1
- package/esm/internal-header/InternalHeaderUserButton.d.ts +1 -1
- package/esm/layout/box/Box.d.ts +1 -1
- package/esm/layout/page/parts/PageBlock.d.ts +1 -1
- package/esm/layout/stack/HStack.d.ts +1 -1
- package/esm/layout/stack/Stack.d.ts +1 -1
- package/esm/layout/stack/VStack.d.ts +1 -1
- package/esm/link/Link.d.ts +1 -1
- package/esm/link-panel/LinkPanel.d.ts +1 -1
- package/esm/link-panel/LinkPanelTitle.d.ts +1 -1
- package/esm/list/List.js +1 -1
- package/esm/loader/Loader.js +2 -1
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/Modal.js +21 -18
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/dialog-polyfill.js +2 -2
- package/esm/modal/dialog-polyfill.js.map +1 -1
- package/esm/modal/types.d.ts +1 -1
- package/esm/pagination/PaginationItem.d.ts +1 -1
- package/esm/panel/Panel.d.ts +1 -1
- package/esm/popover/Popover.d.ts +1 -1
- package/esm/popover/Popover.js +4 -3
- package/esm/popover/Popover.js.map +1 -1
- package/esm/read-more/ReadMore.js +2 -4
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/stepper/Step.d.ts +1 -1
- package/esm/stepper/Step.js +6 -6
- package/esm/stepper/Step.js.map +1 -1
- package/esm/{util → table}/AnimateHeight.js +4 -5
- package/esm/table/AnimateHeight.js.map +1 -0
- package/esm/table/DataCell.d.ts +4 -0
- package/esm/table/DataCell.js +2 -2
- package/esm/table/DataCell.js.map +1 -1
- package/esm/table/ExpandableRow.js +8 -8
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/table/HeaderCell.d.ts +4 -0
- package/esm/table/HeaderCell.js +2 -1
- package/esm/table/HeaderCell.js.map +1 -1
- package/esm/tabs/Tab.d.ts +1 -1
- package/esm/tabs/TabList.js +3 -2
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/tabs/Tabs.d.ts +1 -1
- package/esm/tag/Tag.d.ts +4 -0
- package/esm/tag/Tag.js +4 -2
- package/esm/tag/Tag.js.map +1 -1
- package/esm/timeline/Pin.js +3 -3
- package/esm/timeline/Pin.js.map +1 -1
- package/esm/timeline/period/ClickablePeriod.js +3 -3
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/toggle-group/ToggleGroup.js +1 -1
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/tooltip/Tooltip.js +6 -5
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/BodyLong.d.ts +1 -1
- package/esm/typography/BodyShort.d.ts +1 -1
- package/esm/typography/Detail.d.ts +1 -1
- package/esm/typography/ErrorMessage.d.ts +1 -1
- package/esm/typography/Heading.d.ts +1 -1
- package/esm/typography/Ingress.d.ts +1 -1
- package/esm/typography/Label.d.ts +1 -1
- package/esm/util/Slot.js +1 -1
- package/esm/util/Slot.js.map +1 -1
- package/esm/util/TextareaAutoSize.js +5 -3
- package/esm/util/TextareaAutoSize.js.map +1 -1
- package/esm/util/composeEventHandlers.d.ts +8 -0
- package/esm/util/composeEventHandlers.js +14 -0
- package/esm/util/composeEventHandlers.js.map +1 -0
- package/esm/util/hooks/index.d.ts +8 -0
- package/esm/util/hooks/index.js +9 -0
- package/esm/util/hooks/index.js.map +1 -0
- package/esm/util/hooks/useClientLayoutEffect.js +5 -0
- package/esm/util/hooks/useClientLayoutEffect.js.map +1 -0
- package/esm/util/{useEventListener.d.ts → hooks/useEventListener.d.ts} +1 -1
- package/esm/util/hooks/useEventListener.js.map +1 -0
- package/esm/util/hooks/useId.js.map +1 -0
- package/esm/util/hooks/useMedia.js.map +1 -0
- package/esm/util/hooks/useMergeRefs.d.ts +15 -0
- package/esm/util/hooks/useMergeRefs.js +30 -0
- package/esm/util/hooks/useMergeRefs.js.map +1 -0
- package/esm/util/hooks/usePrevious.d.ts +1 -0
- package/esm/util/{usePrevious.js → hooks/usePrevious.js} +1 -2
- package/esm/util/hooks/usePrevious.js.map +1 -0
- package/esm/util/index.d.ts +4 -5
- package/esm/util/index.js +3 -5
- package/esm/util/index.js.map +1 -1
- package/esm/util/types/OverridableComponent.js.map +1 -0
- package/esm/util/types/index.d.ts +1 -0
- package/esm/util/types/index.js +2 -0
- package/esm/util/types/index.js.map +1 -0
- package/package.json +3 -3
- package/src/accordion/AccordionHeader.tsx +2 -4
- package/src/accordion/AccordionItem.tsx +2 -2
- package/src/alert/alert.stories.tsx +1 -2
- package/src/button/Button.tsx +14 -19
- package/src/button/button.stories.tsx +2 -2
- package/src/chips/Chips.tsx +1 -1
- package/src/chips/Removable.tsx +3 -4
- package/src/chips/Toggle.tsx +1 -1
- package/src/copybutton/CopyButton.tsx +4 -5
- package/src/copybutton/copy-button.stories.tsx +1 -1
- package/src/date/datepicker/DatePicker.tsx +5 -3
- package/src/date/datepicker/parts/WeekRow.tsx +1 -1
- package/src/date/monthpicker/MonthPicker.tsx +4 -3
- package/src/date/parts/DateWrapper.tsx +1 -1
- package/src/date/utils/dates-disabled.ts +1 -1
- package/src/dropdown/Menu/GroupedList/GroupedItem.tsx +23 -23
- package/src/dropdown/Menu/GroupedList/index.tsx +1 -1
- package/src/dropdown/Menu/List/Item.tsx +23 -23
- package/src/dropdown/Menu/List/index.tsx +1 -1
- package/src/dropdown/Toggle.tsx +10 -6
- package/src/expansion-card/ExpansionCard.tsx +1 -1
- package/src/expansion-card/ExpansionCardTitle.tsx +1 -1
- package/src/form/ConfirmationPanel.tsx +1 -1
- package/src/form/Textarea.tsx +2 -1
- package/src/form/checkbox/Checkbox.tsx +2 -1
- package/src/form/combobox/Combobox.tsx +3 -6
- package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +1 -2
- package/src/form/combobox/FilteredOptions/useVirtualFocus.ts +1 -1
- package/src/form/combobox/Input/inputContext.tsx +1 -1
- package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +1 -1
- package/src/form/combobox/combobox.stories.tsx +10 -11
- package/src/form/error-summary/ErrorSummary.tsx +1 -1
- package/src/form/error-summary/ErrorSummaryItem.tsx +1 -1
- package/src/form/radio/Radio.tsx +2 -1
- package/src/form/radio/RadioGroup.tsx +1 -1
- package/src/form/search/Search.tsx +3 -3
- package/src/form/search/SearchButton.tsx +2 -4
- package/src/form/useFormField.ts +1 -1
- package/src/guide-panel/Illustration.tsx +1 -1
- package/src/help-text/HelpText.tsx +7 -25
- package/src/help-text/HelpTextIcon.tsx +1 -1
- package/src/help-text/help-text.stories.tsx +58 -68
- package/src/internal-header/InternalHeader.tsx +1 -1
- package/src/internal-header/InternalHeaderButton.tsx +1 -1
- package/src/internal-header/InternalHeaderTitle.tsx +1 -1
- package/src/internal-header/InternalHeaderUserButton.tsx +1 -1
- package/src/layout/box/Box.tsx +1 -1
- package/src/layout/page/parts/PageBlock.tsx +1 -1
- package/src/layout/stack/HStack.tsx +1 -1
- package/src/layout/stack/Stack.tsx +1 -1
- package/src/layout/stack/VStack.tsx +1 -1
- package/src/link/Link.tsx +1 -1
- package/src/link/{link.stories.tsx → stories/link.stories.tsx} +2 -2
- package/src/link-panel/LinkPanel.tsx +1 -1
- package/src/link-panel/LinkPanelTitle.tsx +1 -1
- package/src/list/List.tsx +1 -1
- package/src/loader/Loader.tsx +2 -1
- package/src/modal/Modal.tsx +30 -30
- package/src/modal/dialog-polyfill.ts +2 -2
- package/src/modal/types.ts +1 -1
- package/src/pagination/PaginationItem.tsx +1 -1
- package/src/panel/Panel.tsx +1 -1
- package/src/popover/Popover.tsx +4 -7
- package/src/read-more/ReadMore.tsx +2 -4
- package/src/stepper/Step.tsx +8 -5
- package/src/{util → table}/AnimateHeight.tsx +5 -9
- package/src/table/DataCell.tsx +6 -1
- package/src/table/ExpandableRow.tsx +11 -6
- package/src/table/HeaderCell.tsx +6 -1
- package/src/table/stories/table.stories.tsx +43 -29
- package/src/table/stories/tests/table.stories.tsx +2 -3
- package/src/tabs/Tab.tsx +1 -1
- package/src/tabs/TabList.tsx +4 -2
- package/src/tabs/Tabs.tsx +1 -1
- package/src/tag/Tag.tsx +9 -2
- package/src/tag/tag.stories.tsx +27 -1
- package/src/timeline/Pin.tsx +3 -6
- package/src/timeline/period/ClickablePeriod.tsx +3 -6
- package/src/toggle-group/ToggleGroup.tsx +1 -1
- package/src/tooltip/Tooltip.tsx +11 -22
- package/src/typography/BodyLong.tsx +1 -1
- package/src/typography/BodyShort.tsx +1 -1
- package/src/typography/Detail.tsx +1 -1
- package/src/typography/ErrorMessage.tsx +1 -1
- package/src/typography/Heading.tsx +1 -1
- package/src/typography/Ingress.tsx +1 -1
- package/src/typography/Label.tsx +1 -1
- package/src/typography/stories/bodylong.stories.tsx +1 -2
- package/src/typography/stories/bodyshort.stories.tsx +1 -2
- package/src/typography/stories/detail.stories.tsx +1 -2
- package/src/typography/stories/error-message.stories.tsx +1 -2
- package/src/typography/stories/heading.stories.tsx +1 -2
- package/src/typography/stories/ingress.stories.tsx +1 -2
- package/src/typography/stories/label.stories.tsx +1 -2
- package/src/util/Slot.tsx +1 -1
- package/src/util/TextareaAutoSize.tsx +7 -3
- package/src/util/__tests__/useMedia.test.tsx +1 -1
- package/src/util/composeEventHandlers.ts +19 -0
- package/src/util/hooks/index.ts +8 -0
- package/src/util/hooks/useCallbackRef.ts +1 -1
- package/src/util/hooks/useClientLayoutEffect.ts +5 -0
- package/src/util/hooks/useControllableState.ts +1 -1
- package/src/util/hooks/useMergeRefs.ts +32 -0
- package/src/util/{usePrevious.ts → hooks/usePrevious.ts} +1 -4
- package/src/util/index.ts +4 -5
- package/src/util/types/index.ts +1 -0
- package/cjs/util/RandomIcon.js +0 -38
- package/cjs/util/mergeRefs.js +0 -16
- package/cjs/util/useClientLayoutEffect.js +0 -10
- package/esm/util/AnimateHeight.js.map +0 -1
- package/esm/util/OverridableComponent.js.map +0 -1
- package/esm/util/RandomIcon.d.ts +0 -2
- package/esm/util/RandomIcon.js +0 -9
- package/esm/util/RandomIcon.js.map +0 -1
- package/esm/util/mergeRefs.d.ts +0 -2
- package/esm/util/mergeRefs.js +0 -14
- package/esm/util/mergeRefs.js.map +0 -1
- package/esm/util/useClientLayoutEffect.js +0 -8
- package/esm/util/useClientLayoutEffect.js.map +0 -1
- package/esm/util/useEventListener.js.map +0 -1
- package/esm/util/useId.js.map +0 -1
- package/esm/util/useMedia.js.map +0 -1
- package/esm/util/usePrevious.d.ts +0 -2
- package/esm/util/usePrevious.js.map +0 -1
- package/src/util/mergeRefs.tsx +0 -16
- package/src/util/useClientLayoutEffect.ts +0 -11
- /package/cjs/util/{useEventListener.js → hooks/useEventListener.js} +0 -0
- /package/cjs/util/{useId.js → hooks/useId.js} +0 -0
- /package/cjs/util/{useMedia.js → hooks/useMedia.js} +0 -0
- /package/cjs/util/{OverridableComponent.js → types/OverridableComponent.js} +0 -0
- /package/esm/{util → table}/AnimateHeight.d.ts +0 -0
- /package/esm/util/{useClientLayoutEffect.d.ts → hooks/useClientLayoutEffect.d.ts} +0 -0
- /package/esm/util/{useEventListener.js → hooks/useEventListener.js} +0 -0
- /package/esm/util/{useId.d.ts → hooks/useId.d.ts} +0 -0
- /package/esm/util/{useId.js → hooks/useId.js} +0 -0
- /package/esm/util/{useMedia.d.ts → hooks/useMedia.d.ts} +0 -0
- /package/esm/util/{useMedia.js → hooks/useMedia.js} +0 -0
- /package/esm/util/{OverridableComponent.d.ts → types/OverridableComponent.d.ts} +0 -0
- /package/esm/util/{OverridableComponent.js → types/OverridableComponent.js} +0 -0
- /package/src/{util → link/stories}/RandomIcon.tsx +0 -0
- /package/src/util/{useEventListener.ts → hooks/useEventListener.ts} +0 -0
- /package/src/util/{useId.ts → hooks/useId.ts} +0 -0
- /package/src/util/{useMedia.ts → hooks/useMedia.ts} +0 -0
- /package/src/util/{OverridableComponent.ts → types/OverridableComponent.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { OverridableComponent } from "../util/
|
|
2
|
+
import { OverridableComponent } from "../util/types";
|
|
3
3
|
import { TypoProps } from "./types";
|
|
4
4
|
export interface ErrorMessageProps extends Pick<TypoProps, "spacing">, React.HTMLAttributes<HTMLParagraphElement> {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { OverridableComponent } from "../util/
|
|
2
|
+
import { OverridableComponent } from "../util/types";
|
|
3
3
|
import { TypoProps } from "./types";
|
|
4
4
|
export interface HeadingProps extends Pick<TypoProps, "spacing" | "visuallyHidden" | "align" | "textColor">, React.HTMLAttributes<HTMLHeadingElement> {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { OverridableComponent } from "../util/
|
|
2
|
+
import { OverridableComponent } from "../util/types";
|
|
3
3
|
import { TypoProps } from "./types";
|
|
4
4
|
export interface LabelProps extends Omit<TypoProps, "weight" | "align" | "truncate">, React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
5
5
|
/**
|
package/esm/util/Slot.js
CHANGED
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
// https://github.com/radix-ui/primitives/blob/main/packages/react/slot/src/Slot.tsx
|
|
13
13
|
import * as React from "react";
|
|
14
|
-
import mergeRefs from "./
|
|
14
|
+
import { mergeRefs } from "./hooks/useMergeRefs";
|
|
15
15
|
export const Slot = React.forwardRef((props, forwardedRef) => {
|
|
16
16
|
const { children } = props, slotProps = __rest(props, ["children"]);
|
|
17
17
|
if (React.isValidElement(children)) {
|
package/esm/util/Slot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slot.js","sourceRoot":"","sources":["../../src/util/Slot.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,oFAAoF;AACpF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"Slot.js","sourceRoot":"","sources":["../../src/util/Slot.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,oFAAoF;AACpF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMjD,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAClC,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IACtB,MAAM,EAAE,QAAQ,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK,EAAlC,YAA0B,CAAQ,CAAC;IAEzC,IAAI,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC,YAAY,CAAM,QAAQ,kCAClC,UAAU,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,KACxC,GAAG,EAAE,YAAY;gBACf,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,EAAG,QAAgB,CAAC,GAAG,CAAC,CAAC;gBAClD,CAAC,CAAE,QAAgB,CAAC,GAAG,IACzB,CAAC;IACL,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,CAAC,KAAK,CACX,oFAAoF,CACrF,CAAC;QACF,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAE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ui/blob/master/packages/mui-base/src/TextareaAutosize/TextareaAutosize.tsx */
|
|
13
|
-
import React, { forwardRef, useEffect,
|
|
13
|
+
import React, { forwardRef, useEffect, useRef, useState } from "react";
|
|
14
14
|
import ReactDOM from "react-dom";
|
|
15
|
-
import {
|
|
15
|
+
import { useClientLayoutEffect } from "../util/hooks";
|
|
16
|
+
import debounce from "./debounce";
|
|
17
|
+
import { useMergeRefs } from "./hooks/useMergeRefs";
|
|
16
18
|
const updateState = (prevState, newState, renders) => {
|
|
17
19
|
const { outerHeightStyle, overflow } = newState;
|
|
18
20
|
// Need a large enough difference to update the height.
|
|
@@ -53,7 +55,7 @@ const TextareaAutosize = forwardRef((_a, ref) => {
|
|
|
53
55
|
var { className, onChange, maxRows, minRows = 1, autoScrollbar, style, value } = _a, other = __rest(_a, ["className", "onChange", "maxRows", "minRows", "autoScrollbar", "style", "value"]);
|
|
54
56
|
const { current: isControlled } = useRef(value != null);
|
|
55
57
|
const inputRef = useRef(null);
|
|
56
|
-
const handleRef =
|
|
58
|
+
const handleRef = useMergeRefs(inputRef, ref);
|
|
57
59
|
const shadowRef = useRef(null);
|
|
58
60
|
const renders = useRef(0);
|
|
59
61
|
const [state, setState] = useState({ outerHeightStyle: 0 });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextareaAutoSize.js","sourceRoot":"","sources":["../../src/util/TextareaAutoSize.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,gHAAgH;AAChH,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"TextareaAutoSize.js","sourceRoot":"","sources":["../../src/util/TextareaAutoSize.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,gHAAgH;AAChH,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,E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EF,SAAS,OAAO,CAAC,GAAU;IACzB,OAAO,CACL,GAAG,KAAK,SAAS;QACjB,GAAG,KAAK,IAAI;QACZ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC;QAC7B,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAC9C,CAAC;AACJ,CAAC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* Utility to consistently call original eventhandler, often from props and internal eventhandler
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare function composeEventHandlers<T extends React.SyntheticEvent>(originalEventHandler?: (event: T) => void, ourEventHandler?: (event: T) => void, { checkForDefaultPrevented }?: {
|
|
7
|
+
checkForDefaultPrevented?: boolean | undefined;
|
|
8
|
+
}): (event: T) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* https://github.com/radix-ui/primitives/blob/main/packages/core/primitive/src/primitive.tsx#L1 */
|
|
2
|
+
/**
|
|
3
|
+
* Utility to consistently call original eventhandler, often from props and internal eventhandler
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
7
|
+
return function handleEvent(event) {
|
|
8
|
+
originalEventHandler === null || originalEventHandler === void 0 ? void 0 : originalEventHandler(event);
|
|
9
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
10
|
+
return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=composeEventHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeEventHandlers.js","sourceRoot":"","sources":["../../src/util/composeEventHandlers.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,oBAAyC,EACzC,eAAoC,EACpC,EAAE,wBAAwB,GAAG,IAAI,EAAE,GAAG,EAAE;IAExC,OAAO,SAAS,WAAW,CAAC,KAAQ;QAClC,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAG,KAAK,CAAC,CAAC;QAE9B,IAAI,wBAAwB,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;YAClE,OAAO,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { useCallbackRef } from "./useCallbackRef";
|
|
2
|
+
export { useClientLayoutEffect } from "./useClientLayoutEffect";
|
|
3
|
+
export { useControllableState } from "./useControllableState";
|
|
4
|
+
export { useMergeRefs } from "./useMergeRefs";
|
|
5
|
+
export { useEventListener } from "./useEventListener";
|
|
6
|
+
export { useId } from "./useId";
|
|
7
|
+
export { useMedia } from "./useMedia";
|
|
8
|
+
export { usePrevious } from "./usePrevious";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { useCallbackRef } from "./useCallbackRef";
|
|
2
|
+
export { useClientLayoutEffect } from "./useClientLayoutEffect";
|
|
3
|
+
export { useControllableState } from "./useControllableState";
|
|
4
|
+
export { useMergeRefs } from "./useMergeRefs";
|
|
5
|
+
export { useEventListener } from "./useEventListener";
|
|
6
|
+
export { useId } from "./useId";
|
|
7
|
+
export { useMedia } from "./useMedia";
|
|
8
|
+
export { usePrevious } from "./usePrevious";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClientLayoutEffect.js","sourceRoot":"","sources":["../../../src/util/hooks/useClientLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAExC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ;IACvD,CAAC,CAAC,eAAe;IACjB,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC"}
|
|
@@ -2,4 +2,4 @@ export interface ListenerT {
|
|
|
2
2
|
addEventListener(name: string, handler: (event?: any) => void, ...args: any[]): any;
|
|
3
3
|
removeEventListener(name: string, handler: (event?: any) => void, ...args: any[]): any;
|
|
4
4
|
}
|
|
5
|
-
export declare const useEventListener: <T extends ListenerT>(name: Parameters<ListenerT["addEventListener"]>[0], handler: Parameters<ListenerT["addEventListener"]>[1], target?:
|
|
5
|
+
export declare const useEventListener: <T extends ListenerT>(name: Parameters<ListenerT["addEventListener"]>[0], handler: Parameters<ListenerT["addEventListener"]>[1], target?: T | Window | null) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventListener.js","sourceRoot":"","sources":["../../../src/util/hooks/useEventListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE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B,CAAC,CAAC;QAEF,cAAc,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEpD,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type PossibleRef<T> = React.Ref<T> | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Use `useMergeRefs`
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function mergeRefs<T>(refs: PossibleRef<T>[]): React.RefCallback<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Merges refs within useCallback
|
|
10
|
+
* @internal
|
|
11
|
+
* @param ...refs: React.Ref<T> | undefined
|
|
12
|
+
* @returns React.useCallback(mergeRefs(refs), refs)
|
|
13
|
+
*/
|
|
14
|
+
export declare function useMergeRefs<T>(...refs: PossibleRef<T>[]): (instance: T | null) => void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* https://github.com/radix-ui/primitives/blob/main/packages/react/compose-refs/src/composeRefs.tsx */
|
|
2
|
+
import React from "react";
|
|
3
|
+
// https://github.com/gregberge/react-merge-refs
|
|
4
|
+
/**
|
|
5
|
+
* Use `useMergeRefs`
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export function mergeRefs(refs) {
|
|
9
|
+
return (value) => {
|
|
10
|
+
refs.forEach((ref) => {
|
|
11
|
+
if (typeof ref === "function") {
|
|
12
|
+
ref(value);
|
|
13
|
+
}
|
|
14
|
+
else if (ref !== null && ref !== undefined) {
|
|
15
|
+
ref.current = value;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Merges refs within useCallback
|
|
22
|
+
* @internal
|
|
23
|
+
* @param ...refs: React.Ref<T> | undefined
|
|
24
|
+
* @returns React.useCallback(mergeRefs(refs), refs)
|
|
25
|
+
*/
|
|
26
|
+
export function useMergeRefs(...refs) {
|
|
27
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
+
return React.useCallback(mergeRefs(refs), refs);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=useMergeRefs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMergeRefs.js","sourceRoot":"","sources":["../../../src/util/hooks/useMergeRefs.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,gDAAgD;AAChD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAI,IAAsB;IACjD,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;gBAC9B,GAAG,CAAC,KAAK,CAAC,CAAC;YACb,CAAC;iBAAM,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBAC5C,GAAwC,CAAC,OAAO,GAAG,KAAK,CAAC;YAC5D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAI,GAAG,IAAsB;IACvD,uDAAuD;IACvD,OAAO,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const usePrevious: <T>(value: T) => T | undefined;
|
|
@@ -6,12 +6,11 @@ import { useEffect, useRef } from "react";
|
|
|
6
6
|
* https://usehooks.com/usePrevious/
|
|
7
7
|
* https://blog.logrocket.com/accessing-previous-props-state-react-hooks/
|
|
8
8
|
*/
|
|
9
|
-
const usePrevious = (value) => {
|
|
9
|
+
export const usePrevious = (value) => {
|
|
10
10
|
const ref = useRef(value);
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
ref.current = value;
|
|
13
13
|
}, [value]);
|
|
14
14
|
return ref.current;
|
|
15
15
|
};
|
|
16
|
-
export default usePrevious;
|
|
17
16
|
//# sourceMappingURL=usePrevious.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrevious.js","sourceRoot":"","sources":["../../../src/util/hooks/usePrevious.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,KAAQ,EAAiB,EAAE;IACxD,MAAM,GAAG,GAAG,MAAM,CAAI,KAAK,CAAC,CAAC;IAC7B,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB,CAAC,CAAC"}
|
package/esm/util/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export type * from "./types";
|
|
2
2
|
export { default as debounce } from "./debounce";
|
|
3
|
-
export { default as mergeRefs } from "./mergeRefs";
|
|
4
3
|
export * from "./omit";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
4
|
+
export { useClientLayoutEffect } from "./hooks/useClientLayoutEffect";
|
|
5
|
+
export { useEventListener } from "./hooks/useEventListener";
|
|
6
|
+
export { useId } from "./hooks/useId";
|
package/esm/util/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from "./OverridableComponent";
|
|
2
1
|
export { default as debounce } from "./debounce";
|
|
3
|
-
export { default as mergeRefs } from "./mergeRefs";
|
|
4
2
|
export * from "./omit";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
3
|
+
export { useClientLayoutEffect } from "./hooks/useClientLayoutEffect";
|
|
4
|
+
export { useEventListener } from "./hooks/useEventListener";
|
|
5
|
+
export { useId } from "./hooks/useId";
|
|
8
6
|
//# sourceMappingURL=index.js.map
|
package/esm/util/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverridableComponent.js","sourceRoot":"","sources":["../../../src/util/types/OverridableComponent.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { OverridableComponent } from "./OverridableComponent";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.15.0",
|
|
4
4
|
"description": "Aksel react-components for NAV designsystem",
|
|
5
5
|
"author": "Aksel | NAV designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@floating-ui/react": "0.25.4",
|
|
41
|
-
"@navikt/aksel-icons": "^5.
|
|
42
|
-
"@navikt/ds-tokens": "^5.
|
|
41
|
+
"@navikt/aksel-icons": "^5.15.0",
|
|
42
|
+
"@navikt/ds-tokens": "^5.15.0",
|
|
43
43
|
"@radix-ui/react-tabs": "1.0.0",
|
|
44
44
|
"@radix-ui/react-toggle-group": "1.0.0",
|
|
45
45
|
"clsx": "^1.2.1",
|
|
@@ -2,6 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import React, { forwardRef, useContext } from "react";
|
|
3
3
|
import { ChevronDownIcon } from "@navikt/aksel-icons";
|
|
4
4
|
import { Heading } from "../typography";
|
|
5
|
+
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
5
6
|
import { AccordionContext } from "./AccordionContext";
|
|
6
7
|
import { AccordionItemContext } from "./AccordionItem";
|
|
7
8
|
|
|
@@ -30,10 +31,7 @@ const AccordionHeader = forwardRef<HTMLButtonElement, AccordionHeaderProps>(
|
|
|
30
31
|
ref={ref}
|
|
31
32
|
{...rest}
|
|
32
33
|
className={cl("navds-accordion__header", className)}
|
|
33
|
-
onClick={(
|
|
34
|
-
itemContext.toggleOpen();
|
|
35
|
-
onClick && onClick(e);
|
|
36
|
-
}}
|
|
34
|
+
onClick={composeEventHandlers(onClick, itemContext.toggleOpen)}
|
|
37
35
|
aria-expanded={itemContext.open}
|
|
38
36
|
type="button"
|
|
39
37
|
>
|
|
@@ -38,7 +38,7 @@ export const AccordionItemContext =
|
|
|
38
38
|
const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
|
|
39
39
|
(
|
|
40
40
|
{ children, className, open, defaultOpen = false, onOpenChange, ...rest },
|
|
41
|
-
ref
|
|
41
|
+
ref,
|
|
42
42
|
) => {
|
|
43
43
|
const [_open, _setOpen] = useControllableState({
|
|
44
44
|
defaultValue: defaultOpen,
|
|
@@ -78,7 +78,7 @@ const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
|
|
|
78
78
|
</AccordionItemContext.Provider>
|
|
79
79
|
</div>
|
|
80
80
|
);
|
|
81
|
-
}
|
|
81
|
+
},
|
|
82
82
|
);
|
|
83
83
|
|
|
84
84
|
export default AccordionItem;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { expect } from "@storybook/jest";
|
|
2
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
-
import { userEvent, within } from "@storybook/
|
|
2
|
+
import { expect, userEvent, within } from "@storybook/test";
|
|
4
3
|
import React from "react";
|
|
5
4
|
import { Alert, AlertProps } from ".";
|
|
6
5
|
import { BodyLong, Heading as DsHeading, Link } from "..";
|
package/src/button/Button.tsx
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
|
-
import React, { forwardRef,
|
|
2
|
+
import React, { forwardRef, useRef, useState } from "react";
|
|
3
3
|
import { Loader } from "../loader";
|
|
4
4
|
import { Label } from "../typography";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "../util";
|
|
5
|
+
import { omit } from "../util";
|
|
6
|
+
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
7
|
+
import { useClientLayoutEffect } from "../util/hooks";
|
|
8
|
+
import { useMergeRefs } from "../util/hooks/useMergeRefs";
|
|
9
|
+
import { OverridableComponent } from "../util/types";
|
|
11
10
|
|
|
12
11
|
export interface ButtonProps
|
|
13
12
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -84,7 +83,7 @@ export const Button: OverridableComponent<ButtonProps, HTMLButtonElement> =
|
|
|
84
83
|
const buttonRef = useRef<HTMLButtonElement | null>(null);
|
|
85
84
|
const [widthOverride, setWidthOverride] = useState<number>();
|
|
86
85
|
|
|
87
|
-
const mergedRef =
|
|
86
|
+
const mergedRef = useMergeRefs(buttonRef, ref);
|
|
88
87
|
|
|
89
88
|
useClientLayoutEffect(() => {
|
|
90
89
|
if (loading) {
|
|
@@ -103,22 +102,18 @@ export const Button: OverridableComponent<ButtonProps, HTMLButtonElement> =
|
|
|
103
102
|
const filterProps: React.ButtonHTMLAttributes<HTMLButtonElement> =
|
|
104
103
|
disabled ?? widthOverride ? omit(rest, ["href"]) : rest;
|
|
105
104
|
|
|
105
|
+
const handleKeyUp = (e: React.KeyboardEvent<HTMLButtonElement>) => {
|
|
106
|
+
if (e.key === " " && !disabled && !widthOverride) {
|
|
107
|
+
e.currentTarget.click();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
106
111
|
return (
|
|
107
112
|
<Component
|
|
108
113
|
{...(Component !== "button" ? { role: "button" } : {})}
|
|
109
114
|
{...filterProps}
|
|
110
115
|
ref={mergedRef}
|
|
111
|
-
onKeyUp={(
|
|
112
|
-
filterProps.onKeyUp?.(e);
|
|
113
|
-
if (
|
|
114
|
-
e.key === " " &&
|
|
115
|
-
!disabled &&
|
|
116
|
-
!widthOverride &&
|
|
117
|
-
!e.isDefaultPrevented()
|
|
118
|
-
) {
|
|
119
|
-
e.currentTarget.click();
|
|
120
|
-
}
|
|
121
|
-
}}
|
|
116
|
+
onKeyUp={composeEventHandlers(filterProps.onKeyUp, handleKeyUp)}
|
|
122
117
|
className={cl(
|
|
123
118
|
className,
|
|
124
119
|
"navds-button",
|
|
@@ -10,7 +10,7 @@ export default {
|
|
|
10
10
|
},
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const variants:
|
|
13
|
+
const variants: (
|
|
14
14
|
| "primary"
|
|
15
15
|
| "secondary"
|
|
16
16
|
| "tertiary"
|
|
@@ -18,7 +18,7 @@ const variants: Array<
|
|
|
18
18
|
| "secondary-neutral"
|
|
19
19
|
| "tertiary-neutral"
|
|
20
20
|
| "danger"
|
|
21
|
-
|
|
21
|
+
)[] = [
|
|
22
22
|
"primary",
|
|
23
23
|
"secondary",
|
|
24
24
|
"tertiary",
|
package/src/chips/Chips.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { HTMLAttributes, forwardRef } from "react";
|
|
3
|
-
import { OverridableComponent } from "../util";
|
|
3
|
+
import { OverridableComponent } from "../util/types";
|
|
4
4
|
import RemovableChips, { RemovableChipsProps } from "./Removable";
|
|
5
5
|
import ToggleChips, { ToggleChipsProps } from "./Toggle";
|
|
6
6
|
|
package/src/chips/Removable.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
import { XMarkIcon } from "@navikt/aksel-icons";
|
|
4
|
+
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
4
5
|
|
|
5
6
|
export interface RemovableChipsProps
|
|
6
7
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -33,6 +34,7 @@ export const RemovableChips = forwardRef<
|
|
|
33
34
|
removeLabel = "slett",
|
|
34
35
|
onDelete,
|
|
35
36
|
type = "button",
|
|
37
|
+
onClick,
|
|
36
38
|
...rest
|
|
37
39
|
},
|
|
38
40
|
ref,
|
|
@@ -48,10 +50,7 @@ export const RemovableChips = forwardRef<
|
|
|
48
50
|
`navds-chips__removable--${variant}`,
|
|
49
51
|
)}
|
|
50
52
|
aria-label={`${children} ${removeLabel}`}
|
|
51
|
-
onClick={(
|
|
52
|
-
onDelete?.();
|
|
53
|
-
rest?.onClick?.(e);
|
|
54
|
-
}}
|
|
53
|
+
onClick={composeEventHandlers(onClick, onDelete)}
|
|
55
54
|
>
|
|
56
55
|
<span className="navds-chips__chip-text">{children}</span>
|
|
57
56
|
<span className="navds-chips__removable-icon">
|
package/src/chips/Toggle.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
|
-
import { OverridableComponent } from "../util";
|
|
3
|
+
import { OverridableComponent } from "../util/types";
|
|
4
4
|
|
|
5
5
|
export interface ToggleChipsProps
|
|
6
6
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -8,6 +8,7 @@ import React, {
|
|
|
8
8
|
} from "react";
|
|
9
9
|
import { CheckmarkIcon, FilesIcon } from "@navikt/aksel-icons";
|
|
10
10
|
import { Label } from "../typography";
|
|
11
|
+
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
11
12
|
import copy from "../util/copy";
|
|
12
13
|
|
|
13
14
|
export interface CopyButtonProps
|
|
@@ -97,6 +98,7 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
97
98
|
title = "Kopier",
|
|
98
99
|
activeTitle = "Kopiert",
|
|
99
100
|
iconPosition = "left",
|
|
101
|
+
onClick,
|
|
100
102
|
...rest
|
|
101
103
|
},
|
|
102
104
|
ref,
|
|
@@ -110,14 +112,11 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
110
112
|
};
|
|
111
113
|
}, []);
|
|
112
114
|
|
|
113
|
-
const handleClick = (
|
|
114
|
-
event: React.MouseEvent<HTMLButtonElement, MouseEvent>,
|
|
115
|
-
) => {
|
|
115
|
+
const handleClick = () => {
|
|
116
116
|
timeoutRef.current && clearTimeout(timeoutRef.current);
|
|
117
117
|
copy(copyText);
|
|
118
118
|
setActive(true);
|
|
119
119
|
onActiveChange?.(true);
|
|
120
|
-
rest.onClick?.(event);
|
|
121
120
|
|
|
122
121
|
timeoutRef.current = window.setTimeout(() => {
|
|
123
122
|
setActive(false);
|
|
@@ -160,7 +159,7 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
|
160
159
|
"navds-copybutton--active": active,
|
|
161
160
|
},
|
|
162
161
|
)}
|
|
163
|
-
onClick={handleClick}
|
|
162
|
+
onClick={composeEventHandlers(onClick, handleClick)}
|
|
164
163
|
>
|
|
165
164
|
<span className="navds-copybutton__content">
|
|
166
165
|
{iconPosition === "left" && copyIcon}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { userEvent, within } from "@storybook/
|
|
2
|
+
import { userEvent, within } from "@storybook/test";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { LinkIcon, ThumbUpIcon } from "@navikt/aksel-icons";
|
|
5
5
|
import { CopyButton } from ".";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import isWeekend from "date-fns/isWeekend";
|
|
3
|
-
import React, { forwardRef,
|
|
3
|
+
import React, { forwardRef, useRef, useState } from "react";
|
|
4
4
|
import { DateRange, DayPicker, isMatch } from "react-day-picker";
|
|
5
|
-
import {
|
|
5
|
+
import { omit } from "../../util";
|
|
6
|
+
import { useId } from "../../util/hooks";
|
|
7
|
+
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
6
8
|
import { DateContext } from "../context";
|
|
7
9
|
import { DatePickerInput } from "../parts/DateInput";
|
|
8
10
|
import { DateWrapper } from "../parts/DateWrapper";
|
|
@@ -88,7 +90,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
|
88
90
|
const [open, setOpen] = useState(_open ?? false);
|
|
89
91
|
|
|
90
92
|
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
|
91
|
-
const mergedRef =
|
|
93
|
+
const mergedRef = useMergeRefs(wrapperRef, ref);
|
|
92
94
|
|
|
93
95
|
const [selectedDates, setSelectedDates] = React.useState<
|
|
94
96
|
Date | Date[] | DateRange | undefined
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { useDayPicker } from "react-day-picker";
|
|
3
3
|
import { Show } from "../../../layout/responsive";
|
|
4
4
|
import { Detail } from "../../../typography";
|
|
5
|
-
import { useId } from "../../../util";
|
|
5
|
+
import { useId } from "../../../util/hooks";
|
|
6
6
|
import { getMonthWeeks } from "../../utils/get-month-weeks";
|
|
7
7
|
import { labelWeek } from "../../utils/labels";
|
|
8
8
|
import WeekNumber from "./WeekNumber";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
|
-
import React, { forwardRef,
|
|
2
|
+
import React, { forwardRef, useRef, useState } from "react";
|
|
3
3
|
import { RootProvider } from "react-day-picker";
|
|
4
|
-
import {
|
|
4
|
+
import { useId } from "../../util/hooks";
|
|
5
|
+
import { useMergeRefs } from "../../util/hooks/useMergeRefs";
|
|
5
6
|
import { DateContext, SharedMonthProvider } from "../context";
|
|
6
7
|
import { MonthPickerInput } from "../parts/DateInput";
|
|
7
8
|
import { DateWrapper } from "../parts/DateWrapper";
|
|
@@ -81,7 +82,7 @@ export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
|
|
|
81
82
|
const [open, setOpen] = useState(_open ?? false);
|
|
82
83
|
|
|
83
84
|
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
|
84
|
-
const mergedRef =
|
|
85
|
+
const mergedRef = useMergeRefs(wrapperRef, ref);
|
|
85
86
|
|
|
86
87
|
const [selectedMonth, setSelectedMonth] = useState<Date | undefined>(
|
|
87
88
|
defaultSelected,
|