@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
package/src/date/DateInput.tsx
CHANGED
|
@@ -28,131 +28,121 @@ export interface DateInputProps
|
|
|
28
28
|
variant?: "datepicker" | "monthpicker";
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const DateInput = forwardRef<HTMLInputElement, DateInputProps>((props, ref) => {
|
|
32
|
+
const {
|
|
33
|
+
className,
|
|
34
|
+
hideLabel = false,
|
|
35
|
+
label,
|
|
36
|
+
description,
|
|
37
|
+
variant = "datepicker",
|
|
38
|
+
...rest
|
|
39
|
+
} = props;
|
|
34
40
|
|
|
35
|
-
const
|
|
36
|
-
(props, ref) => {
|
|
37
|
-
const {
|
|
38
|
-
className,
|
|
39
|
-
hideLabel = false,
|
|
40
|
-
label,
|
|
41
|
-
description,
|
|
42
|
-
variant = "datepicker",
|
|
43
|
-
...rest
|
|
44
|
-
} = props;
|
|
41
|
+
const isDatepickerVariant = variant === "datepicker";
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
const conditionalVariables = {
|
|
44
|
+
prefix: isDatepickerVariant ? "datepicker-input" : "monthpicker-input",
|
|
45
|
+
iconTitle: {
|
|
46
|
+
open: isDatepickerVariant ? "Åpne datovelger" : "Åpne månedsvelger",
|
|
47
|
+
close: isDatepickerVariant ? "Lukk datovelger" : "Lukk månedsvelger",
|
|
48
|
+
},
|
|
49
|
+
};
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
prefix: isDatepickerVariant ? "datepicker-input" : "monthpicker-input",
|
|
50
|
-
iconTitle: {
|
|
51
|
-
open: isDatepickerVariant ? "Åpne datovelger" : "Åpne månedsvelger",
|
|
52
|
-
close: isDatepickerVariant ? "Lukk datovelger" : "Lukk månedsvelger",
|
|
53
|
-
},
|
|
54
|
-
};
|
|
51
|
+
const { onOpen, ariaId, open } = useDateInputContext();
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
const {
|
|
54
|
+
inputProps,
|
|
55
|
+
size = "medium",
|
|
56
|
+
inputDescriptionId,
|
|
57
|
+
errorId,
|
|
58
|
+
showErrorMsg,
|
|
59
|
+
hasError,
|
|
60
|
+
} = useFormField(props, conditionalVariables.prefix);
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
)}
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
className={cl(
|
|
65
|
+
className,
|
|
66
|
+
"navds-form-field",
|
|
67
|
+
`navds-form-field--${size}`,
|
|
68
|
+
"navds-date__field",
|
|
69
|
+
{
|
|
70
|
+
"navds-text-field--error": hasError,
|
|
71
|
+
"navds-date__field--error": hasError,
|
|
72
|
+
"navds-form-field--disabled": !!inputProps.disabled,
|
|
73
|
+
"navds-text-field--disabled": !!inputProps.disabled,
|
|
74
|
+
}
|
|
75
|
+
)}
|
|
76
|
+
>
|
|
77
|
+
<Label
|
|
78
|
+
htmlFor={inputProps.id}
|
|
79
|
+
size={size}
|
|
80
|
+
className={cl("navds-form-field__label", {
|
|
81
|
+
"navds-sr-only": hideLabel,
|
|
82
|
+
})}
|
|
81
83
|
>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
{label}
|
|
85
|
+
</Label>
|
|
86
|
+
{!!description && (
|
|
87
|
+
<BodyShort
|
|
88
|
+
as="div"
|
|
89
|
+
className={cl("navds-form-field__description", {
|
|
86
90
|
"navds-sr-only": hideLabel,
|
|
87
91
|
})}
|
|
92
|
+
id={inputDescriptionId}
|
|
93
|
+
size={size}
|
|
88
94
|
>
|
|
89
|
-
{
|
|
90
|
-
</
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
<input
|
|
105
|
-
ref={ref}
|
|
106
|
-
{...omit(rest, ["error", "errorId", "size"])}
|
|
107
|
-
{...inputProps}
|
|
108
|
-
autoComplete="off"
|
|
109
|
-
aria-controls={ariaId}
|
|
110
|
-
className={cl(
|
|
111
|
-
"navds-date__field-input",
|
|
112
|
-
"navds-text-field__input",
|
|
113
|
-
"navds-body-short",
|
|
114
|
-
`navds-body-${size}`
|
|
115
|
-
)}
|
|
116
|
-
size={14}
|
|
117
|
-
/>
|
|
118
|
-
<button
|
|
119
|
-
disabled={inputProps.disabled}
|
|
120
|
-
tabIndex={open ? -1 : 0}
|
|
121
|
-
onClick={() => onOpen()}
|
|
122
|
-
type="button"
|
|
123
|
-
className="navds-date__field-button"
|
|
124
|
-
>
|
|
125
|
-
<CalendarIcon
|
|
126
|
-
pointerEvents="none"
|
|
127
|
-
title={
|
|
128
|
-
open
|
|
129
|
-
? conditionalVariables.iconTitle.close
|
|
130
|
-
: conditionalVariables.iconTitle.open
|
|
131
|
-
}
|
|
132
|
-
/>
|
|
133
|
-
</button>
|
|
134
|
-
</div>
|
|
135
|
-
<div
|
|
136
|
-
className="navds-form-field__error"
|
|
137
|
-
id={errorId}
|
|
138
|
-
aria-relevant="additions removals"
|
|
139
|
-
aria-live="polite"
|
|
140
|
-
>
|
|
141
|
-
{showErrorMsg && (
|
|
142
|
-
<ErrorMessage size={size}>{props.error}</ErrorMessage>
|
|
95
|
+
{description}
|
|
96
|
+
</BodyShort>
|
|
97
|
+
)}
|
|
98
|
+
<div className="navds-date__field-wrapper">
|
|
99
|
+
<input
|
|
100
|
+
ref={ref}
|
|
101
|
+
{...omit(rest, ["error", "errorId", "size"])}
|
|
102
|
+
{...inputProps}
|
|
103
|
+
autoComplete="off"
|
|
104
|
+
aria-controls={ariaId}
|
|
105
|
+
className={cl(
|
|
106
|
+
"navds-date__field-input",
|
|
107
|
+
"navds-text-field__input",
|
|
108
|
+
"navds-body-short",
|
|
109
|
+
`navds-body-${size}`
|
|
143
110
|
)}
|
|
144
|
-
|
|
111
|
+
size={14}
|
|
112
|
+
/>
|
|
113
|
+
<button
|
|
114
|
+
disabled={inputProps.disabled}
|
|
115
|
+
tabIndex={open ? -1 : 0}
|
|
116
|
+
onClick={() => onOpen()}
|
|
117
|
+
type="button"
|
|
118
|
+
className="navds-date__field-button"
|
|
119
|
+
>
|
|
120
|
+
<CalendarIcon
|
|
121
|
+
pointerEvents="none"
|
|
122
|
+
title={
|
|
123
|
+
open
|
|
124
|
+
? conditionalVariables.iconTitle.close
|
|
125
|
+
: conditionalVariables.iconTitle.open
|
|
126
|
+
}
|
|
127
|
+
/>
|
|
128
|
+
</button>
|
|
145
129
|
</div>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
130
|
+
<div
|
|
131
|
+
className="navds-form-field__error"
|
|
132
|
+
id={errorId}
|
|
133
|
+
aria-relevant="additions removals"
|
|
134
|
+
aria-live="polite"
|
|
135
|
+
>
|
|
136
|
+
{showErrorMsg && <ErrorMessage size={size}>{props.error}</ErrorMessage>}
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
});
|
|
149
141
|
|
|
150
|
-
export const DatePickerInput
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
>((props, ref) => <DateInput {...props} ref={ref} />);
|
|
142
|
+
export const DatePickerInput = forwardRef<HTMLInputElement, DateInputProps>(
|
|
143
|
+
(props, ref) => <DateInput {...props} ref={ref} />
|
|
144
|
+
);
|
|
154
145
|
|
|
155
|
-
export const MonthPickerInput
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
>((props, ref) => <DateInput {...props} variant="monthpicker" ref={ref} />);
|
|
146
|
+
export const MonthPickerInput = forwardRef<HTMLInputElement, DateInputProps>(
|
|
147
|
+
(props, ref) => <DateInput {...props} variant="monthpicker" ref={ref} />
|
|
148
|
+
);
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
SelectSingleEventHandler,
|
|
13
13
|
} from "react-day-picker";
|
|
14
14
|
import { omit, Popover, useId } from "../..";
|
|
15
|
-
import {
|
|
15
|
+
import { DateInputProps, DatePickerInput } from "../DateInput";
|
|
16
16
|
import { DateContext } from "../context";
|
|
17
17
|
import { getLocaleFromString, labels } from "../utils";
|
|
18
18
|
import { Caption, DropdownCaption } from "./caption";
|
|
@@ -120,10 +120,48 @@ export type DatePickerProps = DatePickerDefaultProps & ConditionalModeProps;
|
|
|
120
120
|
|
|
121
121
|
interface DatePickerComponent
|
|
122
122
|
extends React.ForwardRefExoticComponent<DatePickerProps> {
|
|
123
|
+
/**
|
|
124
|
+
* @example
|
|
125
|
+
* ```jsx
|
|
126
|
+
* <DatePicker.Standalone
|
|
127
|
+
* dropdownCaption
|
|
128
|
+
* fromDate={new Date("2020-10-01")}
|
|
129
|
+
* toDate={new Date("2024-10-01")}
|
|
130
|
+
* />
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
123
133
|
Standalone: DatePickerStandaloneType;
|
|
124
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Custom TextField for DatePicker
|
|
136
|
+
* @see 🏷️ {@link DateInputProps}
|
|
137
|
+
*/
|
|
138
|
+
Input: React.ForwardRefExoticComponent<
|
|
139
|
+
DateInputProps & React.RefAttributes<HTMLInputElement>
|
|
140
|
+
>;
|
|
125
141
|
}
|
|
126
142
|
|
|
143
|
+
/**
|
|
144
|
+
* A component that allows users to select a date from a calendar.
|
|
145
|
+
*
|
|
146
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/datepicker)
|
|
147
|
+
* @see 🏷️ {@link DatePickerProps}
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```jsx
|
|
151
|
+
* const { inputProps, datepickerProps } = useMonthpicker({
|
|
152
|
+
* onMonthChange: console.log,
|
|
153
|
+
* });
|
|
154
|
+
*
|
|
155
|
+
* return (
|
|
156
|
+
* <DatePicker {...datepickerProps} dropdownCaption>
|
|
157
|
+
* <DatePicker.Input
|
|
158
|
+
* {...inputProps}
|
|
159
|
+
* label="Velg dato"
|
|
160
|
+
* />
|
|
161
|
+
* </DatePicker>
|
|
162
|
+
* );
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
127
165
|
export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
128
166
|
(
|
|
129
167
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
2
|
import React, { useId, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { useDatepicker, useRangeDatepicker } from "..";
|
|
4
4
|
import { Button } from "../..";
|
|
5
5
|
import DatePicker from "./DatePicker";
|
|
6
6
|
|
|
@@ -18,12 +18,12 @@ export const Default = {
|
|
|
18
18
|
render: (props) => {
|
|
19
19
|
const [open, setOpen] = useState(false);
|
|
20
20
|
|
|
21
|
-
const rangeCtx =
|
|
21
|
+
const rangeCtx = useRangeDatepicker({
|
|
22
22
|
fromDate: new Date("Aug 23 2020"),
|
|
23
23
|
toDate: new Date("Aug 23 2023"),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
const singleCtx =
|
|
26
|
+
const singleCtx = useDatepicker({
|
|
27
27
|
fromDate: new Date("Aug 23 2020"),
|
|
28
28
|
toDate: new Date("Aug 23 2023"),
|
|
29
29
|
});
|
|
@@ -147,7 +147,7 @@ export const ShowWeekNumber = () => (
|
|
|
147
147
|
);
|
|
148
148
|
|
|
149
149
|
export const UseDatepicker = () => {
|
|
150
|
-
const { datepickerProps, inputProps } =
|
|
150
|
+
const { datepickerProps, inputProps } = useDatepicker({
|
|
151
151
|
fromDate: new Date("Aug 23 2019"),
|
|
152
152
|
toDate: new Date("Feb 23 2024"),
|
|
153
153
|
onDateChange: console.log,
|
|
@@ -163,12 +163,11 @@ export const UseDatepicker = () => {
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
export const UseRangedDatepicker = () => {
|
|
166
|
-
const { datepickerProps, fromInputProps, toInputProps } =
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
166
|
+
const { datepickerProps, fromInputProps, toInputProps } = useRangeDatepicker({
|
|
167
|
+
fromDate: new Date("Aug 23 2019"),
|
|
168
|
+
onRangeChange: console.log,
|
|
169
|
+
onValidate: console.log,
|
|
170
|
+
});
|
|
172
171
|
|
|
173
172
|
return (
|
|
174
173
|
<div style={{ display: "flex", gap: "1rem" }}>
|
|
@@ -183,7 +182,7 @@ export const UseRangedDatepicker = () => {
|
|
|
183
182
|
};
|
|
184
183
|
|
|
185
184
|
export const OpenOnFocus = () => {
|
|
186
|
-
const { datepickerProps, inputProps } =
|
|
185
|
+
const { datepickerProps, inputProps } = useDatepicker({
|
|
187
186
|
onDateChange: console.log,
|
|
188
187
|
openOnFocus: false,
|
|
189
188
|
});
|
|
@@ -243,7 +242,7 @@ export const UserControlled = () => {
|
|
|
243
242
|
|
|
244
243
|
export const Validering = () => {
|
|
245
244
|
const [error, setError] = useState(false);
|
|
246
|
-
const { datepickerProps, inputProps } =
|
|
245
|
+
const { datepickerProps, inputProps } = useDatepicker({
|
|
247
246
|
fromDate: new Date("Aug 2 2019"),
|
|
248
247
|
onValidate: (val) => setError(val.isWeekend),
|
|
249
248
|
defaultSelected: new Date("Nov 26 2022"),
|
|
@@ -289,13 +288,12 @@ export const ErrorInput = () => {
|
|
|
289
288
|
};
|
|
290
289
|
|
|
291
290
|
export const UseRangedDatepickerValidation = () => {
|
|
292
|
-
const { datepickerProps, fromInputProps, toInputProps } =
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
});
|
|
291
|
+
const { datepickerProps, fromInputProps, toInputProps } = useRangeDatepicker({
|
|
292
|
+
fromDate: new Date("Aug 23 2019"),
|
|
293
|
+
disableWeekends: true,
|
|
294
|
+
disabled: [new Date("Oct 10 2022")],
|
|
295
|
+
onValidate: console.table,
|
|
296
|
+
});
|
|
299
297
|
|
|
300
298
|
return (
|
|
301
299
|
<div style={{ display: "flex", gap: "1rem" }}>
|
|
@@ -310,7 +308,7 @@ export const UseRangedDatepickerValidation = () => {
|
|
|
310
308
|
};
|
|
311
309
|
|
|
312
310
|
export const defaultShownMonth = () => {
|
|
313
|
-
const { datepickerProps, inputProps } =
|
|
311
|
+
const { datepickerProps, inputProps } = useDatepicker({
|
|
314
312
|
fromDate: new Date("Aug 23 2019"),
|
|
315
313
|
onDateChange: console.log,
|
|
316
314
|
defaultMonth: new Date("Oct 23 2022"),
|
|
@@ -326,7 +324,7 @@ export const defaultShownMonth = () => {
|
|
|
326
324
|
};
|
|
327
325
|
|
|
328
326
|
export const Size = () => {
|
|
329
|
-
const { datepickerProps, inputProps } =
|
|
327
|
+
const { datepickerProps, inputProps } = useDatepicker({
|
|
330
328
|
fromDate: new Date("Aug 23 2019"),
|
|
331
329
|
toDate: new Date("Feb 23 2024"),
|
|
332
330
|
onDateChange: console.log,
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import { act, render } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { DatePicker, useDatepicker } from "..";
|
|
6
6
|
|
|
7
7
|
const App = () => {
|
|
8
|
-
const { datepickerProps, inputProps } =
|
|
8
|
+
const { datepickerProps, inputProps } = useDatepicker({
|
|
9
9
|
fromDate: new Date("Aug 23 2019"),
|
|
10
10
|
onDateChange: console.log,
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
</
|
|
14
|
+
<DatePicker {...datepickerProps}>
|
|
15
|
+
<DatePicker.Input {...inputProps} label="Velg dato" />
|
|
16
|
+
</DatePicker>
|
|
17
17
|
);
|
|
18
18
|
};
|
|
19
19
|
|
package/src/date/hooks/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { useDatepicker
|
|
1
|
+
export { useDatepicker } from "./useDatepicker";
|
|
2
2
|
export type { DateValidationT } from "./useDatepicker";
|
|
3
|
-
export { useRangeDatepicker
|
|
3
|
+
export { useRangeDatepicker } from "./useRangeDatepicker";
|
|
4
4
|
export type { RangeValidationT } from "./useRangeDatepicker";
|
|
5
|
-
export { useMonthpicker
|
|
5
|
+
export { useMonthpicker } from "./useMonthPicker";
|
|
6
6
|
export type { MonthValidationT } from "./useMonthPicker";
|
|
@@ -113,6 +113,19 @@ const getValidationMessage = (val = {}): DateValidationT => ({
|
|
|
113
113
|
...val,
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @see 🏷️ {@link UseDatepickerOptions}
|
|
119
|
+
* @see 🏷️ {@link UseDatepickerValue}
|
|
120
|
+
* @see 🏷️ {@link DateValidationT}
|
|
121
|
+
* @example
|
|
122
|
+
* const { datepickerProps, inputProps } = useDatepicker({
|
|
123
|
+
* fromDate: new Date("Aug 23 2019"),
|
|
124
|
+
* toDate: new Date("Feb 23 2024"),
|
|
125
|
+
* onDateChange: console.log,
|
|
126
|
+
* onValidate: console.log,
|
|
127
|
+
* });
|
|
128
|
+
*/
|
|
116
129
|
export const useDatepicker = (
|
|
117
130
|
opt: UseDatepickerOptions = {}
|
|
118
131
|
): UseDatepickerValue => {
|
|
@@ -110,6 +110,19 @@ const getIsAfter = (opt: { toDate?: Date; date?: Date }) =>
|
|
|
110
110
|
(opt.toDate.getFullYear() === opt.date.getFullYear() &&
|
|
111
111
|
opt.toDate.getMonth() < opt.date.getMonth()));
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
*
|
|
115
|
+
* @see 🏷️ {@link UseMonthPickerOptions}
|
|
116
|
+
* @see 🏷️ {@link UseMonthPickerValue}
|
|
117
|
+
* @see 🏷️ {@link MonthValidationT}
|
|
118
|
+
* @example
|
|
119
|
+
* const { monthpickerProps, inputProps } = useMonthpicker({
|
|
120
|
+
* fromDate: new Date("Aug 23 2019"),
|
|
121
|
+
* toDate: new Date("Feb 23 2024"),
|
|
122
|
+
* onMonthChange: console.log,
|
|
123
|
+
* onValidate: console.log,
|
|
124
|
+
* });
|
|
125
|
+
*/
|
|
113
126
|
export const useMonthpicker = (
|
|
114
127
|
opt: UseMonthPickerOptions = {}
|
|
115
128
|
): UseMonthPickerValue => {
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
import { act, render } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { DatePicker, useRangeDatepicker } from "..";
|
|
6
6
|
|
|
7
7
|
const RangeDemo = () => {
|
|
8
8
|
const { datepickerProps, fromInputProps, selectedRange, toInputProps } =
|
|
9
|
-
|
|
9
|
+
useRangeDatepicker({
|
|
10
10
|
fromDate: new Date("Aug 23 2019"),
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<div style={{ display: "flex", gap: "1rem" }}>
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
<
|
|
18
|
-
</
|
|
15
|
+
<DatePicker {...datepickerProps}>
|
|
16
|
+
<DatePicker.Input {...fromInputProps} label="Fra" />
|
|
17
|
+
<DatePicker.Input {...toInputProps} label="Til" />
|
|
18
|
+
</DatePicker>
|
|
19
19
|
<div title="res">{JSON.stringify(selectedRange)}</div>
|
|
20
20
|
</div>
|
|
21
21
|
);
|
|
@@ -102,7 +102,7 @@ const RANGE = {
|
|
|
102
102
|
TO: "TO",
|
|
103
103
|
} as const;
|
|
104
104
|
|
|
105
|
-
type RangeT = typeof RANGE[keyof typeof RANGE];
|
|
105
|
+
type RangeT = (typeof RANGE)[keyof typeof RANGE];
|
|
106
106
|
|
|
107
107
|
const fromValidation = (day: Date, opt?: UseRangeDatepickerOptions) => {
|
|
108
108
|
const isBefore =
|
|
@@ -190,6 +190,18 @@ const initialValidation = (
|
|
|
190
190
|
return getValidationMessage({ ...fromVal }, { ...toVal });
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
*
|
|
195
|
+
* @see 🏷️ {@link UseRangeDatepickerOptions}
|
|
196
|
+
* @see 🏷️ {@link UseRangeDatepickerValue}
|
|
197
|
+
* @see 🏷️ {@link RangeValidationT}
|
|
198
|
+
* @example
|
|
199
|
+
* const { datepickerProps, fromInputProps, toInputProps } = useRangeDatepicker({
|
|
200
|
+
* fromDate: new Date("Aug 23 2019"),
|
|
201
|
+
* onRangeChange: console.log,
|
|
202
|
+
* onValidate: console.log,
|
|
203
|
+
* });
|
|
204
|
+
*/
|
|
193
205
|
export const useRangeDatepicker = (
|
|
194
206
|
opt: UseRangeDatepickerOptions = {}
|
|
195
207
|
): UseRangeDatepickerValue => {
|
package/src/date/index.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
export { type DateInputProps } from "./DateInput";
|
|
2
2
|
export {
|
|
3
3
|
type DatePickerProps,
|
|
4
|
-
default as
|
|
4
|
+
default as DatePicker,
|
|
5
5
|
} from "./datepicker/DatePicker";
|
|
6
6
|
export { type DatePickerStandaloneProps } from "./datepicker/DatePickerStandalone";
|
|
7
7
|
export { type MonthPickerStandaloneProps } from "./monthpicker/MonthPickerStandalone";
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
useDatepicker,
|
|
10
|
+
useMonthpicker,
|
|
11
|
+
useRangeDatepicker,
|
|
12
12
|
type RangeValidationT,
|
|
13
13
|
type DateValidationT,
|
|
14
14
|
type MonthValidationT,
|
|
15
15
|
} from "./hooks";
|
|
16
16
|
export {
|
|
17
|
-
default as
|
|
17
|
+
default as MonthPicker,
|
|
18
18
|
type MonthPickerProps,
|
|
19
19
|
} from "./monthpicker/MonthPicker";
|
|
@@ -2,7 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import React, { forwardRef, useRef, useState } from "react";
|
|
3
3
|
import { RootProvider } from "react-day-picker";
|
|
4
4
|
import { Popover, useId } from "../..";
|
|
5
|
-
import {
|
|
5
|
+
import { DateInputProps, MonthPickerInput } from "../DateInput";
|
|
6
6
|
import { DateContext, SharedMonthProvider } from "../context";
|
|
7
7
|
import { getLocaleFromString, Matcher } from "../utils";
|
|
8
8
|
import MonthCaption from "./MonthCaption";
|
|
@@ -91,15 +91,47 @@ export interface MonthPickerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
91
91
|
interface MonthPickerComponent
|
|
92
92
|
extends React.ForwardRefExoticComponent<MonthPickerProps> {
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```jsx
|
|
96
|
+
* <MonthPicker.Standalone
|
|
97
|
+
* dropdownCaption
|
|
98
|
+
* fromDate={new Date("1 Oct 2020")}
|
|
99
|
+
* toDate={new Date("1 Oct 2024")}
|
|
100
|
+
* />
|
|
101
|
+
* ```
|
|
95
102
|
*/
|
|
96
103
|
Standalone: MonthPickerStandaloneType;
|
|
97
104
|
/**
|
|
98
|
-
*
|
|
105
|
+
* Custom TextField for MonthPicker
|
|
106
|
+
* @see 🏷️ {@link DateInputProps}
|
|
99
107
|
*/
|
|
100
|
-
Input:
|
|
108
|
+
Input: React.ForwardRefExoticComponent<
|
|
109
|
+
DateInputProps & React.RefAttributes<HTMLInputElement>
|
|
110
|
+
>;
|
|
101
111
|
}
|
|
102
112
|
|
|
113
|
+
/**
|
|
114
|
+
* A component that displays a month picker.
|
|
115
|
+
*
|
|
116
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/monthpicker)
|
|
117
|
+
* @see 🏷️ {@link MonthPickerProps}
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```jsx
|
|
121
|
+
* const { inputProps, monthpickerProps } = useMonthpicker({
|
|
122
|
+
* onMonthChange: console.log,
|
|
123
|
+
* });
|
|
124
|
+
*
|
|
125
|
+
* return (
|
|
126
|
+
* <MonthPicker {...monthpickerProps} dropdownCaption>
|
|
127
|
+
* <MonthPicker.Input
|
|
128
|
+
* {...inputProps}
|
|
129
|
+
* label="Velg måned"
|
|
130
|
+
* />
|
|
131
|
+
* </MonthPicker>
|
|
132
|
+
* );
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
103
135
|
export const MonthPicker = forwardRef<HTMLDivElement, MonthPickerProps>(
|
|
104
136
|
(
|
|
105
137
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useId, useState } from "react";
|
|
2
2
|
import { Button } from "../..";
|
|
3
|
-
import {
|
|
3
|
+
import { useMonthpicker } from "../hooks";
|
|
4
4
|
import MonthPicker from "./MonthPicker";
|
|
5
5
|
|
|
6
6
|
export default {
|
|
@@ -23,7 +23,7 @@ export default {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export const Default = () => {
|
|
26
|
-
const { inputProps, monthpickerProps } =
|
|
26
|
+
const { inputProps, monthpickerProps } = useMonthpicker({
|
|
27
27
|
disabled: [new Date("Apr 1 2022")],
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -74,7 +74,7 @@ export const Standalone = () => {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
export const UseMonthpicker = () => {
|
|
77
|
-
const { inputProps, monthpickerProps } =
|
|
77
|
+
const { inputProps, monthpickerProps } = useMonthpicker({
|
|
78
78
|
disabled: [new Date("Apr 1 2022")],
|
|
79
79
|
onMonthChange: console.log,
|
|
80
80
|
fromDate: new Date("Jan 1 2022"),
|
|
@@ -95,7 +95,7 @@ export const UseMonthpicker = () => {
|
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
export const UseMonthpickerFormat = () => {
|
|
98
|
-
const { inputProps, monthpickerProps } =
|
|
98
|
+
const { inputProps, monthpickerProps } = useMonthpicker({
|
|
99
99
|
disabled: [new Date("Apr 1 2022")],
|
|
100
100
|
onMonthChange: console.log,
|
|
101
101
|
inputFormat: "MM.yyyy",
|
|
@@ -115,7 +115,7 @@ export const UseMonthpickerFormat = () => {
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
export const Required = () => {
|
|
118
|
-
const { inputProps, monthpickerProps } =
|
|
118
|
+
const { inputProps, monthpickerProps } = useMonthpicker({
|
|
119
119
|
locale: "nb",
|
|
120
120
|
defaultSelected: new Date(),
|
|
121
121
|
disabled: [new Date("Apr 1 2022")],
|