@navikt/ds-react 7.13.0 → 7.14.0-alpha.1
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/cjs/date/Date.Dialog.d.ts +18 -0
- package/cjs/date/Date.Dialog.js +67 -0
- package/cjs/date/Date.Dialog.js.map +1 -0
- package/cjs/date/Date.Input.d.ts +50 -0
- package/cjs/date/Date.Input.js +96 -0
- package/cjs/date/Date.Input.js.map +1 -0
- package/cjs/date/Date.locale.d.ts +44 -0
- package/cjs/date/Date.locale.js +57 -0
- package/cjs/date/Date.locale.js.map +1 -0
- package/cjs/date/Date.typeutils.d.ts +14 -0
- package/cjs/date/Date.typeutils.js +15 -0
- package/cjs/date/Date.typeutils.js.map +1 -0
- package/cjs/date/date-utils/calendar-range.d.ts +11 -0
- package/cjs/date/date-utils/calendar-range.js +30 -0
- package/cjs/date/date-utils/calendar-range.js.map +1 -0
- package/cjs/date/date-utils/check-dates.d.ts +8 -0
- package/cjs/date/date-utils/check-dates.js +20 -0
- package/cjs/date/date-utils/check-dates.js.map +1 -0
- package/cjs/date/date-utils/clamp-dates.d.ts +19 -0
- package/cjs/date/date-utils/clamp-dates.js +41 -0
- package/cjs/date/date-utils/clamp-dates.js.map +1 -0
- package/cjs/date/date-utils/dates-disabled.d.ts +1 -0
- package/cjs/date/date-utils/dates-disabled.js +29 -0
- package/cjs/date/date-utils/dates-disabled.js.map +1 -0
- package/cjs/date/date-utils/dropdown-options.d.ts +13 -0
- package/cjs/date/date-utils/dropdown-options.js +45 -0
- package/cjs/date/date-utils/dropdown-options.js.map +1 -0
- package/cjs/date/date-utils/format-date.d.ts +2 -0
- package/cjs/date/date-utils/format-date.js +13 -0
- package/cjs/date/date-utils/format-date.js.map +1 -0
- package/cjs/date/date-utils/index.d.ts +8 -0
- package/cjs/date/date-utils/index.js +27 -0
- package/cjs/date/date-utils/index.js.map +1 -0
- package/cjs/date/date-utils/is-match.d.ts +3 -0
- package/cjs/date/date-utils/is-match.js +61 -0
- package/cjs/date/date-utils/is-match.js.map +1 -0
- package/cjs/date/date-utils/parse-date.d.ts +4 -0
- package/cjs/date/date-utils/parse-date.js +87 -0
- package/cjs/date/date-utils/parse-date.js.map +1 -0
- package/cjs/date/datepicker/DatePicker.d.ts +3 -3
- package/cjs/date/datepicker/DatePicker.js +47 -63
- package/cjs/date/datepicker/DatePicker.js.map +1 -1
- package/cjs/date/datepicker/DatePicker.types.d.ts +108 -0
- package/cjs/date/datepicker/DatePicker.types.js +3 -0
- package/cjs/date/datepicker/DatePicker.types.js.map +1 -0
- package/cjs/date/datepicker/hooks/useDatepicker.d.ts +90 -0
- package/cjs/date/datepicker/hooks/useDatepicker.js +164 -0
- package/cjs/date/datepicker/hooks/useDatepicker.js.map +1 -0
- package/cjs/date/datepicker/hooks/useRangeDatepicker.d.ts +76 -0
- package/cjs/date/datepicker/hooks/useRangeDatepicker.js +322 -0
- package/cjs/date/datepicker/hooks/useRangeDatepicker.js.map +1 -0
- package/cjs/date/datepicker/index.d.ts +4 -3
- package/cjs/date/datepicker/index.js +8 -7
- package/cjs/date/datepicker/index.js.map +1 -1
- package/cjs/date/datepicker/parts/DatePicker.DayButton.d.ts +9 -0
- package/cjs/date/datepicker/parts/DatePicker.DayButton.js +70 -0
- package/cjs/date/datepicker/parts/DatePicker.DayButton.js.map +1 -0
- package/cjs/date/datepicker/parts/DatePicker.Months.d.ts +11 -0
- package/cjs/date/datepicker/parts/DatePicker.Months.js +84 -0
- package/cjs/date/datepicker/parts/DatePicker.Months.js.map +1 -0
- package/cjs/date/datepicker/parts/DatePicker.RDP.d.ts +15 -0
- package/cjs/date/datepicker/parts/DatePicker.RDP.js +103 -0
- package/cjs/date/datepicker/parts/DatePicker.RDP.js.map +1 -0
- package/cjs/date/datepicker/parts/DatePicker.Standalone.d.ts +18 -0
- package/cjs/date/datepicker/parts/DatePicker.Standalone.js +60 -0
- package/cjs/date/datepicker/parts/DatePicker.Standalone.js.map +1 -0
- package/cjs/date/datepicker/parts/DatePicker.WeekNumber.d.ts +9 -0
- package/cjs/date/datepicker/parts/DatePicker.WeekNumber.js +64 -0
- package/cjs/date/datepicker/parts/DatePicker.WeekNumber.js.map +1 -0
- package/cjs/date/datepicker/parts/DatePicker.WeekRow.d.ts +8 -0
- package/cjs/date/datepicker/parts/DatePicker.WeekRow.js +28 -0
- package/cjs/date/datepicker/parts/DatePicker.WeekRow.js.map +1 -0
- package/cjs/date/monthpicker/MonthPicker.context.d.ts +21 -0
- package/cjs/date/monthpicker/MonthPicker.context.js +48 -0
- package/cjs/date/monthpicker/MonthPicker.context.js.map +1 -0
- package/cjs/date/monthpicker/MonthPicker.d.ts +3 -3
- package/cjs/date/monthpicker/MonthPicker.js +34 -43
- package/cjs/date/monthpicker/MonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/MonthPicker.types.d.ts +86 -0
- package/cjs/date/monthpicker/MonthPicker.types.js +3 -0
- package/cjs/date/monthpicker/MonthPicker.types.js.map +1 -0
- package/cjs/date/monthpicker/MonthPicker.util.d.ts +2 -0
- package/cjs/date/monthpicker/MonthPicker.util.js +156 -0
- package/cjs/date/monthpicker/MonthPicker.util.js.map +1 -0
- package/cjs/date/monthpicker/hooks/useMonthPicker.d.ts +85 -0
- package/cjs/date/monthpicker/hooks/useMonthPicker.js +179 -0
- package/cjs/date/monthpicker/hooks/useMonthPicker.js.map +1 -0
- package/cjs/date/monthpicker/index.d.ts +4 -4
- package/cjs/date/monthpicker/index.js +6 -6
- package/cjs/date/monthpicker/index.js.map +1 -1
- package/cjs/date/monthpicker/parts/MonthPicker.Button.d.ts +11 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Button.js +82 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Button.js.map +1 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Caption.d.ts +3 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Caption.js +52 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Caption.js.map +1 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Standalone.d.ts +10 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Standalone.js +51 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Standalone.js.map +1 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Table.d.ts +3 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Table.js +79 -0
- package/cjs/date/monthpicker/parts/MonthPicker.Table.js.map +1 -0
- package/cjs/form/combobox/Combobox.d.ts +1 -1
- package/cjs/form/combobox/Input/InputController.d.ts +1 -1
- package/cjs/modal/Modal.js +2 -2
- package/cjs/modal/Modal.js.map +1 -1
- package/cjs/popover/Popover.js +3 -3
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/tooltip/Tooltip.js +2 -5
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/esm/date/Date.Dialog.d.ts +18 -0
- package/esm/date/Date.Dialog.js +38 -0
- package/esm/date/Date.Dialog.js.map +1 -0
- package/esm/date/Date.Input.d.ts +50 -0
- package/esm/date/Date.Input.js +66 -0
- package/esm/date/Date.Input.js.map +1 -0
- package/esm/date/Date.locale.d.ts +44 -0
- package/esm/date/Date.locale.js +47 -0
- package/esm/date/Date.locale.js.map +1 -0
- package/esm/date/Date.typeutils.d.ts +14 -0
- package/esm/date/Date.typeutils.js +10 -0
- package/esm/date/Date.typeutils.js.map +1 -0
- package/esm/date/date-utils/calendar-range.d.ts +11 -0
- package/esm/date/date-utils/calendar-range.js +27 -0
- package/esm/date/date-utils/calendar-range.js.map +1 -0
- package/esm/date/date-utils/check-dates.d.ts +8 -0
- package/esm/date/date-utils/check-dates.js +14 -0
- package/esm/date/date-utils/check-dates.js.map +1 -0
- package/esm/date/date-utils/clamp-dates.d.ts +19 -0
- package/esm/date/date-utils/clamp-dates.js +37 -0
- package/esm/date/date-utils/clamp-dates.js.map +1 -0
- package/esm/date/date-utils/dates-disabled.d.ts +1 -0
- package/esm/date/date-utils/dates-disabled.js +25 -0
- package/esm/date/date-utils/dates-disabled.js.map +1 -0
- package/esm/date/date-utils/dropdown-options.d.ts +13 -0
- package/esm/date/date-utils/dropdown-options.js +41 -0
- package/esm/date/date-utils/dropdown-options.js.map +1 -0
- package/esm/date/date-utils/format-date.d.ts +2 -0
- package/esm/date/date-utils/format-date.js +9 -0
- package/esm/date/date-utils/format-date.js.map +1 -0
- package/esm/date/date-utils/index.d.ts +8 -0
- package/esm/date/date-utils/index.js +9 -0
- package/esm/date/date-utils/index.js.map +1 -0
- package/esm/date/date-utils/is-match.d.ts +3 -0
- package/esm/date/date-utils/is-match.js +57 -0
- package/esm/date/date-utils/is-match.js.map +1 -0
- package/esm/date/date-utils/parse-date.d.ts +4 -0
- package/esm/date/date-utils/parse-date.js +83 -0
- package/esm/date/date-utils/parse-date.js.map +1 -0
- package/esm/date/datepicker/DatePicker.d.ts +3 -3
- package/esm/date/datepicker/DatePicker.js +46 -62
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePicker.types.d.ts +108 -0
- package/esm/date/datepicker/DatePicker.types.js +2 -0
- package/esm/date/datepicker/DatePicker.types.js.map +1 -0
- package/esm/date/datepicker/hooks/useDatepicker.d.ts +90 -0
- package/esm/date/datepicker/hooks/useDatepicker.js +160 -0
- package/esm/date/datepicker/hooks/useDatepicker.js.map +1 -0
- package/esm/date/datepicker/hooks/useRangeDatepicker.d.ts +76 -0
- package/esm/date/datepicker/hooks/useRangeDatepicker.js +318 -0
- package/esm/date/datepicker/hooks/useRangeDatepicker.js.map +1 -0
- package/esm/date/datepicker/index.d.ts +4 -3
- package/esm/date/datepicker/index.js +4 -3
- package/esm/date/datepicker/index.js.map +1 -1
- package/esm/date/datepicker/parts/DatePicker.DayButton.d.ts +9 -0
- package/esm/date/datepicker/parts/DatePicker.DayButton.js +41 -0
- package/esm/date/datepicker/parts/DatePicker.DayButton.js.map +1 -0
- package/esm/date/datepicker/parts/DatePicker.Months.d.ts +11 -0
- package/esm/date/datepicker/parts/DatePicker.Months.js +58 -0
- package/esm/date/datepicker/parts/DatePicker.Months.js.map +1 -0
- package/esm/date/datepicker/parts/DatePicker.RDP.d.ts +15 -0
- package/esm/date/datepicker/parts/DatePicker.RDP.js +74 -0
- package/esm/date/datepicker/parts/DatePicker.RDP.js.map +1 -0
- package/esm/date/datepicker/parts/DatePicker.Standalone.d.ts +18 -0
- package/esm/date/datepicker/parts/DatePicker.Standalone.js +31 -0
- package/esm/date/datepicker/parts/DatePicker.Standalone.js.map +1 -0
- package/esm/date/datepicker/parts/DatePicker.WeekNumber.d.ts +9 -0
- package/esm/date/datepicker/parts/DatePicker.WeekNumber.js +35 -0
- package/esm/date/datepicker/parts/DatePicker.WeekNumber.js.map +1 -0
- package/esm/date/datepicker/parts/DatePicker.WeekRow.d.ts +8 -0
- package/esm/date/datepicker/parts/DatePicker.WeekRow.js +22 -0
- package/esm/date/datepicker/parts/DatePicker.WeekRow.js.map +1 -0
- package/esm/date/monthpicker/MonthPicker.context.d.ts +21 -0
- package/esm/date/monthpicker/MonthPicker.context.js +41 -0
- package/esm/date/monthpicker/MonthPicker.context.js.map +1 -0
- package/esm/date/monthpicker/MonthPicker.d.ts +3 -3
- package/esm/date/monthpicker/MonthPicker.js +31 -40
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.types.d.ts +86 -0
- package/esm/date/monthpicker/MonthPicker.types.js +2 -0
- package/esm/date/monthpicker/MonthPicker.types.js.map +1 -0
- package/esm/date/monthpicker/MonthPicker.util.d.ts +2 -0
- package/esm/date/monthpicker/MonthPicker.util.js +152 -0
- package/esm/date/monthpicker/MonthPicker.util.js.map +1 -0
- package/esm/date/monthpicker/hooks/useMonthPicker.d.ts +85 -0
- package/esm/date/monthpicker/hooks/useMonthPicker.js +175 -0
- package/esm/date/monthpicker/hooks/useMonthPicker.js.map +1 -0
- package/esm/date/monthpicker/index.d.ts +4 -4
- package/esm/date/monthpicker/index.js +3 -3
- package/esm/date/monthpicker/index.js.map +1 -1
- package/esm/date/monthpicker/parts/MonthPicker.Button.d.ts +11 -0
- package/esm/date/monthpicker/parts/MonthPicker.Button.js +52 -0
- package/esm/date/monthpicker/parts/MonthPicker.Button.js.map +1 -0
- package/esm/date/monthpicker/parts/MonthPicker.Caption.d.ts +3 -0
- package/esm/date/monthpicker/parts/MonthPicker.Caption.js +46 -0
- package/esm/date/monthpicker/parts/MonthPicker.Caption.js.map +1 -0
- package/esm/date/monthpicker/parts/MonthPicker.Standalone.d.ts +10 -0
- package/esm/date/monthpicker/parts/MonthPicker.Standalone.js +22 -0
- package/esm/date/monthpicker/parts/MonthPicker.Standalone.js.map +1 -0
- package/esm/date/monthpicker/parts/MonthPicker.Table.d.ts +3 -0
- package/esm/date/monthpicker/parts/MonthPicker.Table.js +50 -0
- package/esm/date/monthpicker/parts/MonthPicker.Table.js.map +1 -0
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/Input/InputController.d.ts +1 -1
- package/esm/modal/Modal.js +3 -3
- package/esm/modal/Modal.js.map +1 -1
- package/esm/popover/Popover.js +4 -4
- package/esm/popover/Popover.js.map +1 -1
- package/esm/tooltip/Tooltip.js +2 -5
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/package.json +6 -7
- package/src/date/{parts/DateWrapper.tsx → Date.Dialog.tsx} +12 -9
- package/src/date/{parts/DateInput.tsx → Date.Input.tsx} +30 -5
- package/src/date/{utils/locale.ts → Date.locale.ts} +11 -2
- package/src/date/Date.typeutils.ts +32 -0
- package/src/date/date-utils/calendar-range.test.ts +54 -0
- package/src/date/date-utils/calendar-range.ts +46 -0
- package/src/date/date-utils/check-dates.test.ts +49 -0
- package/src/date/date-utils/check-dates.ts +28 -0
- package/src/date/date-utils/clamp-dates.test.ts +156 -0
- package/src/date/date-utils/clamp-dates.ts +63 -0
- package/src/date/{utils/__tests__ → date-utils}/dates-disabled.test.ts +1 -1
- package/src/date/{utils → date-utils}/dates-disabled.ts +1 -2
- package/src/date/date-utils/dropdown-options.test.ts +143 -0
- package/src/date/date-utils/dropdown-options.ts +79 -0
- package/src/date/{utils/__tests__ → date-utils}/format-dates.test.ts +2 -2
- package/src/date/date-utils/index.ts +16 -0
- package/src/date/{utils/__tests__ → date-utils}/is-match.test.ts +1 -1
- package/src/date/{utils → date-utils}/is-match.ts +2 -11
- package/src/date/{utils/__tests__ → date-utils}/parse-dates.test.ts +2 -1
- package/src/date/datepicker/DatePicker.tsx +67 -92
- package/src/date/datepicker/{types.ts → DatePicker.types.ts} +10 -4
- package/src/date/{hooks → datepicker/hooks}/useDatepicker.tsx +12 -13
- package/src/date/{hooks → datepicker/hooks}/useRangeDatepicker.test.tsx +1 -1
- package/src/date/{hooks → datepicker/hooks}/useRangeDatepicker.tsx +19 -19
- package/src/date/datepicker/index.ts +4 -5
- package/src/date/datepicker/parts/DatePicker.DayButton.tsx +56 -0
- package/src/date/datepicker/parts/DatePicker.Months.tsx +149 -0
- package/src/date/datepicker/parts/DatePicker.RDP.tsx +170 -0
- package/src/date/datepicker/parts/DatePicker.Standalone.tsx +93 -0
- package/src/date/datepicker/parts/DatePicker.WeekNumber.tsx +86 -0
- package/src/date/datepicker/parts/{WeekRow.tsx → DatePicker.WeekRow.tsx} +20 -21
- package/src/date/monthpicker/MonthPicker.context.tsx +103 -0
- package/src/date/monthpicker/MonthPicker.tsx +63 -68
- package/src/date/monthpicker/{types.ts → MonthPicker.types.ts} +1 -1
- package/src/date/{utils/navigation.ts → monthpicker/MonthPicker.util.ts} +2 -1
- package/src/date/{hooks → monthpicker/hooks}/useMonthPicker.tsx +14 -13
- package/src/date/monthpicker/index.ts +4 -4
- package/src/date/monthpicker/{MonthButton.tsx → parts/MonthPicker.Button.tsx} +21 -10
- package/src/date/monthpicker/{MonthCaption.tsx → parts/MonthPicker.Caption.tsx} +20 -21
- package/src/date/monthpicker/parts/MonthPicker.Standalone.tsx +86 -0
- package/src/date/monthpicker/{MonthSelector.tsx → parts/MonthPicker.Table.tsx} +7 -7
- package/src/modal/Modal.tsx +3 -3
- package/src/popover/Popover.tsx +4 -4
- package/src/tooltip/Tooltip.tsx +2 -6
- package/src/date/context/index.ts +0 -9
- package/src/date/context/useDateInputContext.tsx +0 -34
- package/src/date/context/useDateTranslationContext.ts +0 -9
- package/src/date/context/useSharedMonthContext.tsx +0 -68
- package/src/date/datepicker/DatePickerStandalone.tsx +0 -136
- package/src/date/datepicker/datepicker.test.tsx +0 -28
- package/src/date/datepicker/parts/Caption.tsx +0 -54
- package/src/date/datepicker/parts/DayButton.tsx +0 -32
- package/src/date/datepicker/parts/DropdownCaption.tsx +0 -110
- package/src/date/datepicker/parts/HeadRow.tsx +0 -56
- package/src/date/datepicker/parts/Row.tsx +0 -48
- package/src/date/datepicker/parts/TableHead.tsx +0 -17
- package/src/date/datepicker/parts/WeekNumber.tsx +0 -75
- package/src/date/hooks/index.ts +0 -6
- package/src/date/monthpicker/MonthPickerStandalone.tsx +0 -102
- package/src/date/utils/__tests__/check-dates.test.ts +0 -22
- package/src/date/utils/__tests__/get-dates.test.ts +0 -121
- package/src/date/utils/__tests__/get-initial-year.test.ts +0 -83
- package/src/date/utils/__tests__/get-month-weeks.test.ts +0 -116
- package/src/date/utils/check-dates.ts +0 -13
- package/src/date/utils/get-dates.ts +0 -60
- package/src/date/utils/get-initial-year.ts +0 -25
- package/src/date/utils/get-month-weeks.ts +0 -93
- package/src/date/utils/index.ts +0 -18
- /package/src/date/{utils → date-utils}/format-date.ts +0 -0
- /package/src/date/{utils → date-utils}/parse-date.ts +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TFunction } from "../util/i18n/i18n.types";
|
|
3
|
+
type DateWrapperProps = {
|
|
4
|
+
open: boolean;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
anchor: HTMLDivElement | null;
|
|
8
|
+
/** @deprecated Temporary to support locale prop */
|
|
9
|
+
locale: "nb" | "nn" | "en" | undefined;
|
|
10
|
+
translate: TFunction<"DatePicker">;
|
|
11
|
+
variant: "single" | "multiple" | "range" | "month";
|
|
12
|
+
popoverProps: {
|
|
13
|
+
id?: string;
|
|
14
|
+
strategy?: "absolute" | "fixed";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
declare const DateDialog: ({ open, children, onClose, anchor, locale, translate, variant, popoverProps, }: DateWrapperProps) => React.JSX.Element;
|
|
18
|
+
export { DateDialog };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DateDialog = void 0;
|
|
30
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const button_1 = require("../button");
|
|
33
|
+
const modal_1 = require("../modal");
|
|
34
|
+
const Modal_context_1 = require("../modal/Modal.context");
|
|
35
|
+
const popover_1 = require("../popover");
|
|
36
|
+
const hooks_1 = require("../util/hooks");
|
|
37
|
+
const i18n_hooks_1 = require("../util/i18n/i18n.hooks");
|
|
38
|
+
const Date_locale_1 = require("./Date.locale");
|
|
39
|
+
const variantToLabel = {
|
|
40
|
+
single: "chooseDate",
|
|
41
|
+
multiple: "chooseDates",
|
|
42
|
+
range: "chooseDateRange",
|
|
43
|
+
month: "chooseMonth",
|
|
44
|
+
};
|
|
45
|
+
const DateDialog = ({ open, children, onClose, anchor, locale, translate, variant, popoverProps, }) => {
|
|
46
|
+
const translateGlobal = (0, i18n_hooks_1.useI18n)("global", (0, Date_locale_1.getGlobalTranslations)(locale));
|
|
47
|
+
const modalRef = (0, react_1.useRef)(null);
|
|
48
|
+
const isInModal = (0, Modal_context_1.useModalContext)(false) !== undefined;
|
|
49
|
+
const hideModal = (0, hooks_1.useMedia)("screen and (min-width: 768px)", true) && !isInModal;
|
|
50
|
+
if (hideModal) {
|
|
51
|
+
return (react_1.default.createElement(popover_1.Popover, Object.assign({ arrow: false, anchorEl: anchor, open: open, onClose: onClose, placement: "bottom-start", role: "dialog", className: (0, clsx_1.default)("navds-date__popover", {
|
|
52
|
+
"navds-date": variant === "month",
|
|
53
|
+
}), flip: false }, popoverProps), children));
|
|
54
|
+
}
|
|
55
|
+
return (react_1.default.createElement(modal_1.Modal, { ref: modalRef, open: open, onClose: (event) => {
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
onClose();
|
|
58
|
+
}, "aria-label": translate(variantToLabel[variant]), className: (0, clsx_1.default)("navds-date__modal", {
|
|
59
|
+
"navds-date__nested-modal": isInModal,
|
|
60
|
+
"navds-date": variant === "month",
|
|
61
|
+
}), closeOnBackdropClick: true, placement: "top" },
|
|
62
|
+
react_1.default.createElement("div", { className: "navds-date__modal-body" },
|
|
63
|
+
children,
|
|
64
|
+
react_1.default.createElement(button_1.Button, { variant: "tertiary", onClick: () => { var _a; return (_a = modalRef === null || modalRef === void 0 ? void 0 : modalRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, size: "small", type: "button" }, translateGlobal("close")))));
|
|
65
|
+
};
|
|
66
|
+
exports.DateDialog = DateDialog;
|
|
67
|
+
//# sourceMappingURL=Date.Dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Date.Dialog.js","sourceRoot":"","sources":["../../src/date/Date.Dialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAsB;AACtB,+CAAsC;AACtC,sCAAmC;AACnC,oCAAiC;AACjC,0DAAyD;AACzD,wCAAqC;AACrC,yCAAyC;AACzC,wDAAkD;AAElD,+CAAsD;AAEtD,MAAM,cAAc,GAAG;IACrB,MAAM,EAAE,YAAY;IACpB,QAAQ,EAAE,aAAa;IACvB,KAAK,EAAE,iBAAiB;IACxB,KAAK,EAAE,aAAa;CACZ,CAAC;AAiBX,MAAM,UAAU,GAAG,CAAC,EAClB,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,GACK,EAAE,EAAE;IACrB,MAAM,eAAe,GAAG,IAAA,oBAAO,EAAC,QAAQ,EAAE,IAAA,mCAAqB,EAAC,MAAM,CAAC,CAAC,CAAC;IACzE,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAoB,IAAI,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAA,+BAAe,EAAC,KAAK,CAAC,KAAK,SAAS,CAAC;IACvD,MAAM,SAAS,GACb,IAAA,gBAAQ,EAAC,+BAA+B,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;IAEhE,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CACL,8BAAC,iBAAO,kBACN,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,cAAc,EACxB,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,IAAA,cAAE,EAAC,qBAAqB,EAAE;gBACnC,YAAY,EAAE,OAAO,KAAK,OAAO;aAClC,CAAC,EACF,IAAI,EAAE,KAAK,IACP,YAAY,GAEf,QAAQ,CACD,CACX,CAAC;IACJ,CAAC;IAED,OAAO,CACL,8BAAC,aAAK,IACJ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACZ,CAAC,gBACW,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAC9C,SAAS,EAAE,IAAA,cAAE,EAAC,mBAAmB,EAAE;YACjC,0BAA0B,EAAE,SAAS;YACrC,YAAY,EAAE,OAAO,KAAK,OAAO;SAClC,CAAC,EACF,oBAAoB,QACpB,SAAS,EAAC,KAAK;QAEf,uCAAK,SAAS,EAAC,wBAAwB;YACpC,QAAQ;YACT,8BAAC,eAAM,IACL,OAAO,EAAC,UAAU,EAClB,OAAO,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,0CAAE,KAAK,EAAE,CAAA,EAAA,EACzC,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,QAAQ,IAEZ,eAAe,CAAC,OAAO,CAAC,CAClB,CACL,CACA,CACT,CAAC;AACJ,CAAC,CAAC;AACO,gCAAU"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { InputHTMLAttributes } from "react";
|
|
2
|
+
import { FormFieldProps } from "../form/useFormField";
|
|
3
|
+
interface DateInputContextProps {
|
|
4
|
+
/**
|
|
5
|
+
* Open state for popover
|
|
6
|
+
*/
|
|
7
|
+
open: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Callback for onOpen toggle
|
|
10
|
+
*/
|
|
11
|
+
onOpen: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Aria-connected ID
|
|
14
|
+
*/
|
|
15
|
+
ariaId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Flag for enabled-check
|
|
18
|
+
*/
|
|
19
|
+
defined: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const DateInputContextProvider: React.ForwardRefExoticComponent<DateInputContextProps & {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
} & React.RefAttributes<unknown>>, useDateInputContext: <S extends boolean = true>(strict?: S) => S extends true ? DateInputContextProps : DateInputContextProps | undefined;
|
|
24
|
+
export interface DateInputProps extends FormFieldProps, Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
25
|
+
/**
|
|
26
|
+
* Input label
|
|
27
|
+
*/
|
|
28
|
+
label: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Shows label and description for screen readers only
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
hideLabel?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Changes padding and font-sizes
|
|
36
|
+
* @default "medium"
|
|
37
|
+
*/
|
|
38
|
+
size?: "medium" | "small";
|
|
39
|
+
/**
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
variant?: "datepicker" | "monthpicker";
|
|
43
|
+
/**
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
setAnchorRef?: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;
|
|
47
|
+
}
|
|
48
|
+
export declare const DatePickerInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
49
|
+
export declare const MonthPickerInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
var _a;
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.MonthPickerInput = exports.DatePickerInput = exports.useDateInputContext = exports.DateInputContextProvider = void 0;
|
|
42
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
43
|
+
const react_1 = __importStar(require("react"));
|
|
44
|
+
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
45
|
+
const ReadOnlyIcon_1 = require("../form/ReadOnlyIcon");
|
|
46
|
+
const useFormField_1 = require("../form/useFormField");
|
|
47
|
+
const typography_1 = require("../typography");
|
|
48
|
+
const util_1 = require("../util");
|
|
49
|
+
const create_context_1 = require("../util/create-context");
|
|
50
|
+
const Date_locale_1 = require("./Date.locale");
|
|
51
|
+
_a = (0, create_context_1.createContext)({
|
|
52
|
+
errorMessage: "useDateInputContext must be used with DateInputContext",
|
|
53
|
+
}), exports.DateInputContextProvider = _a[0], exports.useDateInputContext = _a[1];
|
|
54
|
+
const DateInput = (0, react_1.forwardRef)((props, ref) => {
|
|
55
|
+
const { className, hideLabel = false, label, description, variant = "datepicker", setAnchorRef } = props, rest = __rest(props, ["className", "hideLabel", "label", "description", "variant", "setAnchorRef"]);
|
|
56
|
+
const buttonRef = (0, react_1.useRef)(null);
|
|
57
|
+
const translate = (0, Date_locale_1.useDateTranslationContext)().translate;
|
|
58
|
+
const isDatepickerVariant = variant === "datepicker";
|
|
59
|
+
const conditionalVariables = {
|
|
60
|
+
prefix: isDatepickerVariant ? "datepicker-input" : "monthpicker-input",
|
|
61
|
+
iconTitle: {
|
|
62
|
+
open: isDatepickerVariant ? "openDatePicker" : "openMonthPicker",
|
|
63
|
+
close: isDatepickerVariant ? "closeDatePicker" : "closeMonthPicker",
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const context = (0, exports.useDateInputContext)();
|
|
67
|
+
const { inputProps, size = "medium", inputDescriptionId, errorId, showErrorMsg, hasError, readOnly, } = (0, useFormField_1.useFormField)(props, conditionalVariables.prefix);
|
|
68
|
+
return (react_1.default.createElement("div", { className: (0, clsx_1.default)(className, "navds-form-field", `navds-form-field--${size}`, "navds-date__field", {
|
|
69
|
+
"navds-text-field--error": hasError,
|
|
70
|
+
"navds-date__field--error": hasError,
|
|
71
|
+
"navds-form-field--disabled": !!inputProps.disabled,
|
|
72
|
+
"navds-text-field--disabled": !!inputProps.disabled,
|
|
73
|
+
"navds-form-field--readonly": readOnly,
|
|
74
|
+
"navds-text-field--readonly": readOnly,
|
|
75
|
+
"navds-date__field--readonly": readOnly,
|
|
76
|
+
}) },
|
|
77
|
+
react_1.default.createElement(typography_1.Label, { htmlFor: inputProps.id, size: size, className: (0, clsx_1.default)("navds-form-field__label", {
|
|
78
|
+
"navds-sr-only": hideLabel,
|
|
79
|
+
}) },
|
|
80
|
+
readOnly && react_1.default.createElement(ReadOnlyIcon_1.ReadOnlyIcon, null),
|
|
81
|
+
label),
|
|
82
|
+
!!description && (react_1.default.createElement(typography_1.BodyShort, { as: "div", className: (0, clsx_1.default)("navds-form-field__description", {
|
|
83
|
+
"navds-sr-only": hideLabel,
|
|
84
|
+
}), id: inputDescriptionId, size: size }, description)),
|
|
85
|
+
react_1.default.createElement("div", { className: "navds-date__field-wrapper" },
|
|
86
|
+
react_1.default.createElement("input", Object.assign({ ref: ref }, (0, util_1.omit)(rest, ["error", "errorId", "size"]), inputProps, { autoComplete: "off", "aria-controls": (context === null || context === void 0 ? void 0 : context.open) ? context.ariaId : undefined, readOnly: readOnly, className: (0, clsx_1.default)("navds-date__field-input", "navds-text-field__input", "navds-body-short", `navds-body-short--${size}`), size: isDatepickerVariant ? 11 : 14 })),
|
|
87
|
+
react_1.default.createElement("button", { disabled: inputProps.disabled || readOnly, tabIndex: readOnly ? -1 : (context === null || context === void 0 ? void 0 : context.open) ? -1 : 0, onClick: () => {
|
|
88
|
+
context === null || context === void 0 ? void 0 : context.onOpen();
|
|
89
|
+
setAnchorRef === null || setAnchorRef === void 0 ? void 0 : setAnchorRef(buttonRef.current);
|
|
90
|
+
}, type: "button", className: "navds-date__field-button", ref: buttonRef },
|
|
91
|
+
react_1.default.createElement(aksel_icons_1.CalendarIcon, { title: translate(conditionalVariables.iconTitle[(context === null || context === void 0 ? void 0 : context.open) ? "close" : "open"]) }))),
|
|
92
|
+
react_1.default.createElement("div", { className: "navds-form-field__error", id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (react_1.default.createElement(typography_1.ErrorMessage, { size: size, showIcon: true }, props.error)))));
|
|
93
|
+
});
|
|
94
|
+
exports.DatePickerInput = (0, react_1.forwardRef)((props, ref) => react_1.default.createElement(DateInput, Object.assign({}, props, { ref: ref })));
|
|
95
|
+
exports.MonthPickerInput = (0, react_1.forwardRef)((props, ref) => react_1.default.createElement(DateInput, Object.assign({}, props, { variant: "monthpicker", ref: ref })));
|
|
96
|
+
//# sourceMappingURL=Date.Input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Date.Input.js","sourceRoot":"","sources":["../../src/date/Date.Input.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TFunction } from "../util/i18n/i18n.types";
|
|
2
|
+
/** @private */
|
|
3
|
+
export declare const getLocaleFromString: (locale?: "nb" | "nn" | "en") => import("date-fns/locale").Locale;
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
* Temporary for backwards compatibility with locale prop. Can be removed when locale prop has been removed.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getTranslations: (locale: string | undefined) => {
|
|
9
|
+
chooseDate: string;
|
|
10
|
+
chooseDates: string;
|
|
11
|
+
chooseDateRange: string;
|
|
12
|
+
chooseMonth: string;
|
|
13
|
+
week: string;
|
|
14
|
+
weekNumber: string;
|
|
15
|
+
selectWeekNumber: string;
|
|
16
|
+
month: string;
|
|
17
|
+
goToNextMonth: string;
|
|
18
|
+
goToPreviousMonth: string;
|
|
19
|
+
year: string;
|
|
20
|
+
goToNextYear: string;
|
|
21
|
+
goToPreviousYear: string;
|
|
22
|
+
openDatePicker: string;
|
|
23
|
+
openMonthPicker: string;
|
|
24
|
+
closeDatePicker: string;
|
|
25
|
+
closeMonthPicker: string;
|
|
26
|
+
} | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
* Temporary for backwards compatibility with locale prop. Can be removed when locale prop has been removed.
|
|
30
|
+
*/
|
|
31
|
+
export declare const getGlobalTranslations: (locale: string | undefined) => {
|
|
32
|
+
dateLocale: import("date-fns/locale").Locale;
|
|
33
|
+
showMore: string;
|
|
34
|
+
showLess: string;
|
|
35
|
+
readOnly: string;
|
|
36
|
+
close: string;
|
|
37
|
+
} | undefined;
|
|
38
|
+
interface DateTranslationContextProps {
|
|
39
|
+
translate: TFunction<"DatePicker">;
|
|
40
|
+
}
|
|
41
|
+
export declare const DateTranslationContextProvider: import("react").ForwardRefExoticComponent<DateTranslationContextProps & {
|
|
42
|
+
children: import("react").ReactNode;
|
|
43
|
+
} & import("react").RefAttributes<unknown>>, useDateTranslationContext: <S extends boolean = true>(strict?: S) => S extends true ? DateTranslationContextProps : DateTranslationContextProps | undefined;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.useDateTranslationContext = exports.DateTranslationContextProvider = exports.getGlobalTranslations = exports.getTranslations = exports.getLocaleFromString = void 0;
|
|
8
|
+
const locale_1 = require("date-fns/locale");
|
|
9
|
+
const create_context_1 = require("../util/create-context");
|
|
10
|
+
const en_1 = __importDefault(require("../util/i18n/locales/en"));
|
|
11
|
+
const nn_1 = __importDefault(require("../util/i18n/locales/nn"));
|
|
12
|
+
/** @private */
|
|
13
|
+
const getLocaleFromString = (locale = "nb") => {
|
|
14
|
+
switch (locale) {
|
|
15
|
+
case "nn":
|
|
16
|
+
return locale_1.nn;
|
|
17
|
+
case "en":
|
|
18
|
+
return locale_1.enGB;
|
|
19
|
+
default:
|
|
20
|
+
return locale_1.nb;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.getLocaleFromString = getLocaleFromString;
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* Temporary for backwards compatibility with locale prop. Can be removed when locale prop has been removed.
|
|
27
|
+
*/
|
|
28
|
+
const getTranslations = (locale) => {
|
|
29
|
+
switch (locale) {
|
|
30
|
+
case "nn":
|
|
31
|
+
return nn_1.default.DatePicker;
|
|
32
|
+
case "en":
|
|
33
|
+
case "en-GB":
|
|
34
|
+
return en_1.default.DatePicker;
|
|
35
|
+
default:
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.getTranslations = getTranslations;
|
|
40
|
+
/**
|
|
41
|
+
* @private
|
|
42
|
+
* Temporary for backwards compatibility with locale prop. Can be removed when locale prop has been removed.
|
|
43
|
+
*/
|
|
44
|
+
const getGlobalTranslations = (locale) => {
|
|
45
|
+
switch (locale) {
|
|
46
|
+
case "nn":
|
|
47
|
+
return nn_1.default.global;
|
|
48
|
+
case "en":
|
|
49
|
+
case "en-GB":
|
|
50
|
+
return en_1.default.global;
|
|
51
|
+
default:
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.getGlobalTranslations = getGlobalTranslations;
|
|
56
|
+
_a = (0, create_context_1.createContext)(), exports.DateTranslationContextProvider = _a[0], exports.useDateTranslationContext = _a[1];
|
|
57
|
+
//# sourceMappingURL=Date.locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Date.locale.js","sourceRoot":"","sources":["../../src/date/Date.locale.ts"],"names":[],"mappings":";;;;;;;AAAA,4CAA+C;AAC/C,2DAAuD;AAEvD,iEAAsD;AACtD,iEAAsD;AAEtD,eAAe;AACR,MAAM,mBAAmB,GAAG,CAAC,SAA6B,IAAI,EAAE,EAAE;IACvE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,IAAI;YACP,OAAO,WAAE,CAAC;QACZ,KAAK,IAAI;YACP,OAAO,aAAI,CAAC;QACd;YACE,OAAO,WAAE,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B;AAEF;;;GAGG;AACI,MAAM,eAAe,GAAG,CAAC,MAA0B,EAAE,EAAE;IAC5D,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,IAAI;YACP,OAAO,YAAe,CAAC,UAAU,CAAC;QACpC,KAAK,IAAI,CAAC;QACV,KAAK,OAAO;YACV,OAAO,YAAe,CAAC,UAAU,CAAC;QACpC;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B;AAEF;;;GAGG;AACI,MAAM,qBAAqB,GAAG,CAAC,MAA0B,EAAE,EAAE;IAClE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,IAAI;YACP,OAAO,YAAe,CAAC,MAAM,CAAC;QAChC,KAAK,IAAI,CAAC;QACV,KAAK,OAAO;YACV,OAAO,YAAe,CAAC,MAAM,CAAC;QAChC;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,qBAAqB,yBAUhC;AAMW,KACX,IAAA,8BAAa,GAA+B,EADhC,sCAA8B,UAAE,iCAAyB,SACxB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type DateRange = {
|
|
2
|
+
from: Date | undefined;
|
|
3
|
+
to?: Date | undefined;
|
|
4
|
+
};
|
|
5
|
+
export type DateBefore = {
|
|
6
|
+
before: Date;
|
|
7
|
+
};
|
|
8
|
+
export type DateAfter = {
|
|
9
|
+
after: Date;
|
|
10
|
+
};
|
|
11
|
+
export declare function isDateAfterType(value: unknown): value is DateAfter;
|
|
12
|
+
export declare function isDateBeforeType(value: unknown): value is DateBefore;
|
|
13
|
+
export declare function isDateRange(value: unknown): value is DateRange;
|
|
14
|
+
export type Matcher = ((date: Date) => boolean) | Date | Date[] | DateRange | DateBefore | DateAfter;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDateAfterType = isDateAfterType;
|
|
4
|
+
exports.isDateBeforeType = isDateBeforeType;
|
|
5
|
+
exports.isDateRange = isDateRange;
|
|
6
|
+
function isDateAfterType(value) {
|
|
7
|
+
return Boolean(value && typeof value === "object" && "after" in value);
|
|
8
|
+
}
|
|
9
|
+
function isDateBeforeType(value) {
|
|
10
|
+
return Boolean(value && typeof value === "object" && "before" in value);
|
|
11
|
+
}
|
|
12
|
+
function isDateRange(value) {
|
|
13
|
+
return Boolean(value && typeof value === "object" && "from" in value);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Date.typeutils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Date.typeutils.js","sourceRoot":"","sources":["../../src/date/Date.typeutils.ts"],"names":[],"mappings":";;AAaA,0CAEC;AAED,4CAEC;AAED,kCAEC;AAVD,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,CAAC,CAAC;AACzE,CAAC;AAED,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,CAAC,CAAC;AAC1E,CAAC;AAED,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the min and max-dates possible to show and navigate to in the calendar.
|
|
3
|
+
* In the cases there is not a startMonth or endMonth, and layout is "label" no min or max dates are set.
|
|
4
|
+
* @returns Return the start and end months for the calendar navigation.
|
|
5
|
+
*/
|
|
6
|
+
export declare function calendarRange({ captionLayout, startMonth, endMonth, today, }: {
|
|
7
|
+
captionLayout?: "label" | "dropdown";
|
|
8
|
+
startMonth?: Date;
|
|
9
|
+
endMonth?: Date;
|
|
10
|
+
today?: Date;
|
|
11
|
+
}): (Date | undefined)[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calendarRange = calendarRange;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
/**
|
|
6
|
+
* Generates the min and max-dates possible to show and navigate to in the calendar.
|
|
7
|
+
* In the cases there is not a startMonth or endMonth, and layout is "label" no min or max dates are set.
|
|
8
|
+
* @returns Return the start and end months for the calendar navigation.
|
|
9
|
+
*/
|
|
10
|
+
function calendarRange({ captionLayout, startMonth, endMonth, today, }) {
|
|
11
|
+
const hasYearDropdown = captionLayout === "dropdown";
|
|
12
|
+
const todayDate = today !== null && today !== void 0 ? today : new Date();
|
|
13
|
+
if (startMonth) {
|
|
14
|
+
startMonth = (0, date_fns_1.startOfMonth)(startMonth);
|
|
15
|
+
}
|
|
16
|
+
else if (!startMonth && hasYearDropdown) {
|
|
17
|
+
startMonth = (0, date_fns_1.startOfYear)((0, date_fns_1.addYears)(todayDate, -100));
|
|
18
|
+
}
|
|
19
|
+
if (endMonth) {
|
|
20
|
+
endMonth = (0, date_fns_1.endOfMonth)(endMonth);
|
|
21
|
+
}
|
|
22
|
+
else if (!endMonth && hasYearDropdown) {
|
|
23
|
+
endMonth = (0, date_fns_1.endOfYear)(todayDate);
|
|
24
|
+
}
|
|
25
|
+
return [
|
|
26
|
+
startMonth ? (0, date_fns_1.startOfDay)(startMonth) : startMonth,
|
|
27
|
+
endMonth ? (0, date_fns_1.startOfDay)(endMonth) : endMonth,
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=calendar-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-range.js","sourceRoot":"","sources":["../../../src/date/date-utils/calendar-range.ts"],"names":[],"mappings":";;AAcA,sCA+BC;AA7CD,uCAOkB;AAElB;;;;GAIG;AACH,SAAgB,aAAa,CAAC,EAC5B,aAAa,EACb,UAAU,EACV,QAAQ,EACR,KAAK,GAMN;IACC,MAAM,eAAe,GAAG,aAAa,KAAK,UAAU,CAAC;IAErD,MAAM,SAAS,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,IAAI,EAAE,CAAC;IAEtC,IAAI,UAAU,EAAE,CAAC;QACf,UAAU,GAAG,IAAA,uBAAY,EAAC,UAAU,CAAC,CAAC;IACxC,CAAC;SAAM,IAAI,CAAC,UAAU,IAAI,eAAe,EAAE,CAAC;QAC1C,UAAU,GAAG,IAAA,sBAAW,EAAC,IAAA,mBAAQ,EAAC,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,GAAG,IAAA,qBAAU,EAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;SAAM,IAAI,CAAC,QAAQ,IAAI,eAAe,EAAE,CAAC;QACxC,QAAQ,GAAG,IAAA,oBAAS,EAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAED,OAAO;QACL,UAAU,CAAC,CAAC,CAAC,IAAA,qBAAU,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU;QAChD,QAAQ,CAAC,CAAC,CAAC,IAAA,qBAAU,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const dateIsInCurrentMonth: (date: Date, dateToCompare: Date) => boolean;
|
|
2
|
+
/** @private */
|
|
3
|
+
export declare function isValidDate(day?: Date): boolean;
|
|
4
|
+
export declare function isDateOutsideRange({ day, fromDate, toDate, }: {
|
|
5
|
+
day: Date;
|
|
6
|
+
fromDate?: Date;
|
|
7
|
+
toDate?: Date;
|
|
8
|
+
}): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dateIsInCurrentMonth = void 0;
|
|
4
|
+
exports.isValidDate = isValidDate;
|
|
5
|
+
exports.isDateOutsideRange = isDateOutsideRange;
|
|
6
|
+
const date_fns_1 = require("date-fns");
|
|
7
|
+
const dateIsInCurrentMonth = (date, dateToCompare) => {
|
|
8
|
+
return (0, date_fns_1.isThisMonth)((0, date_fns_1.setYear)(date, Number(dateToCompare.getFullYear())));
|
|
9
|
+
};
|
|
10
|
+
exports.dateIsInCurrentMonth = dateIsInCurrentMonth;
|
|
11
|
+
/** @private */
|
|
12
|
+
function isValidDate(day) {
|
|
13
|
+
return !!(day && !Number.isNaN(day.getTime()) && day.getFullYear() > 999);
|
|
14
|
+
}
|
|
15
|
+
function isDateOutsideRange({ day, fromDate, toDate, }) {
|
|
16
|
+
const isDateAfter = toDate && (0, date_fns_1.differenceInCalendarDays)(day, toDate) > 0;
|
|
17
|
+
const isDateBefore = fromDate && (0, date_fns_1.differenceInCalendarDays)(fromDate, day) > 0;
|
|
18
|
+
return isDateAfter || isDateBefore || false;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=check-dates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-dates.js","sourceRoot":"","sources":["../../../src/date/date-utils/check-dates.ts"],"names":[],"mappings":";;;AAUA,kCAEC;AAED,gDAaC;AA3BD,uCAA0E;AAEnE,MAAM,oBAAoB,GAAG,CAClC,IAAU,EACV,aAAmB,EACV,EAAE;IACX,OAAO,IAAA,sBAAW,EAAC,IAAA,kBAAO,EAAC,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC,CAAC;AALW,QAAA,oBAAoB,wBAK/B;AAEF,eAAe;AACf,SAAgB,WAAW,CAAC,GAAU;IACpC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC;AAC5E,CAAC;AAED,SAAgB,kBAAkB,CAAC,EACjC,GAAG,EACH,QAAQ,EACR,MAAM,GAKP;IACC,MAAM,WAAW,GAAG,MAAM,IAAI,IAAA,mCAAwB,EAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACxE,MAAM,YAAY,GAAG,QAAQ,IAAI,IAAA,mCAAwB,EAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAE7E,OAAO,WAAW,IAAI,YAAY,IAAI,KAAK,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes sure the month is within the min and max daterange to avoid showing disabled months
|
|
3
|
+
* @note We do not warn the user if start > end now
|
|
4
|
+
*/
|
|
5
|
+
declare const clampDisplayMonth: ({ month, start, end, }: {
|
|
6
|
+
month?: Date;
|
|
7
|
+
start?: Date;
|
|
8
|
+
end?: Date;
|
|
9
|
+
}) => Date | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Makes sure the month is within the min and max daterange to avoid showing disabled months
|
|
12
|
+
* @note We do not warn the user if start > end now
|
|
13
|
+
*/
|
|
14
|
+
declare const clampDisplayYear: ({ month, start, end, }: {
|
|
15
|
+
month?: Date;
|
|
16
|
+
start?: Date;
|
|
17
|
+
end?: Date;
|
|
18
|
+
}) => Date | undefined;
|
|
19
|
+
export { clampDisplayYear, clampDisplayMonth };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clampDisplayMonth = exports.clampDisplayYear = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
/**
|
|
6
|
+
* Makes sure the month is within the min and max daterange to avoid showing disabled months
|
|
7
|
+
* @note We do not warn the user if start > end now
|
|
8
|
+
*/
|
|
9
|
+
const clampDisplayMonth = ({ month, start, end, }) => {
|
|
10
|
+
if (!month) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
let monthToShow = month;
|
|
14
|
+
if (start && (0, date_fns_1.isBefore)(monthToShow, start)) {
|
|
15
|
+
monthToShow = start;
|
|
16
|
+
}
|
|
17
|
+
if (end && (0, date_fns_1.isAfter)(monthToShow, end)) {
|
|
18
|
+
monthToShow = end;
|
|
19
|
+
}
|
|
20
|
+
return (0, date_fns_1.startOfMonth)(monthToShow);
|
|
21
|
+
};
|
|
22
|
+
exports.clampDisplayMonth = clampDisplayMonth;
|
|
23
|
+
/**
|
|
24
|
+
* Makes sure the month is within the min and max daterange to avoid showing disabled months
|
|
25
|
+
* @note We do not warn the user if start > end now
|
|
26
|
+
*/
|
|
27
|
+
const clampDisplayYear = ({ month, start, end, }) => {
|
|
28
|
+
if (!month) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
let monthToShow = month;
|
|
32
|
+
if (start && monthToShow.getFullYear() < start.getFullYear()) {
|
|
33
|
+
monthToShow = start;
|
|
34
|
+
}
|
|
35
|
+
if (end && monthToShow.getFullYear() > end.getFullYear()) {
|
|
36
|
+
monthToShow = end;
|
|
37
|
+
}
|
|
38
|
+
return (0, date_fns_1.startOfYear)(monthToShow);
|
|
39
|
+
};
|
|
40
|
+
exports.clampDisplayYear = clampDisplayYear;
|
|
41
|
+
//# sourceMappingURL=clamp-dates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp-dates.js","sourceRoot":"","sources":["../../../src/date/date-utils/clamp-dates.ts"],"names":[],"mappings":";;;AAAA,uCAAwE;AAExE;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CAAC,EACzB,KAAK,EACL,KAAK,EACL,GAAG,GAKJ,EAAoB,EAAE;IACrB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,IAAI,KAAK,IAAI,IAAA,mBAAQ,EAAC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;QAC1C,WAAW,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,GAAG,IAAI,IAAA,kBAAO,EAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC;QACrC,WAAW,GAAG,GAAG,CAAC;IACpB,CAAC;IAED,OAAO,IAAA,uBAAY,EAAC,WAAW,CAAC,CAAC;AACnC,CAAC,CAAC;AAgCyB,8CAAiB;AA9B5C;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,EACxB,KAAK,EACL,KAAK,EACL,GAAG,GAKJ,EAAoB,EAAE;IACrB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,IAAI,KAAK,IAAI,WAAW,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7D,WAAW,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,GAAG,IAAI,WAAW,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;QACzD,WAAW,GAAG,GAAG,CAAC;IACpB,CAAC;IAED,OAAO,IAAA,sBAAW,EAAC,WAAW,CAAC,CAAC;AAClC,CAAC,CAAC;AAEO,4CAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const disableDate: (disabledSelection: Date | any[], date: Date) => boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.disableDate = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
const Date_typeutils_1 = require("../Date.typeutils");
|
|
6
|
+
const disableDate = (disabledSelection, date) => {
|
|
7
|
+
let result = false;
|
|
8
|
+
if (disabledSelection instanceof Date) {
|
|
9
|
+
return (0, date_fns_1.isSameDay)(disabledSelection, date);
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(disabledSelection)) {
|
|
12
|
+
for (let i = 0; i < disabledSelection.length; i++) {
|
|
13
|
+
const selection = disabledSelection[i];
|
|
14
|
+
if ((0, Date_typeutils_1.isDateRange)(selection)) {
|
|
15
|
+
if (selection.from && selection.to) {
|
|
16
|
+
result = date >= selection.from && date <= selection.to;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (selection instanceof Date) {
|
|
20
|
+
result = (0, date_fns_1.isSameDay)(selection, date);
|
|
21
|
+
}
|
|
22
|
+
if (result)
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
exports.disableDate = disableDate;
|
|
29
|
+
//# sourceMappingURL=dates-disabled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dates-disabled.js","sourceRoot":"","sources":["../../../src/date/date-utils/dates-disabled.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,sDAAgD;AAEzC,MAAM,WAAW,GAAG,CACzB,iBAA+B,EAC/B,IAAU,EACD,EAAE;IACX,IAAI,MAAM,GAAY,KAAK,CAAC;IAC5B,IAAI,iBAAiB,YAAY,IAAI,EAAE,CAAC;QACtC,OAAO,IAAA,oBAAS,EAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClD,MAAM,SAAS,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;YACvC,IAAI,IAAA,4BAAW,EAAC,SAAS,CAAC,EAAE,CAAC;gBAC3B,IAAI,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,EAAE,EAAE,CAAC;oBACnC,MAAM,GAAG,IAAI,IAAI,SAAS,CAAC,IAAI,IAAI,IAAI,IAAI,SAAS,CAAC,EAAE,CAAC;gBAC1D,CAAC;YACH,CAAC;iBAAM,IAAI,SAAS,YAAY,IAAI,EAAE,CAAC;gBACrC,MAAM,GAAG,IAAA,oBAAS,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACtC,CAAC;YACD,IAAI,MAAM;gBAAE,MAAM;QACpB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAvBW,QAAA,WAAW,eAuBtB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Locale } from "date-fns";
|
|
2
|
+
/** Return the months to show in the dropdown. */
|
|
3
|
+
export declare function getMonthOptions(displayMonth: Date, navStart: Date | undefined, navEnd: Date | undefined, locale: Locale): {
|
|
4
|
+
value: number;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
}[] | undefined;
|
|
8
|
+
/** Return the years to show in the dropdown. */
|
|
9
|
+
export declare function getYearOptions(navStart: Date | undefined, navEnd: Date | undefined, locale: Locale): {
|
|
10
|
+
value: number;
|
|
11
|
+
label: string;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
}[] | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMonthOptions = getMonthOptions;
|
|
4
|
+
exports.getYearOptions = getYearOptions;
|
|
5
|
+
const date_fns_1 = require("date-fns");
|
|
6
|
+
/** Return the months to show in the dropdown. */
|
|
7
|
+
function getMonthOptions(displayMonth, navStart, navEnd, locale) {
|
|
8
|
+
const months = (0, date_fns_1.eachMonthOfInterval)({
|
|
9
|
+
start: (0, date_fns_1.startOfYear)(displayMonth),
|
|
10
|
+
end: (0, date_fns_1.endOfYear)(displayMonth),
|
|
11
|
+
});
|
|
12
|
+
const options = months.map((month) => {
|
|
13
|
+
const label = (0, date_fns_1.format)(month, "LLLL", { locale });
|
|
14
|
+
const value = (0, date_fns_1.getMonth)(month);
|
|
15
|
+
const disabled = (navStart && month < (0, date_fns_1.startOfMonth)(navStart)) ||
|
|
16
|
+
(navEnd && month > (0, date_fns_1.startOfMonth)(navEnd)) ||
|
|
17
|
+
false;
|
|
18
|
+
return { value, label, disabled };
|
|
19
|
+
});
|
|
20
|
+
return options;
|
|
21
|
+
}
|
|
22
|
+
/** Return the years to show in the dropdown. */
|
|
23
|
+
function getYearOptions(navStart, navEnd, locale) {
|
|
24
|
+
if (!navStart)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (!navEnd)
|
|
27
|
+
return undefined;
|
|
28
|
+
const firstNavYear = (0, date_fns_1.startOfYear)(navStart);
|
|
29
|
+
const lastNavYear = (0, date_fns_1.endOfYear)(navEnd);
|
|
30
|
+
const years = [];
|
|
31
|
+
let year = firstNavYear;
|
|
32
|
+
while ((0, date_fns_1.isBefore)(year, lastNavYear) || (0, date_fns_1.isSameYear)(year, lastNavYear)) {
|
|
33
|
+
years.push(year);
|
|
34
|
+
year = (0, date_fns_1.addYears)(year, 1);
|
|
35
|
+
}
|
|
36
|
+
return years.map((_year) => {
|
|
37
|
+
const label = (0, date_fns_1.format)(_year, "yyyy", { locale });
|
|
38
|
+
return {
|
|
39
|
+
value: (0, date_fns_1.getYear)(_year),
|
|
40
|
+
label,
|
|
41
|
+
disabled: false,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=dropdown-options.js.map
|