react-day-picker 8.0.0-beta.33 → 8.0.0-beta.35
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/CHANGELOG.md +8 -0
- package/build/components/Button/Button.js +1 -0
- package/build/components/Button/Button.js.map +1 -1
- package/build/components/Caption/Caption.js +3 -2
- package/build/components/Caption/Caption.js.map +1 -1
- package/build/components/CaptionLabel/CaptionLabel.js +1 -0
- package/build/components/CaptionLabel/CaptionLabel.js.map +1 -1
- package/build/components/Day/hooks/useDay.d.ts +3 -3
- package/build/components/Day/hooks/useDay.js +5 -5
- package/build/components/Day/hooks/useDay.js.map +1 -1
- package/build/components/Day/hooks/useDayFocus.js +22 -8
- package/build/components/Day/hooks/useDayFocus.js.map +1 -1
- package/build/components/DayContent/DayContent.js +1 -0
- package/build/components/DayContent/DayContent.js.map +1 -1
- package/build/components/Dropdown/Dropdown.js +1 -0
- package/build/components/Dropdown/Dropdown.js.map +1 -1
- package/build/components/Footer/Footer.js +1 -0
- package/build/components/Footer/Footer.js.map +1 -1
- package/build/components/Head/Head.js +1 -0
- package/build/components/Head/Head.js.map +1 -1
- package/build/components/MonthsDropdown/MonthsDropdown.js +1 -0
- package/build/components/MonthsDropdown/MonthsDropdown.js.map +1 -1
- package/build/components/Navigation/Navigation.js +1 -0
- package/build/components/Navigation/Navigation.js.map +1 -1
- package/build/components/Root/Root.js +1 -0
- package/build/components/Root/Root.js.map +1 -1
- package/build/components/Row/Row.js +1 -0
- package/build/components/Row/Row.js.map +1 -1
- package/build/components/Table/Table.js +1 -0
- package/build/components/Table/Table.js.map +1 -1
- package/build/components/WeekNumber/WeekNumber.js +1 -0
- package/build/components/WeekNumber/WeekNumber.js.map +1 -1
- package/build/components/YearsDropdown/YearsDropdown.js +1 -0
- package/build/components/YearsDropdown/YearsDropdown.js.map +1 -1
- package/build/components/index.d.ts +0 -5
- package/build/contexts/DayPicker/DayPickerProvider.js +4 -4
- package/build/contexts/DayPicker/DayPickerProvider.js.map +1 -1
- package/build/contexts/DayPicker/index.d.ts +1 -0
- package/build/contexts/DayPicker/utils/parseModifierProps.d.ts +1 -2
- package/build/contexts/DayPicker/utils/parseModifierProps.js +1 -2
- package/build/contexts/DayPicker/utils/parseModifierProps.js.map +1 -1
- package/build/contexts/Focus/FocusContext.d.ts +6 -0
- package/build/contexts/Focus/FocusContext.js +55 -6
- package/build/contexts/Focus/FocusContext.js.map +1 -1
- package/build/contexts/Navigation/NavigationContext.js +1 -0
- package/build/contexts/Navigation/NavigationContext.js.map +1 -1
- package/build/contexts/Navigation/useNavigationState.js +1 -0
- package/build/contexts/Navigation/useNavigationState.js.map +1 -1
- package/build/contexts/RootProvider.js.map +1 -1
- package/build/contexts/SelectMultiple/SelectMultipleContext.d.ts +1 -1
- package/build/contexts/SelectMultiple/SelectMultipleContext.js +2 -2
- package/build/contexts/SelectMultiple/SelectMultipleContext.js.map +1 -1
- package/build/contexts/SelectRange/SelectRangeContext.d.ts +1 -1
- package/build/contexts/SelectRange/SelectRangeContext.js +2 -2
- package/build/contexts/SelectRange/SelectRangeContext.js.map +1 -1
- package/build/contexts/SelectSingle/SelectSingleContext.d.ts +1 -1
- package/build/contexts/SelectSingle/SelectSingleContext.js +2 -2
- package/build/contexts/SelectSingle/SelectSingleContext.js.map +1 -1
- package/build/contexts/index.d.ts +1 -1
- package/build/hooks/index.d.ts +0 -1
- package/build/hooks/useInput/useInput.d.ts +1 -1
- package/build/hooks/useInput/useInput.js.map +1 -1
- package/build/hooks/useModifiers/useModifiers.js +4 -3
- package/build/hooks/useModifiers/useModifiers.js.map +1 -1
- package/build/hooks/useModifiers/utils/getModifierStatus.js.map +1 -1
- package/build/hooks/useModifiers/utils/isMatch.js.map +1 -1
- package/build/main.js +2 -7
- package/build/main.js.map +1 -1
- package/build/packages/react-day-picker/src/DayPicker.d.ts +89 -0
- package/build/packages/react-day-picker/src/components/Button/Button.d.ts +7 -0
- package/build/packages/react-day-picker/src/components/Button/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Caption/Caption.d.ts +18 -0
- package/build/packages/react-day-picker/src/components/Caption/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/CaptionLabel/CaptionLabel.d.ts +8 -0
- package/build/packages/react-day-picker/src/components/CaptionLabel/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Day/Day.d.ts +13 -0
- package/build/packages/react-day-picker/src/components/Day/hooks/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Day/hooks/useDay.d.ts +58 -0
- package/build/packages/react-day-picker/src/components/Day/hooks/useDayFocus.d.ts +8 -0
- package/build/packages/react-day-picker/src/components/Day/index.d.ts +2 -0
- package/build/packages/react-day-picker/src/components/DayContent/DayContent.d.ts +15 -0
- package/build/packages/react-day-picker/src/components/DayContent/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Dropdown/Dropdown.d.ts +16 -0
- package/build/packages/react-day-picker/src/components/Dropdown/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Footer/Footer.d.ts +3 -0
- package/build/packages/react-day-picker/src/components/Footer/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Head/Head.d.ts +5 -0
- package/build/packages/react-day-picker/src/components/Head/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Head/utils/getWeekdays.d.ts +6 -0
- package/build/packages/react-day-picker/src/components/Head/utils/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/IconDropdown/IconDropdown.d.ts +6 -0
- package/build/packages/react-day-picker/src/components/IconDropdown/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/IconLeft/IconLeft.d.ts +6 -0
- package/build/packages/react-day-picker/src/components/IconLeft/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/IconRight/IconRight.d.ts +6 -0
- package/build/packages/react-day-picker/src/components/IconRight/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/MonthsDropdown/MonthsDropdown.d.ts +12 -0
- package/build/packages/react-day-picker/src/components/MonthsDropdown/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Navigation/Navigation.d.ts +20 -0
- package/build/packages/react-day-picker/src/components/Navigation/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Root/Root.d.ts +6 -0
- package/build/packages/react-day-picker/src/components/Root/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Row/Row.d.ts +16 -0
- package/build/packages/react-day-picker/src/components/Row/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Table/Table.d.ts +12 -0
- package/build/packages/react-day-picker/src/components/Table/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/Table/utils/getOutsideEndDays.d.ts +3 -0
- package/build/packages/react-day-picker/src/components/Table/utils/getOutsideStartDays.d.ts +4 -0
- package/build/packages/react-day-picker/src/components/Table/utils/getWeeks.d.ts +17 -0
- package/build/packages/react-day-picker/src/components/WeekNumber/WeekNumber.d.ts +15 -0
- package/build/packages/react-day-picker/src/components/WeekNumber/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/YearsDropdown/YearsDropdown.d.ts +16 -0
- package/build/packages/react-day-picker/src/components/YearsDropdown/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/components/index.d.ts +13 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/DayPickerContext.d.ts +31 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/DayPickerProvider.d.ts +12 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/defaultClassNames.d.ts +5 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/formatters/formatCaption.d.ts +7 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/formatters/formatDay.d.ts +7 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/formatters/formatMonthCaption.d.ts +7 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/formatters/formatWeekNumber.d.ts +4 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/formatters/formatWeekdayName.d.ts +7 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/formatters/formatYearCaption.d.ts +6 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/formatters/index.d.ts +6 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/index.d.ts +2 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/labels/index.d.ts +7 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/labels/labelDay.d.ts +5 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/labels/labelMonthDropdown.d.ts +4 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/labels/labelNext.d.ts +5 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/labels/labelPrevious.d.ts +5 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/labels/labelWeekNumber.d.ts +5 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/labels/labelWeekday.d.ts +5 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/labels/labelYearDropdown.d.ts +4 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/useDayPicker.d.ts +8 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/utils/index.d.ts +2 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/utils/parseFromToProps.d.ts +9 -0
- package/build/packages/react-day-picker/src/contexts/DayPicker/utils/parseModifierProps.d.ts +8 -0
- package/build/packages/react-day-picker/src/contexts/Focus/FocusContext.d.ts +30 -0
- package/build/packages/react-day-picker/src/contexts/Focus/index.d.ts +2 -0
- package/build/packages/react-day-picker/src/contexts/Focus/useFocus.d.ts +3 -0
- package/build/packages/react-day-picker/src/contexts/Navigation/NavigationContext.d.ts +24 -0
- package/build/packages/react-day-picker/src/contexts/Navigation/index.d.ts +2 -0
- package/build/packages/react-day-picker/src/contexts/Navigation/useNavigation.d.ts +3 -0
- package/build/packages/react-day-picker/src/contexts/Navigation/useNavigationState.d.ts +7 -0
- package/build/packages/react-day-picker/src/contexts/Navigation/utils/getDisplayMonths.d.ts +8 -0
- package/build/packages/react-day-picker/src/contexts/Navigation/utils/getInitialMonth.d.ts +3 -0
- package/build/packages/react-day-picker/src/contexts/Navigation/utils/getNextMonth.d.ts +18 -0
- package/build/packages/react-day-picker/src/contexts/Navigation/utils/getPreviousMonth.d.ts +19 -0
- package/build/packages/react-day-picker/src/contexts/RootProvider.d.ts +8 -0
- package/build/packages/react-day-picker/src/contexts/SelectMultiple/SelectMultipleContext.d.ts +32 -0
- package/build/packages/react-day-picker/src/contexts/SelectMultiple/index.d.ts +2 -0
- package/build/packages/react-day-picker/src/contexts/SelectMultiple/useSelectMultiple.d.ts +3 -0
- package/build/packages/react-day-picker/src/contexts/SelectRange/SelectRangeContext.d.ts +32 -0
- package/build/packages/react-day-picker/src/contexts/SelectRange/index.d.ts +2 -0
- package/build/packages/react-day-picker/src/contexts/SelectRange/useSelectRange.d.ts +3 -0
- package/build/packages/react-day-picker/src/contexts/SelectRange/utils/addToRange.d.ts +8 -0
- package/build/packages/react-day-picker/src/contexts/SelectSingle/SelectSingleContext.d.ts +35 -0
- package/build/packages/react-day-picker/src/contexts/SelectSingle/index.d.ts +2 -0
- package/build/packages/react-day-picker/src/contexts/SelectSingle/useSelectSingle.d.ts +3 -0
- package/build/packages/react-day-picker/src/contexts/index.d.ts +7 -0
- package/build/packages/react-day-picker/src/hooks/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/hooks/useControlledValue/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/hooks/useControlledValue/useControlledValue.d.ts +12 -0
- package/build/packages/react-day-picker/src/hooks/useInput/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/hooks/useInput/useInput.d.ts +28 -0
- package/build/packages/react-day-picker/src/hooks/useInput/utils/isValidDate.d.ts +2 -0
- package/build/packages/react-day-picker/src/hooks/useModifiers/index.d.ts +1 -0
- package/build/packages/react-day-picker/src/hooks/useModifiers/useModifiers.d.ts +3 -0
- package/build/packages/react-day-picker/src/hooks/useModifiers/utils/getModifierStatus.d.ts +7 -0
- package/build/packages/react-day-picker/src/hooks/useModifiers/utils/isDateInRange.d.ts +3 -0
- package/build/packages/react-day-picker/src/hooks/useModifiers/utils/isMatch.d.ts +5 -0
- package/build/packages/react-day-picker/src/main.d.ts +5 -0
- package/build/packages/react-day-picker/src/types/DayPicker.d.ts +225 -0
- package/build/packages/react-day-picker/src/types/DayPickerCustom.d.ts +11 -0
- package/build/packages/react-day-picker/src/types/DayPickerMultiple.d.ts +16 -0
- package/build/packages/react-day-picker/src/types/DayPickerRange.d.ts +17 -0
- package/build/packages/react-day-picker/src/types/DayPickerSingle.d.ts +14 -0
- package/build/packages/react-day-picker/src/types/EventHandlers.d.ts +51 -0
- package/build/packages/react-day-picker/src/types/Formatters.d.ts +24 -0
- package/build/packages/react-day-picker/src/types/Labels.d.ts +28 -0
- package/build/packages/react-day-picker/src/types/Matchers.d.ts +34 -0
- package/build/packages/react-day-picker/src/types/Modifiers.d.ts +16 -0
- package/build/packages/react-day-picker/src/types/Styles.d.ts +85 -0
- package/build/packages/react-day-picker/src/types/index.d.ts +11 -0
- package/build/test/PageObjects.d.ts +3 -0
- package/build/test/customRender.d.ts +1 -1
- package/build/test/customRenderHook.d.ts +1 -1
- package/build/test/po.d.ts +29 -0
- package/build/test/setup.d.ts +0 -1
- package/build/test/utils.d.ts +2 -0
- package/build/types/DayPicker.d.ts +5 -8
- package/dist/main.js +270 -207
- package/dist/main.js.map +1 -1
- package/package.json +9 -18
- package/build/test/index.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,14 @@ See the preview website at https://react-day-picker-next.netlify.app.
|
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
+
### v8.0.0-beta.35
|
|
22
|
+
|
|
23
|
+
- feat: add extended keyboard navigation (#1300) (2a098719)
|
|
24
|
+
- chore: export missing Button component (5ba65841)
|
|
25
|
+
- chore: rename `handleDayClick` to `onDayClick` (3d1678b2)
|
|
26
|
+
- chore: limit documented exports (c2fbd576)
|
|
27
|
+
- build: fix circular dependency (5cd0c2c8)
|
|
28
|
+
|
|
21
29
|
### v8.0.0-beta.33
|
|
22
30
|
|
|
23
31
|
- chore: unify context files (#1303) (d66b3981)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __assign } from '../../_virtual/_tslib.js';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
|
|
4
|
+
import '../../contexts/DayPicker/DayPickerContext.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Render a button HTML element applying the reset class name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/** The props for the [[Button]] component. */\nexport type ButtonProps = React.HTMLProps<HTMLButtonElement>;\n\n/**\n * Render a button HTML element applying the reset class name.\n */\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (props, ref) => {\n const { classNames, styles } = useDayPicker();\n\n const classNamesArr = [classNames.button_reset, classNames.button];\n if (props.className) {\n classNamesArr.push(props.className);\n }\n const className = classNamesArr.join(' ');\n\n const style = { ...styles.button_reset, ...styles.button };\n if (props.style) {\n Object.assign(style, props.style);\n }\n\n return (\n <button\n {...props}\n ref={ref}\n type=\"button\"\n className={className}\n style={style}\n />\n );\n }\n);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/** The props for the [[Button]] component. */\nexport type ButtonProps = React.HTMLProps<HTMLButtonElement>;\n\n/**\n * Render a button HTML element applying the reset class name.\n */\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (props, ref) => {\n const { classNames, styles } = useDayPicker();\n\n const classNamesArr = [classNames.button_reset, classNames.button];\n if (props.className) {\n classNamesArr.push(props.className);\n }\n const className = classNamesArr.join(' ');\n\n const style = { ...styles.button_reset, ...styles.button };\n if (props.style) {\n Object.assign(style, props.style);\n }\n\n return (\n <button\n {...props}\n ref={ref}\n type=\"button\"\n className={className}\n style={style}\n />\n );\n }\n);\n"],"names":[],"mappings":";;;;;AAOA;;;IAGa,MAAM,GAAG,KAAK,CAAC,UAAU,CACpC,UAAC,KAAK,EAAE,GAAG;IACH,IAAA,KAAyB,YAAY,EAAE,EAArC,UAAU,gBAAA,EAAE,MAAM,YAAmB,CAAC;IAE9C,IAAM,aAAa,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACnE,IAAI,KAAK,CAAC,SAAS,EAAE;QACnB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;KACrC;IACD,IAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE1C,IAAM,KAAK,yBAAQ,MAAM,CAAC,YAAY,GAAK,MAAM,CAAC,MAAM,CAAE,CAAC;IAC3D,IAAI,KAAK,CAAC,KAAK,EAAE;QACf,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;KACnC;IAED,QACE,2CACM,KAAK,IACT,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,IACZ,EACF;AACJ,CAAC;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { isSameMonth } from 'date-fns';
|
|
3
3
|
import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
|
|
4
|
+
import '../../contexts/DayPicker/DayPickerContext.js';
|
|
4
5
|
import '../../contexts/Navigation/NavigationContext.js';
|
|
5
6
|
import { useNavigation } from '../../contexts/Navigation/useNavigation.js';
|
|
6
7
|
import { MonthsDropdown } from '../MonthsDropdown/MonthsDropdown.js';
|
|
@@ -17,13 +18,13 @@ function Caption(props) {
|
|
|
17
18
|
var context = useDayPicker();
|
|
18
19
|
var classNames = context.classNames, numberOfMonths = context.numberOfMonths, disableNavigation = context.disableNavigation, styles = context.styles, captionLayout = context.captionLayout, onMonthChange = context.onMonthChange, dir = context.dir, CaptionLabel = context.components.CaptionLabel;
|
|
19
20
|
var _b = useNavigation(), previousMonth = _b.previousMonth, nextMonth = _b.nextMonth, goToMonth = _b.goToMonth, displayMonths = _b.displayMonths;
|
|
20
|
-
var handlePreviousClick = function (
|
|
21
|
+
var handlePreviousClick = function () {
|
|
21
22
|
if (!previousMonth)
|
|
22
23
|
return;
|
|
23
24
|
goToMonth(previousMonth);
|
|
24
25
|
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(previousMonth);
|
|
25
26
|
};
|
|
26
|
-
var handleNextClick = function (
|
|
27
|
+
var handleNextClick = function () {
|
|
27
28
|
if (!nextMonth)
|
|
28
29
|
return;
|
|
29
30
|
goToMonth(nextMonth);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Caption.js","sources":["../../../src/components/Caption/Caption.tsx"],"sourcesContent":["import React from 'react';\n\nimport { isSameMonth } from 'date-fns';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { useNavigation } from '../../contexts/Navigation';\nimport { MonthsDropdown } from '../MonthsDropdown';\nimport { Navigation } from '../Navigation';\nimport { YearsDropdown } from '../YearsDropdown';\nimport { MonthChangeEventHandler } from '../../types/EventHandlers';\n\n/** Represent the props of the [[Caption]] component. */\nexport interface CaptionProps {\n /** The month where the caption is displayed. */\n displayMonth: Date;\n}\n\n/**\n * The layout of the caption:\n *\n * - `dropdown` - display a month / year dropdown\n * - `buttons` - display previous / next month button.\n */\nexport type CaptionLayout = 'dropdown' | 'buttons';\n\n/**\n * Render the caption of a month, which includes title and navigation buttons.\n * The caption has a different layout when setting the `numberOfMonths` prop.\n */\nexport function Caption(props: CaptionProps): JSX.Element {\n const { displayMonth } = props;\n const context = useDayPicker();\n const {\n classNames,\n numberOfMonths,\n disableNavigation,\n styles,\n captionLayout,\n onMonthChange,\n dir,\n components: { CaptionLabel }\n } = context;\n\n const { previousMonth, nextMonth, goToMonth, displayMonths } =\n useNavigation();\n\n const handlePreviousClick: React.MouseEventHandler = (
|
|
1
|
+
{"version":3,"file":"Caption.js","sources":["../../../src/components/Caption/Caption.tsx"],"sourcesContent":["import React from 'react';\n\nimport { isSameMonth } from 'date-fns';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { useNavigation } from '../../contexts/Navigation';\nimport { MonthsDropdown } from '../MonthsDropdown';\nimport { Navigation } from '../Navigation';\nimport { YearsDropdown } from '../YearsDropdown';\nimport { MonthChangeEventHandler } from '../../types/EventHandlers';\n\n/** Represent the props of the [[Caption]] component. */\nexport interface CaptionProps {\n /** The month where the caption is displayed. */\n displayMonth: Date;\n}\n\n/**\n * The layout of the caption:\n *\n * - `dropdown` - display a month / year dropdown\n * - `buttons` - display previous / next month button.\n */\nexport type CaptionLayout = 'dropdown' | 'buttons';\n\n/**\n * Render the caption of a month, which includes title and navigation buttons.\n * The caption has a different layout when setting the `numberOfMonths` prop.\n */\nexport function Caption(props: CaptionProps): JSX.Element {\n const { displayMonth } = props;\n const context = useDayPicker();\n const {\n classNames,\n numberOfMonths,\n disableNavigation,\n styles,\n captionLayout,\n onMonthChange,\n dir,\n components: { CaptionLabel }\n } = context;\n\n const { previousMonth, nextMonth, goToMonth, displayMonths } =\n useNavigation();\n\n const handlePreviousClick: React.MouseEventHandler = () => {\n if (!previousMonth) return;\n goToMonth(previousMonth);\n onMonthChange?.(previousMonth);\n };\n\n const handleNextClick: React.MouseEventHandler = () => {\n if (!nextMonth) return;\n goToMonth(nextMonth);\n onMonthChange?.(nextMonth);\n };\n\n const handleMonthChange: MonthChangeEventHandler = (newMonth) => {\n goToMonth(newMonth);\n onMonthChange?.(newMonth);\n };\n\n const displayIndex = displayMonths.findIndex((month) =>\n isSameMonth(displayMonth, month)\n );\n let isFirst = displayIndex === 0;\n let isLast = displayIndex === displayMonths.length - 1;\n if (dir === 'rtl') {\n [isLast, isFirst] = [isFirst, isLast];\n }\n\n const captionLabel = <CaptionLabel displayMonth={displayMonth} />;\n const hideNext = numberOfMonths > 1 && (isFirst || !isLast);\n const hidePrevious = numberOfMonths > 1 && (isLast || !isFirst);\n\n return (\n <div className={classNames.caption} style={styles.caption}>\n {disableNavigation && captionLabel}\n {!disableNavigation && (\n <>\n {captionLayout === 'dropdown' ? (\n <div\n className={classNames.caption_dropdowns}\n style={styles.caption_dropdowns}\n >\n <MonthsDropdown\n onChange={handleMonthChange}\n displayMonth={displayMonth}\n />\n <YearsDropdown\n onChange={handleMonthChange}\n displayMonth={displayMonth}\n />\n </div>\n ) : (\n <>\n <CaptionLabel displayMonth={displayMonth} />\n <Navigation\n displayMonth={displayMonth}\n hideNext={hideNext}\n hidePrevious={hidePrevious}\n nextMonth={nextMonth}\n previousMonth={previousMonth}\n onPreviousClick={handlePreviousClick}\n onNextClick={handleNextClick}\n />\n </>\n )}\n </>\n )}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AAyBA;;;;SAIgB,OAAO,CAAC,KAAmB;;IACjC,IAAA,YAAY,GAAK,KAAK,aAAV,CAAW;IAC/B,IAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IAE7B,IAAA,UAAU,GAQR,OAAO,WARC,EACV,cAAc,GAOZ,OAAO,eAPK,EACd,iBAAiB,GAMf,OAAO,kBANQ,EACjB,MAAM,GAKJ,OAAO,OALH,EACN,aAAa,GAIX,OAAO,cAJI,EACb,aAAa,GAGX,OAAO,cAHI,EACb,GAAG,GAED,OAAO,IAFN,EACW,YAAY,GACxB,OAAO,wBADiB,CAChB;IAEN,IAAA,KACJ,aAAa,EAAE,EADT,aAAa,mBAAA,EAAE,SAAS,eAAA,EAAE,SAAS,eAAA,EAAE,aAAa,mBACzC,CAAC;IAElB,IAAM,mBAAmB,GAA4B;QACnD,IAAI,C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AK,UAAU,IAC3B,6BACE,SAAS,EAAE,UAAU,CAAC,iBAAiB,EACvC,KAAK,EAAE,MAAM,CAAC,iBAAiB;YAE/B,oBAAC,cAAc,IACb,QAAQ,EAAE,iBAAiB,EAC3B,YAAY,EAAE,YAAY,GAC1B;YACF,oBAAC,aAAa,IACZ,QAAQ,EAAE,iBAAiB,EAC3B,YAAY,EAAE,YAAY,GAC1B,CACE,KAEN;YACE,oBAAC,YAAY,IAAC,YAAY,EAAE,YAAY,GAAI;YAC5C,oBAAC,UAAU,IACT,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,mBAAmB,EACpC,WAAW,EAAE,eAAe,GAC5B,CACD,CACJ,CACA,CACJ,CACG,EACN;AACJ;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
|
|
3
|
+
import '../../contexts/DayPicker/DayPickerContext.js';
|
|
3
4
|
|
|
4
5
|
/** Render the caption for the displayed month. This component is used when `captionLayout="buttons"`. */
|
|
5
6
|
function CaptionLabel(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptionLabel.js","sources":["../../../src/components/CaptionLabel/CaptionLabel.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/** The props for the [[CaptionLabel]] component. */\nexport interface CaptionLabelProps {\n /** The month where the caption is displayed. */\n displayMonth: Date;\n}\n\n/** Render the caption for the displayed month. This component is used when `captionLayout=\"buttons\"`. */\nexport function CaptionLabel(props: CaptionLabelProps): JSX.Element {\n const {\n locale,\n classNames,\n styles,\n formatters: { formatCaption }\n } = useDayPicker();\n return (\n <div\n key=\"caption\"\n className={classNames.caption_label}\n style={styles.caption_label}\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {formatCaption(props.displayMonth, { locale })}\n </div>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CaptionLabel.js","sources":["../../../src/components/CaptionLabel/CaptionLabel.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/** The props for the [[CaptionLabel]] component. */\nexport interface CaptionLabelProps {\n /** The month where the caption is displayed. */\n displayMonth: Date;\n}\n\n/** Render the caption for the displayed month. This component is used when `captionLayout=\"buttons\"`. */\nexport function CaptionLabel(props: CaptionLabelProps): JSX.Element {\n const {\n locale,\n classNames,\n styles,\n formatters: { formatCaption }\n } = useDayPicker();\n return (\n <div\n key=\"caption\"\n className={classNames.caption_label}\n style={styles.caption_label}\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {formatCaption(props.displayMonth, { locale })}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;AAUA;SACgB,YAAY,CAAC,KAAwB;IAC7C,IAAA,KAKF,YAAY,EAAE,EAJhB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,MAAM,YAAA,EACQ,aAAa,8BACX,CAAC;IACnB,QACE,6BACE,GAAG,EAAC,SAAS,EACb,SAAS,EAAE,UAAU,CAAC,aAAa,EACnC,KAAK,EAAE,MAAM,CAAC,aAAa,eACjB,QAAQ,iBACN,MAAM,IAEjB,aAAa,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAC1C,EACN;AACJ;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DateRange, ModifierStatus, StyledComponent } from '../../../types';
|
|
3
|
-
import { SelectMultipleContextValue } from '../../../contexts/SelectMultiple';
|
|
4
|
-
import { SelectRangeContextValue } from '../../../contexts/SelectRange';
|
|
5
|
-
import { SelectSingleContextValue } from '../../../contexts/SelectSingle';
|
|
3
|
+
import { SelectMultipleContextValue } from '../../../contexts/SelectMultiple/SelectMultipleContext';
|
|
4
|
+
import { SelectRangeContextValue } from '../../../contexts/SelectRange/SelectRangeContext';
|
|
5
|
+
import { SelectSingleContextValue } from '../../../contexts/SelectSingle/SelectSingleContext';
|
|
6
6
|
export declare type UseDay = {
|
|
7
7
|
/** Whether the date is outside the display month/ */
|
|
8
8
|
isOutside: boolean;
|
|
@@ -5,15 +5,15 @@ import { isDayPickerMultiple } from '../../../types/DayPickerMultiple.js';
|
|
|
5
5
|
import { isDayPickerRange } from '../../../types/DayPickerRange.js';
|
|
6
6
|
import { isDayPickerSingle } from '../../../types/DayPickerSingle.js';
|
|
7
7
|
import { useDayPicker } from '../../../contexts/DayPicker/useDayPicker.js';
|
|
8
|
+
import '../../../contexts/DayPicker/DayPickerContext.js';
|
|
8
9
|
import '../../../contexts/SelectMultiple/SelectMultipleContext.js';
|
|
9
10
|
import { useSelectMultiple } from '../../../contexts/SelectMultiple/useSelectMultiple.js';
|
|
10
11
|
import '../../../contexts/SelectRange/SelectRangeContext.js';
|
|
11
12
|
import { useSelectRange } from '../../../contexts/SelectRange/useSelectRange.js';
|
|
12
13
|
import '../../../contexts/SelectSingle/SelectSingleContext.js';
|
|
13
14
|
import { useSelectSingle } from '../../../contexts/SelectSingle/useSelectSingle.js';
|
|
14
|
-
import 'date-fns/locale/en-US';
|
|
15
|
-
import { useModifiers } from '../../../hooks/useModifiers/useModifiers.js';
|
|
16
15
|
import { useDayFocus } from './useDayFocus.js';
|
|
16
|
+
import { useModifiers } from '../../../hooks/useModifiers/useModifiers.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* This hook returns details about the content to render in the day cell.
|
|
@@ -91,13 +91,13 @@ buttonRef) {
|
|
|
91
91
|
var handleClick = function (e) {
|
|
92
92
|
var _a, _b, _c, _d;
|
|
93
93
|
if (isDayPickerSingle(context)) {
|
|
94
|
-
(_a = single.
|
|
94
|
+
(_a = single.onDayClick) === null || _a === void 0 ? void 0 : _a.call(single, date, modifiers, e);
|
|
95
95
|
}
|
|
96
96
|
else if (isDayPickerMultiple(context)) {
|
|
97
|
-
(_b = multiple.
|
|
97
|
+
(_b = multiple.onDayClick) === null || _b === void 0 ? void 0 : _b.call(multiple, date, modifiers, e);
|
|
98
98
|
}
|
|
99
99
|
else if (isDayPickerRange(context)) {
|
|
100
|
-
(_c = range.
|
|
100
|
+
(_c = range.onDayClick) === null || _c === void 0 ? void 0 : _c.call(range, date, modifiers, e);
|
|
101
101
|
}
|
|
102
102
|
(_d = context.onDayClick) === null || _d === void 0 ? void 0 : _d.call(context, date, modifiers, e);
|
|
103
103
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDay.js","sources":["../../../../src/components/Day/hooks/useDay.tsx"],"sourcesContent":["import React from 'react';\n\nimport { isSameMonth } from 'date-fns';\n\nimport {\n DateRange,\n isDayPickerMultiple,\n isDayPickerRange,\n isDayPickerSingle,\n ModifierStatus,\n StyledComponent\n} from '../../../types';\n\nimport { useDayPicker } from '../../../contexts/DayPicker';\nimport {\n SelectMultipleContextValue,\n useSelectMultiple\n} from '../../../contexts/SelectMultiple';\nimport {\n SelectRangeContextValue,\n useSelectRange\n} from '../../../contexts/SelectRange';\nimport {\n SelectSingleContextValue,\n useSelectSingle\n} from '../../../contexts/SelectSingle';\nimport { useModifiers } from '../../../hooks';\n\nimport { useDayFocus } from './useDayFocus';\n\nexport type UseDay = {\n /** Whether the date is outside the display month/ */\n isOutside: boolean;\n /** The modifiers for the given date. */\n modifiers: ModifierStatus;\n /** The days in DayPicker currently selected. */\n selected: Date | Date[] | DateRange | undefined;\n /**\n * The props for rendering the day as interactive element.\n *\n * When `undefined`, DayPicker should render a non interactive element with non-interactive\n * props.\n */\n buttonProps?: Omit<React.HTMLProps<HTMLButtonElement>, 'ref'>;\n /**\n * The props for rendering the day as not interactive element.\n *\n * When both this value and `buttonProps` are `undefined`, DayPicker should not render anything.\n */\n nonInteractiveProps?: StyledComponent;\n single: SelectSingleContextValue;\n multiple: SelectMultipleContextValue;\n range: SelectRangeContextValue;\n};\n\n/**\n * This hook returns details about the content to render in the day cell.\n *\n *\n * When a day cell is rendered in the table, DayPicker can either:\n *\n * - render nothing: when the day is outside the month or has matched the\n * \"hidden\" modifier.\n * - render a button. When a selection mode is set, DayPicker renders a button\n * to allow the focus and the selection. In case of `custom` selection\n * mode, DayPicker expects a `onDayClick` prop to render a button.\n * - render a non-interactive element: when no selection mode is set, the day\n * cell shouldn’t respond to any interaction. DayPicker should render a `div`\n * or a `span`.\n *\n * ### Usage\n *\n * Use this hook to customize the behavior of the [[Day]] component. Create a\n * new `Day` component using this hook and pass it to the `components` prop.\n * The source of [[Day]] can be a good starting point.\n *\n * */\nexport function useDay(\n /** The day rendered in the month. */\n date: Date,\n /** The month where the date is displayed. DayPicker renders days outside the display month when `showOutsideDays` is true. */\n displayMonth: Date,\n /** A ref to the button element. */\n buttonRef: React.RefObject<HTMLButtonElement>\n): UseDay {\n const context = useDayPicker();\n const single = useSelectSingle();\n const multiple = useSelectMultiple();\n const range = useSelectRange();\n const { focus, blur, focusOnKeyDown, isFocused } = useDayFocus(\n date,\n buttonRef\n );\n\n const { modifiers, modifierClassNames, modifierStyle } = useModifiers(date);\n const isOutside = !isSameMonth(date, displayMonth);\n\n const returnValue = {\n isOutside,\n modifiers,\n selected: isDayPickerSingle(context)\n ? single.selected\n : isDayPickerMultiple(context)\n ? multiple.selected\n : isDayPickerRange(context)\n ? range.selected\n : undefined,\n single,\n multiple,\n range\n };\n if (isOutside && !context.showOutsideDays) {\n return returnValue;\n }\n if (modifiers.hidden) {\n return returnValue;\n }\n\n const classNames = [context.classNames.day].concat(modifierClassNames);\n let style: React.CSSProperties = { ...context.styles.day, ...modifierStyle };\n\n if (isOutside) {\n classNames.push(context.classNames.day_outside);\n style = { ...context.styles, ...context.styles.day_outside };\n }\n\n const { DayContent } = context.components;\n const children = (\n <DayContent date={date} displayMonth={displayMonth} modifiers={modifiers} />\n );\n\n let className = classNames.join(' ');\n\n if (!context.mode && !context.onDayClick) {\n return {\n ...returnValue,\n nonInteractiveProps: {\n style,\n className,\n children\n }\n };\n }\n\n // #region Event handlers\n const handleClick: React.MouseEventHandler = (e) => {\n if (isDayPickerSingle(context)) {\n single.handleDayClick?.(date, modifiers, e);\n } else if (isDayPickerMultiple(context)) {\n multiple.handleDayClick?.(date, modifiers, e);\n } else if (isDayPickerRange(context)) {\n range.handleDayClick?.(date, modifiers, e);\n }\n context.onDayClick?.(date, modifiers, e);\n };\n\n const handleFocus: React.FocusEventHandler = (e) => {\n focus(date);\n context.onDayFocus?.(date, modifiers, e);\n };\n\n const handleBlur: React.FocusEventHandler = (e) => {\n blur();\n context.onDayBlur?.(date, modifiers, e);\n };\n\n const handleKeyDown: React.KeyboardEventHandler = (e) => {\n focusOnKeyDown(e);\n context.onDayKeyDown?.(date, modifiers, e);\n };\n\n const handleKeyUp: React.KeyboardEventHandler = (e) => {\n context.onDayKeyUp?.(date, modifiers, e);\n };\n const handleMouseEnter: React.MouseEventHandler = (e) => {\n context.onDayMouseEnter?.(date, modifiers, e);\n };\n const handleMouseLeave: React.MouseEventHandler = (e) => {\n context.onDayMouseLeave?.(date, modifiers, e);\n };\n const handleTouchCancel: React.TouchEventHandler = (e) => {\n context.onDayTouchCancel?.(date, modifiers, e);\n };\n const handleTouchEnd: React.TouchEventHandler = (e) => {\n context.onDayTouchEnd?.(date, modifiers, e);\n };\n const handleTouchMove: React.TouchEventHandler = (e) => {\n context.onDayTouchMove?.(date, modifiers, e);\n };\n const handleTouchStart: React.TouchEventHandler = (e) => {\n context.onDayTouchStart?.(date, modifiers, e);\n };\n\n if (isOutside) {\n classNames.push(context.classNames.day_outside);\n style = { ...context.styles, ...context.styles.day_outside };\n }\n\n className = classNames.join(' ');\n\n const { selected, disabled } = modifiers;\n\n const tabIndex = disabled || isFocused ? -1 : 0;\n\n return {\n ...returnValue,\n buttonProps: {\n children,\n 'aria-pressed': selected,\n style: style,\n disabled: disabled,\n className: className,\n tabIndex: tabIndex,\n onClick: handleClick,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onKeyDown: handleKeyDown,\n onKeyUp: handleKeyUp,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onTouchCancel: handleTouchCancel,\n onTouchEnd: handleTouchEnd,\n onTouchMove: handleTouchMove,\n onTouchStart: handleTouchStart\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuDA;;;;;;;;;;;;;;;;;;;;;;SAsBgB,MAAM;AACpB;AACA,IAAU;AACV;AACA,YAAkB;AAClB;AACA,SAA6C;IAE7C,IAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IAC/B,IAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,IAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IACrC,IAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IACzB,IAAA,KAA6C,WAAW,CAC5D,IAAI,EACJ,SAAS,CACV,EAHO,KAAK,WAAA,EAAE,IAAI,UAAA,EAAE,cAAc,oBAAA,EAAE,SAAS,eAG7C,CAAC;IAEI,IAAA,KAAmD,YAAY,CAAC,IAAI,CAAC,EAAnE,SAAS,eAAA,EAAE,kBAAkB,wBAAA,EAAE,aAAa,mBAAuB,CAAC;IAC5E,IAAM,SAAS,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAEnD,IAAM,WAAW,GAAG;QAClB,SAAS,WAAA;QACT,SAAS,WAAA;QACT,QAAQ,EAAE,iBAAiB,CAAC,OAAO,CAAC;cAChC,MAAM,CAAC,QAAQ;cACf,mBAAmB,CAAC,OAAO,CAAC;kBAC5B,QAAQ,CAAC,QAAQ;kBACjB,gBAAgB,CAAC,OAAO,CAAC;sBACzB,KAAK,CAAC,QAAQ;sBACd,SAAS;QACb,MAAM,QAAA;QACN,QAAQ,UAAA;QACR,KAAK,OAAA;KACN,CAAC;IACF,IAAI,SAAS,IAAI,CAAC,OAAO,CAAC,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AAE,UAAU;YAClB,SAAS,EAAE,aAAa;YACxB,OAAO,EAAE,WAAW;YACpB,YAAY,EAAE,gBAAgB;YAC9B,YAAY,EAAE,gBAAgB;YAC9B,aAAa,EAAE,iBAAiB;YAChC,UAAU,EAAE,cAAc;YAC1B,WAAW,EAAE,eAAe;YAC5B,YAAY,EAAE,gBAAgB;SAC/B,IACD;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"useDay.js","sources":["../../../../src/components/Day/hooks/useDay.tsx"],"sourcesContent":["import React from 'react';\n\nimport { isSameMonth } from 'date-fns';\n\nimport {\n DateRange,\n isDayPickerMultiple,\n isDayPickerRange,\n isDayPickerSingle,\n ModifierStatus,\n StyledComponent\n} from '../../../types';\n\nimport { useDayPicker } from '../../../contexts/DayPicker';\nimport { useSelectMultiple } from '../../../contexts/SelectMultiple';\nimport { useSelectRange } from '../../../contexts/SelectRange';\nimport { useSelectSingle } from '../../../contexts/SelectSingle';\n\nimport { useDayFocus } from './useDayFocus';\nimport { SelectMultipleContextValue } from '../../../contexts/SelectMultiple/SelectMultipleContext';\nimport { SelectRangeContextValue } from '../../../contexts/SelectRange/SelectRangeContext';\nimport { SelectSingleContextValue } from '../../../contexts/SelectSingle/SelectSingleContext';\nimport { useModifiers } from '../../../hooks/useModifiers';\n\nexport type UseDay = {\n /** Whether the date is outside the display month/ */\n isOutside: boolean;\n /** The modifiers for the given date. */\n modifiers: ModifierStatus;\n /** The days in DayPicker currently selected. */\n selected: Date | Date[] | DateRange | undefined;\n /**\n * The props for rendering the day as interactive element.\n *\n * When `undefined`, DayPicker should render a non interactive element with non-interactive\n * props.\n */\n buttonProps?: Omit<React.HTMLProps<HTMLButtonElement>, 'ref'>;\n /**\n * The props for rendering the day as not interactive element.\n *\n * When both this value and `buttonProps` are `undefined`, DayPicker should not render anything.\n */\n nonInteractiveProps?: StyledComponent;\n single: SelectSingleContextValue;\n multiple: SelectMultipleContextValue;\n range: SelectRangeContextValue;\n};\n\n/**\n * This hook returns details about the content to render in the day cell.\n *\n *\n * When a day cell is rendered in the table, DayPicker can either:\n *\n * - render nothing: when the day is outside the month or has matched the\n * \"hidden\" modifier.\n * - render a button. When a selection mode is set, DayPicker renders a button\n * to allow the focus and the selection. In case of `custom` selection\n * mode, DayPicker expects a `onDayClick` prop to render a button.\n * - render a non-interactive element: when no selection mode is set, the day\n * cell shouldn’t respond to any interaction. DayPicker should render a `div`\n * or a `span`.\n *\n * ### Usage\n *\n * Use this hook to customize the behavior of the [[Day]] component. Create a\n * new `Day` component using this hook and pass it to the `components` prop.\n * The source of [[Day]] can be a good starting point.\n *\n * */\nexport function useDay(\n /** The day rendered in the month. */\n date: Date,\n /** The month where the date is displayed. DayPicker renders days outside the display month when `showOutsideDays` is true. */\n displayMonth: Date,\n /** A ref to the button element. */\n buttonRef: React.RefObject<HTMLButtonElement>\n): UseDay {\n const context = useDayPicker();\n const single = useSelectSingle();\n const multiple = useSelectMultiple();\n const range = useSelectRange();\n const { focus, blur, focusOnKeyDown, isFocused } = useDayFocus(\n date,\n buttonRef\n );\n\n const { modifiers, modifierClassNames, modifierStyle } = useModifiers(date);\n const isOutside = !isSameMonth(date, displayMonth);\n\n const returnValue = {\n isOutside,\n modifiers,\n selected: isDayPickerSingle(context)\n ? single.selected\n : isDayPickerMultiple(context)\n ? multiple.selected\n : isDayPickerRange(context)\n ? range.selected\n : undefined,\n single,\n multiple,\n range\n };\n if (isOutside && !context.showOutsideDays) {\n return returnValue;\n }\n if (modifiers.hidden) {\n return returnValue;\n }\n\n const classNames = [context.classNames.day].concat(modifierClassNames);\n let style: React.CSSProperties = { ...context.styles.day, ...modifierStyle };\n\n if (isOutside) {\n classNames.push(context.classNames.day_outside);\n style = { ...context.styles, ...context.styles.day_outside };\n }\n\n const { DayContent } = context.components;\n const children = (\n <DayContent date={date} displayMonth={displayMonth} modifiers={modifiers} />\n );\n\n let className = classNames.join(' ');\n\n if (!context.mode && !context.onDayClick) {\n return {\n ...returnValue,\n nonInteractiveProps: {\n style,\n className,\n children\n }\n };\n }\n\n // #region Event handlers\n const handleClick: React.MouseEventHandler = (e) => {\n if (isDayPickerSingle(context)) {\n single.onDayClick?.(date, modifiers, e);\n } else if (isDayPickerMultiple(context)) {\n multiple.onDayClick?.(date, modifiers, e);\n } else if (isDayPickerRange(context)) {\n range.onDayClick?.(date, modifiers, e);\n }\n context.onDayClick?.(date, modifiers, e);\n };\n\n const handleFocus: React.FocusEventHandler = (e) => {\n focus(date);\n context.onDayFocus?.(date, modifiers, e);\n };\n\n const handleBlur: React.FocusEventHandler = (e) => {\n blur();\n context.onDayBlur?.(date, modifiers, e);\n };\n\n const handleKeyDown: React.KeyboardEventHandler = (e) => {\n focusOnKeyDown(e);\n context.onDayKeyDown?.(date, modifiers, e);\n };\n\n const handleKeyUp: React.KeyboardEventHandler = (e) => {\n context.onDayKeyUp?.(date, modifiers, e);\n };\n const handleMouseEnter: React.MouseEventHandler = (e) => {\n context.onDayMouseEnter?.(date, modifiers, e);\n };\n const handleMouseLeave: React.MouseEventHandler = (e) => {\n context.onDayMouseLeave?.(date, modifiers, e);\n };\n const handleTouchCancel: React.TouchEventHandler = (e) => {\n context.onDayTouchCancel?.(date, modifiers, e);\n };\n const handleTouchEnd: React.TouchEventHandler = (e) => {\n context.onDayTouchEnd?.(date, modifiers, e);\n };\n const handleTouchMove: React.TouchEventHandler = (e) => {\n context.onDayTouchMove?.(date, modifiers, e);\n };\n const handleTouchStart: React.TouchEventHandler = (e) => {\n context.onDayTouchStart?.(date, modifiers, e);\n };\n\n if (isOutside) {\n classNames.push(context.classNames.day_outside);\n style = { ...context.styles, ...context.styles.day_outside };\n }\n\n className = classNames.join(' ');\n\n const { selected, disabled } = modifiers;\n\n const tabIndex = disabled || isFocused ? -1 : 0;\n\n return {\n ...returnValue,\n buttonProps: {\n children,\n 'aria-pressed': selected,\n style: style,\n disabled: disabled,\n className: className,\n tabIndex: tabIndex,\n onClick: handleClick,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onKeyDown: handleKeyDown,\n onKeyUp: handleKeyUp,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onTouchCancel: handleTouchCancel,\n onTouchEnd: handleTouchEnd,\n onTouchMove: handleTouchMove,\n onTouchStart: handleTouchStart\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAiDA;;;;;;;;;;;;;;;;;;;;;;SAsBgB,MAAM;AACpB;AACA,IAAU;AACV;AACA,YAAkB;AAClB;AACA,SAA6C;IAE7C,IAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IAC/B,IAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,IAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IACrC,IAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IACzB,IAAA,KAA6C,WAAW,CAC5D,IAAI,EACJ,SAAS,CACV,EAHO,KAAK,WAAA,EAAE,IAAI,UAAA,EAAE,cAAc,oBAAA,EAAE,SAAS,eAG7C,CAAC;IAEI,IAAA,KAAmD,YAAY,CAAC,IAAI,CAAC,EAAnE,SAAS,eAAA,EAAE,kBAAkB,wBAAA,EAAE,aAAa,mBAAuB,CAAC;IAC5E,IAAM,SAAS,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAEnD,IAAM,WAAW,GAAG;QAClB,SAAS,WAAA;QACT,SAAS,WAAA;QACT,QAAQ,EAAE,iBAAiB,CAAC,OAAO,CAAC;cAChC,MAAM,CAAC,QAAQ;cACf,mBAAmB,CAAC,OAAO,CAAC;kBAC5B,QAAQ,CAAC,QAAQ;kBACjB,gBAAgB,CAAC,OAAO,CAAC;sBACzB,KAAK,CAAC,QAAQ;sBACd,SAAS;QACb,MAAM,QAAA;QACN,QAAQ,UAAA;QACR,KAAK,OAAA;KACN,CAAC;IACF,IAAI,SAAS,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;QACzC,OAAO,WAAW,CAAC;KACpB;IACD,IAAI,SAAS,CAAC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AY,EAAE,gBAAgB;YAC9B,YAAY,EAAE,gBAAgB;YAC9B,aAAa,EAAE,iBAAiB;YAChC,UAAU,EAAE,cAAc;YAC1B,WAAW,EAAE,eAAe;YAC5B,YAAY,EAAE,gBAAgB;SAC/B,IACD;AACJ;;;;"}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { isSameDay } from 'date-fns';
|
|
3
|
-
import 'date-fns/locale/en-US';
|
|
4
3
|
import { useDayPicker } from '../../../contexts/DayPicker/useDayPicker.js';
|
|
5
|
-
import '../../../contexts/
|
|
6
|
-
import '../../Button/Button.js';
|
|
7
|
-
import '../../../contexts/SelectMultiple/SelectMultipleContext.js';
|
|
8
|
-
import '../../../contexts/SelectRange/SelectRangeContext.js';
|
|
9
|
-
import '../../../contexts/SelectSingle/SelectSingleContext.js';
|
|
4
|
+
import '../../../contexts/DayPicker/DayPickerContext.js';
|
|
10
5
|
import '../../../contexts/Focus/FocusContext.js';
|
|
11
6
|
import { useFocus } from '../../../contexts/Focus/useFocus.js';
|
|
12
|
-
import '../../../contexts/DayPicker/DayPickerContext.js';
|
|
13
7
|
|
|
14
8
|
/** Handle the focus for the day element. */
|
|
15
9
|
function useDayFocus(date, buttonRef) {
|
|
16
|
-
var _a = useFocus(), focusedDay = _a[0], _b = _a[1], focusDayAfter = _b.focusDayAfter, focusDayBefore = _b.focusDayBefore, focusWeekAfterDay = _b.focusWeekAfterDay, focusWeekBeforeDay = _b.focusWeekBeforeDay, blur = _b.blur, focus = _b.focus;
|
|
10
|
+
var _a = useFocus(), focusedDay = _a[0], _b = _a[1], focusDayAfter = _b.focusDayAfter, focusDayBefore = _b.focusDayBefore, focusWeekAfterDay = _b.focusWeekAfterDay, focusWeekBeforeDay = _b.focusWeekBeforeDay, blur = _b.blur, focus = _b.focus, focusMonthBefore = _b.focusMonthBefore, focusMonthAfter = _b.focusMonthAfter, focusYearBefore = _b.focusYearBefore, focusYearAfter = _b.focusYearAfter, focusStartOfWeek = _b.focusStartOfWeek, focusEndOfWeek = _b.focusEndOfWeek;
|
|
17
11
|
var dir = useDayPicker().dir;
|
|
18
12
|
// Focus the HTML element if this is the focused day.
|
|
19
13
|
React.useEffect(function () {
|
|
@@ -46,6 +40,26 @@ function useDayFocus(date, buttonRef) {
|
|
|
46
40
|
e.stopPropagation();
|
|
47
41
|
focusWeekBeforeDay();
|
|
48
42
|
break;
|
|
43
|
+
case 'PageUp':
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
e.shiftKey ? focusYearBefore() : focusMonthBefore();
|
|
47
|
+
break;
|
|
48
|
+
case 'PageDown':
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
e.shiftKey ? focusYearAfter() : focusMonthAfter();
|
|
52
|
+
break;
|
|
53
|
+
case 'Home':
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
focusStartOfWeek();
|
|
57
|
+
break;
|
|
58
|
+
case 'End':
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
e.stopPropagation();
|
|
61
|
+
focusEndOfWeek();
|
|
62
|
+
break;
|
|
49
63
|
}
|
|
50
64
|
};
|
|
51
65
|
var isFocused = Boolean(focusedDay && !isSameDay(focusedDay, date));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDayFocus.js","sources":["../../../../src/components/Day/hooks/useDayFocus.ts"],"sourcesContent":["import React from 'react';\n\nimport { isSameDay } from 'date-fns';\n\nimport { useDayPicker } from '../../../contexts';\nimport { useFocus } from '../../../contexts/Focus';\n\n/** Handle the focus for the day element. */\nexport function useDayFocus(\n date: Date,\n buttonRef: React.RefObject<HTMLButtonElement>\n): {\n focus: (date: Date) => void;\n blur: () => void;\n focusOnKeyDown: React.KeyboardEventHandler;\n isFocused: boolean;\n} {\n const [\n focusedDay,\n {\n focusDayAfter,\n focusDayBefore,\n focusWeekAfterDay,\n focusWeekBeforeDay,\n blur,\n focus\n }\n ] = useFocus();\n const { dir } = useDayPicker();\n\n // Focus the HTML element if this is the focused day.\n React.useEffect(() => {\n if (!focusedDay) return;\n if (isSameDay(focusedDay, date)) {\n buttonRef.current?.focus();\n }\n }, [focusedDay, date, buttonRef]);\n\n const focusOnKeyDown: React.KeyboardEventHandler = (e) => {\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n dir === 'rtl' ? focusDayAfter() : focusDayBefore();\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n dir === 'rtl' ? focusDayBefore() : focusDayAfter();\n break;\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n focusWeekAfterDay();\n break;\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n focusWeekBeforeDay();\n break;\n }\n };\n\n const isFocused = Boolean(focusedDay && !isSameDay(focusedDay, date));\n\n return { focus, blur, focusOnKeyDown, isFocused };\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDayFocus.js","sources":["../../../../src/components/Day/hooks/useDayFocus.ts"],"sourcesContent":["import React from 'react';\n\nimport { isSameDay } from 'date-fns';\n\nimport { useDayPicker } from '../../../contexts/DayPicker';\nimport { useFocus } from '../../../contexts/Focus';\n\n/** Handle the focus for the day element. */\nexport function useDayFocus(\n date: Date,\n buttonRef: React.RefObject<HTMLButtonElement>\n): {\n focus: (date: Date) => void;\n blur: () => void;\n focusOnKeyDown: React.KeyboardEventHandler;\n isFocused: boolean;\n} {\n const [\n focusedDay,\n {\n focusDayAfter,\n focusDayBefore,\n focusWeekAfterDay,\n focusWeekBeforeDay,\n blur,\n focus,\n focusMonthBefore,\n focusMonthAfter,\n focusYearBefore,\n focusYearAfter,\n focusStartOfWeek,\n focusEndOfWeek\n }\n ] = useFocus();\n const { dir } = useDayPicker();\n\n // Focus the HTML element if this is the focused day.\n React.useEffect(() => {\n if (!focusedDay) return;\n if (isSameDay(focusedDay, date)) {\n buttonRef.current?.focus();\n }\n }, [focusedDay, date, buttonRef]);\n\n const focusOnKeyDown: React.KeyboardEventHandler = (e) => {\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n dir === 'rtl' ? focusDayAfter() : focusDayBefore();\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n dir === 'rtl' ? focusDayBefore() : focusDayAfter();\n break;\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n focusWeekAfterDay();\n break;\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n focusWeekBeforeDay();\n break;\n case 'PageUp':\n e.preventDefault();\n e.stopPropagation();\n e.shiftKey ? focusYearBefore() : focusMonthBefore();\n break;\n case 'PageDown':\n e.preventDefault();\n e.stopPropagation();\n e.shiftKey ? focusYearAfter() : focusMonthAfter();\n break;\n case 'Home':\n e.preventDefault();\n e.stopPropagation();\n focusStartOfWeek();\n break;\n case 'End':\n e.preventDefault();\n e.stopPropagation();\n focusEndOfWeek();\n break;\n }\n };\n\n const isFocused = Boolean(focusedDay && !isSameDay(focusedDay, date));\n\n return { focus, blur, focusOnKeyDown, isFocused };\n}\n"],"names":[],"mappings":";;;;;;;AAOA;SACgB,WAAW,CACzB,IAAU,EACV,SAA6C;IAOvC,IAAA,KAgBF,QAAQ,EAAE,EAfZ,UAAU,QAAA,EACV,UAaC,EAZC,aAAa,mBAAA,EACb,cAAc,oBAAA,EACd,iBAAiB,uBAAA,EACjB,kBAAkB,wBAAA,EAClB,IAAI,UAAA,EACJ,KAAK,WAAA,EACL,gBAAgB,sBAAA,EAChB,eAAe,qBAAA,EACf,eAAe,qBAAA,EACf,cAAc,oBAAA,EACd,gBAAgB,sBAAA,EAChB,cAAc,oBAEJ,CAAC;IACP,IAAA,GAAG,GAAK,YAAY,EAAE,IAAnB,CAAoB;;IAG/B,KAAK,CAAC,SAAS,CAAC;;QACd,IAAI,CAAC,UAAU;YAAE,OAAO;QACxB,IAAI,SAAS,CAA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AC;gBACnB,CAAC,CAAC,eAAe,EAAE,CAAC;gBACpB,gBAAgB,EAAE,CAAC;gBACnB,MAAM;YACR,KAAK,KAAK;gBACR,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,CAAC,CAAC,eAAe,EAAE,CAAC;gBACpB,cAAc,EAAE,CAAC;gBACjB,MAAM;SACT;KACF,CAAC;IAEF,IAAM,SAAS,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;IAEtE,OAAO,EAAE,KAAK,OAAA,EAAE,IAAI,MAAA,EAAE,cAAc,gBAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AACpD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DayContent.js","sources":["../../../src/components/DayContent/DayContent.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\nimport { ModifierStatus } from '../../types';\n\n/** Represent the props for the [[DayContent]] component. */\nexport interface DayContentProps {\n /** The date representing the day. */\n date: Date;\n /** The month where the day is displayed. */\n displayMonth: Date;\n /** The modifier status for the date. */\n modifiers: ModifierStatus;\n}\n\n/**\n * Render the content of the day cell.\n */\nexport function DayContent(props: DayContentProps): JSX.Element {\n const {\n locale,\n classNames,\n styles,\n labels: { labelDay },\n formatters: { formatDay }\n } = useDayPicker();\n\n return (\n <>\n <span aria-hidden=\"true\">{formatDay(props.date, { locale })}</span>\n <span className={classNames.vhidden} style={styles.vhidden}>\n {labelDay(props.date, props.modifiers, { locale })}\n </span>\n </>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DayContent.js","sources":["../../../src/components/DayContent/DayContent.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\nimport { ModifierStatus } from '../../types';\n\n/** Represent the props for the [[DayContent]] component. */\nexport interface DayContentProps {\n /** The date representing the day. */\n date: Date;\n /** The month where the day is displayed. */\n displayMonth: Date;\n /** The modifier status for the date. */\n modifiers: ModifierStatus;\n}\n\n/**\n * Render the content of the day cell.\n */\nexport function DayContent(props: DayContentProps): JSX.Element {\n const {\n locale,\n classNames,\n styles,\n labels: { labelDay },\n formatters: { formatDay }\n } = useDayPicker();\n\n return (\n <>\n <span aria-hidden=\"true\">{formatDay(props.date, { locale })}</span>\n <span className={classNames.vhidden} style={styles.vhidden}>\n {labelDay(props.date, props.modifiers, { locale })}\n </span>\n </>\n );\n}\n"],"names":[],"mappings":";;;;AAgBA;;;SAGgB,UAAU,CAAC,KAAsB;IACzC,IAAA,KAMF,YAAY,EAAE,EALhB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,MAAM,YAAA,EACI,QAAQ,qBAAA,EACJ,SAAS,0BACP,CAAC;IAEnB,QACE;QACE,6CAAkB,MAAM,IAAE,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAAQ;QACnE,8BAAM,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,IACvD,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAC7C,CACN,EACH;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/** The props for the [[Dropdown]] component. */\nexport interface DropdownProps {\n caption?: React.ReactNode;\n children?: React.SelectHTMLAttributes<HTMLSelectElement>['children'];\n className?: string;\n ['aria-label']?: string;\n style?: React.CSSProperties;\n value?: React.SelectHTMLAttributes<HTMLSelectElement>['value'];\n onChange?: React.ChangeEventHandler<HTMLSelectElement>;\n}\n\n/**\n * Render a styled select component – displaying a caption and a custom\n * drop-down icon.\n */\nexport function Dropdown(props: DropdownProps): JSX.Element {\n const { onChange, value, children, caption, className, style } = props;\n const {\n classNames,\n styles,\n components: { IconDropdown }\n } = useDayPicker();\n return (\n <div className={className} style={style}>\n <span className={classNames.vhidden}>{props['aria-label']}</span>\n <select\n aria-label={props['aria-label']}\n className={classNames.dropdown}\n style={styles.dropdown}\n value={value}\n onChange={onChange}\n >\n {children}\n </select>\n <div\n className={classNames.caption_label}\n style={styles.caption_label}\n aria-hidden=\"true\"\n >\n {caption}\n {\n <IconDropdown\n className={classNames.dropdown_icon}\n style={styles.dropdown_icon}\n />\n }\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/** The props for the [[Dropdown]] component. */\nexport interface DropdownProps {\n caption?: React.ReactNode;\n children?: React.SelectHTMLAttributes<HTMLSelectElement>['children'];\n className?: string;\n ['aria-label']?: string;\n style?: React.CSSProperties;\n value?: React.SelectHTMLAttributes<HTMLSelectElement>['value'];\n onChange?: React.ChangeEventHandler<HTMLSelectElement>;\n}\n\n/**\n * Render a styled select component – displaying a caption and a custom\n * drop-down icon.\n */\nexport function Dropdown(props: DropdownProps): JSX.Element {\n const { onChange, value, children, caption, className, style } = props;\n const {\n classNames,\n styles,\n components: { IconDropdown }\n } = useDayPicker();\n return (\n <div className={className} style={style}>\n <span className={classNames.vhidden}>{props['aria-label']}</span>\n <select\n aria-label={props['aria-label']}\n className={classNames.dropdown}\n style={styles.dropdown}\n value={value}\n onChange={onChange}\n >\n {children}\n </select>\n <div\n className={classNames.caption_label}\n style={styles.caption_label}\n aria-hidden=\"true\"\n >\n {caption}\n {\n <IconDropdown\n className={classNames.dropdown_icon}\n style={styles.dropdown_icon}\n />\n }\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;AAeA;;;;SAIgB,QAAQ,CAAC,KAAoB;IACnC,IAAA,QAAQ,GAAiD,KAAK,SAAtD,EAAE,KAAK,GAA0C,KAAK,MAA/C,EAAE,QAAQ,GAAgC,KAAK,SAArC,EAAE,OAAO,GAAuB,KAAK,QAA5B,EAAE,SAAS,GAAY,KAAK,UAAjB,EAAE,KAAK,GAAK,KAAK,MAAV,CAAW;IACjE,IAAA,KAIF,YAAY,EAAE,EAHhB,UAAU,gBAAA,EACV,MAAM,YAAA,EACQ,YAAY,6BACV,CAAC;IACnB,QACE,6BAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK;QACrC,8BAAM,SAAS,EAAE,UAAU,CAAC,OAAO,IAAG,KAAK,CAAC,YAAY,CAAC,CAAQ;QACjE,8CACc,KAAK,CAAC,YAAY,CAAC,EAC/B,SAAS,EAAE,UAAU,CAAC,QAAQ,EAC9B,KAAK,EAAE,MAAM,CAAC,QAAQ,EACtB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,IAEjB,QAAQ,CACF;QACT,6BACE,SAAS,EAAE,UAAU,CAAC,aAAa,EACnC,KAAK,EAAE,MAAM,CAAC,aAAa,iBACf,MAAM;YAEjB,OAAO;YAEN,oBAAC,YAAY,IACX,SAAS,EAAE,UAAU,CAAC,aAAa,EACnC,KAAK,EAAE,MAAM,CAAC,aAAa,GAC3B,CAEA,CACF,EACN;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Footer.js","sources":["../../../src/components/Footer/Footer.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/** Render the Footer component (empty as default).*/\nexport function Footer(): JSX.Element {\n const {\n footer,\n styles,\n classNames: { tfoot }\n } = useDayPicker();\n if (!footer) return <></>;\n return (\n <tfoot className={tfoot} style={styles.tfoot}>\n <tr>\n <td colSpan={8}>{footer}</td>\n </tr>\n </tfoot>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Footer.js","sources":["../../../src/components/Footer/Footer.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/** Render the Footer component (empty as default).*/\nexport function Footer(): JSX.Element {\n const {\n footer,\n styles,\n classNames: { tfoot }\n } = useDayPicker();\n if (!footer) return <></>;\n return (\n <tfoot className={tfoot} style={styles.tfoot}>\n <tr>\n <td colSpan={8}>{footer}</td>\n </tr>\n </tfoot>\n );\n}\n"],"names":[],"mappings":";;;;AAIA;SACgB,MAAM;IACd,IAAA,KAIF,YAAY,EAAE,EAHhB,MAAM,YAAA,EACN,MAAM,YAAA,EACQ,KAAK,sBACH,CAAC;IACnB,IAAI,CAAC,MAAM;QAAE,OAAO,yCAAK,CAAC;IAC1B,QACE,+BAAO,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK;QAC1C;YACE,4BAAI,OAAO,EAAE,CAAC,IAAG,MAAM,CAAM,CAC1B,CACC,EACR;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Head.js","sources":["../../../src/components/Head/Head.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\nimport { getWeekdays } from './utils';\n\n/**\n * Render the Head component - i.e. the table head with the weekday names.\n */\nexport function Head(): JSX.Element {\n const {\n classNames,\n styles,\n showWeekNumber,\n locale,\n formatters: { formatWeekdayName },\n labels: { labelWeekday }\n } = useDayPicker();\n\n const weekdays = getWeekdays(locale);\n\n return (\n <thead style={styles.head} className={classNames.head}>\n <tr style={styles.head_row} className={classNames.head_row}>\n {showWeekNumber && (\n <th\n scope=\"col\"\n style={styles.head_cell}\n className={classNames.head_cell}\n ></th>\n )}\n {weekdays.map((weekday, i) => (\n <th\n key={i}\n scope=\"col\"\n className={classNames.head_cell}\n style={styles.head_cell}\n >\n <span className={classNames.vhidden} aria-label=\"\">\n {labelWeekday(weekday, { locale })}\n </span>\n <span aria-hidden={true}>\n {formatWeekdayName(weekday, { locale })}\n </span>\n </th>\n ))}\n </tr>\n </thead>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Head.js","sources":["../../../src/components/Head/Head.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\nimport { getWeekdays } from './utils';\n\n/**\n * Render the Head component - i.e. the table head with the weekday names.\n */\nexport function Head(): JSX.Element {\n const {\n classNames,\n styles,\n showWeekNumber,\n locale,\n formatters: { formatWeekdayName },\n labels: { labelWeekday }\n } = useDayPicker();\n\n const weekdays = getWeekdays(locale);\n\n return (\n <thead style={styles.head} className={classNames.head}>\n <tr style={styles.head_row} className={classNames.head_row}>\n {showWeekNumber && (\n <th\n scope=\"col\"\n style={styles.head_cell}\n className={classNames.head_cell}\n ></th>\n )}\n {weekdays.map((weekday, i) => (\n <th\n key={i}\n scope=\"col\"\n className={classNames.head_cell}\n style={styles.head_cell}\n >\n <span className={classNames.vhidden} aria-label=\"\">\n {labelWeekday(weekday, { locale })}\n </span>\n <span aria-hidden={true}>\n {formatWeekdayName(weekday, { locale })}\n </span>\n </th>\n ))}\n </tr>\n </thead>\n );\n}\n"],"names":[],"mappings":";;;;;AAMA;;;SAGgB,IAAI;IACZ,IAAA,KAOF,YAAY,EAAE,EANhB,UAAU,gBAAA,EACV,MAAM,YAAA,EACN,cAAc,oBAAA,EACd,MAAM,YAAA,EACQ,iBAAiB,kCAAA,EACrB,YAAY,yBACN,CAAC;IAEnB,IAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAErC,QACE,+BAAO,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,IAAI;QACnD,4BAAI,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ;YACvD,cAAc,KACb,4BACE,KAAK,EAAC,KAAK,EACX,KAAK,EAAE,MAAM,CAAC,SAAS,EACvB,SAAS,EAAE,UAAU,CAAC,SAAS,GAC3B,CACP;YACA,QAAQ,CAAC,GAAG,CAAC,UAAC,OAAO,EAAE,CAAC,IAAK,QAC5B,4BACE,GAAG,EAAE,CAAC,EACN,KAAK,EAAC,KAAK,EACX,SAAS,EAAE,UAAU,CAAC,SAAS,EAC/B,KAAK,EAAE,MAAM,CAAC,SAAS;gBAEvB,8BAAM,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAa,EAAE,IAC/C,YAAY,CAAC,OAAO,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAC7B;gBACP,6CAAmB,IAAI,IACpB,iBAAiB,CAAC,OAAO,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAClC,CACJ,IACN,CAAC,CACC,CACC,EACR;AACJ;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { isSameYear, setMonth, startOfMonth } from 'date-fns';
|
|
3
3
|
import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
|
|
4
|
+
import '../../contexts/DayPicker/DayPickerContext.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Render the dropdown to navigate between months.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthsDropdown.js","sources":["../../../src/components/MonthsDropdown/MonthsDropdown.tsx"],"sourcesContent":["import React from 'react';\n\nimport { isSameYear, setMonth as setDateMonth, startOfMonth } from 'date-fns';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { MonthChangeEventHandler } from '../../types/EventHandlers';\n\n/** The props for the [[MonthsDropdown]] component. */\nexport interface MonthsDropdownProps {\n /** The month where the dropdown is displayed. */\n displayMonth: Date;\n onChange: MonthChangeEventHandler;\n}\n\n/**\n * Render the dropdown to navigate between months.\n */\nexport function MonthsDropdown(props: MonthsDropdownProps): JSX.Element {\n const { displayMonth } = props;\n\n const {\n fromDate,\n toDate,\n styles,\n locale,\n formatters: { formatMonthCaption },\n classNames,\n components: { Dropdown },\n labels: { labelMonthDropdown }\n } = useDayPicker();\n\n if (!fromDate && !toDate) {\n // TODO: use type guards\n return <></>;\n }\n const dropdownMonths: Date[] = [];\n\n if (fromDate && toDate) {\n if (isSameYear(fromDate, toDate)) {\n // only display the months included in the range\n for (\n let month = fromDate.getMonth();\n month <= toDate.getMonth();\n month++\n ) {\n dropdownMonths.push(setDateMonth(startOfMonth(fromDate), month));\n }\n } else {\n // display all the 12 months\n for (let month = 0; month <= 11; month++) {\n const anyDate = new Date(); // any date is OK, we just need the year\n dropdownMonths.push(setDateMonth(startOfMonth(anyDate), month));\n }\n }\n }\n\n const handleChange: React.ChangeEventHandler<HTMLSelectElement> = (e) => {\n const newMonth = setDateMonth(\n new Date(displayMonth),\n Number(e.target.value)\n );\n props.onChange(newMonth);\n };\n\n return (\n <Dropdown\n aria-label={labelMonthDropdown()}\n className={classNames.dropdown_month}\n style={styles.dropdown_month}\n onChange={handleChange}\n value={displayMonth.getMonth()}\n caption={formatMonthCaption(displayMonth, { locale })}\n >\n {dropdownMonths.map((m) => (\n <option key={m.getMonth()} value={m.getMonth()}>\n {formatMonthCaption(m, { locale })}\n </option>\n ))}\n </Dropdown>\n );\n}\n"],"names":["setDateMonth"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MonthsDropdown.js","sources":["../../../src/components/MonthsDropdown/MonthsDropdown.tsx"],"sourcesContent":["import React from 'react';\n\nimport { isSameYear, setMonth as setDateMonth, startOfMonth } from 'date-fns';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { MonthChangeEventHandler } from '../../types/EventHandlers';\n\n/** The props for the [[MonthsDropdown]] component. */\nexport interface MonthsDropdownProps {\n /** The month where the dropdown is displayed. */\n displayMonth: Date;\n onChange: MonthChangeEventHandler;\n}\n\n/**\n * Render the dropdown to navigate between months.\n */\nexport function MonthsDropdown(props: MonthsDropdownProps): JSX.Element {\n const { displayMonth } = props;\n\n const {\n fromDate,\n toDate,\n styles,\n locale,\n formatters: { formatMonthCaption },\n classNames,\n components: { Dropdown },\n labels: { labelMonthDropdown }\n } = useDayPicker();\n\n if (!fromDate && !toDate) {\n // TODO: use type guards\n return <></>;\n }\n const dropdownMonths: Date[] = [];\n\n if (fromDate && toDate) {\n if (isSameYear(fromDate, toDate)) {\n // only display the months included in the range\n for (\n let month = fromDate.getMonth();\n month <= toDate.getMonth();\n month++\n ) {\n dropdownMonths.push(setDateMonth(startOfMonth(fromDate), month));\n }\n } else {\n // display all the 12 months\n for (let month = 0; month <= 11; month++) {\n const anyDate = new Date(); // any date is OK, we just need the year\n dropdownMonths.push(setDateMonth(startOfMonth(anyDate), month));\n }\n }\n }\n\n const handleChange: React.ChangeEventHandler<HTMLSelectElement> = (e) => {\n const newMonth = setDateMonth(\n new Date(displayMonth),\n Number(e.target.value)\n );\n props.onChange(newMonth);\n };\n\n return (\n <Dropdown\n aria-label={labelMonthDropdown()}\n className={classNames.dropdown_month}\n style={styles.dropdown_month}\n onChange={handleChange}\n value={displayMonth.getMonth()}\n caption={formatMonthCaption(displayMonth, { locale })}\n >\n {dropdownMonths.map((m) => (\n <option key={m.getMonth()} value={m.getMonth()}>\n {formatMonthCaption(m, { locale })}\n </option>\n ))}\n </Dropdown>\n );\n}\n"],"names":["setDateMonth"],"mappings":";;;;;AAcA;;;SAGgB,cAAc,CAAC,KAA0B;IAC/C,IAAA,YAAY,GAAK,KAAK,aAAV,CAAW;IAEzB,IAAA,KASF,YAAY,EAAE,EARhB,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,MAAM,YAAA,EACN,MAAM,YAAA,EACQ,kBAAkB,mCAAA,EAChC,UAAU,gBAAA,EACI,QAAQ,yBAAA,EACZ,kBAAkB,+BACZ,CAAC;IAEnB,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE;;QAExB,OAAO,yCAAK,CAAC;KACd;IACD,IAAM,cAAc,GAAW,EAAE,CAAC;IAElC,IAAI,QAAQ,IAAI,MAAM,EAAE;QACtB,IAAI,UAAU,CAA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C3B,IACV,CAAC,CACO,EACX;AACJ;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
|
|
3
|
+
import '../../contexts/DayPicker/DayPickerContext.js';
|
|
3
4
|
import { Button } from '../Button/Button.js';
|
|
4
5
|
|
|
5
6
|
/** A component rendering the navigation buttons or the drop-downs. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navigation.js","sources":["../../../src/components/Navigation/Navigation.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { Button } from '../Button';\n\n/** The props for the [[Navigation]] component. */\nexport interface NavigationProps {\n /** The month where the caption is displayed. */\n displayMonth: Date;\n /** The previous month. */\n previousMonth?: Date;\n /** The next month. */\n nextMonth?: Date;\n /** Hide the previous button. */\n hidePrevious: boolean;\n /** Hide the next button. */\n hideNext: boolean;\n /** Event handler when the next button is clicked. */\n onNextClick: React.MouseEventHandler<HTMLButtonElement>;\n /** Event handler when the previous button is clicked. */\n onPreviousClick: React.MouseEventHandler<HTMLButtonElement>;\n}\n\n/** A component rendering the navigation buttons or the drop-downs. */\nexport function Navigation(props: NavigationProps): JSX.Element {\n const {\n dir,\n locale,\n classNames,\n styles,\n labels: { labelPrevious, labelNext },\n components: { IconRight, IconLeft }\n } = useDayPicker();\n let { onPreviousClick, onNextClick } = props;\n if (dir === 'rtl') {\n [onNextClick, onPreviousClick] = [onPreviousClick, onNextClick];\n }\n\n const { previousMonth, nextMonth } = props;\n\n const previousLabel = labelPrevious(previousMonth, { locale });\n const previousClassName = [\n classNames.nav_button,\n classNames.nav_button_previous\n ].join(' ');\n\n const nextLabel = labelNext(nextMonth, { locale });\n const nextClassName = [\n classNames.nav_button,\n classNames.nav_button_next\n ].join(' ');\n\n if (!nextMonth && !previousMonth) {\n return <></>;\n }\n\n return (\n <div className={classNames.nav} style={styles.nav}>\n {!props.hidePrevious && (\n <Button\n aria-label={previousLabel}\n className={previousClassName}\n style={styles.nav_button_next}\n disabled={!previousMonth}\n onClick={dir === 'rtl' ? onNextClick : onPreviousClick}\n >\n {dir === 'rtl' ? (\n <IconRight\n className={classNames.nav_icon}\n style={styles.nav_icon}\n />\n ) : (\n <IconLeft className={classNames.nav_icon} style={styles.nav_icon} />\n )}\n </Button>\n )}\n {!props.hideNext && (\n <Button\n aria-label={nextLabel}\n className={nextClassName}\n style={styles.nav_button_next}\n disabled={!nextMonth}\n onClick={dir === 'rtl' ? onPreviousClick : onNextClick}\n >\n {dir === 'rtl' ? (\n <IconLeft className={classNames.nav_icon} style={styles.nav_icon} />\n ) : (\n <IconRight\n className={classNames.nav_icon}\n style={styles.nav_icon}\n />\n )}\n </Button>\n )}\n </div>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Navigation.js","sources":["../../../src/components/Navigation/Navigation.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { Button } from '../Button';\n\n/** The props for the [[Navigation]] component. */\nexport interface NavigationProps {\n /** The month where the caption is displayed. */\n displayMonth: Date;\n /** The previous month. */\n previousMonth?: Date;\n /** The next month. */\n nextMonth?: Date;\n /** Hide the previous button. */\n hidePrevious: boolean;\n /** Hide the next button. */\n hideNext: boolean;\n /** Event handler when the next button is clicked. */\n onNextClick: React.MouseEventHandler<HTMLButtonElement>;\n /** Event handler when the previous button is clicked. */\n onPreviousClick: React.MouseEventHandler<HTMLButtonElement>;\n}\n\n/** A component rendering the navigation buttons or the drop-downs. */\nexport function Navigation(props: NavigationProps): JSX.Element {\n const {\n dir,\n locale,\n classNames,\n styles,\n labels: { labelPrevious, labelNext },\n components: { IconRight, IconLeft }\n } = useDayPicker();\n let { onPreviousClick, onNextClick } = props;\n if (dir === 'rtl') {\n [onNextClick, onPreviousClick] = [onPreviousClick, onNextClick];\n }\n\n const { previousMonth, nextMonth } = props;\n\n const previousLabel = labelPrevious(previousMonth, { locale });\n const previousClassName = [\n classNames.nav_button,\n classNames.nav_button_previous\n ].join(' ');\n\n const nextLabel = labelNext(nextMonth, { locale });\n const nextClassName = [\n classNames.nav_button,\n classNames.nav_button_next\n ].join(' ');\n\n if (!nextMonth && !previousMonth) {\n return <></>;\n }\n\n return (\n <div className={classNames.nav} style={styles.nav}>\n {!props.hidePrevious && (\n <Button\n aria-label={previousLabel}\n className={previousClassName}\n style={styles.nav_button_next}\n disabled={!previousMonth}\n onClick={dir === 'rtl' ? onNextClick : onPreviousClick}\n >\n {dir === 'rtl' ? (\n <IconRight\n className={classNames.nav_icon}\n style={styles.nav_icon}\n />\n ) : (\n <IconLeft className={classNames.nav_icon} style={styles.nav_icon} />\n )}\n </Button>\n )}\n {!props.hideNext && (\n <Button\n aria-label={nextLabel}\n className={nextClassName}\n style={styles.nav_button_next}\n disabled={!nextMonth}\n onClick={dir === 'rtl' ? onPreviousClick : onNextClick}\n >\n {dir === 'rtl' ? (\n <IconLeft className={classNames.nav_icon} style={styles.nav_icon} />\n ) : (\n <IconRight\n className={classNames.nav_icon}\n style={styles.nav_icon}\n />\n )}\n </Button>\n )}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;AAuBA;SACgB,UAAU,CAAC,KAAsB;;IACzC,IAAA,KAOF,YAAY,EAAE,EANhB,GAAG,SAAA,EACH,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,MAAM,YAAA,EACN,cAAoC,EAA1B,aAAa,mBAAA,EAAE,SAAS,eAAA,EAClC,kBAAmC,EAArB,SAAS,eAAA,EAAE,QAAQ,cACjB,CAAC;IACb,IAAA,eAAe,GAAkB,KAAK,gBAAvB,EAAE,WAAW,GAAK,KAAK,YAAV,CAAW;IAC7C,IAAI,GAAG,KAAK,KAAK,EAAE;QACjB,KAAiC,CAAC,eAAe,EAAE,WAAW,CAAC,EAA9D,WAAW,QAAA,EAAE,eAAe,QAAA,CAAmC;KACjE;IAEO,IAAA,aAAa,GAAgB,K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pB,OAAO,EAAE,GAAG,KAAK,KAAK,GAAG,eAAe,GAAG,WAAW,IAErD,GAAG,KAAK,KAAK,IACZ,oBAAC,QAAQ,IAAC,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,GAAI,KAEpE,oBAAC,SAAS,IACR,SAAS,EAAE,UAAU,CAAC,QAAQ,EAC9B,KAAK,EAAE,MAAM,CAAC,QAAQ,GACtB,CACH,CACM,CACV,CACG,EACN;AACJ;;;;"}
|
|
@@ -2,6 +2,7 @@ import { __assign } from '../../_virtual/_tslib.js';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Table } from '../Table/Table.js';
|
|
4
4
|
import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
|
|
5
|
+
import '../../contexts/DayPicker/DayPickerContext.js';
|
|
5
6
|
import '../../contexts/Navigation/NavigationContext.js';
|
|
6
7
|
import { useNavigation } from '../../contexts/Navigation/useNavigation.js';
|
|
7
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.js","sources":["../../../src/components/Root/Root.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Table } from '../Table';\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { useNavigation } from '../../contexts/Navigation';\n\n/**\n * Render the container with the months and their captions. The number of months\n * rendered depends by the `numberOfMonths` prop.\n */\nexport function Root(): JSX.Element {\n const {\n dir,\n className,\n classNames,\n style,\n styles,\n numberOfMonths,\n showWeekNumber,\n components: { Caption }\n } = useDayPicker();\n\n const { displayMonths } = useNavigation();\n\n const rootClassNames = [className ?? classNames.root];\n if (numberOfMonths > 1) {\n rootClassNames.push(classNames.multiple_month);\n }\n if (showWeekNumber) {\n rootClassNames.push(classNames.with_weeknumber);\n }\n if (className) rootClassNames.concat(className.split(' '));\n\n const renderMonth = (displayMonth: Date, displayIndex: number) => {\n const className = [classNames.month];\n const style = { ...styles.month };\n let isFirst = displayIndex === 0;\n let isLast = displayIndex === displayMonths.length - 1;\n\n if (dir === 'rtl') [isLast, isFirst] = [isFirst, isLast];\n\n if (isFirst) {\n className.push(classNames.caption_first);\n Object.assign(style, styles.caption_first);\n }\n if (isLast) className.push(classNames.caption_last);\n if (!isFirst && !isLast) className.push(classNames.caption_middle);\n\n return (\n <div key={displayIndex} className={className.join(' ')} style={style}>\n <Caption displayMonth={displayMonth} />\n <Table displayMonth={displayMonth} />\n </div>\n );\n };\n\n return (\n <div\n className={rootClassNames.join(' ')}\n style={{ ...styles.root, ...style }}\n dir={dir}\n >\n <div className={classNames.months} style={styles.months}>\n {displayMonths.map(renderMonth)}\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Root.js","sources":["../../../src/components/Root/Root.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Table } from '../Table';\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { useNavigation } from '../../contexts/Navigation';\n\n/**\n * Render the container with the months and their captions. The number of months\n * rendered depends by the `numberOfMonths` prop.\n */\nexport function Root(): JSX.Element {\n const {\n dir,\n className,\n classNames,\n style,\n styles,\n numberOfMonths,\n showWeekNumber,\n components: { Caption }\n } = useDayPicker();\n\n const { displayMonths } = useNavigation();\n\n const rootClassNames = [className ?? classNames.root];\n if (numberOfMonths > 1) {\n rootClassNames.push(classNames.multiple_month);\n }\n if (showWeekNumber) {\n rootClassNames.push(classNames.with_weeknumber);\n }\n if (className) rootClassNames.concat(className.split(' '));\n\n const renderMonth = (displayMonth: Date, displayIndex: number) => {\n const className = [classNames.month];\n const style = { ...styles.month };\n let isFirst = displayIndex === 0;\n let isLast = displayIndex === displayMonths.length - 1;\n\n if (dir === 'rtl') [isLast, isFirst] = [isFirst, isLast];\n\n if (isFirst) {\n className.push(classNames.caption_first);\n Object.assign(style, styles.caption_first);\n }\n if (isLast) className.push(classNames.caption_last);\n if (!isFirst && !isLast) className.push(classNames.caption_middle);\n\n return (\n <div key={displayIndex} className={className.join(' ')} style={style}>\n <Caption displayMonth={displayMonth} />\n <Table displayMonth={displayMonth} />\n </div>\n );\n };\n\n return (\n <div\n className={rootClassNames.join(' ')}\n style={{ ...styles.root, ...style }}\n dir={dir}\n >\n <div className={classNames.months} style={styles.months}>\n {displayMonths.map(renderMonth)}\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;AAMA;;;;SAIgB,IAAI;IACZ,IAAA,KASF,YAAY,EAAE,EARhB,GAAG,SAAA,EACH,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,KAAK,WAAA,EACL,MAAM,YAAA,EACN,cAAc,oBAAA,EACd,cAAc,oBAAA,EACA,OAAO,wBACL,CAAC;IAEX,IAAA,aAAa,GAAK,aAAa,EAAE,cAApB,CAAqB;IAE1C,IAAM,cAAc,GAAG,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,cAAc,GAAG,CAAC,EAAE;QACtB,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;KAChD;IACD,IAAI,cAAc,EAAE;QAClB,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;KACjD;IACD,IAAI,SAAS;QAAE,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAE3D,IAAM,WAAW,GAAG,UAAC,YAAkB,EAAE,YAAoB;;QAC3D,IAAM,SAAS,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACrC,IAAM,KAAK,gBAAQ,MAAM,CAAC,KAAK,CAAE,CAAC;QAClC,IAAI,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC;QACjC,IAAI,MAAM,GAAG,YAAY,KAAK,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QAEvD,IAAI,GAAG,KAAK,KAAK;YAAE,KAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,EAApC,MAAM,QAAA,EAAE,OAAO,QAAA,CAAsB;QAEzD,IAAI,OAAO,EAAE;YACX,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YACzC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;SAC5C;QACD,IAAI,MAAM;YAAE,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM;YAAE,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAEnE,QACE,6BAAK,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK;YAClE,oBAAC,OAAO,IAAC,YAAY,EAAE,YAAY,GAAI;YACvC,oBAAC,KAAK,IAAC,YAAY,EAAE,YAAY,GAAI,CACjC,EACN;KACH,CAAC;IAEF,QACE,6BACE,SAAS,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EACnC,KAAK,wBAAO,MAAM,CAAC,IAAI,GAAK,KAAK,GACjC,GAAG,EAAE,GAAG;QAER,6BAAK,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,IACpD,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAC3B,CACF,EACN;AACJ;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { getUnixTime } from 'date-fns';
|
|
3
3
|
import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
|
|
4
|
+
import '../../contexts/DayPicker/DayPickerContext.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Render a row in the calendar, with the days and optionally the week number.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.js","sources":["../../../src/components/Row/Row.tsx"],"sourcesContent":["import React from 'react';\n\nimport { getUnixTime } from 'date-fns';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/**\n * The props for the [[Row]] component.\n */\nexport interface RowProps {\n /** The month where the row is displayed. */\n displayMonth: Date;\n /** The number of the week to render. */\n weekNumber: number;\n /** The days contained in the week. */\n dates: Date[];\n}\n\n/**\n * Render a row in the calendar, with the days and optionally the week number.\n */\nexport function Row(props: RowProps): JSX.Element {\n const {\n styles,\n classNames,\n showWeekNumber,\n components: { Day, WeekNumber }\n } = useDayPicker();\n\n let weekNumberCell;\n if (showWeekNumber) {\n weekNumberCell = (\n <td className={classNames.cell} style={styles.cell}>\n <WeekNumber number={props.weekNumber} dates={props.dates} />\n </td>\n );\n }\n\n return (\n <tr className={classNames.row} style={styles.row}>\n {weekNumberCell}\n {props.dates.map((date) => (\n <td\n className={classNames.cell}\n style={styles.cell}\n key={getUnixTime(date)}\n >\n <Day displayMonth={props.displayMonth} date={date} />\n </td>\n ))}\n </tr>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Row.js","sources":["../../../src/components/Row/Row.tsx"],"sourcesContent":["import React from 'react';\n\nimport { getUnixTime } from 'date-fns';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/**\n * The props for the [[Row]] component.\n */\nexport interface RowProps {\n /** The month where the row is displayed. */\n displayMonth: Date;\n /** The number of the week to render. */\n weekNumber: number;\n /** The days contained in the week. */\n dates: Date[];\n}\n\n/**\n * Render a row in the calendar, with the days and optionally the week number.\n */\nexport function Row(props: RowProps): JSX.Element {\n const {\n styles,\n classNames,\n showWeekNumber,\n components: { Day, WeekNumber }\n } = useDayPicker();\n\n let weekNumberCell;\n if (showWeekNumber) {\n weekNumberCell = (\n <td className={classNames.cell} style={styles.cell}>\n <WeekNumber number={props.weekNumber} dates={props.dates} />\n </td>\n );\n }\n\n return (\n <tr className={classNames.row} style={styles.row}>\n {weekNumberCell}\n {props.dates.map((date) => (\n <td\n className={classNames.cell}\n style={styles.cell}\n key={getUnixTime(date)}\n >\n <Day displayMonth={props.displayMonth} date={date} />\n </td>\n ))}\n </tr>\n );\n}\n"],"names":[],"mappings":";;;;;AAkBA;;;SAGgB,GAAG,CAAC,KAAe;IAC3B,IAAA,KAKF,YAAY,EAAE,EAJhB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,cAAc,oBAAA,EACd,kBAA+B,EAAjB,GAAG,SAAA,EAAE,UAAU,gBACb,CAAC;IAEnB,IAAI,cAAc,CAAC;IACnB,IAAI,cAAc,EAAE;QAClB,cAAc,IACZ,4BAAI,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI;YAChD,oBAAC,UAAU,IAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,CACzD,CACN,CAAC;KACH;IAED,QACE,4BAAI,SAAS,EAAE,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG;QAC7C,cAAc;QACd,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,QACzB,4BACE,SAAS,EAAE,UAAU,CAAC,IAAI,EAC1B,KAAK,EAAE,MAAM,CAAC,IAAI,EAClB,GAAG,EAAE,WAAW,CAAC,IAAI,CAAC;YAEtB,oBAAC,GAAG,IAAC,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,GAAI,CAClD,IACN,CAAC,CACC,EACL;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sources":["../../../src/components/Table/Table.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\nimport { getWeeks } from './utils/getWeeks';\n\n/**\n * The props for the [[Table]] component.\n */\nexport interface TableProps {\n /** The month where the table is displayed. */\n displayMonth: Date;\n}\n\n/**\n * Render the table with the calendar.\n */\nexport function Table(props: TableProps): JSX.Element {\n const {\n locale,\n classNames,\n styles,\n hideHead,\n fixedWeeks,\n components: { Head, Row, Footer }\n } = useDayPicker();\n const weeks = getWeeks(props.displayMonth, { locale, fixedWeeks });\n return (\n <table className={classNames.table} style={styles.table}>\n {!hideHead && <Head />}\n <tbody className={classNames.tbody} style={styles.tbody}>\n {weeks.map((week) => (\n <Row\n displayMonth={props.displayMonth}\n key={week.weekNumber}\n dates={week.dates}\n weekNumber={week.weekNumber}\n />\n ))}\n </tbody>\n <Footer />\n </table>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Table.js","sources":["../../../src/components/Table/Table.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\nimport { getWeeks } from './utils/getWeeks';\n\n/**\n * The props for the [[Table]] component.\n */\nexport interface TableProps {\n /** The month where the table is displayed. */\n displayMonth: Date;\n}\n\n/**\n * Render the table with the calendar.\n */\nexport function Table(props: TableProps): JSX.Element {\n const {\n locale,\n classNames,\n styles,\n hideHead,\n fixedWeeks,\n components: { Head, Row, Footer }\n } = useDayPicker();\n const weeks = getWeeks(props.displayMonth, { locale, fixedWeeks });\n return (\n <table className={classNames.table} style={styles.table}>\n {!hideHead && <Head />}\n <tbody className={classNames.tbody} style={styles.tbody}>\n {weeks.map((week) => (\n <Row\n displayMonth={props.displayMonth}\n key={week.weekNumber}\n dates={week.dates}\n weekNumber={week.weekNumber}\n />\n ))}\n </tbody>\n <Footer />\n </table>\n );\n}\n"],"names":[],"mappings":";;;;;AAcA;;;SAGgB,KAAK,CAAC,KAAiB;IAC/B,IAAA,KAOF,YAAY,EAAE,EANhB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,MAAM,YAAA,EACN,QAAQ,cAAA,EACR,UAAU,gBAAA,EACV,kBAAiC,EAAnB,IAAI,UAAA,EAAE,GAAG,SAAA,EAAE,MAAM,YACf,CAAC;IACnB,IAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,MAAM,QAAA,EAAE,UAAU,YAAA,EAAE,CAAC,CAAC;IACnE,QACE,+BAAO,SAAS,EAAE,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK;QACpD,CAAC,QAAQ,IAAI,oBAAC,IAAI,OAAG;QACtB,+BAAO,SAAS,EAAE,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IACpD,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,QACnB,oBAAC,GAAG,IACF,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,GAAG,EAAE,IAAI,CAAC,UAAU,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,UAAU,EAAE,IAAI,CAAC,UAAU,GAC3B,IACH,CAAC,CACI;QACR,oBAAC,MAAM,OAAG,CACJ,EACR;AACJ;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Button } from '../Button/Button.js';
|
|
3
3
|
import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
|
|
4
|
+
import '../../contexts/DayPicker/DayPickerContext.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Render the week number element. If `onWeekNumberClick` is passed to DayPicker, it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WeekNumber.js","sources":["../../../src/components/WeekNumber/WeekNumber.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Button } from '../Button';\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/**\n * The props for the [[WeekNumber]] component.\n */\nexport interface WeekNumberProps {\n /** The number of the week. */\n number: number;\n /** The dates in the week. */\n dates: Date[];\n}\n\n/**\n * Render the week number element. If `onWeekNumberClick` is passed to DayPicker, it\n * renders a button, otherwise a span element.\n */\nexport function WeekNumber(props: WeekNumberProps): JSX.Element {\n const { number: weekNumber, dates } = props;\n const {\n onWeekNumberClick,\n styles,\n classNames,\n locale,\n labels: { labelWeekNumber },\n formatters: { formatWeekNumber }\n } = useDayPicker();\n\n const handleClick: React.MouseEventHandler = function (e) {\n onWeekNumberClick?.(weekNumber, dates, e);\n };\n\n const content = formatWeekNumber(Number(weekNumber), { locale });\n\n if (!onWeekNumberClick) {\n return (\n <span className={classNames.weeknumber} style={styles.weeknumber}>\n {content}\n </span>\n );\n }\n\n const label = labelWeekNumber(Number(weekNumber), { locale });\n\n return (\n <Button\n aria-label={label}\n className={classNames.weeknumber}\n style={styles.weeknumber}\n onClick={handleClick}\n >\n {content}\n </Button>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WeekNumber.js","sources":["../../../src/components/WeekNumber/WeekNumber.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Button } from '../Button';\nimport { useDayPicker } from '../../contexts/DayPicker';\n\n/**\n * The props for the [[WeekNumber]] component.\n */\nexport interface WeekNumberProps {\n /** The number of the week. */\n number: number;\n /** The dates in the week. */\n dates: Date[];\n}\n\n/**\n * Render the week number element. If `onWeekNumberClick` is passed to DayPicker, it\n * renders a button, otherwise a span element.\n */\nexport function WeekNumber(props: WeekNumberProps): JSX.Element {\n const { number: weekNumber, dates } = props;\n const {\n onWeekNumberClick,\n styles,\n classNames,\n locale,\n labels: { labelWeekNumber },\n formatters: { formatWeekNumber }\n } = useDayPicker();\n\n const handleClick: React.MouseEventHandler = function (e) {\n onWeekNumberClick?.(weekNumber, dates, e);\n };\n\n const content = formatWeekNumber(Number(weekNumber), { locale });\n\n if (!onWeekNumberClick) {\n return (\n <span className={classNames.weeknumber} style={styles.weeknumber}>\n {content}\n </span>\n );\n }\n\n const label = labelWeekNumber(Number(weekNumber), { locale });\n\n return (\n <Button\n aria-label={label}\n className={classNames.weeknumber}\n style={styles.weeknumber}\n onClick={handleClick}\n >\n {content}\n </Button>\n );\n}\n"],"names":[],"mappings":";;;;;AAeA;;;;SAIgB,UAAU,CAAC,KAAsB;IACvC,IAAQ,UAAU,GAAY,KAAK,OAAjB,EAAE,KAAK,GAAK,KAAK,MAAV,CAAW;IACtC,IAAA,KAOF,YAAY,EAAE,EANhB,iBAAiB,uBAAA,EACjB,MAAM,YAAA,EACN,UAAU,gBAAA,EACV,MAAM,YAAA,EACI,eAAe,4BAAA,EACX,gBAAgB,iCACd,CAAC;IAEnB,IAAM,WAAW,GAA4B,UAAU,CAAC;QACtD,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;KAC3C,CAAC;IAEF,IAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;IAEjE,IAAI,CAAC,iBAAiB,EAAE;QACtB,QACE,8BAAM,SAAS,EAAE,UAAU,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,IAC7D,OAAO,CACH,EACP;KACH;IAED,IAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;IAE9D,QACE,oBAAC,MAAM,kBACO,KAAK,EACjB,SAAS,EAAE,UAAU,CAAC,UAAU,EAChC,KAAK,EAAE,MAAM,CAAC,UAAU,EACxB,OAAO,EAAE,WAAW,IAEnB,OAAO,CACD,EACT;AACJ;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { setYear, startOfYear } from 'date-fns';
|
|
3
3
|
import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
|
|
4
|
+
import '../../contexts/DayPicker/DayPickerContext.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Render a dropdown to change the year. Take in account the `nav.fromDate` and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YearsDropdown.js","sources":["../../../src/components/YearsDropdown/YearsDropdown.tsx"],"sourcesContent":["import React from 'react';\n\nimport { setYear, startOfYear } from 'date-fns';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { MonthChangeEventHandler } from '../../types/EventHandlers';\n\n/**\n * The props for the [[YearsDropdown]] component.\n */\nexport interface YearsDropdownProps {\n /** The month where the drop-down is displayed. */\n displayMonth: Date;\n /** Callback to handle the `change` event. */\n onChange: MonthChangeEventHandler;\n}\n\n/**\n * Render a dropdown to change the year. Take in account the `nav.fromDate` and\n * `toDate` from context.\n */\nexport function YearsDropdown(props: YearsDropdownProps): JSX.Element {\n const { displayMonth } = props;\n const {\n fromDate,\n toDate,\n locale,\n styles,\n classNames,\n components: { Dropdown },\n formatters: { formatYearCaption },\n labels: { labelYearDropdown }\n } = useDayPicker();\n\n const years: Date[] = [];\n if (fromDate && toDate) {\n const fromYear = fromDate.getFullYear();\n const toYear = toDate.getFullYear();\n for (let year = fromYear; year <= toYear; year++) {\n years.push(setYear(startOfYear(new Date()), year));\n }\n }\n\n const handleChange: React.ChangeEventHandler<HTMLSelectElement> = (e) => {\n const newMonth = setYear(new Date(displayMonth), Number(e.target.value));\n props.onChange(newMonth);\n };\n\n return (\n <Dropdown\n aria-label={labelYearDropdown()}\n className={classNames.dropdown_month}\n style={styles.dropdown_month}\n onChange={handleChange}\n value={displayMonth.getFullYear()}\n caption={formatYearCaption(displayMonth, { locale })}\n >\n {years.map((year) => (\n <option key={year.getFullYear()} value={year.getFullYear()}>\n {formatYearCaption(year, { locale })}\n </option>\n ))}\n </Dropdown>\n );\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"YearsDropdown.js","sources":["../../../src/components/YearsDropdown/YearsDropdown.tsx"],"sourcesContent":["import React from 'react';\n\nimport { setYear, startOfYear } from 'date-fns';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { MonthChangeEventHandler } from '../../types/EventHandlers';\n\n/**\n * The props for the [[YearsDropdown]] component.\n */\nexport interface YearsDropdownProps {\n /** The month where the drop-down is displayed. */\n displayMonth: Date;\n /** Callback to handle the `change` event. */\n onChange: MonthChangeEventHandler;\n}\n\n/**\n * Render a dropdown to change the year. Take in account the `nav.fromDate` and\n * `toDate` from context.\n */\nexport function YearsDropdown(props: YearsDropdownProps): JSX.Element {\n const { displayMonth } = props;\n const {\n fromDate,\n toDate,\n locale,\n styles,\n classNames,\n components: { Dropdown },\n formatters: { formatYearCaption },\n labels: { labelYearDropdown }\n } = useDayPicker();\n\n const years: Date[] = [];\n if (fromDate && toDate) {\n const fromYear = fromDate.getFullYear();\n const toYear = toDate.getFullYear();\n for (let year = fromYear; year <= toYear; year++) {\n years.push(setYear(startOfYear(new Date()), year));\n }\n }\n\n const handleChange: React.ChangeEventHandler<HTMLSelectElement> = (e) => {\n const newMonth = setYear(new Date(displayMonth), Number(e.target.value));\n props.onChange(newMonth);\n };\n\n return (\n <Dropdown\n aria-label={labelYearDropdown()}\n className={classNames.dropdown_month}\n style={styles.dropdown_month}\n onChange={handleChange}\n value={displayMonth.getFullYear()}\n caption={formatYearCaption(displayMonth, { locale })}\n >\n {years.map((year) => (\n <option key={year.getFullYear()} value={year.getFullYear()}>\n {formatYearCaption(year, { locale })}\n </option>\n ))}\n </Dropdown>\n );\n}\n"],"names":[],"mappings":";;;;;AAiBA;;;;SAIgB,aAAa,CAAC,KAAyB;IAC7C,IAAA,YAAY,GAAK,KAAK,aAAV,CAAW;IACzB,IAAA,KASF,YAAY,EAAE,EARhB,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,MAAM,YAAA,EACN,MAAM,YAAA,EACN,UAAU,gBAAA,EACI,QAAQ,yBAAA,EACR,iBAAiB,kCAAA,EACrB,iBAAiB,8BACX,CAAC;IAEnB,IAAM,KAAK,GAAW,EAAE,CAAC;IACzB,IAAI,QAAQ,IAAI,MAAM,EAAE;QACtB,IAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QACxC,IAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACpC,KAAK,IAAI,IAAI,GAAG,QAAQ,EAAE,IAAI,IAAI,MAAM,EAAE,IAAI,EAAE,EAAE;YAChD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;SACpD;KACF;IAED,IAAM,YAAY,GAAgD,UAAC,CAAC;QAClE,IAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACzE,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC1B,CAAC;IAEF,QACE,oBAAC,QAAQ,kBACK,iBAAiB,EAAE,EAC/B,SAAS,EAAE,UAAU,CAAC,cAAc,EACpC,KAAK,EAAE,MAAM,CAAC,cAAc,EAC5B,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,YAAY,CAAC,WAAW,EAAE,EACjC,OAAO,EAAE,iBAAiB,CAAC,YAAY,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,IAEnD,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,QACnB,gCAAQ,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,IACvD,iBAAiB,CAAC,IAAI,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAC7B,IACV,CAAC,CACO,EACX;AACJ;;;;"}
|
|
@@ -9,10 +9,5 @@ export * from './Head';
|
|
|
9
9
|
export * from './IconDropdown';
|
|
10
10
|
export * from './IconRight';
|
|
11
11
|
export * from './IconLeft';
|
|
12
|
-
export * from './MonthsDropdown';
|
|
13
|
-
export * from './Navigation';
|
|
14
|
-
export * from './Root';
|
|
15
12
|
export * from './Row';
|
|
16
|
-
export * from './Table';
|
|
17
13
|
export * from './WeekNumber';
|
|
18
|
-
export * from './YearsDropdown';
|