@navikt/ds-react 3.4.2 → 4.1.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 +5912 -3911
- package/cjs/accordion/Accordion.js +22 -2
- package/cjs/alert/Alert.js +9 -0
- package/cjs/button/Button.js +10 -0
- package/cjs/chat/Chat.js +16 -0
- package/cjs/chips/Chips.js +27 -0
- package/cjs/chips/Toggle.js +4 -6
- package/cjs/copybutton/CopyButton.js +11 -0
- package/cjs/date/DateInput.js +1 -1
- package/cjs/date/datepicker/DatePicker.js +22 -0
- package/cjs/date/hooks/index.js +4 -4
- package/cjs/date/hooks/useDatepicker.js +13 -0
- package/cjs/date/hooks/useMonthPicker.js +13 -0
- package/cjs/date/hooks/useRangeDatepicker.js +12 -0
- package/cjs/date/index.js +6 -6
- package/cjs/date/monthpicker/MonthPicker.js +22 -0
- package/cjs/dropdown/Dropdown.js +88 -0
- package/cjs/dropdown/Menu/Divider.js +47 -0
- package/cjs/dropdown/Menu/GroupedList/Heading.js +47 -0
- package/cjs/dropdown/Menu/GroupedList/Item.js +54 -0
- package/cjs/dropdown/Menu/GroupedList/index.js +51 -0
- package/cjs/dropdown/Menu/GroupedList/package.json +6 -0
- package/cjs/dropdown/Menu/List/Item.js +54 -0
- package/cjs/dropdown/Menu/List/index.js +49 -0
- package/cjs/dropdown/Menu/List/package.json +6 -0
- package/cjs/dropdown/Menu/index.js +64 -0
- package/cjs/dropdown/Menu/package.json +6 -0
- package/cjs/dropdown/Toggle.js +66 -0
- package/cjs/dropdown/index.js +23 -0
- package/cjs/dropdown/package.json +6 -0
- package/cjs/expansion-card/ExpansionCard.js +18 -0
- package/cjs/form/ConfirmationPanel.js +18 -0
- package/cjs/form/Select.js +16 -0
- package/cjs/form/Switch.js +11 -0
- package/cjs/form/TextField.js +11 -0
- package/cjs/form/Textarea.js +11 -0
- package/cjs/form/checkbox/CheckboxGroup.js +15 -0
- package/cjs/form/error-summary/ErrorSummary.js +18 -0
- package/cjs/form/radio/RadioGroup.js +10 -0
- package/cjs/form/search/Search.js +13 -0
- package/cjs/guide-panel/GuidePanel.js +15 -0
- package/cjs/help-text/HelpText.js +13 -0
- package/cjs/index.js +4 -0
- package/cjs/internal-header/InternalHeader.js +83 -0
- package/cjs/internal-header/InternalHeaderButton.js +47 -0
- package/cjs/internal-header/InternalHeaderTitle.js +48 -0
- package/cjs/internal-header/InternalHeaderUser.js +51 -0
- package/cjs/internal-header/InternalHeaderUserButton.js +54 -0
- package/cjs/internal-header/index.js +8 -0
- package/cjs/internal-header/package.json +6 -0
- package/cjs/link/Link.js +13 -0
- package/cjs/link-panel/LinkPanel.js +17 -0
- package/cjs/loader/Loader.js +11 -0
- package/cjs/modal/Modal.js +27 -0
- package/cjs/pagination/Pagination.js +17 -0
- package/cjs/panel/Panel.js +19 -0
- package/cjs/popover/Popover.js +20 -0
- package/cjs/provider/Provider.js +13 -0
- package/cjs/read-more/ReadMore.js +17 -0
- package/cjs/skeleton/Skeleton.js +51 -0
- package/cjs/skeleton/index.js +8 -0
- package/cjs/skeleton/package.json +6 -0
- package/cjs/stepper/Step.js +3 -4
- package/cjs/stepper/Stepper.js +24 -0
- package/cjs/table/Table.js +32 -0
- package/cjs/tabs/Tabs.js +27 -1
- package/cjs/tag/Tag.js +11 -0
- package/cjs/timeline/AxisLabels.js +90 -0
- package/cjs/timeline/Pin.js +106 -0
- package/cjs/timeline/Timeline.js +180 -0
- package/cjs/timeline/TimelineRow.js +86 -0
- package/cjs/timeline/hooks/usePeriodContext.js +16 -0
- package/cjs/timeline/hooks/useRowContext.js +18 -0
- package/cjs/timeline/hooks/useTimelineContext.js +23 -0
- package/cjs/timeline/hooks/useTimelineRows.js +79 -0
- package/cjs/timeline/index.js +8 -0
- package/cjs/timeline/package.json +6 -0
- package/cjs/timeline/period/ClickablePeriod.js +120 -0
- package/cjs/timeline/period/NonClickablePeriod.js +18 -0
- package/cjs/timeline/period/index.js +46 -0
- package/cjs/timeline/period/package.json +6 -0
- package/cjs/timeline/utils/calc.js +19 -0
- package/cjs/timeline/utils/filter.js +18 -0
- package/cjs/timeline/utils/index.js +7 -0
- package/cjs/timeline/utils/package.json +6 -0
- package/cjs/timeline/utils/period.js +40 -0
- package/cjs/timeline/utils/sort.js +10 -0
- package/cjs/timeline/utils/timeline.js +79 -0
- package/cjs/timeline/utils/types.external.js +2 -0
- package/cjs/timeline/utils/types.internal.js +2 -0
- package/cjs/timeline/zoom/ZoomButton.js +68 -0
- package/cjs/timeline/zoom/index.js +50 -0
- package/cjs/timeline/zoom/package.json +6 -0
- package/cjs/toggle-group/ToggleGroup.js +17 -2
- package/cjs/tooltip/Tooltip.js +13 -0
- package/cjs/typography/BodyLong.js +14 -0
- package/cjs/typography/BodyShort.js +14 -0
- package/cjs/typography/Detail.js +14 -0
- package/cjs/typography/ErrorMessage.js +14 -0
- package/cjs/typography/Heading.js +14 -0
- package/cjs/typography/Ingress.js +14 -0
- package/cjs/typography/Label.js +14 -0
- package/esm/accordion/Accordion.d.ts +40 -6
- package/esm/accordion/Accordion.js +22 -2
- package/esm/accordion/Accordion.js.map +1 -1
- package/esm/accordion/AccordionContent.d.ts +1 -2
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.d.ts +1 -2
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/AccordionItem.d.ts +1 -2
- package/esm/accordion/AccordionItem.js.map +1 -1
- package/esm/alert/Alert.d.ts +9 -0
- package/esm/alert/Alert.js +9 -0
- package/esm/alert/Alert.js.map +1 -1
- package/esm/button/Button.d.ts +10 -0
- package/esm/button/Button.js +10 -0
- package/esm/button/Button.js.map +1 -1
- package/esm/chat/Bubble.d.ts +1 -2
- package/esm/chat/Bubble.js.map +1 -1
- package/esm/chat/Chat.d.ts +21 -2
- package/esm/chat/Chat.js +16 -0
- package/esm/chat/Chat.js.map +1 -1
- package/esm/chips/Chips.d.ts +42 -4
- package/esm/chips/Chips.js +27 -0
- package/esm/chips/Chips.js.map +1 -1
- package/esm/chips/Removable.d.ts +0 -2
- package/esm/chips/Removable.js.map +1 -1
- package/esm/chips/Toggle.d.ts +11 -3
- package/esm/chips/Toggle.js +4 -6
- package/esm/chips/Toggle.js.map +1 -1
- package/esm/copybutton/CopyButton.d.ts +11 -0
- package/esm/copybutton/CopyButton.js +11 -0
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/DateInput.d.ts +2 -3
- package/esm/date/DateInput.js +1 -1
- package/esm/date/DateInput.js.map +1 -1
- package/esm/date/datepicker/DatePicker.d.ts +38 -2
- package/esm/date/datepicker/DatePicker.js +22 -0
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/hooks/index.d.ts +3 -3
- package/esm/date/hooks/index.js +3 -3
- package/esm/date/hooks/index.js.map +1 -1
- package/esm/date/hooks/useDatepicker.d.ts +13 -0
- package/esm/date/hooks/useDatepicker.js +13 -0
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.d.ts +13 -0
- package/esm/date/hooks/useMonthPicker.js +13 -0
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/hooks/useRangeDatepicker.d.ts +12 -0
- package/esm/date/hooks/useRangeDatepicker.js +12 -0
- package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/index.d.ts +3 -3
- package/esm/date/index.js +3 -3
- package/esm/date/index.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.d.ts +34 -4
- package/esm/date/monthpicker/MonthPicker.js +22 -0
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/dropdown/Dropdown.d.ts +74 -0
- package/esm/dropdown/Dropdown.js +60 -0
- package/esm/dropdown/Dropdown.js.map +1 -0
- package/esm/dropdown/Menu/Divider.d.ts +3 -0
- package/esm/dropdown/Menu/Divider.js +19 -0
- package/esm/dropdown/Menu/Divider.js.map +1 -0
- package/esm/dropdown/Menu/GroupedList/Heading.d.ts +9 -0
- package/esm/dropdown/Menu/GroupedList/Heading.js +19 -0
- package/esm/dropdown/Menu/GroupedList/Heading.js.map +1 -0
- package/esm/dropdown/Menu/GroupedList/Item.d.ts +10 -0
- package/esm/dropdown/Menu/GroupedList/Item.js +26 -0
- package/esm/dropdown/Menu/GroupedList/Item.js.map +1 -0
- package/esm/dropdown/Menu/GroupedList/index.d.ts +23 -0
- package/esm/dropdown/Menu/GroupedList/index.js +23 -0
- package/esm/dropdown/Menu/GroupedList/index.js.map +1 -0
- package/esm/dropdown/Menu/List/Item.d.ts +10 -0
- package/esm/dropdown/Menu/List/Item.js +26 -0
- package/esm/dropdown/Menu/List/Item.js.map +1 -0
- package/esm/dropdown/Menu/List/index.d.ts +18 -0
- package/esm/dropdown/Menu/List/index.js +21 -0
- package/esm/dropdown/Menu/List/index.js.map +1 -0
- package/esm/dropdown/Menu/index.d.ts +35 -0
- package/esm/dropdown/Menu/index.js +36 -0
- package/esm/dropdown/Menu/index.js.map +1 -0
- package/esm/dropdown/Toggle.d.ts +9 -0
- package/esm/dropdown/Toggle.js +38 -0
- package/esm/dropdown/Toggle.js.map +1 -0
- package/esm/dropdown/index.d.ts +2 -0
- package/esm/dropdown/index.js +3 -0
- package/esm/dropdown/index.js.map +1 -0
- package/esm/expansion-card/ExpansionCard.d.ts +40 -8
- package/esm/expansion-card/ExpansionCard.js +18 -0
- package/esm/expansion-card/ExpansionCard.js.map +1 -1
- package/esm/expansion-card/ExpansionCardContent.d.ts +1 -2
- package/esm/expansion-card/ExpansionCardContent.js.map +1 -1
- package/esm/expansion-card/ExpansionCardDescription.d.ts +2 -4
- package/esm/expansion-card/ExpansionCardDescription.js.map +1 -1
- package/esm/expansion-card/ExpansionCardHeader.d.ts +1 -2
- package/esm/expansion-card/ExpansionCardHeader.js.map +1 -1
- package/esm/expansion-card/ExpansionCardTitle.d.ts +2 -4
- package/esm/expansion-card/ExpansionCardTitle.js.map +1 -1
- package/esm/form/ConfirmationPanel.d.ts +18 -0
- package/esm/form/ConfirmationPanel.js +18 -0
- package/esm/form/ConfirmationPanel.js.map +1 -1
- package/esm/form/Select.d.ts +16 -0
- package/esm/form/Select.js +16 -0
- package/esm/form/Select.js.map +1 -1
- package/esm/form/Switch.d.ts +11 -0
- package/esm/form/Switch.js +11 -0
- package/esm/form/Switch.js.map +1 -1
- package/esm/form/TextField.d.ts +11 -0
- package/esm/form/TextField.js +11 -0
- package/esm/form/TextField.js.map +1 -1
- package/esm/form/Textarea.d.ts +11 -0
- package/esm/form/Textarea.js +11 -0
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.d.ts +15 -0
- package/esm/form/checkbox/CheckboxGroup.js +15 -0
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/error-summary/ErrorSummary.d.ts +18 -0
- package/esm/form/error-summary/ErrorSummary.js +18 -0
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/radio/RadioGroup.d.ts +10 -0
- package/esm/form/radio/RadioGroup.js +10 -0
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/form/search/Search.d.ts +13 -0
- package/esm/form/search/Search.js +13 -0
- package/esm/form/search/Search.js.map +1 -1
- package/esm/guide-panel/GuidePanel.d.ts +15 -0
- package/esm/guide-panel/GuidePanel.js +15 -0
- package/esm/guide-panel/GuidePanel.js.map +1 -1
- package/esm/help-text/HelpText.d.ts +13 -0
- package/esm/help-text/HelpText.js +13 -0
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/index.d.ts +4 -0
- package/esm/index.js +4 -0
- package/esm/index.js.map +1 -1
- package/esm/internal-header/InternalHeader.d.ts +60 -0
- package/esm/internal-header/InternalHeader.js +55 -0
- package/esm/internal-header/InternalHeader.js.map +1 -0
- package/esm/internal-header/InternalHeaderButton.d.ts +10 -0
- package/esm/internal-header/InternalHeaderButton.js +19 -0
- package/esm/internal-header/InternalHeaderButton.js.map +1 -0
- package/esm/internal-header/InternalHeaderTitle.d.ts +10 -0
- package/esm/internal-header/InternalHeaderTitle.js +20 -0
- package/esm/internal-header/InternalHeaderTitle.js.map +1 -0
- package/esm/internal-header/InternalHeaderUser.d.ts +13 -0
- package/esm/internal-header/InternalHeaderUser.js +23 -0
- package/esm/internal-header/InternalHeaderUser.js.map +1 -0
- package/esm/internal-header/InternalHeaderUserButton.d.ts +14 -0
- package/esm/internal-header/InternalHeaderUserButton.js +26 -0
- package/esm/internal-header/InternalHeaderUserButton.js.map +1 -0
- package/esm/internal-header/index.d.ts +5 -0
- package/esm/internal-header/index.js +2 -0
- package/esm/internal-header/index.js.map +1 -0
- package/esm/link/Link.d.ts +13 -0
- package/esm/link/Link.js +13 -0
- package/esm/link/Link.js.map +1 -1
- package/esm/link-panel/LinkPanel.d.ts +28 -4
- package/esm/link-panel/LinkPanel.js +17 -0
- package/esm/link-panel/LinkPanel.js.map +1 -1
- package/esm/link-panel/LinkPanelDescription.d.ts +2 -4
- package/esm/link-panel/LinkPanelDescription.js.map +1 -1
- package/esm/link-panel/LinkPanelTitle.d.ts +2 -4
- package/esm/link-panel/LinkPanelTitle.js.map +1 -1
- package/esm/list/List.d.ts +5 -2
- package/esm/list/List.js.map +1 -1
- package/esm/list/ListItem.d.ts +1 -3
- package/esm/list/ListItem.js.map +1 -1
- package/esm/loader/Loader.d.ts +11 -0
- package/esm/loader/Loader.js +11 -0
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/Modal.d.ts +27 -0
- package/esm/modal/Modal.js +27 -0
- package/esm/modal/Modal.js.map +1 -1
- package/esm/pagination/Pagination.d.ts +17 -0
- package/esm/pagination/Pagination.js +17 -0
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/panel/Panel.d.ts +19 -0
- package/esm/panel/Panel.js +19 -0
- package/esm/panel/Panel.js.map +1 -1
- package/esm/popover/Popover.d.ts +20 -0
- package/esm/popover/Popover.js +20 -0
- package/esm/popover/Popover.js.map +1 -1
- package/esm/provider/Provider.d.ts +13 -0
- package/esm/provider/Provider.js +13 -0
- package/esm/provider/Provider.js.map +1 -1
- package/esm/read-more/ReadMore.d.ts +17 -0
- package/esm/read-more/ReadMore.js +17 -0
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/skeleton/Skeleton.d.ts +18 -0
- package/esm/skeleton/Skeleton.js +23 -0
- package/esm/skeleton/Skeleton.js.map +1 -0
- package/esm/skeleton/index.d.ts +2 -0
- package/esm/skeleton/index.js +2 -0
- package/esm/skeleton/index.js.map +1 -0
- package/esm/stepper/Step.d.ts +1 -4
- package/esm/stepper/Step.js +1 -2
- package/esm/stepper/Step.js.map +1 -1
- package/esm/stepper/Stepper.d.ts +31 -2
- package/esm/stepper/Stepper.js +24 -0
- package/esm/stepper/Stepper.js.map +1 -1
- package/esm/table/Table.d.ts +32 -0
- package/esm/table/Table.js +32 -0
- package/esm/table/Table.js.map +1 -1
- package/esm/tabs/Tab.d.ts +1 -2
- package/esm/tabs/Tab.js.map +1 -1
- package/esm/tabs/TabList.d.ts +1 -2
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/tabs/TabPanel.d.ts +1 -2
- package/esm/tabs/TabPanel.js.map +1 -1
- package/esm/tabs/Tabs.d.ts +43 -6
- package/esm/tabs/Tabs.js +27 -1
- package/esm/tabs/Tabs.js.map +1 -1
- package/esm/tag/Tag.d.ts +11 -0
- package/esm/tag/Tag.js +11 -0
- package/esm/tag/Tag.js.map +1 -1
- package/esm/timeline/AxisLabels.d.ts +6 -0
- package/esm/timeline/AxisLabels.js +81 -0
- package/esm/timeline/AxisLabels.js.map +1 -0
- package/esm/timeline/Pin.d.ts +17 -0
- package/esm/timeline/Pin.js +81 -0
- package/esm/timeline/Pin.js.map +1 -0
- package/esm/timeline/Timeline.d.ts +63 -0
- package/esm/timeline/Timeline.js +152 -0
- package/esm/timeline/Timeline.js.map +1 -0
- package/esm/timeline/TimelineRow.d.ts +22 -0
- package/esm/timeline/TimelineRow.js +58 -0
- package/esm/timeline/TimelineRow.js.map +1 -0
- package/esm/timeline/hooks/usePeriodContext.d.ts +9 -0
- package/esm/timeline/hooks/usePeriodContext.js +13 -0
- package/esm/timeline/hooks/usePeriodContext.js.map +1 -0
- package/esm/timeline/hooks/useRowContext.d.ts +11 -0
- package/esm/timeline/hooks/useRowContext.js +15 -0
- package/esm/timeline/hooks/useRowContext.js.map +1 -0
- package/esm/timeline/hooks/useTimelineContext.d.ts +15 -0
- package/esm/timeline/hooks/useTimelineContext.js +20 -0
- package/esm/timeline/hooks/useTimelineContext.js.map +1 -0
- package/esm/timeline/hooks/useTimelineRows.d.ts +4 -0
- package/esm/timeline/hooks/useTimelineRows.js +74 -0
- package/esm/timeline/hooks/useTimelineRows.js.map +1 -0
- package/esm/timeline/index.d.ts +6 -0
- package/esm/timeline/index.js +2 -0
- package/esm/timeline/index.js.map +1 -0
- package/esm/timeline/period/ClickablePeriod.d.ts +9 -0
- package/esm/timeline/period/ClickablePeriod.js +93 -0
- package/esm/timeline/period/ClickablePeriod.js.map +1 -0
- package/esm/timeline/period/NonClickablePeriod.d.ts +7 -0
- package/esm/timeline/period/NonClickablePeriod.js +14 -0
- package/esm/timeline/period/NonClickablePeriod.js.map +1 -0
- package/esm/timeline/period/index.d.ts +57 -0
- package/esm/timeline/period/index.js +18 -0
- package/esm/timeline/period/index.js.map +1 -0
- package/esm/timeline/utils/calc.d.ts +5 -0
- package/esm/timeline/utils/calc.js +15 -0
- package/esm/timeline/utils/calc.js.map +1 -0
- package/esm/timeline/utils/filter.d.ts +10 -0
- package/esm/timeline/utils/filter.js +11 -0
- package/esm/timeline/utils/filter.js.map +1 -0
- package/esm/timeline/utils/index.d.ts +1 -0
- package/esm/timeline/utils/index.js +2 -0
- package/esm/timeline/utils/index.js.map +1 -0
- package/esm/timeline/utils/period.d.ts +2 -0
- package/esm/timeline/utils/period.js +33 -0
- package/esm/timeline/utils/period.js.map +1 -0
- package/esm/timeline/utils/sort.d.ts +4 -0
- package/esm/timeline/utils/sort.js +5 -0
- package/esm/timeline/utils/sort.js.map +1 -0
- package/esm/timeline/utils/timeline.d.ts +12 -0
- package/esm/timeline/utils/timeline.js +73 -0
- package/esm/timeline/utils/timeline.js.map +1 -0
- package/esm/timeline/utils/types.external.d.ts +53 -0
- package/esm/timeline/utils/types.external.js +2 -0
- package/esm/timeline/utils/types.external.js.map +1 -0
- package/esm/timeline/utils/types.internal.d.ts +61 -0
- package/esm/timeline/utils/types.internal.js +2 -0
- package/esm/timeline/utils/types.internal.js.map +1 -0
- package/esm/timeline/zoom/ZoomButton.d.ts +19 -0
- package/esm/timeline/zoom/ZoomButton.js +43 -0
- package/esm/timeline/zoom/ZoomButton.js.map +1 -0
- package/esm/timeline/zoom/index.d.ts +11 -0
- package/esm/timeline/zoom/index.js +22 -0
- package/esm/timeline/zoom/index.js.map +1 -0
- package/esm/toggle-group/ToggleGroup.d.ts +20 -2
- package/esm/toggle-group/ToggleGroup.js +17 -2
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/toggle-group/ToggleItem.d.ts +1 -2
- package/esm/toggle-group/ToggleItem.js.map +1 -1
- package/esm/tooltip/Tooltip.d.ts +13 -0
- package/esm/tooltip/Tooltip.js +13 -0
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/BodyLong.d.ts +14 -0
- package/esm/typography/BodyLong.js +14 -0
- package/esm/typography/BodyLong.js.map +1 -1
- package/esm/typography/BodyShort.d.ts +14 -0
- package/esm/typography/BodyShort.js +14 -0
- package/esm/typography/BodyShort.js.map +1 -1
- package/esm/typography/Detail.d.ts +14 -0
- package/esm/typography/Detail.js +14 -0
- package/esm/typography/Detail.js.map +1 -1
- package/esm/typography/ErrorMessage.d.ts +14 -0
- package/esm/typography/ErrorMessage.js +14 -0
- package/esm/typography/ErrorMessage.js.map +1 -1
- package/esm/typography/Heading.d.ts +14 -0
- package/esm/typography/Heading.js +14 -0
- package/esm/typography/Heading.js.map +1 -1
- package/esm/typography/Ingress.d.ts +14 -0
- package/esm/typography/Ingress.js +14 -0
- package/esm/typography/Ingress.js.map +1 -1
- package/esm/typography/Label.d.ts +14 -0
- package/esm/typography/Label.js +14 -0
- package/esm/typography/Label.js.map +1 -1
- package/package.json +2 -2
- package/src/accordion/Accordion.tsx +49 -7
- package/src/accordion/AccordionContent.tsx +1 -5
- package/src/accordion/AccordionHeader.tsx +1 -5
- package/src/accordion/AccordionItem.tsx +1 -5
- package/src/accordion/accordion.stories.tsx +4 -2
- package/src/alert/Alert.tsx +9 -0
- package/src/button/Button.tsx +10 -0
- package/src/chat/Bubble.tsx +1 -5
- package/src/chat/Chat.tsx +23 -2
- package/src/chips/Chips.tsx +42 -4
- package/src/chips/Removable.tsx +1 -4
- package/src/chips/Toggle.tsx +47 -11
- package/src/chips/chips.stories.tsx +73 -20
- package/src/copybutton/CopyButton.tsx +11 -0
- package/src/date/DateInput.tsx +105 -115
- package/src/date/datepicker/DatePicker.tsx +40 -2
- package/src/date/datepicker/datepicker.stories.tsx +19 -21
- package/src/date/datepicker/datepicker.test.tsx +5 -5
- package/src/date/hooks/index.ts +3 -3
- package/src/date/hooks/useDatepicker.tsx +13 -0
- package/src/date/hooks/useMonthPicker.tsx +13 -0
- package/src/date/hooks/useRangeDatepicker.test.tsx +6 -6
- package/src/date/hooks/useRangeDatepicker.tsx +13 -1
- package/src/date/index.ts +5 -5
- package/src/date/monthpicker/MonthPicker.tsx +36 -4
- package/src/date/monthpicker/monthpicker.stories.tsx +5 -5
- package/src/date/utils/__tests__/get-dates.test.ts +0 -1
- package/src/dropdown/Dropdown.tsx +119 -0
- package/src/dropdown/Menu/Divider.tsx +15 -0
- package/src/dropdown/Menu/GroupedList/Heading.tsx +28 -0
- package/src/dropdown/Menu/GroupedList/Item.tsx +41 -0
- package/src/dropdown/Menu/GroupedList/index.tsx +43 -0
- package/src/dropdown/Menu/List/Item.tsx +38 -0
- package/src/dropdown/Menu/List/index.tsx +32 -0
- package/src/dropdown/Menu/index.tsx +96 -0
- package/src/dropdown/Toggle.tsx +48 -0
- package/src/dropdown/dropdown.stories.tsx +91 -0
- package/src/dropdown/index.ts +2 -0
- package/src/expansion-card/ExpansionCard.tsx +46 -8
- package/src/expansion-card/ExpansionCardContent.tsx +25 -28
- package/src/expansion-card/ExpansionCardDescription.tsx +22 -24
- package/src/expansion-card/ExpansionCardHeader.tsx +31 -34
- package/src/expansion-card/ExpansionCardTitle.tsx +3 -5
- package/src/form/ConfirmationPanel.tsx +18 -0
- package/src/form/Select.tsx +16 -0
- package/src/form/Switch.tsx +11 -0
- package/src/form/TextField.tsx +11 -0
- package/src/form/Textarea.tsx +11 -0
- package/src/form/checkbox/CheckboxGroup.tsx +15 -0
- package/src/form/error-summary/ErrorSummary.tsx +18 -0
- package/src/form/radio/RadioGroup.tsx +10 -0
- package/src/form/search/Search.tsx +13 -0
- package/src/guide-panel/GuidePanel.tsx +15 -0
- package/src/help-text/HelpText.tsx +13 -0
- package/src/index.ts +4 -0
- package/src/internal-header/InternalHeader.tsx +93 -0
- package/src/internal-header/InternalHeaderButton.tsx +23 -0
- package/src/internal-header/InternalHeaderTitle.tsx +27 -0
- package/src/internal-header/InternalHeaderUser.tsx +35 -0
- package/src/internal-header/InternalHeaderUserButton.tsx +40 -0
- package/src/internal-header/header.stories.tsx +225 -0
- package/src/internal-header/index.ts +8 -0
- package/src/link/Link.tsx +13 -0
- package/src/link-panel/LinkPanel.tsx +30 -4
- package/src/link-panel/LinkPanelDescription.tsx +12 -15
- package/src/link-panel/LinkPanelTitle.tsx +15 -18
- package/src/list/List.tsx +7 -2
- package/src/list/ListItem.tsx +1 -6
- package/src/loader/Loader.tsx +11 -0
- package/src/modal/Modal.tsx +27 -0
- package/src/pagination/Pagination.tsx +17 -0
- package/src/panel/Panel.tsx +19 -0
- package/src/popover/Popover.tsx +20 -0
- package/src/provider/Provider.tsx +13 -0
- package/src/read-more/ReadMore.tsx +17 -0
- package/src/skeleton/Skeleton.tsx +48 -0
- package/src/skeleton/index.ts +2 -0
- package/src/skeleton/skeleton.stories.tsx +118 -0
- package/src/stepper/Step.tsx +57 -60
- package/src/stepper/Stepper.tsx +31 -2
- package/src/table/Table.tsx +32 -0
- package/src/tabs/Tab.tsx +38 -39
- package/src/tabs/TabList.tsx +1 -5
- package/src/tabs/TabPanel.tsx +1 -5
- package/src/tabs/Tabs.tsx +48 -7
- package/src/tag/Tag.tsx +11 -0
- package/src/timeline/AxisLabels.tsx +143 -0
- package/src/timeline/Pin.tsx +169 -0
- package/src/timeline/Timeline.tsx +237 -0
- package/src/timeline/TimelineRow.tsx +122 -0
- package/src/timeline/hooks/usePeriodContext.tsx +22 -0
- package/src/timeline/hooks/useRowContext.tsx +26 -0
- package/src/timeline/hooks/useTimelineContext.tsx +37 -0
- package/src/timeline/hooks/useTimelineRows.ts +161 -0
- package/src/timeline/index.ts +6 -0
- package/src/timeline/period/ClickablePeriod.tsx +193 -0
- package/src/timeline/period/NonClickablePeriod.tsx +46 -0
- package/src/timeline/period/index.tsx +130 -0
- package/src/timeline/timeline.stories.tsx +444 -0
- package/src/timeline/utils/calc.ts +26 -0
- package/src/timeline/utils/filter.ts +32 -0
- package/src/timeline/utils/index.ts +6 -0
- package/src/timeline/utils/period.ts +48 -0
- package/src/timeline/utils/sort.ts +11 -0
- package/src/timeline/utils/timeline.ts +83 -0
- package/src/timeline/utils/types.external.ts +67 -0
- package/src/timeline/utils/types.internal.ts +76 -0
- package/src/timeline/zoom/ZoomButton.tsx +83 -0
- package/src/timeline/zoom/index.tsx +30 -0
- package/src/toggle-group/ToggleGroup.tsx +23 -3
- package/src/toggle-group/ToggleItem.tsx +1 -5
- package/src/tooltip/Tooltip.tsx +13 -0
- package/src/typography/BodyLong.tsx +14 -0
- package/src/typography/BodyShort.tsx +14 -0
- package/src/typography/Detail.tsx +14 -0
- package/src/typography/ErrorMessage.tsx +14 -0
- package/src/typography/Heading.tsx +14 -0
- package/src/typography/Ingress.tsx +14 -0
- package/src/typography/Label.tsx +14 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React, { createContext, useState } from "react";
|
|
2
|
+
import Toggle, { ToggleProps } from "./Toggle";
|
|
3
|
+
import Menu, { MenuType } from "./Menu";
|
|
4
|
+
|
|
5
|
+
export interface DropdownProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Handler called when an item is selected.
|
|
9
|
+
*/
|
|
10
|
+
onSelect?: (element: React.MouseEvent) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the Menu closes when a selection is made.
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
closeOnSelect?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
defaultOpen?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Controlled state of the dropdown. When set, you will need to handle onClose and onSelect manually.
|
|
22
|
+
*/
|
|
23
|
+
open?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DropdownType extends React.FC<DropdownProps> {
|
|
27
|
+
/**
|
|
28
|
+
* @see 🏷️ {@link ToggleProps}
|
|
29
|
+
*/
|
|
30
|
+
Toggle: React.ForwardRefExoticComponent<
|
|
31
|
+
ToggleProps & React.RefAttributes<HTMLButtonElement>
|
|
32
|
+
>;
|
|
33
|
+
/**
|
|
34
|
+
* @see 🏷️ {@link MenuType}
|
|
35
|
+
*/
|
|
36
|
+
Menu: MenuType;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface DropdownContextType {
|
|
40
|
+
readonly isOpen: boolean;
|
|
41
|
+
handleToggle: (v: boolean) => void;
|
|
42
|
+
readonly anchorEl: Element | null;
|
|
43
|
+
setAnchorEl: React.Dispatch<React.SetStateAction<Element | null>>;
|
|
44
|
+
onSelect: (element: React.MouseEvent) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const DropdownContext = createContext<DropdownContextType | null>(null);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A component that displays a dropdown menu when the user clicks on its toggle button.
|
|
51
|
+
*
|
|
52
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/dropdown)
|
|
53
|
+
* @see 🏷️ {@link DropdownProps}
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```jsx
|
|
57
|
+
* <Dropdown>
|
|
58
|
+
* <Button as={Dropdown.Toggle}>Toggle</Button>
|
|
59
|
+
* <Dropdown.Menu>
|
|
60
|
+
* <Dropdown.Menu.GroupedList>
|
|
61
|
+
* <Dropdown.Menu.GroupedList.Heading>
|
|
62
|
+
* Systemer og oppslagsverk
|
|
63
|
+
* </Dropdown.Menu.GroupedList.Heading>
|
|
64
|
+
* <Dropdown.Menu.GroupedList.Item>
|
|
65
|
+
* Gosys
|
|
66
|
+
* </Dropdown.Menu.GroupedList.Item>
|
|
67
|
+
* <Dropdown.Menu.GroupedList.Item>
|
|
68
|
+
* Infotrygd
|
|
69
|
+
* </Dropdown.Menu.GroupedList.Item>
|
|
70
|
+
* </Dropdown.Menu.GroupedList>
|
|
71
|
+
* <Dropdown.Menu.Divider />
|
|
72
|
+
* <Dropdown.Menu.List>
|
|
73
|
+
* <Dropdown.Menu.List.Item>Gosys</Dropdown.Menu.List.Item>
|
|
74
|
+
* <Dropdown.Menu.List.Item>Infotrygd</Dropdown.Menu.List.Item>
|
|
75
|
+
* </Dropdown.Menu.List>
|
|
76
|
+
* </Dropdown.Menu>
|
|
77
|
+
* </Dropdown>
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export const Dropdown = (({
|
|
81
|
+
children,
|
|
82
|
+
onSelect,
|
|
83
|
+
closeOnSelect = true,
|
|
84
|
+
defaultOpen = false,
|
|
85
|
+
open,
|
|
86
|
+
}) => {
|
|
87
|
+
const [isOpen, setIsOpen] = useState<boolean>(defaultOpen);
|
|
88
|
+
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
|
|
89
|
+
|
|
90
|
+
const handleToggle = (v: boolean) => {
|
|
91
|
+
if (open === undefined) {
|
|
92
|
+
setIsOpen(v);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<DropdownContext.Provider
|
|
98
|
+
value={{
|
|
99
|
+
isOpen: open ?? isOpen,
|
|
100
|
+
handleToggle,
|
|
101
|
+
anchorEl,
|
|
102
|
+
setAnchorEl,
|
|
103
|
+
onSelect: (event) => {
|
|
104
|
+
onSelect?.(event);
|
|
105
|
+
if (closeOnSelect) {
|
|
106
|
+
open === undefined && setIsOpen(false);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
{children}
|
|
112
|
+
</DropdownContext.Provider>
|
|
113
|
+
);
|
|
114
|
+
}) as DropdownType;
|
|
115
|
+
|
|
116
|
+
Dropdown.Toggle = Toggle;
|
|
117
|
+
Dropdown.Menu = Menu;
|
|
118
|
+
|
|
119
|
+
export default Dropdown;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import cl from "clsx";
|
|
3
|
+
|
|
4
|
+
export const Divider = forwardRef<
|
|
5
|
+
HTMLHRElement,
|
|
6
|
+
React.HTMLAttributes<HTMLHRElement>
|
|
7
|
+
>(({ className, ...rest }, ref) => (
|
|
8
|
+
<hr
|
|
9
|
+
{...rest}
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cl("navds-dropdown__divider", className)}
|
|
12
|
+
/>
|
|
13
|
+
));
|
|
14
|
+
|
|
15
|
+
export default Divider;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import cl from "clsx";
|
|
3
|
+
|
|
4
|
+
export interface GroupedHeadingProps
|
|
5
|
+
extends React.HTMLAttributes<HTMLDetailsElement> {
|
|
6
|
+
/**
|
|
7
|
+
* Heading
|
|
8
|
+
*/
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const GroupedHeading = forwardRef<
|
|
13
|
+
HTMLDetailsElement,
|
|
14
|
+
GroupedHeadingProps
|
|
15
|
+
>(({ className, ...rest }, ref) => (
|
|
16
|
+
<dt
|
|
17
|
+
{...rest}
|
|
18
|
+
ref={ref}
|
|
19
|
+
className={cl(
|
|
20
|
+
"navds-dropdown__list-heading",
|
|
21
|
+
"navds-heading",
|
|
22
|
+
"navds-heading--xsmall",
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
/>
|
|
26
|
+
));
|
|
27
|
+
|
|
28
|
+
export default GroupedHeading;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { OverridableComponent } from "../../../util/OverridableComponent";
|
|
2
|
+
import cl from "clsx";
|
|
3
|
+
import React, { forwardRef, useContext } from "react";
|
|
4
|
+
import { DropdownContext } from "../../Dropdown";
|
|
5
|
+
|
|
6
|
+
export interface GroupedItemProps
|
|
7
|
+
extends React.ButtonHTMLAttributes<HTMLElement> {
|
|
8
|
+
/**
|
|
9
|
+
* Menu item content
|
|
10
|
+
*/
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const GroupedItem: OverridableComponent<
|
|
15
|
+
GroupedItemProps,
|
|
16
|
+
HTMLButtonElement
|
|
17
|
+
> = forwardRef(({ as: Component = "button", className, ...rest }, ref) => {
|
|
18
|
+
const context = useContext(DropdownContext);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<dd className="navds-dropdown__list-item">
|
|
22
|
+
<Component
|
|
23
|
+
{...rest}
|
|
24
|
+
value={rest.children}
|
|
25
|
+
onClick={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
26
|
+
context?.onSelect?.(event);
|
|
27
|
+
rest?.onClick?.(event);
|
|
28
|
+
}}
|
|
29
|
+
ref={ref}
|
|
30
|
+
className={cl(
|
|
31
|
+
"navds-dropdown__item",
|
|
32
|
+
"navds-body-short",
|
|
33
|
+
"navds-body-short--small",
|
|
34
|
+
className
|
|
35
|
+
)}
|
|
36
|
+
/>
|
|
37
|
+
</dd>
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export default GroupedItem;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { OverridableComponent } from "../../../util/OverridableComponent";
|
|
4
|
+
import GroupedHeading, { GroupedHeadingProps } from "./Heading";
|
|
5
|
+
import GroupedItem, { GroupedItemProps } from "./Item";
|
|
6
|
+
|
|
7
|
+
export interface GroupedListProps
|
|
8
|
+
extends React.HTMLAttributes<HTMLDListElement> {
|
|
9
|
+
/**
|
|
10
|
+
* Menu list content
|
|
11
|
+
*/
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface GroupedListType
|
|
16
|
+
extends React.ForwardRefExoticComponent<
|
|
17
|
+
GroupedListProps & React.RefAttributes<HTMLDListElement>
|
|
18
|
+
> {
|
|
19
|
+
/**
|
|
20
|
+
* @see 🏷️ {@link GroupedHeadingProps}
|
|
21
|
+
*/
|
|
22
|
+
Heading: React.ForwardRefExoticComponent<
|
|
23
|
+
GroupedHeadingProps & React.RefAttributes<HTMLDetailsElement>
|
|
24
|
+
>;
|
|
25
|
+
/**
|
|
26
|
+
* @see 🏷️ {@link GroupedItemProps}
|
|
27
|
+
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
28
|
+
*/
|
|
29
|
+
Item: OverridableComponent<GroupedItemProps, HTMLButtonElement>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const DescriptionList = forwardRef(
|
|
33
|
+
({ className, children, ...rest }, ref) => (
|
|
34
|
+
<dl {...rest} ref={ref} className={cl("navds-dropdown__list", className)}>
|
|
35
|
+
{children}
|
|
36
|
+
</dl>
|
|
37
|
+
)
|
|
38
|
+
) as GroupedListType;
|
|
39
|
+
|
|
40
|
+
DescriptionList.Heading = GroupedHeading;
|
|
41
|
+
DescriptionList.Item = GroupedItem;
|
|
42
|
+
|
|
43
|
+
export default DescriptionList;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { forwardRef, useContext } from "react";
|
|
2
|
+
import cl from "clsx";
|
|
3
|
+
import { OverridableComponent } from "../../../util/OverridableComponent";
|
|
4
|
+
import { DropdownContext } from "../../Dropdown";
|
|
5
|
+
|
|
6
|
+
export interface ListItemProps extends React.ButtonHTMLAttributes<HTMLElement> {
|
|
7
|
+
/**
|
|
8
|
+
* Menu item content
|
|
9
|
+
*/
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const ListItem: OverridableComponent<ListItemProps, HTMLButtonElement> =
|
|
14
|
+
forwardRef(({ as: Component = "button", className, ...rest }, ref) => {
|
|
15
|
+
const context = useContext(DropdownContext);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<li className="navds-dropdown__list-item">
|
|
19
|
+
<Component
|
|
20
|
+
{...rest}
|
|
21
|
+
value={rest.children}
|
|
22
|
+
onClick={(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
23
|
+
context?.onSelect?.(event);
|
|
24
|
+
rest?.onClick?.(event);
|
|
25
|
+
}}
|
|
26
|
+
ref={ref}
|
|
27
|
+
className={cl(
|
|
28
|
+
"navds-dropdown__item",
|
|
29
|
+
"navds-body-short",
|
|
30
|
+
"navds-body-short--small",
|
|
31
|
+
className
|
|
32
|
+
)}
|
|
33
|
+
/>
|
|
34
|
+
</li>
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export default ListItem;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { OverridableComponent } from "../../../util/OverridableComponent";
|
|
4
|
+
import ListItem, { ListItemProps } from "./Item";
|
|
5
|
+
|
|
6
|
+
export interface ListProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
7
|
+
/**
|
|
8
|
+
* Menu list content
|
|
9
|
+
*/
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ListType
|
|
14
|
+
extends React.ForwardRefExoticComponent<
|
|
15
|
+
ListProps & React.RefAttributes<HTMLUListElement>
|
|
16
|
+
> {
|
|
17
|
+
/**
|
|
18
|
+
* @see 🏷️ {@link ListItemProps}
|
|
19
|
+
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
20
|
+
*/
|
|
21
|
+
Item: OverridableComponent<ListItemProps, HTMLButtonElement>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const List = forwardRef(({ className, children, ...rest }, ref) => (
|
|
25
|
+
<ul {...rest} ref={ref} className={cl("navds-dropdown__list", className)}>
|
|
26
|
+
{children}
|
|
27
|
+
</ul>
|
|
28
|
+
)) as ListType;
|
|
29
|
+
|
|
30
|
+
List.Item = ListItem;
|
|
31
|
+
|
|
32
|
+
export default List;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import cl from "clsx";
|
|
2
|
+
import React, { forwardRef, useContext } from "react";
|
|
3
|
+
import { Popover } from "../../popover";
|
|
4
|
+
import { DropdownContext } from "../Dropdown";
|
|
5
|
+
import Divider from "./Divider";
|
|
6
|
+
import GroupedList, { GroupedListType } from "./GroupedList";
|
|
7
|
+
import List, { ListType } from "./List";
|
|
8
|
+
|
|
9
|
+
interface MenuProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Dropdown content
|
|
12
|
+
*/
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* onClose callback
|
|
16
|
+
*/
|
|
17
|
+
onClose?: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Popover positionion strategy
|
|
20
|
+
* @default "absolute"
|
|
21
|
+
*/
|
|
22
|
+
strategy?: "fixed" | "absolute";
|
|
23
|
+
/*
|
|
24
|
+
* Default dialog-placement on open
|
|
25
|
+
* @default "bottom-end"
|
|
26
|
+
*/
|
|
27
|
+
placement?:
|
|
28
|
+
| "top"
|
|
29
|
+
| "bottom"
|
|
30
|
+
| "right"
|
|
31
|
+
| "left"
|
|
32
|
+
| "top-start"
|
|
33
|
+
| "top-end"
|
|
34
|
+
| "bottom-start"
|
|
35
|
+
| "bottom-end"
|
|
36
|
+
| "right-start"
|
|
37
|
+
| "right-end"
|
|
38
|
+
| "left-start"
|
|
39
|
+
| "left-end";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface MenuType<Props = MenuProps>
|
|
43
|
+
extends React.ForwardRefExoticComponent<
|
|
44
|
+
Props & React.RefAttributes<HTMLDivElement>
|
|
45
|
+
> {
|
|
46
|
+
/**
|
|
47
|
+
* @see 🏷️ {@link ListType}
|
|
48
|
+
*/
|
|
49
|
+
List: ListType;
|
|
50
|
+
/**
|
|
51
|
+
* @see 🏷️ {@link GroupedListType}
|
|
52
|
+
*/
|
|
53
|
+
GroupedList: GroupedListType;
|
|
54
|
+
/**
|
|
55
|
+
* @see 🏷️ {@link React.HTMLAttributes<HTMLHRElement>}
|
|
56
|
+
*/
|
|
57
|
+
Divider: React.ForwardRefExoticComponent<
|
|
58
|
+
React.HTMLAttributes<HTMLHRElement> & React.RefAttributes<HTMLHRElement>
|
|
59
|
+
>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const Menu = forwardRef<HTMLDivElement, MenuProps>(
|
|
63
|
+
({ className, onClose, placement = "bottom-end", ...rest }, ref) => {
|
|
64
|
+
const context = useContext(DropdownContext);
|
|
65
|
+
|
|
66
|
+
if (!context) {
|
|
67
|
+
console.warn("Dropdown.Menu has to be wrapped in <Dropdown />");
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const { isOpen, anchorEl, handleToggle } = context;
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Popover
|
|
75
|
+
{...rest}
|
|
76
|
+
placement={placement}
|
|
77
|
+
ref={ref}
|
|
78
|
+
arrow={false}
|
|
79
|
+
className={cl("navds-dropdown__menu", className)}
|
|
80
|
+
offset={-4}
|
|
81
|
+
anchorEl={anchorEl}
|
|
82
|
+
open={isOpen}
|
|
83
|
+
onClose={() => {
|
|
84
|
+
handleToggle(false);
|
|
85
|
+
onClose && onClose();
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
) as MenuType;
|
|
91
|
+
|
|
92
|
+
Menu.List = List;
|
|
93
|
+
Menu.GroupedList = GroupedList;
|
|
94
|
+
Menu.Divider = Divider;
|
|
95
|
+
|
|
96
|
+
export default Menu;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { forwardRef, useContext } from "react";
|
|
2
|
+
import cl from "clsx";
|
|
3
|
+
import { DropdownContext } from ".";
|
|
4
|
+
|
|
5
|
+
export interface ToggleProps
|
|
6
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
7
|
+
/**
|
|
8
|
+
* Button content
|
|
9
|
+
*/
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Toggle = forwardRef<HTMLButtonElement, ToggleProps>(
|
|
14
|
+
({ className, onClick, ...rest }, ref) => {
|
|
15
|
+
const context = useContext(DropdownContext);
|
|
16
|
+
|
|
17
|
+
if (!context) {
|
|
18
|
+
console.warn("Dropdown.Toggle has to be wrapped in <Dropdown />");
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { setAnchorEl, handleToggle, isOpen } = context;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<button
|
|
26
|
+
{...rest}
|
|
27
|
+
ref={(el) => {
|
|
28
|
+
setAnchorEl(el);
|
|
29
|
+
|
|
30
|
+
if (typeof ref === "function") {
|
|
31
|
+
ref(el);
|
|
32
|
+
} else if (ref != null) {
|
|
33
|
+
ref.current = el;
|
|
34
|
+
}
|
|
35
|
+
}}
|
|
36
|
+
onClick={(e) => {
|
|
37
|
+
setAnchorEl(e.currentTarget);
|
|
38
|
+
handleToggle(!isOpen);
|
|
39
|
+
onClick && onClick(e);
|
|
40
|
+
}}
|
|
41
|
+
aria-expanded={isOpen}
|
|
42
|
+
className={cl("navds-dropdown__toggle", className)}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export default Toggle;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Dropdown } from "..";
|
|
3
|
+
import { Meta } from "@storybook/react";
|
|
4
|
+
import { Button } from "../button";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "ds-react/Dropdown",
|
|
8
|
+
component: Dropdown,
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
export const Default = () => {
|
|
12
|
+
return (
|
|
13
|
+
<Dropdown onSelect={(event) => console.log(event)}>
|
|
14
|
+
<Dropdown.Toggle>Toggle</Dropdown.Toggle>
|
|
15
|
+
<Dropdown.Menu strategy="fixed">
|
|
16
|
+
<Dropdown.Menu.GroupedList>
|
|
17
|
+
<Dropdown.Menu.GroupedList.Heading>
|
|
18
|
+
Systemer og oppslagsverk
|
|
19
|
+
</Dropdown.Menu.GroupedList.Heading>
|
|
20
|
+
<Dropdown.Menu.GroupedList.Item
|
|
21
|
+
onClick={() => console.log("GroupedList.Item-click")}
|
|
22
|
+
>
|
|
23
|
+
Gosys
|
|
24
|
+
</Dropdown.Menu.GroupedList.Item>
|
|
25
|
+
</Dropdown.Menu.GroupedList>
|
|
26
|
+
<Dropdown.Menu.Divider />
|
|
27
|
+
<Dropdown.Menu.List>
|
|
28
|
+
<Dropdown.Menu.List.Item onClick={() => console.log("Item-click")}>
|
|
29
|
+
Gosys
|
|
30
|
+
</Dropdown.Menu.List.Item>
|
|
31
|
+
<Dropdown.Menu.List.Item>Psys</Dropdown.Menu.List.Item>
|
|
32
|
+
<Dropdown.Menu.List.Item disabled>Infotrygd</Dropdown.Menu.List.Item>
|
|
33
|
+
</Dropdown.Menu.List>
|
|
34
|
+
</Dropdown.Menu>
|
|
35
|
+
</Dropdown>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const DefaultOpen = {
|
|
40
|
+
render: () => (
|
|
41
|
+
<Dropdown onSelect={(event) => console.log(event)} defaultOpen>
|
|
42
|
+
<Button as={Dropdown.Toggle}>Toggle</Button>
|
|
43
|
+
<Dropdown.Menu
|
|
44
|
+
strategy="fixed"
|
|
45
|
+
onClose={() => console.log("ONCLOSE default")}
|
|
46
|
+
>
|
|
47
|
+
<Dropdown.Menu.GroupedList>
|
|
48
|
+
<Dropdown.Menu.GroupedList.Heading>
|
|
49
|
+
Systemer og oppslagsverk
|
|
50
|
+
</Dropdown.Menu.GroupedList.Heading>
|
|
51
|
+
<Dropdown.Menu.GroupedList.Item
|
|
52
|
+
onClick={() => console.log("GroupedList.Item-click")}
|
|
53
|
+
>
|
|
54
|
+
Gosys
|
|
55
|
+
</Dropdown.Menu.GroupedList.Item>
|
|
56
|
+
</Dropdown.Menu.GroupedList>
|
|
57
|
+
</Dropdown.Menu>
|
|
58
|
+
</Dropdown>
|
|
59
|
+
),
|
|
60
|
+
args: { chromatic: { delay: 300 } },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const ControlledOpen = {
|
|
64
|
+
render: () => {
|
|
65
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
66
|
+
const [openState, setOpenState] = useState(true);
|
|
67
|
+
return (
|
|
68
|
+
<Dropdown onSelect={(event) => console.log(event)} open={openState}>
|
|
69
|
+
<Button as={Dropdown.Toggle} onClick={() => setOpenState(!openState)}>
|
|
70
|
+
Toggle
|
|
71
|
+
</Button>
|
|
72
|
+
<Dropdown.Menu
|
|
73
|
+
strategy="fixed"
|
|
74
|
+
onClose={() => console.log("ONCLOSE CONTROLLED")}
|
|
75
|
+
>
|
|
76
|
+
<Dropdown.Menu.GroupedList>
|
|
77
|
+
<Dropdown.Menu.GroupedList.Heading>
|
|
78
|
+
Systemer og oppslagsverk
|
|
79
|
+
</Dropdown.Menu.GroupedList.Heading>
|
|
80
|
+
<Dropdown.Menu.GroupedList.Item
|
|
81
|
+
onClick={() => console.log("GroupedList.Item-click")}
|
|
82
|
+
>
|
|
83
|
+
Gosys
|
|
84
|
+
</Dropdown.Menu.GroupedList.Item>
|
|
85
|
+
</Dropdown.Menu.GroupedList>
|
|
86
|
+
</Dropdown.Menu>
|
|
87
|
+
</Dropdown>
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
args: { chromatic: { delay: 300 } },
|
|
91
|
+
};
|
|
@@ -1,28 +1,48 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { createContext, forwardRef, useRef, useState } from "react";
|
|
3
|
+
import { OverridableComponent } from "../util/OverridableComponent";
|
|
3
4
|
import ExpansionCardContent, {
|
|
4
|
-
|
|
5
|
+
ExpansionCardContentProps,
|
|
5
6
|
} from "./ExpansionCardContent";
|
|
6
7
|
import {
|
|
7
8
|
ExpansionCardDescription,
|
|
8
|
-
|
|
9
|
+
ExpansionCardDescriptionProps,
|
|
9
10
|
} from "./ExpansionCardDescription";
|
|
10
11
|
import ExpansionCardHeader, {
|
|
11
|
-
|
|
12
|
+
ExpansionCardHeaderProps,
|
|
12
13
|
} from "./ExpansionCardHeader";
|
|
13
14
|
import {
|
|
14
15
|
ExpansionCardTitle,
|
|
15
|
-
|
|
16
|
+
ExpansionCardTitleProps,
|
|
16
17
|
} from "./ExpansionCardTitle";
|
|
17
18
|
|
|
18
19
|
interface ExpansionCardComponent
|
|
19
20
|
extends React.ForwardRefExoticComponent<
|
|
20
21
|
ExpansionCardProps & React.RefAttributes<HTMLDivElement>
|
|
21
22
|
> {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @see 🏷️ {@link ExpansionCardHeaderProps}
|
|
25
|
+
*/
|
|
26
|
+
Header: React.ForwardRefExoticComponent<
|
|
27
|
+
ExpansionCardHeaderProps & React.RefAttributes<HTMLDivElement>
|
|
28
|
+
>;
|
|
29
|
+
/**
|
|
30
|
+
* @see 🏷️ {@link ExpansionCardTitleProps}
|
|
31
|
+
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
32
|
+
*/
|
|
33
|
+
Title: OverridableComponent<ExpansionCardTitleProps, HTMLHeadingElement>;
|
|
34
|
+
/**
|
|
35
|
+
* @see 🏷️ {@link ExpansionCardDescriptionProps}
|
|
36
|
+
*/
|
|
37
|
+
Description: React.ForwardRefExoticComponent<
|
|
38
|
+
ExpansionCardDescriptionProps & React.RefAttributes<HTMLParagraphElement>
|
|
39
|
+
>;
|
|
40
|
+
/**
|
|
41
|
+
* @see 🏷️ {@link ExpansionCardContentProps}
|
|
42
|
+
*/
|
|
43
|
+
Content: React.ForwardRefExoticComponent<
|
|
44
|
+
ExpansionCardContentProps & React.RefAttributes<HTMLDivElement>
|
|
45
|
+
>;
|
|
26
46
|
}
|
|
27
47
|
|
|
28
48
|
interface ExpansionCardCommonProps
|
|
@@ -77,6 +97,24 @@ export const ExpansionCardContext = createContext<ExpansionCardContextProps>({
|
|
|
77
97
|
export type ExpansionCardProps = ExpansionCardCommonProps &
|
|
78
98
|
ExpansionCardConditionalProps;
|
|
79
99
|
|
|
100
|
+
/**
|
|
101
|
+
* A component that displays an expandable card.
|
|
102
|
+
*
|
|
103
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/expansioncard)
|
|
104
|
+
* @see 🏷️ {@link ExpansionCardProps}
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```jsx
|
|
108
|
+
* <ExpansionCard aria-label="default-demo">
|
|
109
|
+
* <ExpansionCard.Header>
|
|
110
|
+
* <ExpansionCard.Title>Utbetaling av sykepenger</ExpansionCard.Title>
|
|
111
|
+
* </ExpansionCard.Header>
|
|
112
|
+
* <ExpansionCard.Content>
|
|
113
|
+
* <Innhold />
|
|
114
|
+
* </ExpansionCard.Content>
|
|
115
|
+
* </ExpansionCard>
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
80
118
|
export const ExpansionCard = forwardRef<HTMLDivElement, ExpansionCardProps>(
|
|
81
119
|
(
|
|
82
120
|
{
|