react-day-picker 8.0.0-beta.32 → 8.0.0-beta.33
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 +12 -3
- package/build/DayPicker.d.ts +3 -2
- package/build/DayPicker.js +6 -5
- package/build/DayPicker.js.map +1 -1
- package/build/components/Button/Button.d.ts +1 -1
- package/build/components/Button/Button.js +1 -1
- package/build/components/Button/Button.js.map +1 -1
- package/build/components/Caption/Caption.d.ts +7 -0
- package/build/components/Caption/Caption.js +8 -8
- package/build/components/Caption/Caption.js.map +1 -1
- package/build/components/CaptionLabel/CaptionLabel.js +1 -1
- package/build/components/CaptionLabel/CaptionLabel.js.map +1 -1
- package/build/components/Day/Day.js +1 -1
- package/build/components/Day/Day.js.map +1 -1
- package/build/components/Day/hooks/useDay.d.ts +2 -2
- 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.d.ts +1 -1
- package/build/components/Day/hooks/useDayFocus.js +1 -1
- package/build/components/Day/hooks/useDayFocus.js.map +1 -1
- package/build/components/DayContent/DayContent.js +1 -1
- package/build/components/DayContent/DayContent.js.map +1 -1
- package/build/components/Dropdown/Dropdown.d.ts +1 -1
- package/build/components/Dropdown/Dropdown.js +1 -1
- package/build/components/Dropdown/Dropdown.js.map +1 -1
- package/build/components/Footer/Footer.js +1 -1
- package/build/components/Footer/Footer.js.map +1 -1
- package/build/components/Head/Head.js +1 -1
- package/build/components/Head/Head.js.map +1 -1
- package/build/components/IconDropdown/IconDropdown.d.ts +2 -2
- package/build/components/IconDropdown/IconDropdown.js +1 -1
- package/build/components/IconDropdown/IconDropdown.js.map +1 -1
- package/build/components/IconLeft/IconLeft.d.ts +2 -2
- package/build/components/IconLeft/IconLeft.js +3 -3
- package/build/components/IconLeft/IconLeft.js.map +1 -1
- package/build/components/IconRight/IconRight.d.ts +2 -2
- package/build/components/IconRight/IconRight.js +3 -3
- package/build/components/IconRight/IconRight.js.map +1 -1
- package/build/components/MonthsDropdown/MonthsDropdown.d.ts +1 -1
- package/build/components/MonthsDropdown/MonthsDropdown.js +1 -1
- package/build/components/MonthsDropdown/MonthsDropdown.js.map +1 -1
- package/build/components/Navigation/Navigation.d.ts +1 -1
- package/build/components/Navigation/Navigation.js +1 -1
- package/build/components/Navigation/Navigation.js.map +1 -1
- package/build/components/Root/Root.js +1 -2
- package/build/components/Root/Root.js.map +1 -1
- package/build/components/Row/Row.js +1 -1
- package/build/components/Row/Row.js.map +1 -1
- package/build/components/Table/Table.js +1 -1
- package/build/components/Table/Table.js.map +1 -1
- package/build/components/WeekNumber/WeekNumber.js +1 -1
- package/build/components/WeekNumber/WeekNumber.js.map +1 -1
- package/build/components/YearsDropdown/YearsDropdown.d.ts +1 -1
- package/build/components/YearsDropdown/YearsDropdown.js +1 -1
- package/build/components/YearsDropdown/YearsDropdown.js.map +1 -1
- package/build/contexts/DayPicker/DayPickerContext.d.ts +3 -2
- package/build/contexts/DayPicker/DayPickerContext.js +1 -1
- package/build/contexts/DayPicker/DayPickerContext.js.map +1 -1
- package/build/contexts/DayPicker/DayPickerProvider.d.ts +1 -1
- package/build/contexts/DayPicker/DayPickerProvider.js +1 -1
- package/build/contexts/DayPicker/DayPickerProvider.js.map +1 -1
- package/build/contexts/DayPicker/defaultClassNames.js +1 -3
- package/build/contexts/DayPicker/defaultClassNames.js.map +1 -1
- package/build/contexts/DayPicker/labels/labelDay.d.ts +2 -2
- package/build/contexts/DayPicker/labels/labelDay.js +1 -1
- package/build/contexts/DayPicker/labels/labelDay.js.map +1 -1
- package/build/contexts/DayPicker/labels/labelNext.d.ts +2 -2
- package/build/contexts/DayPicker/labels/labelNext.js.map +1 -1
- package/build/contexts/DayPicker/labels/labelPrevious.d.ts +2 -2
- package/build/contexts/DayPicker/labels/labelPrevious.js.map +1 -1
- package/build/contexts/DayPicker/labels/labelWeekNumber.d.ts +2 -2
- package/build/contexts/DayPicker/labels/labelWeekNumber.js.map +1 -1
- package/build/contexts/DayPicker/labels/labelWeekday.d.ts +2 -2
- package/build/contexts/DayPicker/labels/labelWeekday.js.map +1 -1
- package/build/contexts/DayPicker/useDayPicker.js +1 -1
- package/build/contexts/DayPicker/useDayPicker.js.map +1 -1
- package/build/contexts/DayPicker/utils/parseModifierProps.js +1 -0
- package/build/contexts/DayPicker/utils/parseModifierProps.js.map +1 -1
- package/build/contexts/Focus/FocusContext.d.ts +5 -1
- package/build/contexts/Focus/FocusContext.js +63 -3
- package/build/contexts/Focus/FocusContext.js.map +1 -1
- package/build/contexts/Focus/index.d.ts +0 -1
- package/build/contexts/Focus/useFocus.js +1 -1
- package/build/contexts/Focus/useFocus.js.map +1 -1
- package/build/contexts/Navigation/NavigationContext.d.ts +5 -1
- package/build/contexts/Navigation/NavigationContext.js +23 -3
- package/build/contexts/Navigation/NavigationContext.js.map +1 -1
- package/build/contexts/Navigation/index.d.ts +0 -1
- package/build/contexts/Navigation/useNavigation.js +1 -1
- package/build/contexts/Navigation/useNavigation.js.map +1 -1
- package/build/contexts/RootProvider.d.ts +8 -0
- package/build/contexts/{ContextProvider.js → RootProvider.js} +9 -14
- package/build/contexts/RootProvider.js.map +1 -0
- package/build/contexts/SelectMultiple/SelectMultipleContext.d.ts +14 -2
- package/build/contexts/SelectMultiple/SelectMultipleContext.js +73 -3
- package/build/contexts/SelectMultiple/SelectMultipleContext.js.map +1 -1
- package/build/contexts/SelectMultiple/index.d.ts +0 -1
- package/build/contexts/SelectMultiple/useSelectMultiple.js +1 -1
- package/build/contexts/SelectMultiple/useSelectMultiple.js.map +1 -1
- package/build/contexts/SelectRange/SelectRangeContext.d.ts +14 -3
- package/build/contexts/SelectRange/SelectRangeContext.js +114 -3
- package/build/contexts/SelectRange/SelectRangeContext.js.map +1 -1
- package/build/contexts/SelectRange/index.d.ts +0 -1
- package/build/contexts/SelectRange/useSelectRange.js +1 -1
- package/build/contexts/SelectRange/useSelectRange.js.map +1 -1
- package/build/contexts/SelectSingle/SelectSingleContext.d.ts +17 -3
- package/build/contexts/SelectSingle/SelectSingleContext.js +36 -3
- package/build/contexts/SelectSingle/SelectSingleContext.js.map +1 -1
- package/build/contexts/SelectSingle/index.d.ts +0 -1
- package/build/contexts/SelectSingle/useSelectSingle.js +1 -1
- package/build/contexts/SelectSingle/useSelectSingle.js.map +1 -1
- package/build/contexts/index.d.ts +1 -1
- package/build/hooks/useControlledValue/useControlledValue.js +2 -2
- package/build/hooks/useControlledValue/useControlledValue.js.map +1 -1
- package/build/hooks/useInput/useInput.d.ts +11 -32
- package/build/hooks/useInput/useInput.js +2 -4
- package/build/hooks/useInput/useInput.js.map +1 -1
- package/build/hooks/useModifiers/useModifiers.js +3 -5
- package/build/hooks/useModifiers/useModifiers.js.map +1 -1
- package/build/hooks/useModifiers/utils/isDateInRange.d.ts +1 -1
- package/build/hooks/useModifiers/utils/isDateInRange.js.map +1 -1
- package/build/hooks/useModifiers/utils/isMatch.d.ts +1 -1
- package/build/hooks/useModifiers/utils/isMatch.js +10 -8
- package/build/hooks/useModifiers/utils/isMatch.js.map +1 -1
- package/build/main.js +11 -22
- package/build/main.js.map +1 -1
- package/build/types/{DayPickerProps.d.ts → DayPicker.d.ts} +35 -16
- package/build/types/DayPickerCustom.d.ts +11 -0
- package/build/types/{isDayPickerCustom.js → DayPickerCustom.js} +1 -1
- package/build/types/DayPickerCustom.js.map +1 -0
- package/build/types/{DayPickerMultipleProps.d.ts → DayPickerMultiple.d.ts} +5 -5
- package/build/types/{isDayPickerMultiple.js → DayPickerMultiple.js} +1 -1
- package/build/types/DayPickerMultiple.js.map +1 -0
- package/build/types/{DayPickerRangeProps.d.ts → DayPickerRange.d.ts} +6 -6
- package/build/types/{isDayPickerRange.js → DayPickerRange.js} +1 -1
- package/build/types/DayPickerRange.js.map +1 -0
- package/build/types/DayPickerSingle.d.ts +14 -0
- package/build/types/{isDayPickerSingle.js → DayPickerSingle.js} +1 -1
- package/build/types/DayPickerSingle.js.map +1 -0
- package/build/types/EventHandlers.d.ts +51 -0
- package/build/types/Formatters.d.ts +10 -5
- package/build/types/Labels.d.ts +24 -12
- package/build/types/Matchers.d.ts +34 -0
- package/build/types/Matchers.js +27 -0
- package/build/types/Matchers.js.map +1 -0
- package/build/types/Modifiers.d.ts +15 -4
- package/build/types/Styles.d.ts +83 -2
- package/build/types/index.d.ts +7 -50
- package/dist/main.js +555 -589
- package/dist/main.js.map +1 -1
- package/package.json +3 -2
- package/build/contexts/ContextProvider.d.ts +0 -8
- package/build/contexts/ContextProvider.js.map +0 -1
- package/build/contexts/Focus/FocusProvider.d.ts +0 -5
- package/build/contexts/Focus/FocusProvider.js +0 -66
- package/build/contexts/Focus/FocusProvider.js.map +0 -1
- package/build/contexts/Navigation/NavigationProvider.d.ts +0 -5
- package/build/contexts/Navigation/NavigationProvider.js +0 -26
- package/build/contexts/Navigation/NavigationProvider.js.map +0 -1
- package/build/contexts/SelectMultiple/SelectMultipleProvider.d.ts +0 -9
- package/build/contexts/SelectMultiple/SelectMultipleProvider.js +0 -23
- package/build/contexts/SelectMultiple/SelectMultipleProvider.js.map +0 -1
- package/build/contexts/SelectMultiple/SelectMultipleProviderInternal.d.ts +0 -8
- package/build/contexts/SelectMultiple/SelectMultipleProviderInternal.js +0 -61
- package/build/contexts/SelectMultiple/SelectMultipleProviderInternal.js.map +0 -1
- package/build/contexts/SelectRange/SelectRangeProvider.d.ts +0 -9
- package/build/contexts/SelectRange/SelectRangeProvider.js +0 -26
- package/build/contexts/SelectRange/SelectRangeProvider.js.map +0 -1
- package/build/contexts/SelectRange/SelectRangeProviderInternal.d.ts +0 -8
- package/build/contexts/SelectRange/SelectRangeProviderInternal.js +0 -99
- package/build/contexts/SelectRange/SelectRangeProviderInternal.js.map +0 -1
- package/build/contexts/SelectSingle/SelectSingleProvider.d.ts +0 -9
- package/build/contexts/SelectSingle/SelectSingleProvider.js +0 -20
- package/build/contexts/SelectSingle/SelectSingleProvider.js.map +0 -1
- package/build/contexts/SelectSingle/SelectSingleProviderInternal.d.ts +0 -8
- package/build/contexts/SelectSingle/SelectSingleProviderInternal.js +0 -27
- package/build/contexts/SelectSingle/SelectSingleProviderInternal.js.map +0 -1
- package/build/types/CaptionLayout.d.ts +0 -7
- package/build/types/ClassNames.d.ts +0 -3
- package/build/types/Components.d.ts +0 -39
- package/build/types/CustomModifiers.d.ts +0 -4
- package/build/types/DateAfter.d.ts +0 -7
- package/build/types/DateBefore.d.ts +0 -7
- package/build/types/DateFormatter.d.ts +0 -6
- package/build/types/DateInterval.d.ts +0 -8
- package/build/types/DateRange.d.ts +0 -8
- package/build/types/DayClickEventHandler.d.ts +0 -6
- package/build/types/DayFocusEventHandler.d.ts +0 -6
- package/build/types/DayKeyboardEventHandler.d.ts +0 -6
- package/build/types/DayLabelFormatter.d.ts +0 -7
- package/build/types/DayMouseEventHandler.d.ts +0 -6
- package/build/types/DayOfWeekMatcher.d.ts +0 -7
- package/build/types/DayPickerCustomProps.d.ts +0 -11
- package/build/types/DayPickerSingleProps.d.ts +0 -14
- package/build/types/DayTouchEventHandler.d.ts +0 -6
- package/build/types/InternalModifier.d.ts +0 -2
- package/build/types/Matcher.d.ts +0 -10
- package/build/types/Modifier.d.ts +0 -5
- package/build/types/ModifierClassNames.d.ts +0 -5
- package/build/types/ModifierStatus.d.ts +0 -5
- package/build/types/ModifierStyles.d.ts +0 -4
- package/build/types/MonthChangeEventHandler.d.ts +0 -4
- package/build/types/NavButtonLabelFormatter.d.ts +0 -7
- package/build/types/SelectMultipleEventHandler.d.ts +0 -12
- package/build/types/SelectRangeEventHandler.d.ts +0 -10
- package/build/types/SelectSingleEventHandler.d.ts +0 -12
- package/build/types/StyledComponentProps.d.ts +0 -10
- package/build/types/StyledElement.d.ts +0 -76
- package/build/types/WeekNumberClickEventHandler.d.ts +0 -9
- package/build/types/WeekNumberFormatter.d.ts +0 -6
- package/build/types/WeekNumberLabelFormatter.d.ts +0 -5
- package/build/types/WeekdayLabelFormatter.d.ts +0 -4
- package/build/types/isArrayOfDates.d.ts +0 -2
- package/build/types/isArrayOfDates.js +0 -9
- package/build/types/isArrayOfDates.js.map +0 -1
- package/build/types/isDateAfterType.d.ts +0 -3
- package/build/types/isDateAfterType.js +0 -7
- package/build/types/isDateAfterType.js.map +0 -1
- package/build/types/isDateBeforeType.d.ts +0 -3
- package/build/types/isDateBeforeType.js +0 -7
- package/build/types/isDateBeforeType.js.map +0 -1
- package/build/types/isDateInterval.d.ts +0 -3
- package/build/types/isDateInterval.js +0 -10
- package/build/types/isDateInterval.js.map +0 -1
- package/build/types/isDateRange.d.ts +0 -3
- package/build/types/isDateRange.js +0 -8
- package/build/types/isDateRange.js.map +0 -1
- package/build/types/isDateType.d.ts +0 -2
- package/build/types/isDateType.js +0 -9
- package/build/types/isDateType.js.map +0 -1
- package/build/types/isDayOfWeekType.d.ts +0 -3
- package/build/types/isDayOfWeekType.js +0 -7
- package/build/types/isDayOfWeekType.js.map +0 -1
- package/build/types/isDayPickerCustom.d.ts +0 -4
- package/build/types/isDayPickerCustom.js.map +0 -1
- package/build/types/isDayPickerMultiple.d.ts +0 -4
- package/build/types/isDayPickerMultiple.js.map +0 -1
- package/build/types/isDayPickerRange.d.ts +0 -4
- package/build/types/isDayPickerRange.js.map +0 -1
- package/build/types/isDayPickerSingle.d.ts +0 -4
- package/build/types/isDayPickerSingle.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-day-picker",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.33",
|
|
4
4
|
"description": "Customizable Date Picker for React",
|
|
5
5
|
"author": "Giampaolo Bellavite <io@gpbl.dev>",
|
|
6
6
|
"homepage": "http://react-day-picker.js.org",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"css-types": "yarn tcm -p style.css",
|
|
23
23
|
"lint": "eslint --ext .ts,.tsx src",
|
|
24
24
|
"test": "jest",
|
|
25
|
-
"typecheck": "tsc --project ./tsconfig.json --noEmit"
|
|
25
|
+
"typecheck": "tsc --project ./tsconfig.json --noEmit",
|
|
26
|
+
"typecheck:watch": "tsc --project ./tsconfig.json --noEmit --skipLibCheck --watch"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
28
29
|
"build",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { DayPickerProps } from '../types';
|
|
3
|
-
/** The props of the [[ContextProvider]] provider. */
|
|
4
|
-
export declare type ContextProviderProps = DayPickerProps & {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
};
|
|
7
|
-
/** Provide the value for all the context providers. */
|
|
8
|
-
export declare function ContextProvider(props: ContextProviderProps): JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextProvider.js","sources":["../../src/contexts/ContextProvider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { DayPickerProps } from '../types';\n\nimport { DayPickerProvider } from './DayPicker/DayPickerProvider';\nimport { FocusProvider } from './Focus';\nimport { NavigationProvider } from './Navigation';\nimport { SelectMultipleProvider } from './SelectMultiple';\nimport { SelectRangeProvider } from './SelectRange';\nimport { SelectSingleProvider } from './SelectSingle';\n\n/** The props of the [[ContextProvider]] provider. */\nexport type ContextProviderProps = DayPickerProps & {\n children: React.ReactNode;\n};\n\n/** Provide the value for all the context providers. */\nexport function ContextProvider(props: ContextProviderProps): JSX.Element {\n const { children, ...initialProps } = props;\n\n return (\n <DayPickerProvider initialProps={initialProps}>\n <NavigationProvider>\n <SelectSingleProvider initialProps={initialProps}>\n <SelectMultipleProvider initialProps={initialProps}>\n <SelectRangeProvider initialProps={initialProps}>\n <FocusProvider>{children}</FocusProvider>\n </SelectRangeProvider>\n </SelectMultipleProvider>\n </SelectSingleProvider>\n </NavigationProvider>\n </DayPickerProvider>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAgBA;SACgB,eAAe,CAAC,KAA2B;IACjD,IAAA,QAAQ,GAAsB,KAAK,SAA3B,EAAK,YAAY,UAAK,KAAK,EAArC,YAA6B,CAAF,CAAW;IAE5C,QACE,oBAAC,iBAAiB,IAAC,YAAY,EAAE,YAAY;QAC3C,oBAAC,kBAAkB;YACjB,oBAAC,oBAAoB,IAAC,YAAY,EAAE,YAAY;gBAC9C,oBAAC,sBAAsB,IAAC,YAAY,EAAE,YAAY;oBAChD,oBAAC,mBAAmB,IAAC,YAAY,EAAE,YAAY;wBAC7C,oBAAC,aAAa,QAAE,QAAQ,CAAiB,CACrB,CACC,CACJ,CACJ,CACH,EACpB;AACJ;;;;"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { addDays, addWeeks, isSameMonth, addMonths } from 'date-fns';
|
|
3
|
-
import { useDayPicker } from '../DayPicker/useDayPicker.js';
|
|
4
|
-
import '../Navigation/NavigationContext.js';
|
|
5
|
-
import { useNavigation } from '../Navigation/useNavigation.js';
|
|
6
|
-
import { FocusContext } from './FocusContext.js';
|
|
7
|
-
|
|
8
|
-
/** The provider for the [[FocusContext]]. */
|
|
9
|
-
function FocusProvider(_a) {
|
|
10
|
-
var children = _a.children;
|
|
11
|
-
var _b = React.useState(), focusedDay = _b[0], setDay = _b[1];
|
|
12
|
-
var _c = useNavigation(), goToMonth = _c.goToMonth, displayMonths = _c.displayMonths;
|
|
13
|
-
var numberOfMonths = useDayPicker().numberOfMonths;
|
|
14
|
-
var blur = function () { return setDay(undefined); };
|
|
15
|
-
var focus = function (date) { return setDay(date); };
|
|
16
|
-
var switchMonth = function (date, offset) {
|
|
17
|
-
if (displayMonths.some(function (m) { return isSameMonth(date, m); }))
|
|
18
|
-
return;
|
|
19
|
-
if (offset < 0) {
|
|
20
|
-
goToMonth(addMonths(date, 1 + offset));
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
goToMonth(date);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var focusDayBefore = function () {
|
|
27
|
-
if (!focusedDay)
|
|
28
|
-
return;
|
|
29
|
-
var before = addDays(focusedDay, -1);
|
|
30
|
-
setDay(before);
|
|
31
|
-
switchMonth(before, numberOfMonths * -1);
|
|
32
|
-
};
|
|
33
|
-
var focusDayAfter = function () {
|
|
34
|
-
if (!focusedDay)
|
|
35
|
-
return;
|
|
36
|
-
var after = addDays(focusedDay, 1);
|
|
37
|
-
setDay(after);
|
|
38
|
-
switchMonth(after, numberOfMonths);
|
|
39
|
-
};
|
|
40
|
-
var focusWeekBeforeDay = function () {
|
|
41
|
-
if (!focusedDay)
|
|
42
|
-
return;
|
|
43
|
-
var up = addWeeks(focusedDay, -1);
|
|
44
|
-
setDay(up);
|
|
45
|
-
switchMonth(up, numberOfMonths * -1);
|
|
46
|
-
};
|
|
47
|
-
var focusWeekAfterDay = function () {
|
|
48
|
-
if (!focusedDay)
|
|
49
|
-
return;
|
|
50
|
-
var down = addWeeks(focusedDay, 1);
|
|
51
|
-
setDay(down);
|
|
52
|
-
switchMonth(down, numberOfMonths);
|
|
53
|
-
};
|
|
54
|
-
var setters = {
|
|
55
|
-
blur: blur,
|
|
56
|
-
focus: focus,
|
|
57
|
-
focusDayAfter: focusDayAfter,
|
|
58
|
-
focusDayBefore: focusDayBefore,
|
|
59
|
-
focusWeekAfterDay: focusWeekAfterDay,
|
|
60
|
-
focusWeekBeforeDay: focusWeekBeforeDay
|
|
61
|
-
};
|
|
62
|
-
return (React.createElement(FocusContext.Provider, { value: [focusedDay, setters] }, children));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export { FocusProvider };
|
|
66
|
-
//# sourceMappingURL=FocusProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FocusProvider.js","sources":["../../../src/contexts/Focus/FocusProvider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { addDays, addMonths, addWeeks, isSameMonth } from 'date-fns';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { useNavigation } from '../../contexts/Navigation';\n\nimport { FocusContext } from './FocusContext';\n\n/** The provider for the [[FocusContext]]. */\nexport function FocusProvider({\n children\n}: {\n children: React.ReactNode;\n}): JSX.Element {\n const [focusedDay, setDay] = React.useState<Date | undefined>();\n const { goToMonth, displayMonths } = useNavigation();\n const { numberOfMonths } = useDayPicker();\n\n const blur = () => setDay(undefined);\n const focus = (date: Date) => setDay(date);\n\n const switchMonth = (date: Date, offset: number) => {\n if (displayMonths.some((m) => isSameMonth(date, m))) return;\n if (offset < 0) {\n goToMonth(addMonths(date, 1 + offset));\n } else {\n goToMonth(date);\n }\n };\n\n const focusDayBefore = () => {\n if (!focusedDay) return;\n const before = addDays(focusedDay, -1);\n setDay(before);\n switchMonth(before, numberOfMonths * -1);\n };\n const focusDayAfter = () => {\n if (!focusedDay) return;\n const after = addDays(focusedDay, 1);\n setDay(after);\n switchMonth(after, numberOfMonths);\n };\n const focusWeekBeforeDay = () => {\n if (!focusedDay) return;\n const up = addWeeks(focusedDay, -1);\n setDay(up);\n switchMonth(up, numberOfMonths * -1);\n };\n const focusWeekAfterDay = () => {\n if (!focusedDay) return;\n const down = addWeeks(focusedDay, 1);\n setDay(down);\n switchMonth(down, numberOfMonths);\n };\n\n const setters = {\n blur,\n focus,\n focusDayAfter,\n focusDayBefore,\n focusWeekAfterDay,\n focusWeekBeforeDay\n };\n\n return (\n <FocusContext.Provider value={[focusedDay, setters]}>\n {children}\n </FocusContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;;AASA;SACgB,aAAa,CAAC,EAI7B;QAHC,QAAQ,cAAA;IAIF,IAAA,KAAuB,KAAK,CAAC,QAAQ,EAAoB,EAAxD,UAAU,QAAA,EAAE,MAAM,QAAsC,CAAC;IAC1D,IAAA,KAA+B,aAAa,EAAE,EAA5C,SAAS,eAAA,EAAE,aAAa,mBAAoB,CAAC;IAC7C,IAAA,cAAc,GAAK,YAAY,EAAE,eAAnB,CAAoB;IAE1C,IAAM,IAAI,GA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AAI,CAAC,UAAU;YAAE,OAAO;QACxB,IAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,CAAC;QACb,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;KACnC,CAAC;IAEF,IAAM,OAAO,GAAG;QACd,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,aAAa,eAAA;QACb,cAAc,gBAAA;QACd,iBAAiB,mBAAA;QACjB,kBAAkB,oBAAA;KACnB,CAAC;IAEF,QACE,oBAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC,IAChD,QAAQ,CACa,EACxB;AACJ;;;;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useDayPicker } from '../DayPicker/useDayPicker.js';
|
|
3
|
-
import { NavigationContext } from './NavigationContext.js';
|
|
4
|
-
import { useNavigationState } from './useNavigationState.js';
|
|
5
|
-
import { getDisplayMonths } from './utils/getDisplayMonths.js';
|
|
6
|
-
import { getNextMonth } from './utils/getNextMonth.js';
|
|
7
|
-
import { getPreviousMonth } from './utils/getPreviousMonth.js';
|
|
8
|
-
|
|
9
|
-
/** Provides the values for the [[NavigationContext]]. */
|
|
10
|
-
function NavigationProvider(props) {
|
|
11
|
-
var context = useDayPicker();
|
|
12
|
-
var _a = useNavigationState(), month = _a[0], goToMonth = _a[1];
|
|
13
|
-
var displayMonths = getDisplayMonths(month, context);
|
|
14
|
-
var nextMonth = getNextMonth(month, context);
|
|
15
|
-
var previousMonth = getPreviousMonth(month, context);
|
|
16
|
-
return (React.createElement(NavigationContext.Provider, { value: {
|
|
17
|
-
month: month,
|
|
18
|
-
displayMonths: displayMonths,
|
|
19
|
-
goToMonth: goToMonth,
|
|
20
|
-
previousMonth: previousMonth,
|
|
21
|
-
nextMonth: nextMonth
|
|
22
|
-
} }, props.children));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { NavigationProvider };
|
|
26
|
-
//# sourceMappingURL=NavigationProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationProvider.js","sources":["../../../src/contexts/Navigation/NavigationProvider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useDayPicker } from '../../contexts/DayPicker';\n\nimport { NavigationContext } from './NavigationContext';\nimport { useNavigationState } from './useNavigationState';\nimport { getDisplayMonths } from './utils/getDisplayMonths';\nimport { getNextMonth } from './utils/getNextMonth';\nimport { getPreviousMonth } from './utils/getPreviousMonth';\n\n/** Provides the values for the [[NavigationContext]]. */\nexport function NavigationProvider(props: {\n children?: React.ReactNode;\n}): JSX.Element {\n const context = useDayPicker();\n const [month, goToMonth] = useNavigationState();\n\n const displayMonths = getDisplayMonths(month, context);\n const nextMonth = getNextMonth(month, context);\n const previousMonth = getPreviousMonth(month, context);\n\n return (\n <NavigationContext.Provider\n value={{\n month,\n displayMonths,\n goToMonth,\n previousMonth,\n nextMonth\n }}\n >\n {props.children}\n </NavigationContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;;;AAUA;SACgB,kBAAkB,CAAC,KAElC;IACC,IAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IACzB,IAAA,KAAqB,kBAAkB,EAAE,EAAxC,KAAK,QAAA,EAAE,SAAS,QAAwB,CAAC;IAEhD,IAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACvD,IAAM,SAAS,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/C,IAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAEvD,QACE,oBAAC,iBAAiB,CAAC,QAAQ,IACzB,KAAK,EAAE;YACL,KAAK,OAAA;YACL,aAAa,eAAA;YACb,SAAS,WAAA;YACT,aAAa,eAAA;YACb,SAAS,WAAA;SACV,IAEA,KAAK,CAAC,QAAQ,CACY,EAC7B;AACJ;;;;"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { DayPickerProps } from '../../types';
|
|
3
|
-
declare type SelectMultipleProviderProps = {
|
|
4
|
-
initialProps: DayPickerProps;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
};
|
|
7
|
-
/** Provides the values for the [[SelectMultipleContext]]. */
|
|
8
|
-
export declare function SelectMultipleProvider(props: SelectMultipleProviderProps): JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import 'date-fns';
|
|
3
|
-
import { isDayPickerMultiple } from '../../types/isDayPickerMultiple.js';
|
|
4
|
-
import { SelectMultipleContext } from './SelectMultipleContext.js';
|
|
5
|
-
import { SelectMultipleProviderInternal } from './SelectMultipleProviderInternal.js';
|
|
6
|
-
|
|
7
|
-
/** Provides the values for the [[SelectMultipleContext]]. */
|
|
8
|
-
function SelectMultipleProvider(props) {
|
|
9
|
-
if (!isDayPickerMultiple(props.initialProps)) {
|
|
10
|
-
var emptyContextValue = {
|
|
11
|
-
selected: undefined,
|
|
12
|
-
modifiers: {
|
|
13
|
-
selected: [],
|
|
14
|
-
disabled: []
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
return (React.createElement(SelectMultipleContext.Provider, { value: emptyContextValue }, props.children));
|
|
18
|
-
}
|
|
19
|
-
return (React.createElement(SelectMultipleProviderInternal, { initialProps: props.initialProps, children: props.children }));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { SelectMultipleProvider };
|
|
23
|
-
//# sourceMappingURL=SelectMultipleProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMultipleProvider.js","sources":["../../../src/contexts/SelectMultiple/SelectMultipleProvider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { DayPickerProps, isDayPickerMultiple } from '../../types';\nimport {\n SelectMultipleContext,\n SelectMultipleContextValue\n} from './SelectMultipleContext';\nimport { SelectMultipleProviderInternal } from './SelectMultipleProviderInternal';\n\ntype SelectMultipleProviderProps = {\n initialProps: DayPickerProps;\n children: React.ReactNode;\n};\n\n/** Provides the values for the [[SelectMultipleContext]]. */\nexport function SelectMultipleProvider(\n props: SelectMultipleProviderProps\n): JSX.Element {\n if (!isDayPickerMultiple(props.initialProps)) {\n const emptyContextValue: SelectMultipleContextValue = {\n selected: undefined,\n modifiers: {\n selected: [],\n disabled: []\n }\n };\n return (\n <SelectMultipleContext.Provider value={emptyContextValue}>\n {props.children}\n </SelectMultipleContext.Provider>\n );\n }\n return (\n <SelectMultipleProviderInternal\n initialProps={props.initialProps}\n children={props.children}\n />\n );\n}\n"],"names":[],"mappings":";;;;;;AAcA;SACgB,sBAAsB,CACpC,KAAkC;IAElC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;QAC5C,IAAM,iBAAiB,GAA+B;YACpD,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE;gBACT,QAAQ,EAAE,EAAE;gBACZ,QAAQ,EAAE,EAAE;aACb;SACF,CAAC;QACF,QACE,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,iBAAiB,IACrD,KAAK,CAAC,QAAQ,CACgB,EACjC;KACH;IACD,QACE,oBAAC,8BAA8B,IAC7B,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GACxB,EACF;AACJ;;;;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { DayPickerMultipleProps } from '../../types';
|
|
3
|
-
declare type SelectMultipleProviderInternalProps = {
|
|
4
|
-
initialProps: DayPickerMultipleProps;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
};
|
|
7
|
-
export declare function SelectMultipleProviderInternal({ initialProps, children }: SelectMultipleProviderInternalProps): JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { __spreadArray } from '../../_virtual/_tslib.js';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { isSameDay } from 'date-fns';
|
|
4
|
-
import { SelectMultipleContext } from './SelectMultipleContext.js';
|
|
5
|
-
|
|
6
|
-
function SelectMultipleProviderInternal(_a) {
|
|
7
|
-
var initialProps = _a.initialProps, children = _a.children;
|
|
8
|
-
var selected = initialProps.selected;
|
|
9
|
-
var handleDayClick = function (day, modifiers, e) {
|
|
10
|
-
var _a, _b;
|
|
11
|
-
(_a = initialProps.onDayClick) === null || _a === void 0 ? void 0 : _a.call(initialProps, day, modifiers, e);
|
|
12
|
-
var isMinSelected = Boolean(initialProps.min &&
|
|
13
|
-
modifiers.selected &&
|
|
14
|
-
selected &&
|
|
15
|
-
selected.length === initialProps.min);
|
|
16
|
-
if (isMinSelected) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
var isMaxSelected = Boolean(initialProps.max &&
|
|
20
|
-
!modifiers.selected &&
|
|
21
|
-
selected &&
|
|
22
|
-
selected.length === initialProps.max);
|
|
23
|
-
if (isMaxSelected) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
var days = selected ? __spreadArray([], selected, true) : [];
|
|
27
|
-
if (modifiers.selected) {
|
|
28
|
-
var index = days.findIndex(function (selectedDay) {
|
|
29
|
-
return isSameDay(day, selectedDay);
|
|
30
|
-
});
|
|
31
|
-
days.splice(index, 1);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
days.push(day);
|
|
35
|
-
}
|
|
36
|
-
(_b = initialProps.onSelect) === null || _b === void 0 ? void 0 : _b.call(initialProps, days, day, modifiers, e);
|
|
37
|
-
};
|
|
38
|
-
var modifiers = {
|
|
39
|
-
selected: [],
|
|
40
|
-
disabled: []
|
|
41
|
-
};
|
|
42
|
-
if (selected) {
|
|
43
|
-
modifiers.selected = selected;
|
|
44
|
-
modifiers.disabled = [
|
|
45
|
-
function disableDay(day) {
|
|
46
|
-
var isMaxSelected = initialProps.max &&
|
|
47
|
-
selected &&
|
|
48
|
-
selected.length > initialProps.max - 1;
|
|
49
|
-
var isSelected = selected === null || selected === void 0 ? void 0 : selected.some(function (selectedDay) {
|
|
50
|
-
return isSameDay(selectedDay, day);
|
|
51
|
-
});
|
|
52
|
-
return Boolean(isMaxSelected && !isSelected);
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
}
|
|
56
|
-
var contextValue = { selected: selected, handleDayClick: handleDayClick, modifiers: modifiers };
|
|
57
|
-
return (React.createElement(SelectMultipleContext.Provider, { value: contextValue }, children));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { SelectMultipleProviderInternal };
|
|
61
|
-
//# sourceMappingURL=SelectMultipleProviderInternal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMultipleProviderInternal.js","sources":["../../../src/contexts/SelectMultiple/SelectMultipleProviderInternal.tsx"],"sourcesContent":["import * as React from 'react';\nimport { isSameDay } from 'date-fns';\nimport { useControlledValue } from '../../hooks/useControlledValue';\nimport { DayClickEventHandler, DayPickerMultipleProps } from '../../types';\nimport {\n SelectMultipleContext,\n SelectMultipleModifiers\n} from './SelectMultipleContext';\n\ntype SelectMultipleProviderInternalProps = {\n initialProps: DayPickerMultipleProps;\n children: React.ReactNode;\n};\n\nexport function SelectMultipleProviderInternal({\n initialProps,\n children\n}: SelectMultipleProviderInternalProps): JSX.Element {\n const { selected } = initialProps;\n const handleDayClick: DayClickEventHandler = (day, modifiers, e) => {\n initialProps.onDayClick?.(day, modifiers, e);\n\n const isMinSelected = Boolean(\n initialProps.min &&\n modifiers.selected &&\n selected &&\n selected.length === initialProps.min\n );\n if (isMinSelected) {\n return;\n }\n const isMaxSelected = Boolean(\n initialProps.max &&\n !modifiers.selected &&\n selected &&\n selected.length === initialProps.max\n );\n if (isMaxSelected) {\n return;\n }\n\n const days = selected ? [...selected] : [];\n if (modifiers.selected) {\n const index = days.findIndex((selectedDay) =>\n isSameDay(day, selectedDay)\n );\n days.splice(index, 1);\n } else {\n days.push(day);\n }\n initialProps.onSelect?.(days, day, modifiers, e);\n };\n\n const modifiers: SelectMultipleModifiers = {\n selected: [],\n disabled: []\n };\n\n if (selected) {\n modifiers.selected = selected;\n modifiers.disabled = [\n function disableDay(day: Date) {\n const isMaxSelected =\n initialProps.max &&\n selected &&\n selected.length > initialProps.max - 1;\n const isSelected = selected?.some((selectedDay) =>\n isSameDay(selectedDay, day)\n );\n return Boolean(isMaxSelected && !isSelected);\n }\n ];\n }\n\n const contextValue = { selected, handleDayClick, modifiers };\n\n return (\n <SelectMultipleContext.Provider value={contextValue}>\n {children}\n </SelectMultipleContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;SAcgB,8BAA8B,CAAC,EAGT;QAFpC,YAAY,kBAAA,EACZ,QAAQ,cAAA;IAEA,IAAA,QAAQ,GAAK,YAAY,SAAjB,CAAkB;IAClC,IAAM,cAAc,GAAyB,UAAC,GAAG,EAAE,SAAS,EAAE,CAAC;;QAC7D,MAAA,YAAY,CAAC,UAAU,+CAAvB,YAAY,EAAc,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QAE7C,IAAM,aAAa,GAAG,OAAO,CAC3B,YAAY,CAAC,GAAG;YACd,SAAS,CAAC,QAAQ;YAClB,QAAQ;YACR,QAAQ,CAAC,MAAM,KAAK,YAAY,CAAC,GAAG,CACvC,CAAC;QACF,IAAI,aAAa,EAAE;YACjB,OAAO;SACR;QACD,IAAM,aAAa,GAAG,OAAO,CAC3B,YAAY,CAAC,GAAG;YACd,CAAC,SAAS,CAAC,QAAQ;YACnB,QAAQ;YACR,QAAQ,CAAC,MAAM,KAAK,YAAY,CAAC,GAAG,CACvC,CAAC;QACF,IAAI,aAAa,EAAE;YACjB,OAAO;SACR;QAED,IAAM,IAAI,GAAG,QAAQ,qBAAO,QAAQ,UAAI,E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
1
|
-
import * as React from 'react';
|
|
2
|
-
import { DayPickerProps } from '../../types';
|
|
3
|
-
declare type SelectRangeProviderProps = {
|
|
4
|
-
initialProps: DayPickerProps;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
};
|
|
7
|
-
/** Provides the values for the [[SelectRangeProvider]]. */
|
|
8
|
-
export declare function SelectRangeProvider(props: SelectRangeProviderProps): JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import 'date-fns';
|
|
3
|
-
import { isDayPickerRange } from '../../types/isDayPickerRange.js';
|
|
4
|
-
import { SelectRangeContext } from './SelectRangeContext.js';
|
|
5
|
-
import { SelectRangeProviderInternal } from './SelectRangeProviderInternal.js';
|
|
6
|
-
|
|
7
|
-
/** Provides the values for the [[SelectRangeProvider]]. */
|
|
8
|
-
function SelectRangeProvider(props) {
|
|
9
|
-
if (!isDayPickerRange(props.initialProps)) {
|
|
10
|
-
var emptyContextValue = {
|
|
11
|
-
selected: undefined,
|
|
12
|
-
modifiers: {
|
|
13
|
-
selected: [],
|
|
14
|
-
range_start: [],
|
|
15
|
-
range_end: [],
|
|
16
|
-
range_middle: [],
|
|
17
|
-
disabled: []
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
return (React.createElement(SelectRangeContext.Provider, { value: emptyContextValue }, props.children));
|
|
21
|
-
}
|
|
22
|
-
return (React.createElement(SelectRangeProviderInternal, { initialProps: props.initialProps, children: props.children }));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { SelectRangeProvider };
|
|
26
|
-
//# sourceMappingURL=SelectRangeProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectRangeProvider.js","sources":["../../../src/contexts/SelectRange/SelectRangeProvider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { DayPickerProps, isDayPickerRange } from '../../types';\n\nimport { SelectRangeContext } from './SelectRangeContext';\nimport { SelectRangeContextValue } from '.';\nimport { SelectRangeProviderInternal } from './SelectRangeProviderInternal';\n\ntype SelectRangeProviderProps = {\n initialProps: DayPickerProps;\n children: React.ReactNode;\n};\n\n/** Provides the values for the [[SelectRangeProvider]]. */\nexport function SelectRangeProvider(\n props: SelectRangeProviderProps\n): JSX.Element {\n if (!isDayPickerRange(props.initialProps)) {\n const emptyContextValue: SelectRangeContextValue = {\n selected: undefined,\n modifiers: {\n selected: [],\n range_start: [],\n range_end: [],\n range_middle: [],\n disabled: []\n }\n };\n return (\n <SelectRangeContext.Provider value={emptyContextValue}>\n {props.children}\n </SelectRangeContext.Provider>\n );\n }\n return (\n <SelectRangeProviderInternal\n initialProps={props.initialProps}\n children={props.children}\n />\n );\n}\n"],"names":[],"mappings":";;;;;;AAaA;SACgB,mBAAmB,CACjC,KAA+B;IAE/B,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;QACzC,IAAM,iBAAiB,GAA4B;YACjD,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE;gBACT,QAAQ,EAAE,EAAE;gBACZ,WAAW,EAAE,EAAE;gBACf,SAAS,EAAE,EAAE;gBACb,YAAY,EAAE,EAAE;gBAChB,QAAQ,EAAE,EAAE;aACb;SACF,CAAC;QACF,QACE,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,iBAAiB,IAClD,KAAK,CAAC,QAAQ,CACa,EAC9B;KACH;IACD,QACE,oBAAC,2BAA2B,IAC1B,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GACxB,EACF;AACJ;;;;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { DayPickerRangeProps } from '../../types';
|
|
3
|
-
declare type SelectRangeProviderInternalProps = {
|
|
4
|
-
initialProps: DayPickerRangeProps;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
};
|
|
7
|
-
export declare function SelectRangeProviderInternal({ initialProps, children }: SelectRangeProviderInternalProps): JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { differenceInCalendarDays, isBefore, isAfter } from 'date-fns';
|
|
3
|
-
import { SelectRangeContext } from './SelectRangeContext.js';
|
|
4
|
-
import { addToRange } from './utils/addToRange.js';
|
|
5
|
-
|
|
6
|
-
function SelectRangeProviderInternal(_a) {
|
|
7
|
-
var initialProps = _a.initialProps, children = _a.children;
|
|
8
|
-
var selected = initialProps.selected;
|
|
9
|
-
var min = initialProps.min;
|
|
10
|
-
var max = initialProps.max;
|
|
11
|
-
var handleDayClick = function (day, modifiers, e) {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
(_a = initialProps.onDayClick) === null || _a === void 0 ? void 0 : _a.call(initialProps, day, modifiers, e);
|
|
14
|
-
var newValue = addToRange(day, selected);
|
|
15
|
-
if ((min || max) &&
|
|
16
|
-
selected &&
|
|
17
|
-
(newValue === null || newValue === void 0 ? void 0 : newValue.to) &&
|
|
18
|
-
newValue.from &&
|
|
19
|
-
newValue.from !== newValue.to) {
|
|
20
|
-
var diff = Math.abs(differenceInCalendarDays(newValue === null || newValue === void 0 ? void 0 : newValue.to, newValue === null || newValue === void 0 ? void 0 : newValue.from));
|
|
21
|
-
if (min && diff < min) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (max && diff >= max) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
(_b = initialProps.onSelect) === null || _b === void 0 ? void 0 : _b.call(initialProps, newValue, day, modifiers, e);
|
|
29
|
-
};
|
|
30
|
-
var modifiers = {
|
|
31
|
-
selected: [],
|
|
32
|
-
range_start: [],
|
|
33
|
-
range_end: [],
|
|
34
|
-
range_middle: [],
|
|
35
|
-
disabled: []
|
|
36
|
-
};
|
|
37
|
-
if (selected) {
|
|
38
|
-
modifiers.selected = [selected];
|
|
39
|
-
if (selected.from) {
|
|
40
|
-
modifiers.range_start = [selected.from];
|
|
41
|
-
if (selected.to) {
|
|
42
|
-
modifiers.range_middle = [
|
|
43
|
-
{
|
|
44
|
-
after: selected.from,
|
|
45
|
-
before: selected.to
|
|
46
|
-
}
|
|
47
|
-
];
|
|
48
|
-
if (max || min) {
|
|
49
|
-
modifiers.disabled = [
|
|
50
|
-
function (date) {
|
|
51
|
-
if (max &&
|
|
52
|
-
selected.to &&
|
|
53
|
-
selected.from &&
|
|
54
|
-
isBefore(date, selected.from)) {
|
|
55
|
-
var diff = differenceInCalendarDays(selected.to, date);
|
|
56
|
-
if (diff >= max) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (max &&
|
|
61
|
-
selected.to &&
|
|
62
|
-
selected.from &&
|
|
63
|
-
isAfter(date, selected.to)) {
|
|
64
|
-
var diff = differenceInCalendarDays(date, selected.from);
|
|
65
|
-
if (diff >= max) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (min && selected.from && isBefore(date, selected.from)) {
|
|
70
|
-
var diff = differenceInCalendarDays(selected.from, date);
|
|
71
|
-
if (diff < min) {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (min &&
|
|
76
|
-
selected.to &&
|
|
77
|
-
selected.from &&
|
|
78
|
-
isAfter(date, selected.to)) {
|
|
79
|
-
var diff = differenceInCalendarDays(date, selected.from);
|
|
80
|
-
if (diff < min) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
];
|
|
87
|
-
}
|
|
88
|
-
modifiers.range_end = [selected.to];
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
modifiers.range_end = [selected.from];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return (React.createElement(SelectRangeContext.Provider, { value: { selected: selected, handleDayClick: handleDayClick, modifiers: modifiers } }, children));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export { SelectRangeProviderInternal };
|
|
99
|
-
//# sourceMappingURL=SelectRangeProviderInternal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectRangeProviderInternal.js","sources":["../../../src/contexts/SelectRange/SelectRangeProviderInternal.tsx"],"sourcesContent":["import * as React from 'react';\nimport { differenceInCalendarDays, isAfter, isBefore } from 'date-fns';\nimport { DayClickEventHandler, DayPickerRangeProps } from '../../types';\nimport { SelectRangeContext, SelectRangeModifiers } from './SelectRangeContext';\nimport { addToRange } from './utils/addToRange';\n\ntype SelectRangeProviderInternalProps = {\n initialProps: DayPickerRangeProps;\n children: React.ReactNode;\n};\n\nexport function SelectRangeProviderInternal({\n initialProps,\n children\n}: SelectRangeProviderInternalProps): JSX.Element {\n const { selected } = initialProps;\n const min = initialProps.min;\n const max = initialProps.max;\n\n const handleDayClick: DayClickEventHandler = (day, modifiers, e) => {\n initialProps.onDayClick?.(day, modifiers, e);\n const newValue = addToRange(day, selected);\n if (\n (min || max) &&\n selected &&\n newValue?.to &&\n newValue.from &&\n newValue.from !== newValue.to\n ) {\n const diff = Math.abs(\n differenceInCalendarDays(newValue?.to, newValue?.from)\n );\n if (min && diff < min) {\n return;\n }\n if (max && diff >= max) {\n return;\n }\n }\n initialProps.onSelect?.(newValue, day, modifiers, e);\n };\n\n const modifiers: SelectRangeModifiers = {\n selected: [],\n range_start: [],\n range_end: [],\n range_middle: [],\n disabled: []\n };\n\n if (selected) {\n modifiers.selected = [selected];\n if (selected.from) {\n modifiers.range_start = [selected.from];\n if (selected.to) {\n modifiers.range_middle = [\n {\n after: selected.from,\n before: selected.to\n }\n ];\n if (max || min) {\n modifiers.disabled = [\n (date: Date) => {\n if (\n max &&\n selected.to &&\n selected.from &&\n isBefore(date, selected.from)\n ) {\n const diff = differenceInCalendarDays(selected.to, date);\n if (diff >= max) {\n return true;\n }\n }\n if (\n max &&\n selected.to &&\n selected.from &&\n isAfter(date, selected.to)\n ) {\n const diff = differenceInCalendarDays(date, selected.from);\n if (diff >= max) {\n return true;\n }\n }\n if (min && selected.from && isBefore(date, selected.from)) {\n const diff = differenceInCalendarDays(selected.from, date);\n if (diff < min) {\n return true;\n }\n }\n if (\n min &&\n selected.to &&\n selected.from &&\n isAfter(date, selected.to)\n ) {\n const diff = differenceInCalendarDays(date, selected.from);\n if (diff < min) {\n return true;\n }\n }\n return false;\n }\n ];\n }\n modifiers.range_end = [selected.to];\n } else {\n modifiers.range_end = [selected.from];\n }\n }\n }\n return (\n <SelectRangeContext.Provider\n value={{ selected, handleDayClick, modifiers }}\n >\n {children}\n </SelectRangeContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;SAWgB,2BAA2B,CAAC,EAGT;QAFjC,YAAY,kBAAA,EACZ,QAAQ,cAAA;IAEA,IAAA,QAAQ,GAAK,YAAY,SAAjB,CAAkB;IAClC,IAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;IAC7B,IAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;IAE7B,IAAM,cAAc,GAAyB,UAAC,GAAG,EAAE,SAAS,EAAE,CAAC;;QAC7D,MAAA,YAAY,CAAC,UAAU,+CAAvB,YAAY,EAAc,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QAC7C,IAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC3C,IACE,CAAC,GAAG,IAAI,GAAG;YACX,QAAQ;aACR,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,EAAE,CAAA;YACZ,QAAQ,CAAC,IAAI;YACb,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,EAC7B;YACA,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CACnB,wBAAwB,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAA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import * as React from 'react';
|
|
2
|
-
import { DayPickerProps } from '../../types';
|
|
3
|
-
declare type SelectSingleProviderProps = {
|
|
4
|
-
initialProps: DayPickerProps;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
};
|
|
7
|
-
/** Provides the values for the [[SelectSingleProvider]]. */
|
|
8
|
-
export declare function SelectSingleProvider(props: SelectSingleProviderProps): JSX.Element;
|
|
9
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import 'date-fns';
|
|
3
|
-
import { isDayPickerSingle } from '../../types/isDayPickerSingle.js';
|
|
4
|
-
import { SelectSingleContext } from './SelectSingleContext.js';
|
|
5
|
-
import { SelectSingleProviderInternal } from './SelectSingleProviderInternal.js';
|
|
6
|
-
|
|
7
|
-
/** Provides the values for the [[SelectSingleProvider]]. */
|
|
8
|
-
function SelectSingleProvider(props) {
|
|
9
|
-
if (!isDayPickerSingle(props.initialProps)) {
|
|
10
|
-
var emptyContextValue = {
|
|
11
|
-
selected: undefined,
|
|
12
|
-
modifiers: { selected: [] }
|
|
13
|
-
};
|
|
14
|
-
return (React.createElement(SelectSingleContext.Provider, { value: emptyContextValue }, props.children));
|
|
15
|
-
}
|
|
16
|
-
return (React.createElement(SelectSingleProviderInternal, { initialProps: props.initialProps, children: props.children }));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { SelectSingleProvider };
|
|
20
|
-
//# sourceMappingURL=SelectSingleProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectSingleProvider.js","sources":["../../../src/contexts/SelectSingle/SelectSingleProvider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { DayPickerProps, isDayPickerSingle } from '../../types';\nimport { SelectSingleContextValue } from './';\nimport { SelectSingleContext } from './SelectSingleContext';\nimport { SelectSingleProviderInternal } from './SelectSingleProviderInternal';\n\ntype SelectSingleProviderProps = {\n initialProps: DayPickerProps;\n children: React.ReactNode;\n};\n\n/** Provides the values for the [[SelectSingleProvider]]. */\nexport function SelectSingleProvider(\n props: SelectSingleProviderProps\n): JSX.Element {\n if (!isDayPickerSingle(props.initialProps)) {\n const emptyContextValue: SelectSingleContextValue = {\n selected: undefined,\n modifiers: { selected: [] }\n };\n return (\n <SelectSingleContext.Provider value={emptyContextValue}>\n {props.children}\n </SelectSingleContext.Provider>\n );\n }\n return (\n <SelectSingleProviderInternal\n initialProps={props.initialProps}\n children={props.children}\n />\n );\n}\n"],"names":[],"mappings":";;;;;;AAYA;SACgB,oBAAoB,CAClC,KAAgC;IAEhC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;QAC1C,IAAM,iBAAiB,GAA6B;YAClD,QAAQ,EAAE,SAAS;YACnB,SAAS,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;SAC5B,CAAC;QACF,QACE,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,iBAAiB,IACnD,KAAK,CAAC,QAAQ,CACc,EAC/B;KACH;IACD,QACE,oBAAC,4BAA4B,IAC3B,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GACxB,EACF;AACJ;;;;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { DayPickerSingleProps } from '../../types';
|
|
3
|
-
declare type SelectSingleProviderInternal = {
|
|
4
|
-
initialProps: DayPickerSingleProps;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
};
|
|
7
|
-
export declare function SelectSingleProviderInternal({ initialProps, children }: SelectSingleProviderInternal): JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { SelectSingleContext } from './SelectSingleContext.js';
|
|
3
|
-
|
|
4
|
-
function SelectSingleProviderInternal(_a) {
|
|
5
|
-
var initialProps = _a.initialProps, children = _a.children;
|
|
6
|
-
var handleDayClick = function (day, dayModifiers, e) {
|
|
7
|
-
var _a, _b;
|
|
8
|
-
if (dayModifiers.selected && !initialProps.required) {
|
|
9
|
-
(_a = initialProps.onSelect) === null || _a === void 0 ? void 0 : _a.call(initialProps, undefined, day, dayModifiers, e);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
(_b = initialProps.onSelect) === null || _b === void 0 ? void 0 : _b.call(initialProps, day, day, dayModifiers, e);
|
|
13
|
-
};
|
|
14
|
-
var modifiers = { selected: [] };
|
|
15
|
-
if (initialProps.selected) {
|
|
16
|
-
modifiers.selected = [initialProps.selected];
|
|
17
|
-
}
|
|
18
|
-
var contextValue = {
|
|
19
|
-
selected: initialProps.selected,
|
|
20
|
-
handleDayClick: handleDayClick,
|
|
21
|
-
modifiers: modifiers
|
|
22
|
-
};
|
|
23
|
-
return (React.createElement(SelectSingleContext.Provider, { value: contextValue }, children));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { SelectSingleProviderInternal };
|
|
27
|
-
//# sourceMappingURL=SelectSingleProviderInternal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectSingleProviderInternal.js","sources":["../../../src/contexts/SelectSingle/SelectSingleProviderInternal.tsx"],"sourcesContent":["import * as React from 'react';\nimport { DayClickEventHandler, DayPickerSingleProps } from '../../types';\nimport { SelectSingleContextValue } from './';\nimport {\n SelectSingleContext,\n SelectSingleModifiers\n} from './SelectSingleContext';\n\ntype SelectSingleProviderInternal = {\n initialProps: DayPickerSingleProps;\n children: React.ReactNode;\n};\n\nexport function SelectSingleProviderInternal({\n initialProps,\n children\n}: SelectSingleProviderInternal): JSX.Element {\n const handleDayClick: DayClickEventHandler = (day, dayModifiers, e) => {\n if (dayModifiers.selected && !initialProps.required) {\n initialProps.onSelect?.(undefined, day, dayModifiers, e);\n return;\n }\n initialProps.onSelect?.(day, day, dayModifiers, e);\n };\n\n const modifiers: SelectSingleModifiers = { selected: [] };\n\n if (initialProps.selected) {\n modifiers.selected = [initialProps.selected];\n }\n\n const contextValue: SelectSingleContextValue = {\n selected: initialProps.selected,\n handleDayClick,\n modifiers\n };\n return (\n <SelectSingleContext.Provider value={contextValue}>\n {children}\n </SelectSingleContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;SAagB,4BAA4B,CAAC,EAGd;QAF7B,YAAY,kBAAA,EACZ,QAAQ,cAAA;IAER,IAAM,cAAc,GAAyB,UAAC,GAAG,EAAE,YAAY,EAAE,CAAC;;QAChE,IAAI,YAAY,CAAC,QAAQ,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE;YACnD,MAAA,YAAY,CAAC,QAAQ,+CAArB,YAAY,EAAY,SAAS,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;YACzD,OAAO;SACR;QACD,MAAA,YAAY,CAAC,QAAQ,+CAArB,YAAY,EAAY,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;KACpD,CAAC;IAEF,IAAM,SAAS,GAA0B,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAE1D,IAAI,YAAY,CAAC,QAAQ,EAAE;QACzB,SAAS,CAAC,QAAQ,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;KAC9C;IAED,IAAM,YAAY,GAA6B;QAC7C,QAAQ,EAAE,YAAY,CAAC,QAAQ;QAC/B,cAAc,gBAAA;QACd,SAAS,WAAA;KACV,CAAC;IACF,QACE,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAC9C,QAAQ,CACoB,EAC/B;AACJ;;;;"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { CaptionProps } from '../components/Caption';
|
|
3
|
-
import { CaptionLabelProps } from '../components/CaptionLabel';
|
|
4
|
-
import { DayProps } from '../components/Day';
|
|
5
|
-
import { DayContentProps } from '../components/DayContent';
|
|
6
|
-
import { DropdownProps } from '../components/Dropdown';
|
|
7
|
-
import { RowProps } from '../components/Row';
|
|
8
|
-
import { WeekNumberProps } from '../components/WeekNumber';
|
|
9
|
-
import { StyledComponentProps } from './StyledComponentProps';
|
|
10
|
-
/**
|
|
11
|
-
* Represent a map of the component that can be changed via the `components`
|
|
12
|
-
* prop.
|
|
13
|
-
*/
|
|
14
|
-
export interface Components {
|
|
15
|
-
/** The component for the caption element. */
|
|
16
|
-
Caption: (props: CaptionProps) => JSX.Element | null;
|
|
17
|
-
/** The component for the caption element. */
|
|
18
|
-
CaptionLabel: (props: CaptionLabelProps) => JSX.Element | null;
|
|
19
|
-
/** The component for the day element. This is a button or a span. */
|
|
20
|
-
Day: (props: DayProps) => JSX.Element | null;
|
|
21
|
-
/** The component for the content of the day element. */
|
|
22
|
-
DayContent: (props: DayContentProps) => JSX.Element | null;
|
|
23
|
-
/** The component for the drop-down elements. */
|
|
24
|
-
Dropdown: (props: DropdownProps) => JSX.Element | null;
|
|
25
|
-
/** The component for the table footer. */
|
|
26
|
-
Footer: () => JSX.Element | null;
|
|
27
|
-
/** The component for the table’s head. */
|
|
28
|
-
Head: () => JSX.Element | null;
|
|
29
|
-
/** The component for the small icon in the drop-downs. */
|
|
30
|
-
IconDropdown: (props: StyledComponentProps) => JSX.Element | null;
|
|
31
|
-
/** The arrow right icon (used for the Navigation buttons). */
|
|
32
|
-
IconRight: (props: StyledComponentProps) => JSX.Element | null;
|
|
33
|
-
/** The arrow left icon (used for the Navigation buttons). */
|
|
34
|
-
IconLeft: (props: StyledComponentProps) => JSX.Element | null;
|
|
35
|
-
/** The component for the table rows. */
|
|
36
|
-
Row: (props: RowProps) => JSX.Element | null;
|
|
37
|
-
/** The component for the week number in the table rows. */
|
|
38
|
-
WeekNumber: (props: WeekNumberProps) => JSX.Element | null;
|
|
39
|
-
}
|