@navikt/ds-react 5.5.0 → 5.6.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 +507 -106
- package/cjs/accordion/Accordion.js +1 -0
- package/cjs/accordion/AccordionContext.js +1 -1
- package/cjs/accordion/AccordionHeader.js +2 -2
- package/cjs/accordion/AccordionItem.js +6 -2
- package/cjs/date/datepicker/DatePicker.js +30 -34
- package/cjs/date/datepicker/DatePickerStandalone.js +23 -26
- package/cjs/date/datepicker/parts/Caption.js +28 -0
- package/cjs/date/datepicker/{DayButton.js → parts/DayButton.js} +1 -2
- package/cjs/date/datepicker/{caption → parts}/DropdownCaption.js +13 -7
- package/cjs/date/datepicker/parts/HeadRow.js +36 -0
- package/cjs/date/datepicker/parts/Row.js +23 -0
- package/cjs/date/datepicker/{TableHead.js → parts/TableHead.js} +4 -3
- package/cjs/date/datepicker/parts/WeekNumber.js +35 -0
- package/cjs/date/datepicker/parts/WeekRow.js +34 -0
- package/cjs/date/hooks/useDatepicker.js +2 -2
- package/cjs/date/hooks/useMonthPicker.js +2 -2
- package/cjs/date/hooks/useRangeDatepicker.js +3 -3
- package/cjs/date/monthpicker/MonthSelector.js +1 -1
- package/cjs/date/utils/get-month-weeks.js +46 -0
- package/cjs/date/utils/labels.js +40 -1
- package/cjs/dropdown/Toggle.js +2 -2
- package/cjs/dropdown/index.js +0 -15
- package/cjs/form/Select.js +1 -1
- package/cjs/form/checkbox/useCheckbox.js +3 -4
- package/cjs/form/combobox/Combobox.js +1 -1
- package/cjs/form/combobox/Input/Input.js +1 -1
- package/cjs/form/search/Search.js +3 -1
- package/cjs/index.js +1 -0
- package/cjs/layout/bleed/Bleed.js +69 -0
- package/cjs/layout/bleed/index.js +5 -0
- package/cjs/layout/bleed/package.json +6 -0
- package/cjs/layout/box/Box.js +1 -1
- package/cjs/layout/responsive/Responsive.js +8 -6
- package/cjs/layout/sidemal-test/AvatarPanel.js +18 -0
- package/cjs/layout/sidemal-test/Content.js +66 -0
- package/cjs/layout/sidemal-test/Filter.js +48 -0
- package/cjs/layout/sidemal-test/Header.js +48 -0
- package/cjs/layout/sidemal-test/Intro.js +36 -0
- package/cjs/layout/sidemal-test/Sidebar.js +49 -0
- package/cjs/layout/sidemal-test/content-box/ContentBox.js +65 -0
- package/cjs/layout/sidemal-test/content-box/index.js +8 -0
- package/cjs/layout/sidemal-test/content-box/package.json +6 -0
- package/cjs/layout/stack/Stack.js +2 -2
- package/cjs/layout/stack/index.js +3 -1
- package/cjs/layout/utilities/css.js +37 -14
- package/cjs/loader/Loader.js +2 -2
- package/cjs/modal/dialog-polyfill.js +2 -0
- package/cjs/popover/Popover.js +3 -2
- package/cjs/tabs/TabList.js +6 -7
- package/cjs/timeline/Pin.js +20 -20
- package/cjs/timeline/Timeline.js +4 -4
- package/cjs/timeline/period/ClickablePeriod.js +19 -19
- package/cjs/timeline/period/index.js +1 -1
- package/cjs/timeline/utils/timeline.js +3 -3
- package/cjs/toggle-group/ToggleGroup.js +1 -1
- package/cjs/tooltip/Tooltip.js +1 -1
- package/cjs/typography/Heading.js +1 -1
- package/cjs/util/RandomIcon.js +1 -0
- package/cjs/util/Slot.js +88 -0
- package/cjs/util/useId.js +2 -4
- package/esm/accordion/Accordion.js +1 -0
- package/esm/accordion/Accordion.js.map +1 -1
- package/esm/accordion/AccordionContext.d.ts +1 -0
- package/esm/accordion/AccordionContext.js +1 -1
- package/esm/accordion/AccordionContext.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +2 -2
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/AccordionItem.js +6 -2
- package/esm/accordion/AccordionItem.js.map +1 -1
- package/esm/date/datepicker/DatePicker.d.ts +14 -5
- package/esm/date/datepicker/DatePicker.js +29 -33
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.d.ts +3 -2
- package/esm/date/datepicker/DatePickerStandalone.js +22 -25
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/esm/date/datepicker/{caption → parts}/Caption.d.ts +3 -0
- package/esm/date/datepicker/parts/Caption.js +22 -0
- package/esm/date/datepicker/parts/Caption.js.map +1 -0
- package/esm/date/datepicker/parts/DayButton.d.ts +4 -0
- package/esm/date/datepicker/{DayButton.js → parts/DayButton.js} +2 -1
- package/esm/date/datepicker/parts/DayButton.js.map +1 -0
- package/esm/date/datepicker/{caption → parts}/DropdownCaption.d.ts +3 -0
- package/esm/date/datepicker/parts/DropdownCaption.js +44 -0
- package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -0
- package/esm/date/datepicker/parts/HeadRow.d.ts +11 -0
- package/esm/date/datepicker/parts/HeadRow.js +29 -0
- package/esm/date/datepicker/parts/HeadRow.js.map +1 -0
- package/esm/date/datepicker/parts/Row.d.ts +17 -0
- package/esm/date/datepicker/parts/Row.js +19 -0
- package/esm/date/datepicker/parts/Row.js.map +1 -0
- package/esm/date/datepicker/parts/TableHead.d.ts +6 -0
- package/esm/date/datepicker/{TableHead.js → parts/TableHead.js} +5 -2
- package/esm/date/datepicker/parts/TableHead.js.map +1 -0
- package/esm/date/datepicker/parts/WeekNumber.d.ts +13 -0
- package/esm/date/datepicker/parts/WeekNumber.js +31 -0
- package/esm/date/datepicker/parts/WeekNumber.js.map +1 -0
- package/esm/date/datepicker/parts/WeekRow.d.ts +5 -0
- package/esm/date/datepicker/parts/WeekRow.js +30 -0
- package/esm/date/datepicker/parts/WeekRow.js.map +1 -0
- package/esm/date/hooks/useDatepicker.js +2 -2
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.js +2 -2
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/hooks/useRangeDatepicker.js +3 -3
- package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/monthpicker/MonthButton.d.ts +2 -2
- package/esm/date/monthpicker/MonthPicker.d.ts +1 -1
- package/esm/date/monthpicker/MonthSelector.js +1 -1
- package/esm/date/monthpicker/MonthSelector.js.map +1 -1
- package/esm/date/utils/get-month-weeks.d.ts +16 -0
- package/esm/date/utils/get-month-weeks.js +42 -0
- package/esm/date/utils/get-month-weeks.js.map +1 -0
- package/esm/date/utils/labels.d.ts +9 -0
- package/esm/date/utils/labels.js +36 -0
- package/esm/date/utils/labels.js.map +1 -1
- package/esm/date/utils/navigation.d.ts +1 -1
- package/esm/date/utils/navigation.js.map +1 -1
- package/esm/dropdown/Toggle.js +1 -1
- package/esm/dropdown/Toggle.js.map +1 -1
- package/esm/dropdown/index.d.ts +1 -2
- package/esm/dropdown/index.js +0 -1
- package/esm/dropdown/index.js.map +1 -1
- package/esm/form/Select.js +1 -1
- package/esm/form/Select.js.map +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +1 -1
- package/esm/form/checkbox/useCheckbox.js +3 -4
- package/esm/form/checkbox/useCheckbox.js.map +1 -1
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/Combobox.js +1 -1
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/Input/Input.d.ts +0 -2
- package/esm/form/combobox/Input/Input.js +1 -1
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/search/Search.js +3 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/layout/bleed/Bleed.d.ts +47 -0
- package/esm/layout/bleed/Bleed.js +41 -0
- package/esm/layout/bleed/Bleed.js.map +1 -0
- package/esm/layout/bleed/index.d.ts +1 -0
- package/esm/layout/bleed/index.js +2 -0
- package/esm/layout/bleed/index.js.map +1 -0
- package/esm/layout/box/Box.d.ts +1 -2
- package/esm/layout/box/Box.js +1 -1
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/responsive/Responsive.d.ts +8 -4
- package/esm/layout/responsive/Responsive.js +8 -6
- package/esm/layout/responsive/Responsive.js.map +1 -1
- package/esm/layout/sidemal-test/AvatarPanel.d.ts +4 -0
- package/esm/layout/sidemal-test/AvatarPanel.js +12 -0
- package/esm/layout/sidemal-test/AvatarPanel.js.map +1 -0
- package/esm/layout/sidemal-test/Content.d.ts +2 -0
- package/esm/layout/sidemal-test/Content.js +60 -0
- package/esm/layout/sidemal-test/Content.js.map +1 -0
- package/esm/layout/sidemal-test/Filter.d.ts +2 -0
- package/esm/layout/sidemal-test/Filter.js +22 -0
- package/esm/layout/sidemal-test/Filter.js.map +1 -0
- package/esm/layout/sidemal-test/Header.d.ts +2 -0
- package/esm/layout/sidemal-test/Header.js +42 -0
- package/esm/layout/sidemal-test/Header.js.map +1 -0
- package/esm/layout/sidemal-test/Intro.d.ts +2 -0
- package/esm/layout/sidemal-test/Intro.js +30 -0
- package/esm/layout/sidemal-test/Intro.js.map +1 -0
- package/esm/layout/sidemal-test/Sidebar.d.ts +4 -0
- package/esm/layout/sidemal-test/Sidebar.js +41 -0
- package/esm/layout/sidemal-test/Sidebar.js.map +1 -0
- package/esm/layout/sidemal-test/content-box/ContentBox.d.ts +8 -0
- package/esm/layout/sidemal-test/content-box/ContentBox.js +37 -0
- package/esm/layout/sidemal-test/content-box/ContentBox.js.map +1 -0
- package/esm/layout/sidemal-test/content-box/index.d.ts +1 -0
- package/esm/layout/sidemal-test/content-box/index.js +2 -0
- package/esm/layout/sidemal-test/content-box/index.js.map +1 -0
- package/esm/layout/stack/Stack.d.ts +7 -3
- package/esm/layout/stack/Stack.js +3 -3
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/layout/stack/index.d.ts +1 -0
- package/esm/layout/stack/index.js +1 -0
- package/esm/layout/stack/index.js.map +1 -1
- package/esm/layout/utilities/css.d.ts +1 -1
- package/esm/layout/utilities/css.js +37 -14
- package/esm/layout/utilities/css.js.map +1 -1
- package/esm/loader/Loader.js +3 -3
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/dialog-polyfill.js +2 -0
- package/esm/modal/dialog-polyfill.js.map +1 -1
- package/esm/popover/Popover.js +3 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/tabs/TabList.js +6 -7
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/timeline/Pin.js +21 -21
- package/esm/timeline/Pin.js.map +1 -1
- package/esm/timeline/Timeline.js +4 -4
- package/esm/timeline/Timeline.js.map +1 -1
- package/esm/timeline/TimelineRow.js.map +1 -1
- package/esm/timeline/hooks/usePeriodContext.d.ts +1 -1
- package/esm/timeline/period/ClickablePeriod.js +20 -20
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/timeline/period/index.d.ts +2 -2
- package/esm/timeline/period/index.js +1 -1
- package/esm/timeline/period/index.js.map +1 -1
- package/esm/timeline/utils/timeline.js +3 -3
- package/esm/timeline/utils/timeline.js.map +1 -1
- package/esm/toggle-group/ToggleGroup.js +1 -1
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/tooltip/Tooltip.js +1 -1
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/Heading.js +1 -1
- package/esm/typography/Heading.js.map +1 -1
- package/esm/util/RandomIcon.js +1 -0
- package/esm/util/RandomIcon.js.map +1 -1
- package/esm/util/Slot.d.ts +6 -0
- package/esm/util/Slot.js +60 -0
- package/esm/util/Slot.js.map +1 -0
- package/esm/util/mergeRefs.d.ts +1 -1
- package/esm/util/useId.js +2 -4
- package/esm/util/useId.js.map +1 -1
- package/package.json +4 -4
- package/src/accordion/Accordion.tsx +1 -0
- package/src/accordion/AccordionContext.tsx +2 -1
- package/src/accordion/AccordionHeader.tsx +2 -2
- package/src/accordion/AccordionItem.tsx +7 -5
- package/src/accordion/accordion.stories.tsx +21 -34
- package/src/alert/alert.stories.tsx +2 -2
- package/src/chips/chips.stories.tsx +29 -32
- package/src/date/datepicker/DatePicker.tsx +63 -58
- package/src/date/datepicker/DatePickerStandalone.tsx +36 -39
- package/src/date/datepicker/datepicker.stories.tsx +67 -2
- package/src/date/datepicker/datepicker.test.tsx +5 -4
- package/src/date/datepicker/{caption → parts}/Caption.tsx +19 -17
- package/src/date/datepicker/{DayButton.tsx → parts/DayButton.tsx} +3 -1
- package/src/date/datepicker/parts/DropdownCaption.tsx +113 -0
- package/src/date/datepicker/parts/HeadRow.tsx +56 -0
- package/src/date/datepicker/parts/Row.tsx +47 -0
- package/src/date/datepicker/{TableHead.tsx → parts/TableHead.tsx} +6 -2
- package/src/date/datepicker/parts/WeekNumber.tsx +79 -0
- package/src/date/datepicker/parts/WeekRow.tsx +60 -0
- package/src/date/hooks/useDatepicker.tsx +2 -2
- package/src/date/hooks/useMonthPicker.tsx +2 -2
- package/src/date/hooks/useRangeDatepicker.test.tsx +11 -11
- package/src/date/hooks/useRangeDatepicker.tsx +3 -3
- package/src/date/monthpicker/MonthButton.tsx +2 -2
- package/src/date/monthpicker/MonthPicker.tsx +1 -1
- package/src/date/monthpicker/MonthSelector.tsx +3 -3
- package/src/date/monthpicker/monthpicker.stories.tsx +1 -1
- package/src/date/utils/__tests__/get-initial-year.test.ts +0 -12
- package/src/date/utils/__tests__/get-month-weeks.test.ts +113 -0
- package/src/date/utils/__tests__/is-match.test.ts +3 -3
- package/src/date/utils/__tests__/parse-dates.test.ts +4 -2
- package/src/date/utils/get-month-weeks.ts +93 -0
- package/src/date/utils/labels.ts +51 -0
- package/src/date/utils/navigation.ts +3 -3
- package/src/dropdown/Toggle.tsx +1 -1
- package/src/dropdown/dropdown.stories.tsx +25 -28
- package/src/dropdown/index.ts +1 -2
- package/src/expansion-card/expansion-card.stories.tsx +143 -161
- package/src/form/ConfirmationPanel.test.tsx +5 -5
- package/src/form/Select.tsx +1 -1
- package/src/form/checkbox/Checkbox.test.tsx +14 -26
- package/src/form/checkbox/checkbox.stories.tsx +66 -71
- package/src/form/checkbox/useCheckbox.ts +3 -4
- package/src/form/combobox/Combobox.tsx +2 -3
- package/src/form/combobox/Input/Input.tsx +1 -3
- package/src/form/combobox/combobox.stories.tsx +20 -23
- package/src/form/combobox/combobox.test.tsx +22 -20
- package/src/form/radio/radio.stories.tsx +39 -44
- package/src/form/search/Search.tsx +1 -0
- package/src/form/search/search.stories.tsx +22 -26
- package/src/form/stories/fieldset.stories.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/layout/bleed/Bleed.stories.tsx +381 -0
- package/src/layout/bleed/Bleed.tsx +130 -0
- package/src/layout/bleed/index.ts +1 -0
- package/src/layout/box/Box.stories.tsx +251 -256
- package/src/layout/box/Box.tsx +2 -1
- package/src/layout/responsive/Responsive.tsx +21 -6
- package/src/layout/responsive/hide.stories.tsx +35 -0
- package/src/layout/responsive/show.stories.tsx +35 -0
- package/src/layout/sidemal-test/AvatarPanel.tsx +27 -0
- package/src/layout/sidemal-test/Content.tsx +129 -0
- package/src/layout/sidemal-test/Filter.tsx +46 -0
- package/src/layout/sidemal-test/Header.tsx +96 -0
- package/src/layout/sidemal-test/Intro.tsx +91 -0
- package/src/layout/sidemal-test/Sidebar.tsx +77 -0
- package/src/layout/sidemal-test/content-box/ContentBox.tsx +46 -0
- package/src/layout/sidemal-test/content-box/index.ts +1 -0
- package/src/layout/sidemal-test/navno-sidemal.stories.mdx +29 -0
- package/src/layout/sidemal-test/navno-sidemal.stories.tsx +65 -0
- package/src/layout/sidemal-test/styling.css +43 -0
- package/src/layout/stack/Stack.tsx +14 -8
- package/src/layout/stack/index.ts +1 -0
- package/src/layout/stack/stack.stories.tsx +23 -1
- package/src/layout/utilities/css.ts +59 -20
- package/src/loader/Loader.tsx +2 -3
- package/src/modal/dialog-polyfill.ts +2 -0
- package/src/pagination/pagination.stories.tsx +35 -42
- package/src/popover/Popover.test.tsx +21 -35
- package/src/popover/Popover.tsx +2 -2
- package/src/popover/popover.stories.tsx +25 -41
- package/src/react-css.d.ts +0 -1
- package/src/read-more/readmore.stories.tsx +35 -36
- package/src/stepper/stepper.stories.tsx +45 -52
- package/src/table/stories/table-expandable.stories.tsx +59 -63
- package/src/tabs/TabList.tsx +4 -6
- package/src/tabs/Tabs.stories.tsx +3 -3
- package/src/tag/tag.stories.tsx +4 -4
- package/src/timeline/Pin.tsx +44 -39
- package/src/timeline/Timeline.tsx +6 -6
- package/src/timeline/TimelineRow.tsx +1 -0
- package/src/timeline/hooks/usePeriodContext.tsx +1 -1
- package/src/timeline/period/ClickablePeriod.tsx +42 -38
- package/src/timeline/period/index.tsx +5 -4
- package/src/timeline/timeline.stories.tsx +11 -10
- package/src/timeline/utils/timeline.ts +3 -3
- package/src/toggle-group/ToggleGroup.stories.tsx +25 -29
- package/src/toggle-group/ToggleGroup.tsx +0 -1
- package/src/tooltip/Tooltip.test.tsx +40 -54
- package/src/tooltip/Tooltip.tsx +1 -1
- package/src/typography/Heading.tsx +1 -1
- package/src/util/RandomIcon.tsx +1 -0
- package/src/util/Slot.tsx +69 -0
- package/src/util/__tests__/Slot.test.tsx +98 -0
- package/src/util/mergeRefs.tsx +1 -1
- package/src/util/useId.ts +1 -3
- package/cjs/date/datepicker/caption/Caption.js +0 -23
- package/cjs/date/datepicker/caption/index.js +0 -10
- package/cjs/date/datepicker/caption/package.json +0 -6
- package/esm/date/datepicker/DayButton.d.ts +0 -3
- package/esm/date/datepicker/DayButton.js.map +0 -1
- package/esm/date/datepicker/TableHead.d.ts +0 -3
- package/esm/date/datepicker/TableHead.js.map +0 -1
- package/esm/date/datepicker/caption/Caption.js +0 -17
- package/esm/date/datepicker/caption/Caption.js.map +0 -1
- package/esm/date/datepicker/caption/DropdownCaption.js +0 -38
- package/esm/date/datepicker/caption/DropdownCaption.js.map +0 -1
- package/esm/date/datepicker/caption/index.d.ts +0 -2
- package/esm/date/datepicker/caption/index.js +0 -3
- package/esm/date/datepicker/caption/index.js.map +0 -1
- package/src/date/datepicker/caption/DropdownCaption.tsx +0 -108
- package/src/date/datepicker/caption/index.ts +0 -2
|
@@ -70,6 +70,7 @@ exports.Accordion = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
70
70
|
variant,
|
|
71
71
|
headingSize,
|
|
72
72
|
size,
|
|
73
|
+
mounted: true,
|
|
73
74
|
} },
|
|
74
75
|
react_1.default.createElement("div", Object.assign({}, rest, { className: (0, clsx_1.default)("navds-accordion", className, `navds-accordion--${size}`, { "navds-accordion--indent": indent }), ref: ref }))));
|
|
75
76
|
});
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AccordionContext = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
exports.AccordionContext = (0, react_1.createContext)({
|
|
6
|
-
variant: "default",
|
|
7
6
|
headingSize: "small",
|
|
8
7
|
size: "medium",
|
|
9
8
|
openItems: [],
|
|
9
|
+
mounted: false,
|
|
10
10
|
});
|
|
@@ -48,7 +48,7 @@ const AccordionHeader = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
48
48
|
var { children, className, onClick } = _a, rest = __rest(_a, ["children", "className", "onClick"]);
|
|
49
49
|
const itemContext = (0, react_1.useContext)(AccordionItem_1.AccordionItemContext);
|
|
50
50
|
const accordionContext = (0, react_1.useContext)(AccordionContext_1.AccordionContext);
|
|
51
|
-
if (
|
|
51
|
+
if (itemContext === null) {
|
|
52
52
|
console.error("<Accordion.Header> has to be used within an <Accordion.Item>, which in turn must be within an <Accordion>");
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
@@ -58,6 +58,6 @@ const AccordionHeader = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
58
58
|
}, "aria-expanded": itemContext.open, type: "button" }),
|
|
59
59
|
react_1.default.createElement("div", { className: "navds-accordion__icon-wrapper" },
|
|
60
60
|
react_1.default.createElement(aksel_icons_1.ChevronDownIcon, { className: "navds-accordion__header-chevron", title: "Vis mer", "aria-hidden": true })),
|
|
61
|
-
react_1.default.createElement(Heading_1.Heading, { size: (_b = accordionContext.headingSize) !== null && _b !== void 0 ? _b : "small", as: "span", className: "navds-accordion__header-content" }, children)));
|
|
61
|
+
react_1.default.createElement(Heading_1.Heading, { size: (_b = accordionContext === null || accordionContext === void 0 ? void 0 : accordionContext.headingSize) !== null && _b !== void 0 ? _b : "small", as: "span", className: "navds-accordion__header-content" }, children)));
|
|
62
62
|
});
|
|
63
63
|
exports.default = AccordionHeader;
|
|
@@ -41,9 +41,10 @@ exports.AccordionItemContext = void 0;
|
|
|
41
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const AccordionContext_1 = require("./AccordionContext");
|
|
44
|
+
const util_1 = require("../util");
|
|
44
45
|
exports.AccordionItemContext = (0, react_1.createContext)(null);
|
|
45
46
|
const AccordionItem = (0, react_1.forwardRef)((_a, ref) => {
|
|
46
|
-
var { children, className, open, defaultOpen = false
|
|
47
|
+
var { children, className, open, defaultOpen = false } = _a, rest = __rest(_a, ["children", "className", "open", "defaultOpen"]);
|
|
47
48
|
const [internalOpen, setInternalOpen] = (0, react_1.useState)(defaultOpen);
|
|
48
49
|
const context = (0, react_1.useContext)(AccordionContext_1.AccordionContext);
|
|
49
50
|
const [_open, _setOpen] = (0, react_1.useState)(defaultOpen);
|
|
@@ -59,11 +60,14 @@ const AccordionItem = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
59
60
|
}
|
|
60
61
|
shouldAnimate.current = true;
|
|
61
62
|
};
|
|
63
|
+
if (!(context === null || context === void 0 ? void 0 : context.mounted)) {
|
|
64
|
+
console.error("<Accordion.Item> has to be used within an <Accordion>");
|
|
65
|
+
}
|
|
62
66
|
return (react_1.default.createElement("div", Object.assign({ className: (0, clsx_1.default)("navds-accordion__item", className, {
|
|
63
67
|
"navds-accordion__item--open": open !== null && open !== void 0 ? open : internalOpen,
|
|
64
68
|
"navds-accordion__item--neutral": (context === null || context === void 0 ? void 0 : context.variant) === "neutral",
|
|
65
69
|
"navds-accordion__item--no-animation": !shouldAnimate.current,
|
|
66
|
-
}), ref: ref }, rest),
|
|
70
|
+
}), ref: ref }, (0, util_1.omit)(rest, ["onClick"])),
|
|
67
71
|
react_1.default.createElement(exports.AccordionItemContext.Provider, { value: {
|
|
68
72
|
open: open !== null && open !== void 0 ? open : internalOpen,
|
|
69
73
|
toggleOpen: handleOpen,
|
|
@@ -46,10 +46,14 @@ const __1 = require("../..");
|
|
|
46
46
|
const DateInput_1 = require("../DateInput");
|
|
47
47
|
const context_1 = require("../context");
|
|
48
48
|
const utils_1 = require("../utils");
|
|
49
|
-
const caption_1 = require("./caption");
|
|
50
49
|
const DatePickerStandalone_1 = __importDefault(require("./DatePickerStandalone"));
|
|
51
|
-
const
|
|
52
|
-
const
|
|
50
|
+
const Caption_1 = __importDefault(require("./parts/Caption"));
|
|
51
|
+
const DayButton_1 = __importDefault(require("./parts/DayButton"));
|
|
52
|
+
const DropdownCaption_1 = __importDefault(require("./parts/DropdownCaption"));
|
|
53
|
+
const HeadRow_1 = require("./parts/HeadRow");
|
|
54
|
+
const Row_1 = __importDefault(require("./parts/Row"));
|
|
55
|
+
const TableHead_1 = __importDefault(require("./parts/TableHead"));
|
|
56
|
+
const WeekNumber_1 = __importDefault(require("./parts/WeekNumber"));
|
|
53
57
|
/**
|
|
54
58
|
* A component that allows users to select a date from a calendar.
|
|
55
59
|
*
|
|
@@ -74,36 +78,25 @@ const TableHead_1 = require("./TableHead");
|
|
|
74
78
|
*/
|
|
75
79
|
exports.DatePicker = (0, react_1.forwardRef)((_a, ref) => {
|
|
76
80
|
var _b;
|
|
77
|
-
var { children, locale = "nb", dropdownCaption, disabled = [], disableWeekends = false, showWeekNumber = false, selected, id, defaultSelected, className, wrapperClassName, open: _open, onClose, onOpenToggle, strategy, bubbleEscape = false } = _a, rest = __rest(_a, ["children", "locale", "dropdownCaption", "disabled", "disableWeekends", "showWeekNumber", "selected", "id", "defaultSelected", "className", "wrapperClassName", "open", "onClose", "onOpenToggle", "strategy", "bubbleEscape"]);
|
|
81
|
+
var { children, locale = "nb", dropdownCaption, disabled = [], disableWeekends = false, showWeekNumber = false, selected, id, defaultSelected, className, wrapperClassName, open: _open, onClose, onOpenToggle, strategy, bubbleEscape = false, onWeekNumberClick } = _a, rest = __rest(_a, ["children", "locale", "dropdownCaption", "disabled", "disableWeekends", "showWeekNumber", "selected", "id", "defaultSelected", "className", "wrapperClassName", "open", "onClose", "onOpenToggle", "strategy", "bubbleEscape", "onWeekNumberClick"]);
|
|
78
82
|
const ariaId = (0, __1.useId)(id);
|
|
79
83
|
const [open, setOpen] = (0, react_1.useState)(_open !== null && _open !== void 0 ? _open : false);
|
|
80
84
|
const wrapperRef = (0, react_1.useRef)(null);
|
|
81
85
|
const [selectedDates, setSelectedDates] = react_1.default.useState(defaultSelected);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
(selectedDays === null || selectedDays === void 0 ? void 0 : selectedDays.from) && (selectedDays === null || selectedDays === void 0 ? void 0 : selectedDays.to) && ((_a = onClose === null || onClose === void 0 ? void 0 : onClose()) !== null && _a !== void 0 ? _a : setOpen(false));
|
|
97
|
-
(rest === null || rest === void 0 ? void 0 : rest.onSelect) &&
|
|
98
|
-
(rest === null || rest === void 0 ? void 0 : rest.onSelect)(selectedDays);
|
|
99
|
-
};
|
|
100
|
-
const overrideProps = {
|
|
101
|
-
mode: (_b = rest.mode) !== null && _b !== void 0 ? _b : "single",
|
|
102
|
-
onSelect: (rest === null || rest === void 0 ? void 0 : rest.mode) === "single"
|
|
103
|
-
? handleSingleSelect
|
|
104
|
-
: (rest === null || rest === void 0 ? void 0 : rest.mode) === "multiple"
|
|
105
|
-
? handleMultipleSelect
|
|
106
|
-
: handleRangeSelect,
|
|
86
|
+
const mode = (_b = rest.mode) !== null && _b !== void 0 ? _b : "single";
|
|
87
|
+
/**
|
|
88
|
+
* @param selected Date | Date[] | DateRange | undefined
|
|
89
|
+
*/
|
|
90
|
+
const handleSelect = (selected) => {
|
|
91
|
+
var _a, _b, _c;
|
|
92
|
+
setSelectedDates(selected);
|
|
93
|
+
if (rest.mode === "single") {
|
|
94
|
+
selected && ((_a = onClose === null || onClose === void 0 ? void 0 : onClose()) !== null && _a !== void 0 ? _a : setOpen(false));
|
|
95
|
+
}
|
|
96
|
+
else if (rest.mode === "range") {
|
|
97
|
+
(selected === null || selected === void 0 ? void 0 : selected.from) && (selected === null || selected === void 0 ? void 0 : selected.to) && ((_b = onClose === null || onClose === void 0 ? void 0 : onClose()) !== null && _b !== void 0 ? _b : setOpen(false));
|
|
98
|
+
}
|
|
99
|
+
(_c = rest === null || rest === void 0 ? void 0 : rest.onSelect) === null || _c === void 0 ? void 0 : _c.call(rest, selected);
|
|
107
100
|
};
|
|
108
101
|
return (react_1.default.createElement(context_1.DateContext.Provider, { value: {
|
|
109
102
|
open: _open !== null && _open !== void 0 ? _open : open,
|
|
@@ -119,10 +112,13 @@ exports.DatePicker = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
119
112
|
var _a;
|
|
120
113
|
(_a = onClose === null || onClose === void 0 ? void 0 : onClose()) !== null && _a !== void 0 ? _a : setOpen(false);
|
|
121
114
|
}, placement: "bottom-start", id: ariaId, role: "dialog", ref: ref, strategy: strategy, className: "navds-date__popover", bubbleEscape: bubbleEscape },
|
|
122
|
-
react_1.default.createElement(react_day_picker_1.DayPicker, Object.assign({ locale: (0, utils_1.getLocaleFromString)(locale)
|
|
123
|
-
Caption: dropdownCaption ?
|
|
124
|
-
|
|
125
|
-
|
|
115
|
+
react_1.default.createElement(react_day_picker_1.DayPicker, Object.assign({ locale: (0, utils_1.getLocaleFromString)(locale), mode: mode, onSelect: handleSelect, selected: selected !== null && selected !== void 0 ? selected : selectedDates, components: {
|
|
116
|
+
Caption: dropdownCaption ? DropdownCaption_1.default : Caption_1.default,
|
|
117
|
+
Head: TableHead_1.default,
|
|
118
|
+
HeadRow: HeadRow_1.HeadRow,
|
|
119
|
+
WeekNumber: WeekNumber_1.default,
|
|
120
|
+
Row: Row_1.default,
|
|
121
|
+
Day: DayButton_1.default,
|
|
126
122
|
}, className: (0, clsx_1.default)("navds-date", className), classNames: {
|
|
127
123
|
vhidden: "navds-sr-only",
|
|
128
124
|
}, disabled: (day) => {
|
|
@@ -132,7 +128,7 @@ exports.DatePicker = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
132
128
|
weekend: (day) => disableWeekends && (0, isWeekend_1.default)(day),
|
|
133
129
|
}, modifiersClassNames: {
|
|
134
130
|
weekend: "rdp-day__weekend",
|
|
135
|
-
}, showWeekNumber: showWeekNumber, fixedWeeks: true, showOutsideDays: true }, (0, __1.omit)(rest, ["onSelect"]))))))));
|
|
131
|
+
}, showWeekNumber: showWeekNumber, onWeekNumberClick: mode === "multiple" ? onWeekNumberClick : undefined, fixedWeeks: true, showOutsideDays: true }, (0, __1.omit)(rest, ["onSelect"]))))))));
|
|
136
132
|
});
|
|
137
133
|
exports.DatePicker.Standalone = DatePickerStandalone_1.default;
|
|
138
134
|
exports.DatePicker.Input = DateInput_1.DatePickerInput;
|
|
@@ -44,42 +44,39 @@ const react_1 = __importStar(require("react"));
|
|
|
44
44
|
const react_day_picker_1 = require("react-day-picker");
|
|
45
45
|
const __1 = require("../..");
|
|
46
46
|
const utils_1 = require("../utils");
|
|
47
|
-
const
|
|
48
|
-
const
|
|
47
|
+
const TableHead_1 = __importDefault(require("./parts/TableHead"));
|
|
48
|
+
const WeekNumber_1 = __importDefault(require("./parts/WeekNumber"));
|
|
49
|
+
const Caption_1 = __importDefault(require("./parts/Caption"));
|
|
50
|
+
const DropdownCaption_1 = __importDefault(require("./parts/DropdownCaption"));
|
|
51
|
+
const Row_1 = __importDefault(require("./parts/Row"));
|
|
52
|
+
const HeadRow_1 = require("./parts/HeadRow");
|
|
53
|
+
const DayButton_1 = __importDefault(require("./parts/DayButton"));
|
|
49
54
|
exports.DatePickerStandalone = (0, react_1.forwardRef)((_a, ref) => {
|
|
50
55
|
var _b;
|
|
51
|
-
var {
|
|
56
|
+
var { className, locale = "nb", dropdownCaption, disabled = [], disableWeekends = false, showWeekNumber = false, selected, defaultSelected, onSelect, fixedWeeks = false, onWeekNumberClick } = _a, rest = __rest(_a, ["className", "locale", "dropdownCaption", "disabled", "disableWeekends", "showWeekNumber", "selected", "defaultSelected", "onSelect", "fixedWeeks", "onWeekNumberClick"]);
|
|
52
57
|
const [selectedDates, setSelectedDates] = react_1.default.useState(defaultSelected);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
setSelectedDates(
|
|
59
|
-
onSelect
|
|
60
|
-
};
|
|
61
|
-
const handleRangeSelect = (selectedDays) => {
|
|
62
|
-
setSelectedDates(selectedDays);
|
|
63
|
-
onSelect && onSelect(selectedDays);
|
|
64
|
-
};
|
|
65
|
-
const overrideProps = {
|
|
66
|
-
mode: (_b = rest.mode) !== null && _b !== void 0 ? _b : "single",
|
|
67
|
-
onSelect: (rest === null || rest === void 0 ? void 0 : rest.mode) === "single"
|
|
68
|
-
? handleSingleSelect
|
|
69
|
-
: (rest === null || rest === void 0 ? void 0 : rest.mode) === "multiple"
|
|
70
|
-
? handleMultipleSelect
|
|
71
|
-
: handleRangeSelect,
|
|
58
|
+
const mode = (_b = rest.mode) !== null && _b !== void 0 ? _b : "single";
|
|
59
|
+
/**
|
|
60
|
+
* @param selected Date | Date[] | DateRange | undefined
|
|
61
|
+
*/
|
|
62
|
+
const handleSelect = (selected) => {
|
|
63
|
+
setSelectedDates(selected);
|
|
64
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(selected);
|
|
72
65
|
};
|
|
73
66
|
return (react_1.default.createElement("div", { ref: ref, className: (0, clsx_1.default)("navds-date__standalone-wrapper", className) },
|
|
74
|
-
react_1.default.createElement(react_day_picker_1.DayPicker, Object.assign({ locale: (0, utils_1.getLocaleFromString)(locale)
|
|
75
|
-
Caption: dropdownCaption ?
|
|
76
|
-
Head: TableHead_1.
|
|
67
|
+
react_1.default.createElement(react_day_picker_1.DayPicker, Object.assign({ locale: (0, utils_1.getLocaleFromString)(locale), mode: mode, onSelect: handleSelect, selected: selected !== null && selected !== void 0 ? selected : selectedDates, components: {
|
|
68
|
+
Caption: dropdownCaption ? DropdownCaption_1.default : Caption_1.default,
|
|
69
|
+
Head: TableHead_1.default,
|
|
70
|
+
HeadRow: HeadRow_1.HeadRow,
|
|
71
|
+
WeekNumber: WeekNumber_1.default,
|
|
72
|
+
Row: Row_1.default,
|
|
73
|
+
Day: DayButton_1.default,
|
|
77
74
|
}, className: "navds-date", classNames: { vhidden: "navds-sr-only" }, disabled: (day) => {
|
|
78
75
|
return ((disableWeekends && (0, isWeekend_1.default)(day)) || (0, react_day_picker_1.isMatch)(day, disabled));
|
|
79
76
|
}, weekStartsOn: 1, initialFocus: false, labels: utils_1.labels, modifiers: {
|
|
80
77
|
weekend: (day) => disableWeekends && (0, isWeekend_1.default)(day),
|
|
81
78
|
}, modifiersClassNames: {
|
|
82
79
|
weekend: "rdp-day__weekend",
|
|
83
|
-
}, showWeekNumber: showWeekNumber, fixedWeeks: fixedWeeks, showOutsideDays: true }, (0, __1.omit)(rest, ["
|
|
80
|
+
}, showWeekNumber: showWeekNumber, onWeekNumberClick: mode === "multiple" ? onWeekNumberClick : undefined, fixedWeeks: fixedWeeks, showOutsideDays: true }, (0, __1.omit)(rest, ["children", "id"])))));
|
|
84
81
|
});
|
|
85
82
|
exports.default = exports.DatePickerStandalone;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DatePickerCaption = void 0;
|
|
7
|
+
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const react_day_picker_1 = require("react-day-picker");
|
|
10
|
+
const __1 = require("../../..");
|
|
11
|
+
const WeekRow_1 = __importDefault(require("./WeekRow"));
|
|
12
|
+
/**
|
|
13
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/Caption
|
|
14
|
+
*/
|
|
15
|
+
const DatePickerCaption = ({ displayMonth, id }) => {
|
|
16
|
+
const { goToMonth, nextMonth, previousMonth } = (0, react_day_picker_1.useNavigation)();
|
|
17
|
+
const { labels: { labelPrevious, labelNext }, formatters: { formatCaption }, locale, } = (0, react_day_picker_1.useDayPicker)();
|
|
18
|
+
const previousLabel = labelPrevious(previousMonth, { locale });
|
|
19
|
+
const nextLabel = labelNext(nextMonth, { locale });
|
|
20
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
21
|
+
react_1.default.createElement("div", { className: "navds-date__caption" },
|
|
22
|
+
react_1.default.createElement(__1.Button, { variant: "tertiary", disabled: !previousMonth, onClick: () => previousMonth && goToMonth(previousMonth), icon: react_1.default.createElement(aksel_icons_1.ArrowLeftIcon, { title: previousLabel }), className: "navds-date__caption-button", type: "button" }),
|
|
23
|
+
react_1.default.createElement(__1.Label, { as: "span", "aria-live": "polite", "aria-atomic": "true", id: id, className: "navds-date__caption-label" }, formatCaption(displayMonth, { locale })),
|
|
24
|
+
react_1.default.createElement(__1.Button, { icon: react_1.default.createElement(aksel_icons_1.ArrowRightIcon, { title: nextLabel }), onClick: () => nextMonth && goToMonth(nextMonth), disabled: !nextMonth, variant: "tertiary", className: "navds-date__caption-button", type: "button" })),
|
|
25
|
+
react_1.default.createElement(WeekRow_1.default, { displayMonth: displayMonth })));
|
|
26
|
+
};
|
|
27
|
+
exports.DatePickerCaption = DatePickerCaption;
|
|
28
|
+
exports.default = exports.DatePickerCaption;
|
|
@@ -26,7 +26,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.DayButton = void 0;
|
|
30
29
|
const format_1 = __importDefault(require("date-fns/format"));
|
|
31
30
|
const react_1 = __importStar(require("react"));
|
|
32
31
|
const react_day_picker_1 = require("react-day-picker");
|
|
@@ -43,4 +42,4 @@ const DayButton = (props) => {
|
|
|
43
42
|
}
|
|
44
43
|
return (react_1.default.createElement(react_day_picker_1.Button, Object.assign({ name: "day", ref: buttonRef }, dayRender.buttonProps, { "aria-label": dateTime, "aria-hidden": dayRender.activeModifiers.outside })));
|
|
45
44
|
};
|
|
46
|
-
exports.
|
|
45
|
+
exports.default = DayButton;
|
|
@@ -14,6 +14,10 @@ const __1 = require("../../..");
|
|
|
14
14
|
const get_dates_1 = require("../../utils/get-dates");
|
|
15
15
|
const labels_1 = require("../../utils/labels");
|
|
16
16
|
const date_fns_1 = require("date-fns");
|
|
17
|
+
const WeekRow_1 = __importDefault(require("./WeekRow"));
|
|
18
|
+
/**
|
|
19
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/CaptionDropdowns
|
|
20
|
+
*/
|
|
17
21
|
const DropdownCaption = ({ displayMonth, id }) => {
|
|
18
22
|
const { goToMonth, nextMonth, previousMonth } = (0, react_day_picker_1.useNavigation)();
|
|
19
23
|
const { fromDate, toDate, formatters: { formatYearCaption, formatMonthCaption, formatCaption }, labels: { labelPrevious, labelNext }, locale, } = (0, react_day_picker_1.useDayPicker)();
|
|
@@ -32,13 +36,15 @@ const DropdownCaption = ({ displayMonth, id }) => {
|
|
|
32
36
|
const nextLabel = labelNext(nextMonth, { locale });
|
|
33
37
|
const yearDropdownLabel = (0, labels_1.labelYearDropdown)(locale);
|
|
34
38
|
const MonthDropdownLabel = (0, labels_1.labelMonthDropdown)(locale);
|
|
35
|
-
return (react_1.default.createElement(
|
|
36
|
-
react_1.default.createElement("
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
react_1.default.createElement(
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
40
|
+
react_1.default.createElement("div", { className: "navds-date__caption" },
|
|
41
|
+
react_1.default.createElement("span", { "aria-live": "polite", "aria-atomic": "true", id: id, className: "navds-sr-only" }, formatCaption(displayMonth, { locale })),
|
|
42
|
+
react_1.default.createElement(__1.Button, { variant: "tertiary", disabled: !previousMonth, onClick: () => previousMonth && goToMonth(previousMonth), icon: react_1.default.createElement(aksel_icons_1.ArrowLeftIcon, { title: previousLabel }), className: "navds-date__caption-button", type: "button" }),
|
|
43
|
+
react_1.default.createElement("div", { className: "navds-date__caption" },
|
|
44
|
+
react_1.default.createElement(__1.Select, { label: MonthDropdownLabel, hideLabel: true, className: "navds-date__caption__month", value: displayMonth.getMonth(), onChange: handleMonthChange }, months.map((m) => (react_1.default.createElement("option", { key: m.getMonth(), value: m.getMonth() }, formatMonthCaption(m, { locale }))))),
|
|
45
|
+
react_1.default.createElement(__1.Select, { label: yearDropdownLabel, hideLabel: true, value: displayMonth.getFullYear(), onChange: handleYearChange, className: "navds-date__caption__year" }, years.map((year) => (react_1.default.createElement("option", { key: year.getFullYear(), value: year.getFullYear() }, formatYearCaption(year, { locale })))))),
|
|
46
|
+
react_1.default.createElement(__1.Button, { icon: react_1.default.createElement(aksel_icons_1.ArrowRightIcon, { title: nextLabel }), onClick: () => nextMonth && goToMonth(nextMonth), disabled: !nextMonth, variant: "tertiary", className: "navds-date__caption-button", type: "button" })),
|
|
47
|
+
react_1.default.createElement(WeekRow_1.default, { displayMonth: displayMonth })));
|
|
42
48
|
};
|
|
43
49
|
exports.DropdownCaption = DropdownCaption;
|
|
44
50
|
exports.default = exports.DropdownCaption;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWeekdays = exports.HeadRow = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const date_fns_1 = require("date-fns");
|
|
9
|
+
const react_day_picker_1 = require("react-day-picker");
|
|
10
|
+
const responsive_1 = require("../../../layout/responsive");
|
|
11
|
+
/**
|
|
12
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/HeadRow
|
|
13
|
+
*/
|
|
14
|
+
function HeadRow() {
|
|
15
|
+
const { classNames, styles, showWeekNumber, locale, formatters: { formatWeekdayName }, labels: { labelWeekday }, } = (0, react_day_picker_1.useDayPicker)();
|
|
16
|
+
const weekdays = getWeekdays(locale);
|
|
17
|
+
return (react_1.default.createElement("tr", { style: styles.head_row, className: classNames.head_row },
|
|
18
|
+
showWeekNumber && (react_1.default.createElement(responsive_1.Hide, { below: "sm", asChild: true },
|
|
19
|
+
react_1.default.createElement("td", { style: styles.head_cell, className: classNames.head_cell }))),
|
|
20
|
+
weekdays.map((weekday, i) => (react_1.default.createElement("th", { key: i, scope: "col", className: classNames.head_cell, style: styles.head_cell, "aria-label": labelWeekday(weekday, { locale }) }, formatWeekdayName(weekday, { locale }))))));
|
|
21
|
+
}
|
|
22
|
+
exports.HeadRow = HeadRow;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a series of 7 days, starting from the week, to use for formatting
|
|
25
|
+
* the weekday names (Monday, Tuesday, etc.).
|
|
26
|
+
*/
|
|
27
|
+
function getWeekdays(locale) {
|
|
28
|
+
const start = (0, date_fns_1.startOfWeek)(new Date(), { locale, weekStartsOn: 1 });
|
|
29
|
+
const days = [];
|
|
30
|
+
for (let i = 0; i < 7; i++) {
|
|
31
|
+
const day = (0, date_fns_1.addDays)(start, i);
|
|
32
|
+
days.push(day);
|
|
33
|
+
}
|
|
34
|
+
return days;
|
|
35
|
+
}
|
|
36
|
+
exports.getWeekdays = getWeekdays;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const date_fns_1 = require("date-fns");
|
|
8
|
+
const react_day_picker_1 = require("react-day-picker");
|
|
9
|
+
const WeekNumber_1 = __importDefault(require("./WeekNumber"));
|
|
10
|
+
const responsive_1 = require("../../../layout/responsive");
|
|
11
|
+
/**
|
|
12
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/Row
|
|
13
|
+
*/
|
|
14
|
+
function Row(props) {
|
|
15
|
+
const { styles, classNames, showWeekNumber } = (0, react_day_picker_1.useDayPicker)();
|
|
16
|
+
return (react_1.default.createElement("tr", { className: classNames.row, style: styles.row },
|
|
17
|
+
showWeekNumber && (react_1.default.createElement(responsive_1.Hide, { below: "sm", asChild: true },
|
|
18
|
+
react_1.default.createElement("td", { className: classNames.cell, style: styles.cell },
|
|
19
|
+
react_1.default.createElement(WeekNumber_1.default, { number: props.weekNumber, dates: props.dates })))),
|
|
20
|
+
props.dates.map((date) => (react_1.default.createElement("td", { className: classNames.cell, style: styles.cell, key: (0, date_fns_1.getUnixTime)(date) },
|
|
21
|
+
react_1.default.createElement(react_day_picker_1.Day, { displayMonth: props.displayMonth, date: date }))))));
|
|
22
|
+
}
|
|
23
|
+
exports.default = Row;
|
|
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TableHead = void 0;
|
|
7
6
|
const react_1 = __importDefault(require("react"));
|
|
8
7
|
const react_day_picker_1 = require("react-day-picker");
|
|
9
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/Head
|
|
10
|
+
*/
|
|
10
11
|
function TableHead() {
|
|
11
12
|
var _a;
|
|
12
13
|
const { classNames, styles, components } = (0, react_day_picker_1.useDayPicker)();
|
|
@@ -14,4 +15,4 @@ function TableHead() {
|
|
|
14
15
|
return (react_1.default.createElement("thead", { style: styles.head, className: classNames.head, "aria-hidden": true },
|
|
15
16
|
react_1.default.createElement(HeadRowComponent, null)));
|
|
16
17
|
}
|
|
17
|
-
exports.
|
|
18
|
+
exports.default = TableHead;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/* https://github.com/gpbl/react-day-picker/blob/7f78cd5/src/components/WeekNumber/WeekNumber.tsx#L21 */
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_day_picker_1 = require("react-day-picker");
|
|
9
|
+
const labels_1 = require("../../utils/labels");
|
|
10
|
+
/**
|
|
11
|
+
* https://github.com/gpbl/react-day-picker/tree/main/src/components/WeekNumber
|
|
12
|
+
*/
|
|
13
|
+
function WeekNumber(props) {
|
|
14
|
+
const { number: weekNumber, dates } = props;
|
|
15
|
+
const { onWeekNumberClick, styles, classNames, locale: { code }, } = (0, react_day_picker_1.useDayPicker)();
|
|
16
|
+
const weekLabel = (0, labels_1.labelWeekNumber)({
|
|
17
|
+
week: Number(weekNumber),
|
|
18
|
+
localeCode: code,
|
|
19
|
+
});
|
|
20
|
+
if (!onWeekNumberClick) {
|
|
21
|
+
return (react_1.default.createElement("span", { className: classNames.weeknumber, style: styles.weeknumber, "aria-label": weekLabel }, weekNumber));
|
|
22
|
+
}
|
|
23
|
+
const label = (0, labels_1.labelWeekNumberButton)({
|
|
24
|
+
week: Number(weekNumber),
|
|
25
|
+
localeCode: code,
|
|
26
|
+
});
|
|
27
|
+
const handleClick = function (e) {
|
|
28
|
+
onWeekNumberClick(weekNumber, dates, e);
|
|
29
|
+
};
|
|
30
|
+
if (props === null || props === void 0 ? void 0 : props.headerVersion) {
|
|
31
|
+
return (react_1.default.createElement(react_day_picker_1.Button, { name: "week-number", "aria-label": label, className: classNames.weeknumber, style: styles.weeknumber, onClick: handleClick }, weekNumber));
|
|
32
|
+
}
|
|
33
|
+
return (react_1.default.createElement(react_day_picker_1.Button, { name: "week-number", "aria-label": label, className: classNames.weeknumber, style: styles.weeknumber, onClick: handleClick }, weekNumber));
|
|
34
|
+
}
|
|
35
|
+
exports.default = WeekNumber;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_day_picker_1 = require("react-day-picker");
|
|
8
|
+
const responsive_1 = require("../../../layout/responsive");
|
|
9
|
+
const typography_1 = require("../../../typography");
|
|
10
|
+
const get_month_weeks_1 = require("../../utils/get-month-weeks");
|
|
11
|
+
const labels_1 = require("../../utils/labels");
|
|
12
|
+
const WeekNumber_1 = __importDefault(require("./WeekNumber"));
|
|
13
|
+
const util_1 = require("../../../util");
|
|
14
|
+
const WeekRow = ({ displayMonth }) => {
|
|
15
|
+
const { locale, fixedWeeks, onWeekNumberClick } = (0, react_day_picker_1.useDayPicker)();
|
|
16
|
+
const labelId = (0, util_1.useId)();
|
|
17
|
+
if (!onWeekNumberClick) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const weeks = (0, get_month_weeks_1.getMonthWeeks)(displayMonth, {
|
|
21
|
+
useFixedWeeks: Boolean(fixedWeeks),
|
|
22
|
+
locale,
|
|
23
|
+
});
|
|
24
|
+
return (react_1.default.createElement(responsive_1.Show, { below: "sm", asChild: true },
|
|
25
|
+
react_1.default.createElement("table", { className: "rdp-table", role: "grid" },
|
|
26
|
+
react_1.default.createElement("tbody", { className: "rdp-tbody" },
|
|
27
|
+
react_1.default.createElement("tr", { className: "rdp-row navds-date__week-row" },
|
|
28
|
+
react_1.default.createElement(typography_1.Detail, { as: "th", weight: "semibold", className: "rdp-cell navds-date__week-cell" },
|
|
29
|
+
react_1.default.createElement("span", { className: "navds-date__week-wrapper", id: labelId }, (0, labels_1.labelWeek)(locale === null || locale === void 0 ? void 0 : locale.code))),
|
|
30
|
+
weeks.map((week) => (react_1.default.createElement("td", { key: week.weekNumber, className: "rdp-cell navds-date__week-cell" },
|
|
31
|
+
react_1.default.createElement("span", { className: "navds-date__week-wrapper" },
|
|
32
|
+
react_1.default.createElement(WeekNumber_1.default, { number: week.weekNumber, dates: week.dates, headerVersion: true }))))))))));
|
|
33
|
+
};
|
|
34
|
+
exports.default = WeekRow;
|
|
@@ -74,7 +74,7 @@ const useDatepicker = (opt = {}) => {
|
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
!open && openOnFocus && handleOpen(true);
|
|
77
|
-
|
|
77
|
+
const day = (0, utils_1.parseDate)(e.target.value, today, locale, "date", allowTwoDigitYear);
|
|
78
78
|
if ((0, utils_1.isValidDate)(day)) {
|
|
79
79
|
setInputValue((0, utils_1.formatDateForInput)(day, locale, "date", inputFormat));
|
|
80
80
|
const isBefore = fromDate && day && (0, differenceInCalendarDays_1.default)(fromDate, day) > 0;
|
|
@@ -83,7 +83,7 @@ const useDatepicker = (opt = {}) => {
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
const handleBlur = (e) => {
|
|
86
|
-
|
|
86
|
+
const day = (0, utils_1.parseDate)(e.target.value, today, locale, "date", allowTwoDigitYear);
|
|
87
87
|
(0, utils_1.isValidDate)(day) &&
|
|
88
88
|
setInputValue((0, utils_1.formatDateForInput)(day, locale, "date", inputFormat));
|
|
89
89
|
};
|
|
@@ -80,7 +80,7 @@ const useMonthpicker = (opt = {}) => {
|
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
!open && openOnFocus && handleOpen(true);
|
|
83
|
-
|
|
83
|
+
const day = (0, utils_1.parseDate)(e.target.value, today, locale, "month", allowTwoDigitYear);
|
|
84
84
|
const isBefore = getIsBefore({ fromDate, date: day });
|
|
85
85
|
const isAfter = getIsAfter({ toDate, date: day });
|
|
86
86
|
if ((0, utils_1.isValidDate)(day)) {
|
|
@@ -92,7 +92,7 @@ const useMonthpicker = (opt = {}) => {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
const handleBlur = (e) => {
|
|
95
|
-
|
|
95
|
+
const day = (0, utils_1.parseDate)(e.target.value, today, locale, "month", allowTwoDigitYear);
|
|
96
96
|
(0, utils_1.isValidDate)(day) &&
|
|
97
97
|
setInputValue((0, utils_1.formatDateForInput)(day, locale, "month", inputFormat));
|
|
98
98
|
};
|
|
@@ -155,7 +155,7 @@ const useRangeDatepicker = (opt = {}) => {
|
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
!open && openOnFocus && setOpen(true);
|
|
158
|
-
|
|
158
|
+
const day = (0, utils_1.parseDate)(e.target.value, today, locale, "date", allowTwoDigitYear);
|
|
159
159
|
if ((0, utils_1.isValidDate)(day)) {
|
|
160
160
|
src === RANGE.FROM
|
|
161
161
|
? setFromInputValue((0, utils_1.formatDateForInput)(day, locale, "date", inputFormat))
|
|
@@ -166,7 +166,7 @@ const useRangeDatepicker = (opt = {}) => {
|
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
const handleBlur = (e, src) => {
|
|
169
|
-
|
|
169
|
+
const day = (0, utils_1.parseDate)(e.target.value, today, locale, "date", allowTwoDigitYear);
|
|
170
170
|
if (!(0, utils_1.isValidDate)(day)) {
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
@@ -186,7 +186,7 @@ const useRangeDatepicker = (opt = {}) => {
|
|
|
186
186
|
if ((range === null || range === void 0 ? void 0 : range.from) && (range === null || range === void 0 ? void 0 : range.to)) {
|
|
187
187
|
setOpen(false);
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
const prevToRange = !(selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.from) && (selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.to) ? selectedRange === null || selectedRange === void 0 ? void 0 : selectedRange.to : range === null || range === void 0 ? void 0 : range.to;
|
|
190
190
|
const resetTo = (0, isBefore_1.default)(prevToRange, range === null || range === void 0 ? void 0 : range.from);
|
|
191
191
|
(range === null || range === void 0 ? void 0 : range.from)
|
|
192
192
|
? setFromInputValue((0, utils_1.formatDateForInput)(range === null || range === void 0 ? void 0 : range.from, locale, "date", inputFormat))
|
|
@@ -73,7 +73,7 @@ const MonthSelector = () => {
|
|
|
73
73
|
months.slice(8, 12),
|
|
74
74
|
];
|
|
75
75
|
return (react_1.default.createElement(__1.BodyShort, { as: "table", className: "rdp-table" },
|
|
76
|
-
react_1.default.createElement("tbody", { className: "rdp-tbody" }, tableMonths.map((
|
|
76
|
+
react_1.default.createElement("tbody", { className: "rdp-tbody" }, tableMonths.map((months, i) => (react_1.default.createElement("tr", { className: "rdp-row", key: i }, months.map((month) => {
|
|
77
77
|
return (react_1.default.createElement("td", { key: month.toDateString(), className: "rdp-cell" },
|
|
78
78
|
react_1.default.createElement(MonthButton_1.default, { month: (0, setYear_1.default)(month, year.getFullYear()), months: months, focus: focus, setFocus: setFocus, tabRoot: tabRoot, setTabRoot: setTabRoot })));
|
|
79
79
|
})))))));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.daysToMonthWeeks = exports.getMonthWeeks = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
function getMonthWeeks(month, options) {
|
|
6
|
+
const _options = Object.assign(Object.assign({}, options), { weekStartsOn: 1 });
|
|
7
|
+
const weeksInMonth = daysToMonthWeeks((0, date_fns_1.startOfMonth)(month), (0, date_fns_1.endOfMonth)(month), _options);
|
|
8
|
+
if (_options === null || _options === void 0 ? void 0 : _options.useFixedWeeks) {
|
|
9
|
+
// Add extra weeks to the month, up to 6 weeks
|
|
10
|
+
const nrOfMonthWeeks = (0, date_fns_1.getWeeksInMonth)(month, _options);
|
|
11
|
+
if (nrOfMonthWeeks < 6) {
|
|
12
|
+
const lastWeek = weeksInMonth[weeksInMonth.length - 1];
|
|
13
|
+
const lastDate = lastWeek.dates[lastWeek.dates.length - 1];
|
|
14
|
+
const toDate = (0, date_fns_1.addWeeks)(lastDate, 6 - nrOfMonthWeeks);
|
|
15
|
+
const extraWeeks = daysToMonthWeeks((0, date_fns_1.addWeeks)(lastDate, 1), toDate, _options);
|
|
16
|
+
weeksInMonth.push(...extraWeeks);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return weeksInMonth;
|
|
20
|
+
}
|
|
21
|
+
exports.getMonthWeeks = getMonthWeeks;
|
|
22
|
+
/** Return the weeks between two dates. */
|
|
23
|
+
function daysToMonthWeeks(fromDate, toDate, options) {
|
|
24
|
+
const toWeek = (0, date_fns_1.endOfWeek)(toDate, options);
|
|
25
|
+
const fromWeek = (0, date_fns_1.startOfWeek)(fromDate, options);
|
|
26
|
+
const nOfDays = (0, date_fns_1.differenceInCalendarDays)(toWeek, fromWeek);
|
|
27
|
+
const days = [];
|
|
28
|
+
for (let i = 0; i <= nOfDays; i++) {
|
|
29
|
+
days.push((0, date_fns_1.addDays)(fromWeek, i));
|
|
30
|
+
}
|
|
31
|
+
const weeksInMonth = days.reduce((result, date) => {
|
|
32
|
+
const weekNumber = (0, date_fns_1.getWeek)(date, options);
|
|
33
|
+
const existingWeek = result.find((value) => value.weekNumber === weekNumber);
|
|
34
|
+
if (existingWeek) {
|
|
35
|
+
existingWeek.dates.push(date);
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
result.push({
|
|
39
|
+
weekNumber,
|
|
40
|
+
dates: [date],
|
|
41
|
+
});
|
|
42
|
+
return result;
|
|
43
|
+
}, []);
|
|
44
|
+
return weeksInMonth;
|
|
45
|
+
}
|
|
46
|
+
exports.daysToMonthWeeks = daysToMonthWeeks;
|