@navikt/ds-react 5.13.0 → 5.14.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/popover/Popover.js +6 -5
- package/cjs/read-more/ReadMore.js +2 -4
- package/cjs/stepper/Step.js +6 -6
- 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/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/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/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/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/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/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/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/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/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 → table}/AnimateHeight.js +0 -0
- /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 → table}/AnimateHeight.js +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 → table}/AnimateHeight.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
|
@@ -40,15 +40,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.ListItem = void 0;
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
|
+
const composeEventHandlers_1 = require("../../../util/composeEventHandlers");
|
|
43
44
|
const context_1 = require("../../context");
|
|
44
45
|
exports.ListItem = (0, react_1.forwardRef)((_a, ref) => {
|
|
45
|
-
var { as: Component = "button", className } = _a, rest = __rest(_a, ["as", "className"]);
|
|
46
|
+
var { as: Component = "button", className, onClick } = _a, rest = __rest(_a, ["as", "className", "onClick"]);
|
|
46
47
|
const context = (0, react_1.useContext)(context_1.DropdownContext);
|
|
47
48
|
return (react_1.default.createElement("li", { className: "navds-dropdown__list-item" },
|
|
48
|
-
react_1.default.createElement(Component, Object.assign({}, rest, { value: rest.children, onClick: (
|
|
49
|
-
var _a, _b;
|
|
50
|
-
(_a = context === null || context === void 0 ? void 0 : context.onSelect) === null || _a === void 0 ? void 0 : _a.call(context, event);
|
|
51
|
-
(_b = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _b === void 0 ? void 0 : _b.call(rest, event);
|
|
52
|
-
}, ref: ref, className: (0, clsx_1.default)("navds-dropdown__item", "navds-body-short", "navds-body-short--small", className) }))));
|
|
49
|
+
react_1.default.createElement(Component, Object.assign({}, rest, { value: rest.children, onClick: (0, composeEventHandlers_1.composeEventHandlers)(onClick, context === null || context === void 0 ? void 0 : context.onSelect), ref: ref, className: (0, clsx_1.default)("navds-dropdown__item", "navds-body-short", "navds-body-short--small", className) }))));
|
|
53
50
|
});
|
|
54
51
|
exports.default = exports.ListItem;
|
package/cjs/dropdown/Toggle.js
CHANGED
|
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.Toggle = void 0;
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
|
+
const composeEventHandlers_1 = require("../util/composeEventHandlers");
|
|
43
44
|
const context_1 = require("./context");
|
|
44
45
|
exports.Toggle = (0, react_1.forwardRef)((_a, ref) => {
|
|
45
46
|
var { className, onClick } = _a, rest = __rest(_a, ["className", "onClick"]);
|
|
@@ -49,6 +50,10 @@ exports.Toggle = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
49
50
|
return null;
|
|
50
51
|
}
|
|
51
52
|
const { setAnchorEl, handleToggle, isOpen } = context;
|
|
53
|
+
const handleClick = (e) => {
|
|
54
|
+
setAnchorEl(e.currentTarget);
|
|
55
|
+
handleToggle(!isOpen);
|
|
56
|
+
};
|
|
52
57
|
return (react_1.default.createElement("button", Object.assign({}, rest, { ref: (el) => {
|
|
53
58
|
setAnchorEl(el);
|
|
54
59
|
if (typeof ref === "function") {
|
|
@@ -57,10 +62,6 @@ exports.Toggle = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
57
62
|
else if (ref != null) {
|
|
58
63
|
ref.current = el;
|
|
59
64
|
}
|
|
60
|
-
}, onClick: (
|
|
61
|
-
setAnchorEl(e.currentTarget);
|
|
62
|
-
handleToggle(!isOpen);
|
|
63
|
-
onClick && onClick(e);
|
|
64
|
-
}, "aria-expanded": isOpen, className: (0, clsx_1.default)("navds-dropdown__toggle", className) })));
|
|
65
|
+
}, onClick: (0, composeEventHandlers_1.composeEventHandlers)(onClick, handleClick), "aria-expanded": isOpen, className: (0, clsx_1.default)("navds-dropdown__toggle", className) })));
|
|
65
66
|
});
|
|
66
67
|
exports.default = exports.Toggle;
|
|
@@ -41,7 +41,7 @@ exports.ConfirmationPanel = void 0;
|
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const typography_1 = require("../typography");
|
|
44
|
-
const
|
|
44
|
+
const hooks_1 = require("../util/hooks");
|
|
45
45
|
const checkbox_1 = require("./checkbox");
|
|
46
46
|
const useFormField_1 = require("./useFormField");
|
|
47
47
|
/**
|
|
@@ -65,7 +65,7 @@ const useFormField_1 = require("./useFormField");
|
|
|
65
65
|
exports.ConfirmationPanel = (0, react_1.forwardRef)((_a, ref) => {
|
|
66
66
|
var { className, children, label } = _a, props = __rest(_a, ["className", "children", "label"]);
|
|
67
67
|
const { errorId, showErrorMsg, hasError, size, inputProps } = (0, useFormField_1.useFormField)(props, "confirmation-panel");
|
|
68
|
-
const id = (0,
|
|
68
|
+
const id = (0, hooks_1.useId)();
|
|
69
69
|
return (react_1.default.createElement("div", { className: (0, clsx_1.default)("navds-confirmation-panel", "navds-form-field", className, {
|
|
70
70
|
"navds-confirmation-panel--small": size === "small",
|
|
71
71
|
"navds-confirmation-panel--error": hasError,
|
package/cjs/form/Textarea.js
CHANGED
|
@@ -43,6 +43,7 @@ const react_1 = __importStar(require("react"));
|
|
|
43
43
|
const typography_1 = require("../typography");
|
|
44
44
|
const util_1 = require("../util");
|
|
45
45
|
const TextareaAutoSize_1 = __importDefault(require("../util/TextareaAutoSize"));
|
|
46
|
+
const hooks_1 = require("../util/hooks");
|
|
46
47
|
const ReadOnlyIcon_1 = require("./ReadOnlyIcon");
|
|
47
48
|
const TextareaCounter_1 = __importDefault(require("./TextareaCounter"));
|
|
48
49
|
const useFormField_1 = require("./useFormField");
|
|
@@ -61,7 +62,7 @@ exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
|
|
|
61
62
|
var _a, _b, _c;
|
|
62
63
|
const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = (0, useFormField_1.useFormField)(props, "textarea");
|
|
63
64
|
const { label, className, description, maxLength, hideLabel = false, resize, UNSAFE_autoScrollbar, i18n, readOnly } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel", "resize", "UNSAFE_autoScrollbar", "i18n", "readOnly"]);
|
|
64
|
-
const maxLengthId = (0,
|
|
65
|
+
const maxLengthId = (0, hooks_1.useId)();
|
|
65
66
|
const hasMaxLength = maxLength !== undefined && maxLength > 0;
|
|
66
67
|
const [controlledValue, setControlledValue] = (0, react_1.useState)((_a = props === null || props === void 0 ? void 0 : props.defaultValue) !== null && _a !== void 0 ? _a : "");
|
|
67
68
|
const getMinRows = () => {
|
|
@@ -31,12 +31,13 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
32
32
|
const typography_1 = require("../../typography");
|
|
33
33
|
const util_1 = require("../../util");
|
|
34
|
+
const hooks_1 = require("../../util/hooks");
|
|
34
35
|
const ReadOnlyIcon_1 = require("../ReadOnlyIcon");
|
|
35
36
|
const useCheckbox_1 = __importDefault(require("./useCheckbox"));
|
|
36
37
|
exports.Checkbox = (0, react_1.forwardRef)((props, ref) => {
|
|
37
38
|
const { inputProps, hasError, size, readOnly, nested } = (0, useCheckbox_1.default)(props);
|
|
38
|
-
const labelId = (0,
|
|
39
|
-
const descriptionId = (0,
|
|
39
|
+
const labelId = (0, hooks_1.useId)();
|
|
40
|
+
const descriptionId = (0, hooks_1.useId)();
|
|
40
41
|
return (react_1.default.createElement("div", { className: (0, clsx_1.default)(props.className, "navds-checkbox", `navds-checkbox--${size}`, {
|
|
41
42
|
"navds-checkbox--error": hasError,
|
|
42
43
|
"navds-checkbox--disabled": inputProps.disabled,
|
|
@@ -41,7 +41,7 @@ exports.Combobox = void 0;
|
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const typography_1 = require("../../typography");
|
|
44
|
-
const
|
|
44
|
+
const useMergeRefs_1 = require("../../util/hooks/useMergeRefs");
|
|
45
45
|
const ClearButton_1 = __importDefault(require("./ClearButton"));
|
|
46
46
|
const ComboboxWrapper_1 = __importDefault(require("./ComboboxWrapper"));
|
|
47
47
|
const FilteredOptions_1 = __importDefault(require("./FilteredOptions/FilteredOptions"));
|
|
@@ -57,7 +57,7 @@ exports.Combobox = (0, react_1.forwardRef)((props, ref) => {
|
|
|
57
57
|
const { activeDecendantId, toggleIsListOpen } = (0, filteredOptionsContext_1.useFilteredOptionsContext)();
|
|
58
58
|
const { selectedOptions } = (0, selectedOptionsContext_1.useSelectedOptionsContext)();
|
|
59
59
|
const { clearInput, error, errorId, focusInput, hasError, inputDescriptionId, inputProps, inputRef, value, showErrorMsg, size = "medium", } = (0, inputContext_1.useInputContext)();
|
|
60
|
-
const mergedInputRef = (0,
|
|
60
|
+
const mergedInputRef = (0, useMergeRefs_1.useMergeRefs)(inputRef, ref);
|
|
61
61
|
return (react_1.default.createElement(ComboboxWrapper_1.default, { className: className, hasError: hasError, inputProps: inputProps, inputSize: size, toggleIsListOpen: toggleIsListOpen, toggleListButtonRef: toggleListButtonRef },
|
|
62
62
|
react_1.default.createElement(typography_1.Label, { htmlFor: inputProps.id, size: size, className: (0, clsx_1.default)("navds-form-field__label", {
|
|
63
63
|
"navds-sr-only": hideLabel,
|
|
@@ -29,8 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.useFilteredOptionsContext = exports.FilteredOptionsProvider = void 0;
|
|
30
30
|
const clsx_1 = __importDefault(require("clsx"));
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
32
|
-
const
|
|
33
|
-
const usePrevious_1 = __importDefault(require("../../../util/usePrevious"));
|
|
32
|
+
const hooks_1 = require("../../../util/hooks");
|
|
34
33
|
const inputContext_1 = require("../Input/inputContext");
|
|
35
34
|
const customOptionsContext_1 = require("../customOptionsContext");
|
|
36
35
|
const filtered_options_util_1 = __importDefault(require("./filtered-options-util"));
|
|
@@ -50,14 +49,14 @@ const FilteredOptionsProvider = ({ children, value: props, }) => {
|
|
|
50
49
|
const opts = [...customOptions, ...options];
|
|
51
50
|
return filtered_options_util_1.default.getMatchingValuesFromList(searchTerm, opts);
|
|
52
51
|
}, [customOptions, externalFilteredOptions, options, searchTerm]);
|
|
53
|
-
const previousSearchTerm = (0,
|
|
52
|
+
const previousSearchTerm = (0, hooks_1.usePrevious)(searchTerm);
|
|
54
53
|
const [isMouseLastUsedInputDevice, setIsMouseLastUsedInputDevice] = (0, react_1.useState)(false);
|
|
55
54
|
const filteredOptionsMap = (0, react_1.useMemo)(() => options.reduce((map, _option) => (Object.assign(Object.assign({}, map), { [filtered_options_util_1.default.getOptionId(id, _option)]: _option })), {
|
|
56
55
|
[filtered_options_util_1.default.getAddNewOptionId(id)]: allowNewValues
|
|
57
56
|
? value
|
|
58
57
|
: undefined,
|
|
59
58
|
}), [allowNewValues, id, options, value]);
|
|
60
|
-
(0,
|
|
59
|
+
(0, hooks_1.useClientLayoutEffect)(() => {
|
|
61
60
|
if (shouldAutocomplete &&
|
|
62
61
|
filtered_options_util_1.default.normalizeText(searchTerm) !== "" &&
|
|
63
62
|
((previousSearchTerm === null || previousSearchTerm === void 0 ? void 0 : previousSearchTerm.length) || 0) < searchTerm.length &&
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.useInputContext = exports.InputContextProvider = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
|
-
const
|
|
28
|
+
const hooks_1 = require("../../../util/hooks");
|
|
29
29
|
const useFormField_1 = require("../../useFormField");
|
|
30
30
|
const InputContext = (0, react_1.createContext)({});
|
|
31
31
|
const InputContextProvider = ({ children, value: props }) => {
|
|
@@ -61,7 +61,7 @@ const InputContextProvider = ({ children, value: props }) => {
|
|
|
61
61
|
var _a, _b;
|
|
62
62
|
(_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
63
63
|
}, []);
|
|
64
|
-
(0,
|
|
64
|
+
(0, hooks_1.useClientLayoutEffect)(() => {
|
|
65
65
|
var _a, _b;
|
|
66
66
|
if (shouldAutocomplete && inputRef && value !== searchTerm) {
|
|
67
67
|
(_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange) === null || _b === void 0 ? void 0 : _b.call(_a, searchTerm.length, value.length);
|
|
@@ -22,13 +22,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.useSelectedOptionsContext = exports.SelectedOptionsProvider = void 0;
|
|
30
27
|
const react_1 = __importStar(require("react"));
|
|
31
|
-
const
|
|
28
|
+
const hooks_1 = require("../../../util/hooks");
|
|
32
29
|
const inputContext_1 = require("../Input/inputContext");
|
|
33
30
|
const customOptionsContext_1 = require("../customOptionsContext");
|
|
34
31
|
const SelectedOptionsContext = (0, react_1.createContext)({});
|
|
@@ -92,7 +89,7 @@ const SelectedOptionsProvider = ({ children, value, }) => {
|
|
|
92
89
|
removeSelectedOption,
|
|
93
90
|
selectedOptions,
|
|
94
91
|
]);
|
|
95
|
-
const prevSelectedOptions = (0,
|
|
92
|
+
const prevSelectedOptions = (0, hooks_1.usePrevious)(selectedOptions);
|
|
96
93
|
const selectedOptionsState = {
|
|
97
94
|
addSelectedOption,
|
|
98
95
|
isMultiSelect,
|
|
@@ -41,7 +41,7 @@ exports.ErrorSummary = void 0;
|
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const typography_1 = require("../../typography");
|
|
44
|
-
const
|
|
44
|
+
const hooks_1 = require("../../util/hooks");
|
|
45
45
|
const ErrorSummaryItem_1 = __importDefault(require("./ErrorSummaryItem"));
|
|
46
46
|
/**
|
|
47
47
|
* A component that displays a summary of errors.
|
|
@@ -63,7 +63,7 @@ const ErrorSummaryItem_1 = __importDefault(require("./ErrorSummaryItem"));
|
|
|
63
63
|
*/
|
|
64
64
|
exports.ErrorSummary = (0, react_1.forwardRef)((_a, ref) => {
|
|
65
65
|
var { children, className, size = "medium", headingTag = "h2", heading } = _a, rest = __rest(_a, ["children", "className", "size", "headingTag", "heading"]);
|
|
66
|
-
const headingId = (0,
|
|
66
|
+
const headingId = (0, hooks_1.useId)();
|
|
67
67
|
return (react_1.default.createElement("section", Object.assign({ ref: ref }, rest, { className: (0, clsx_1.default)(className, "navds-error-summary", `navds-error-summary--${size}`), tabIndex: -1, "aria-live": "polite", "aria-relevant": "all", "aria-labelledby": headingId }),
|
|
68
68
|
react_1.default.createElement(typography_1.Heading, { className: "navds-error-summary__heading", as: headingTag, size: "small", id: headingId }, heading),
|
|
69
69
|
react_1.default.createElement(typography_1.BodyShort, { as: "ul", size: size, className: "navds-error-summary__list" }, react_1.default.Children.map(children, (child) => {
|
package/cjs/form/radio/Radio.js
CHANGED
|
@@ -31,11 +31,12 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
32
32
|
const typography_1 = require("../../typography");
|
|
33
33
|
const util_1 = require("../../util");
|
|
34
|
+
const hooks_1 = require("../../util/hooks");
|
|
34
35
|
const useRadio_1 = require("./useRadio");
|
|
35
36
|
exports.Radio = (0, react_1.forwardRef)((props, ref) => {
|
|
36
37
|
const { inputProps, size, hasError, readOnly } = (0, useRadio_1.useRadio)(props);
|
|
37
|
-
const labelId = (0,
|
|
38
|
-
const descriptionId = (0,
|
|
38
|
+
const labelId = (0, hooks_1.useId)();
|
|
39
|
+
const descriptionId = (0, hooks_1.useId)();
|
|
39
40
|
return (react_1.default.createElement("div", { className: (0, clsx_1.default)(props.className, "navds-radio", `navds-radio--${size}`, {
|
|
40
41
|
"navds-radio--error": hasError,
|
|
41
42
|
"navds-radio--disabled": inputProps.disabled,
|
|
@@ -40,7 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.RadioGroup = exports.RadioGroupContext = void 0;
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
|
-
const
|
|
43
|
+
const hooks_1 = require("../../util/hooks");
|
|
44
44
|
const Fieldset_1 = require("../Fieldset");
|
|
45
45
|
exports.RadioGroupContext = react_1.default.createContext(null);
|
|
46
46
|
/**
|
|
@@ -57,7 +57,7 @@ exports.RadioGroup = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
57
57
|
var _b, _c;
|
|
58
58
|
var { children, className, name, defaultValue, value, onChange = () => { }, required, readOnly } = _a, rest = __rest(_a, ["children", "className", "name", "defaultValue", "value", "onChange", "required", "readOnly"]);
|
|
59
59
|
const fieldset = (0, react_1.useContext)(Fieldset_1.FieldsetContext);
|
|
60
|
-
const nameId = (0,
|
|
60
|
+
const nameId = (0, hooks_1.useId)();
|
|
61
61
|
return (react_1.default.createElement(Fieldset_1.Fieldset, Object.assign({}, rest, { readOnly: readOnly, ref: ref, className: (0, clsx_1.default)(className, "navds-radio-group", `navds-radio-group--${(_c = (_b = rest.size) !== null && _b !== void 0 ? _b : fieldset === null || fieldset === void 0 ? void 0 : fieldset.size) !== null && _c !== void 0 ? _c : "medium"}`), nativeReadOnly: false }),
|
|
62
62
|
react_1.default.createElement(exports.RadioGroupContext.Provider, { value: {
|
|
63
63
|
name: name !== null && name !== void 0 ? name : `radioGroupName-${nameId}`,
|
|
@@ -43,6 +43,7 @@ const react_1 = __importStar(require("react"));
|
|
|
43
43
|
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
44
44
|
const typography_1 = require("../../typography");
|
|
45
45
|
const util_1 = require("../../util");
|
|
46
|
+
const useMergeRefs_1 = require("../../util/hooks/useMergeRefs");
|
|
46
47
|
const useFormField_1 = require("../useFormField");
|
|
47
48
|
const SearchButton_1 = __importDefault(require("./SearchButton"));
|
|
48
49
|
const context_1 = require("./context");
|
|
@@ -63,7 +64,7 @@ exports.Search = (0, react_1.forwardRef)((props, ref) => {
|
|
|
63
64
|
const { inputProps, size = "medium", inputDescriptionId, errorId, showErrorMsg, hasError, } = (0, useFormField_1.useFormField)(props, "searchfield");
|
|
64
65
|
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, variant = "primary", defaultValue, onChange, onSearchClick, htmlSize } = props, rest = __rest(props, ["className", "hideLabel", "label", "description", "value", "clearButtonLabel", "onClear", "clearButton", "children", "variant", "defaultValue", "onChange", "onSearchClick", "htmlSize"]);
|
|
65
66
|
const searchRef = (0, react_1.useRef)(null);
|
|
66
|
-
const mergedRef = (0,
|
|
67
|
+
const mergedRef = (0, useMergeRefs_1.useMergeRefs)(searchRef, ref);
|
|
67
68
|
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : "");
|
|
68
69
|
const handleChange = (0, react_1.useCallback)((v) => {
|
|
69
70
|
value === undefined && setInternalValue(v);
|
|
@@ -41,6 +41,7 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
41
41
|
const react_1 = __importStar(require("react"));
|
|
42
42
|
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
43
43
|
const button_1 = require("../../button");
|
|
44
|
+
const composeEventHandlers_1 = require("../../util/composeEventHandlers");
|
|
44
45
|
const context_1 = require("./context");
|
|
45
46
|
const SearchButton = (0, react_1.forwardRef)((_a, ref) => {
|
|
46
47
|
var _b;
|
|
@@ -51,9 +52,6 @@ const SearchButton = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
53
54
|
const { size, variant, handleClick } = context;
|
|
54
|
-
return (react_1.default.createElement(button_1.Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant === "secondary" ? "secondary" : "primary", className: (0, clsx_1.default)("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (
|
|
55
|
-
handleClick();
|
|
56
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
57
|
-
}, icon: react_1.default.createElement(aksel_icons_1.MagnifyingGlassIcon, Object.assign({}, (children ? { "aria-hidden": true } : { title: "Søk" }))) }), children));
|
|
55
|
+
return (react_1.default.createElement(button_1.Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant === "secondary" ? "secondary" : "primary", className: (0, clsx_1.default)("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (0, composeEventHandlers_1.composeEventHandlers)(onClick, handleClick), icon: react_1.default.createElement(aksel_icons_1.MagnifyingGlassIcon, Object.assign({}, (children ? { "aria-hidden": true } : { title: "Søk" }))) }), children));
|
|
58
56
|
});
|
|
59
57
|
exports.default = SearchButton;
|
package/cjs/form/useFormField.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.useFormField = void 0;
|
|
7
7
|
const clsx_1 = __importDefault(require("clsx"));
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
-
const
|
|
9
|
+
const hooks_1 = require("../util/hooks");
|
|
10
10
|
const context_1 = require("./Fieldset/context");
|
|
11
11
|
/**
|
|
12
12
|
* Handles props and their state for various form-fields in context with Fieldset
|
|
@@ -15,7 +15,7 @@ const useFormField = (props, prefix) => {
|
|
|
15
15
|
var _a, _b, _c;
|
|
16
16
|
const { size, error, errorId: propErrorId } = props;
|
|
17
17
|
const fieldset = (0, react_1.useContext)(context_1.FieldsetContext);
|
|
18
|
-
const genId = (0,
|
|
18
|
+
const genId = (0, hooks_1.useId)();
|
|
19
19
|
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${prefix}-${genId}`;
|
|
20
20
|
const errorId = propErrorId !== null && propErrorId !== void 0 ? propErrorId : `${prefix}-error-${genId}`;
|
|
21
21
|
const inputDescriptionId = `${prefix}-description-${genId}`;
|
|
@@ -16,10 +16,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.DefaultIllustration = void 0;
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
|
-
const
|
|
19
|
+
const hooks_1 = require("../util/hooks");
|
|
20
20
|
const DefaultIllustration = (_a) => {
|
|
21
21
|
var { title, titleId: _titleId } = _a, props = __rest(_a, ["title", "titleId"]);
|
|
22
|
-
let titleId = (0,
|
|
22
|
+
let titleId = (0, hooks_1.useId)();
|
|
23
23
|
titleId = title ? (_titleId ? _titleId : "title-" + titleId) : undefined;
|
|
24
24
|
return (react_1.default.createElement("svg", Object.assign({ width: "56", height: "85", viewBox: "0 0 56 85", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-label": "NAV veileder illustrasjon", focusable: false, role: "img", "aria-labelledby": titleId }, props),
|
|
25
25
|
title ? react_1.default.createElement("title", { id: titleId }, title) : null,
|
|
@@ -41,7 +41,8 @@ exports.HelpText = void 0;
|
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const popover_1 = require("../popover");
|
|
44
|
-
const
|
|
44
|
+
const composeEventHandlers_1 = require("../util/composeEventHandlers");
|
|
45
|
+
const useMergeRefs_1 = require("../util/hooks/useMergeRefs");
|
|
45
46
|
const HelpTextIcon_1 = require("./HelpTextIcon");
|
|
46
47
|
/**
|
|
47
48
|
* A component that displays a help text button with a popover.
|
|
@@ -57,15 +58,12 @@ const HelpTextIcon_1 = require("./HelpTextIcon");
|
|
|
57
58
|
* ```
|
|
58
59
|
*/
|
|
59
60
|
exports.HelpText = (0, react_1.forwardRef)((_a, ref) => {
|
|
60
|
-
var { className, children, placement
|
|
61
|
+
var { className, children, placement, strategy = "absolute", title = "hjelp", onClick, wrapperClassName } = _a, rest = __rest(_a, ["className", "children", "placement", "strategy", "title", "onClick", "wrapperClassName"]);
|
|
61
62
|
const buttonRef = (0, react_1.useRef)(null);
|
|
62
|
-
const mergedRef = (0,
|
|
63
|
+
const mergedRef = (0, useMergeRefs_1.useMergeRefs)(buttonRef, ref);
|
|
63
64
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
64
65
|
return (react_1.default.createElement("div", { className: (0, clsx_1.default)("navds-help-text", wrapperClassName) },
|
|
65
|
-
react_1.default.createElement("button", Object.assign({}, rest, { ref: mergedRef, onClick: (
|
|
66
|
-
setOpen((x) => !x);
|
|
67
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
68
|
-
}, className: (0, clsx_1.default)(className, "navds-help-text__button"), type: "button", "aria-expanded": open }),
|
|
66
|
+
react_1.default.createElement("button", Object.assign({}, rest, { ref: mergedRef, onClick: (0, composeEventHandlers_1.composeEventHandlers)(onClick, () => setOpen((x) => x)), className: (0, clsx_1.default)(className, "navds-help-text__button"), type: "button", "aria-expanded": open }),
|
|
69
67
|
react_1.default.createElement(HelpTextIcon_1.HelpTextIcon, { title: title }),
|
|
70
68
|
react_1.default.createElement(HelpTextIcon_1.HelpTextIcon, { filled: true, title: title })),
|
|
71
69
|
react_1.default.createElement(popover_1.Popover, { onClose: () => setOpen(false), className: "navds-help-text__popover", open: open, anchorEl: buttonRef.current, placement: placement, strategy: strategy, offset: 12 },
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.HelpTextIcon = void 0;
|
|
7
7
|
const clsx_1 = __importDefault(require("clsx"));
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const
|
|
9
|
+
const hooks_1 = require("../util/hooks");
|
|
10
10
|
const HelpTextIcon = ({ title, filled = false, }) => {
|
|
11
|
-
let titleId = (0,
|
|
11
|
+
let titleId = (0, hooks_1.useId)();
|
|
12
12
|
titleId = title ? `title-${titleId}` : undefined;
|
|
13
13
|
return (react_1.default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", focusable: false, role: "img", "aria-labelledby": titleId, className: (0, clsx_1.default)("navds-help-text__icon", {
|
|
14
14
|
"navds-help-text__icon--filled": filled,
|
package/cjs/list/List.js
CHANGED
|
@@ -41,13 +41,13 @@ exports.List = void 0;
|
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const typography_1 = require("../typography");
|
|
44
|
-
const
|
|
44
|
+
const hooks_1 = require("../util/hooks");
|
|
45
45
|
const ListItem_1 = require("./ListItem");
|
|
46
46
|
const context_1 = require("./context");
|
|
47
47
|
exports.List = (0, react_1.forwardRef)((_a, ref) => {
|
|
48
48
|
var _b;
|
|
49
49
|
var { children, className, as: ListTag = "ul", title, description, headingTag = "h3", size } = _a, rest = __rest(_a, ["children", "className", "as", "title", "description", "headingTag", "size"]);
|
|
50
|
-
const ariaId = (0,
|
|
50
|
+
const ariaId = (0, hooks_1.useId)();
|
|
51
51
|
const { isNested, size: _size } = (0, react_1.useContext)(context_1.ListContext);
|
|
52
52
|
const listSize = (_b = size !== null && size !== void 0 ? size : _size) !== null && _b !== void 0 ? _b : "medium";
|
|
53
53
|
return (react_1.default.createElement(context_1.ListContext.Provider, { value: {
|
package/cjs/loader/Loader.js
CHANGED
|
@@ -41,6 +41,7 @@ exports.Loader = void 0;
|
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const util_1 = require("../util");
|
|
44
|
+
const hooks_1 = require("../util/hooks");
|
|
44
45
|
/**
|
|
45
46
|
* A component that displays a loading spinner.
|
|
46
47
|
*
|
|
@@ -54,7 +55,7 @@ const util_1 = require("../util");
|
|
|
54
55
|
*/
|
|
55
56
|
exports.Loader = (0, react_1.forwardRef)((_a, ref) => {
|
|
56
57
|
var { className, size = "medium", title = "venter...", transparent = false, variant = "neutral", id } = _a, rest = __rest(_a, ["className", "size", "title", "transparent", "variant", "id"]);
|
|
57
|
-
const internalId = (0,
|
|
58
|
+
const internalId = (0, hooks_1.useId)();
|
|
58
59
|
return (react_1.default.createElement("svg", Object.assign({ "aria-labelledby": id !== null && id !== void 0 ? id : `loader-${internalId}`, ref: ref, className: (0, clsx_1.default)("navds-loader", className, `navds-loader--${size}`, `navds-loader--${variant}`, {
|
|
59
60
|
"navds-loader--transparent": transparent,
|
|
60
61
|
}), focusable: "false", viewBox: "0 0 50 50", preserveAspectRatio: "xMidYMid" }, (0, util_1.omit)(rest, ["children"])),
|
package/cjs/modal/Modal.js
CHANGED
|
@@ -45,7 +45,9 @@ const react_dom_1 = require("react-dom");
|
|
|
45
45
|
const context_1 = require("../date/context");
|
|
46
46
|
const provider_1 = require("../provider");
|
|
47
47
|
const typography_1 = require("../typography");
|
|
48
|
-
const
|
|
48
|
+
const composeEventHandlers_1 = require("../util/composeEventHandlers");
|
|
49
|
+
const hooks_1 = require("../util/hooks");
|
|
50
|
+
const useMergeRefs_1 = require("../util/hooks/useMergeRefs");
|
|
49
51
|
const ModalBody_1 = __importDefault(require("./ModalBody"));
|
|
50
52
|
const ModalContext_1 = require("./ModalContext");
|
|
51
53
|
const ModalFooter_1 = __importDefault(require("./ModalFooter"));
|
|
@@ -102,8 +104,8 @@ exports.Modal = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
102
104
|
var _b, _c;
|
|
103
105
|
var { header, children, open, onBeforeClose, onCancel, closeOnBackdropClick, width, portal, className, "aria-labelledby": ariaLabelledby, style, onClick } = _a, rest = __rest(_a, ["header", "children", "open", "onBeforeClose", "onCancel", "closeOnBackdropClick", "width", "portal", "className", "aria-labelledby", "style", "onClick"]);
|
|
104
106
|
const modalRef = (0, react_2.useRef)(null);
|
|
105
|
-
const mergedRef = (0,
|
|
106
|
-
const ariaLabelId = (0,
|
|
107
|
+
const mergedRef = (0, useMergeRefs_1.useMergeRefs)(modalRef, ref);
|
|
108
|
+
const ariaLabelId = (0, hooks_1.useId)();
|
|
107
109
|
const rootElement = (_b = (0, provider_1.useProvider)()) === null || _b === void 0 ? void 0 : _b.rootElement;
|
|
108
110
|
const portalNode = (0, react_1.useFloatingPortalNode)({ root: rootElement });
|
|
109
111
|
const dateContext = (0, react_2.useContext)(context_1.DateContext);
|
|
@@ -146,28 +148,29 @@ exports.Modal = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
146
148
|
[`navds-modal--${width}`]: isWidthPreset,
|
|
147
149
|
});
|
|
148
150
|
const mergedStyle = Object.assign(Object.assign({}, style), (!isWidthPreset ? { width } : {}));
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
/**
|
|
152
|
+
* @note `closeOnBackdropClick` has issues on polyfill when nesting modals (DatePicker)
|
|
153
|
+
*/
|
|
154
|
+
const handleModalClick = (event) => {
|
|
155
|
+
if (closeOnBackdropClick &&
|
|
156
|
+
!dialog_polyfill_1.needPolyfill &&
|
|
157
|
+
event.target === modalRef.current &&
|
|
158
|
+
(!onBeforeClose || onBeforeClose() !== false)) {
|
|
159
|
+
modalRef.current.close();
|
|
152
160
|
}
|
|
153
|
-
else if (onCancel)
|
|
154
|
-
onCancel(event);
|
|
155
161
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
: onClick;
|
|
162
|
+
/**
|
|
163
|
+
* @note onCancel fires when you press `Esc`
|
|
164
|
+
*/
|
|
165
|
+
const handleModalCancel = (event) => {
|
|
166
|
+
onBeforeClose && onBeforeClose() === false && event.preventDefault();
|
|
167
|
+
};
|
|
165
168
|
const mergedAriaLabelledBy = !ariaLabelledby && !rest["aria-label"] && header
|
|
166
169
|
? ariaLabelId
|
|
167
170
|
: ariaLabelledby;
|
|
168
171
|
const component = (
|
|
169
172
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
170
|
-
react_2.default.createElement("dialog", Object.assign({}, rest, { ref: mergedRef, className: mergedClassName, style: mergedStyle, onCancel:
|
|
173
|
+
react_2.default.createElement("dialog", Object.assign({}, rest, { ref: mergedRef, className: mergedClassName, style: mergedStyle, onCancel: (0, composeEventHandlers_1.composeEventHandlers)(onCancel, handleModalCancel), onClick: (0, composeEventHandlers_1.composeEventHandlers)(onClick, handleModalClick), "aria-labelledby": mergedAriaLabelledBy }),
|
|
171
174
|
react_2.default.createElement(ModalContext_1.ModalContext.Provider, { value: {
|
|
172
175
|
closeHandler: (0, ModalUtils_1.getCloseHandler)(modalRef, header, onBeforeClose),
|
|
173
176
|
ref: modalRef,
|
package/cjs/popover/Popover.js
CHANGED
|
@@ -43,7 +43,8 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
43
43
|
const react_2 = __importStar(require("react"));
|
|
44
44
|
const context_1 = require("../date/context");
|
|
45
45
|
const ModalContext_1 = require("../modal/ModalContext");
|
|
46
|
-
const
|
|
46
|
+
const hooks_1 = require("../util/hooks");
|
|
47
|
+
const useMergeRefs_1 = require("../util/hooks/useMergeRefs");
|
|
47
48
|
const PopoverContent_1 = __importDefault(require("./PopoverContent"));
|
|
48
49
|
/**
|
|
49
50
|
* A component that displays a popover.
|
|
@@ -89,17 +90,17 @@ exports.Popover = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
89
90
|
(0, react_1.useClick)(context),
|
|
90
91
|
(0, react_1.useDismiss)(context),
|
|
91
92
|
]);
|
|
92
|
-
(0,
|
|
93
|
+
(0, hooks_1.useClientLayoutEffect)(() => {
|
|
93
94
|
refs.setReference(anchorEl);
|
|
94
95
|
}, [anchorEl]);
|
|
95
|
-
const floatingRef = (0,
|
|
96
|
-
(0,
|
|
96
|
+
const floatingRef = (0, useMergeRefs_1.useMergeRefs)(refs.setFloating, ref);
|
|
97
|
+
(0, hooks_1.useClientLayoutEffect)(() => {
|
|
97
98
|
if (!refs.reference.current || !refs.floating.current || !open)
|
|
98
99
|
return;
|
|
99
100
|
const cleanup = (0, react_1.autoUpdate)(refs.reference.current, refs.floating.current, update);
|
|
100
101
|
return () => cleanup();
|
|
101
102
|
}, [refs.floating, refs.reference, update, open, anchorEl]);
|
|
102
|
-
(0,
|
|
103
|
+
(0, hooks_1.useEventListener)("focusin", (0, react_2.useCallback)((e) => {
|
|
103
104
|
if (e.target instanceof HTMLElement &&
|
|
104
105
|
![anchorEl, refs.floating.current].some((element) => element === null || element === void 0 ? void 0 : element.contains(e.target)) &&
|
|
105
106
|
!e.target.contains(refs.floating.current)) {
|
|
@@ -42,6 +42,7 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
44
44
|
const typography_1 = require("../typography");
|
|
45
|
+
const composeEventHandlers_1 = require("../util/composeEventHandlers");
|
|
45
46
|
const useControllableState_1 = require("../util/hooks/useControllableState");
|
|
46
47
|
/**
|
|
47
48
|
* ReadMore
|
|
@@ -70,10 +71,7 @@ exports.ReadMore = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
70
71
|
return (react_1.default.createElement("div", { className: (0, clsx_1.default)("navds-read-more", `navds-read-more--${size}`, className, { "navds-read-more--open": _open }) },
|
|
71
72
|
react_1.default.createElement("button", Object.assign({}, rest, { ref: ref, type: "button", className: (0, clsx_1.default)("navds-read-more__button", "navds-body-short", {
|
|
72
73
|
"navds-body-short--small": size === "small",
|
|
73
|
-
}), onClick: (
|
|
74
|
-
_setOpen((x) => !x);
|
|
75
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
76
|
-
}, "aria-expanded": _open }),
|
|
74
|
+
}), onClick: (0, composeEventHandlers_1.composeEventHandlers)(onClick, () => _setOpen((x) => !x)), "aria-expanded": _open }),
|
|
77
75
|
react_1.default.createElement(aksel_icons_1.ChevronDownIcon, { className: "navds-read-more__expand-icon", "aria-hidden": true }),
|
|
78
76
|
react_1.default.createElement("span", null, header)),
|
|
79
77
|
react_1.default.createElement(typography_1.BodyLong, { as: "div", "aria-hidden": !_open, className: (0, clsx_1.default)("navds-read-more__content", {
|
package/cjs/stepper/Step.js
CHANGED
|
@@ -41,11 +41,12 @@ exports.Step = void 0;
|
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const typography_1 = require("../typography");
|
|
44
|
+
const composeEventHandlers_1 = require("../util/composeEventHandlers");
|
|
44
45
|
const context_1 = require("./context");
|
|
45
46
|
const CompletedIcon = () => (react_1.default.createElement("svg", { width: "14", height: "10", viewBox: "0 0 14 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", focusable: false, role: "img", "aria-hidden": true, "aria-label": "Fullf\u00F8rt" },
|
|
46
47
|
react_1.default.createElement("path", { d: "M4.93563 6.41478L11.3755 0.404669C11.9796 -0.160351 12.9294 -0.130672 13.4959 0.47478C14.0624 1.08027 14.0299 2.03007 13.4249 2.59621L5.92151 9.59934C5.64138 9.85904 5.27598 10 4.90064 10C4.5069 10 4.12756 9.84621 3.83953 9.56111L1.33953 7.06111C0.75401 6.47558 0.75401 5.52542 1.33953 4.93989C1.92506 4.35437 2.87522 4.35437 3.46075 4.93989L4.93563 6.41478Z", fill: "currentColor" })));
|
|
47
48
|
exports.Step = (0, react_1.forwardRef)((_a, ref) => {
|
|
48
|
-
var { className, children, as: Component = "a", unsafe_index = 0, completed = false, interactive } = _a, rest = __rest(_a, ["className", "children", "as", "unsafe_index", "completed", "interactive"]);
|
|
49
|
+
var { className, children, as: Component = "a", unsafe_index = 0, completed = false, interactive, onClick } = _a, rest = __rest(_a, ["className", "children", "as", "unsafe_index", "completed", "interactive", "onClick"]);
|
|
49
50
|
const context = (0, react_1.useContext)(context_1.StepperContext);
|
|
50
51
|
if (context === null) {
|
|
51
52
|
console.error("<Stepper.Step> has to be used within <Stepper>");
|
|
@@ -54,16 +55,15 @@ exports.Step = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
54
55
|
const { activeStep } = context;
|
|
55
56
|
const isInteractive = interactive !== null && interactive !== void 0 ? interactive : context === null || context === void 0 ? void 0 : context.interactive;
|
|
56
57
|
const Comp = isInteractive ? Component : "div";
|
|
58
|
+
const handleStepClick = () => {
|
|
59
|
+
isInteractive && context.onStepChange(unsafe_index + 1);
|
|
60
|
+
};
|
|
57
61
|
return (react_1.default.createElement(Comp, Object.assign({}, rest, { "aria-current": activeStep === unsafe_index, ref: ref, className: (0, clsx_1.default)("navds-stepper__step", className, {
|
|
58
62
|
"navds-stepper__step--active": activeStep === unsafe_index,
|
|
59
63
|
"navds-stepper__step--behind": activeStep > unsafe_index,
|
|
60
64
|
"navds-stepper__step--non-interactive": !isInteractive,
|
|
61
65
|
"navds-stepper__step--completed": completed,
|
|
62
|
-
}), onClick: (
|
|
63
|
-
var _a;
|
|
64
|
-
isInteractive && context.onStepChange(unsafe_index + 1);
|
|
65
|
-
(_a = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _a === void 0 ? void 0 : _a.call(rest, e);
|
|
66
|
-
} }),
|
|
66
|
+
}), onClick: (0, composeEventHandlers_1.composeEventHandlers)(onClick, handleStepClick) }),
|
|
67
67
|
completed ? (react_1.default.createElement("span", { className: "navds-stepper__circle navds-stepper__circle--success" },
|
|
68
68
|
react_1.default.createElement(CompletedIcon, null))) : (react_1.default.createElement(typography_1.Label, { className: "navds-stepper__circle", as: "span", "aria-hidden": "true" }, unsafe_index + 1)),
|
|
69
69
|
react_1.default.createElement(typography_1.Label, { as: "span", className: "navds-stepper__content" }, children)));
|
package/cjs/table/DataCell.js
CHANGED
|
@@ -42,9 +42,9 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const typography_1 = require("../typography");
|
|
44
44
|
exports.DataCell = (0, react_1.forwardRef)((_a, ref) => {
|
|
45
|
-
var { className, children = "", align } = _a, rest = __rest(_a, ["className", "children", "align"]);
|
|
45
|
+
var { className, children = "", align, textSize } = _a, rest = __rest(_a, ["className", "children", "align", "textSize"]);
|
|
46
46
|
return (react_1.default.createElement(typography_1.BodyShort, Object.assign({ as: "td", ref: ref, className: (0, clsx_1.default)("navds-table__data-cell", className, {
|
|
47
47
|
[`navds-table__data-cell--align-${align}`]: align,
|
|
48
|
-
}) }, rest), children));
|
|
48
|
+
}), size: textSize }, rest), children));
|
|
49
49
|
});
|
|
50
50
|
exports.default = exports.DataCell;
|