react-day-picker 8.0.0-beta.31 → 8.0.0-beta.32

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +1 -1
  3. package/build/DayPicker.d.ts +2 -2
  4. package/build/DayPicker.js.map +1 -1
  5. package/build/components/Caption/Caption.js +11 -11
  6. package/build/components/Caption/Caption.js.map +1 -1
  7. package/build/components/Day/hooks/useDay.js +1 -1
  8. package/build/components/Day/hooks/useDay.js.map +1 -1
  9. package/build/components/Day/hooks/useDayFocus.js +11 -4
  10. package/build/components/Day/hooks/useDayFocus.js.map +1 -1
  11. package/build/components/{IconPrevious/IconPrevious.d.ts → IconLeft/IconLeft.d.ts} +1 -1
  12. package/build/components/IconLeft/IconLeft.js +13 -0
  13. package/build/components/IconLeft/IconLeft.js.map +1 -0
  14. package/build/components/IconLeft/index.d.ts +1 -0
  15. package/build/components/{IconNext/IconNext.d.ts → IconRight/IconRight.d.ts} +1 -1
  16. package/build/components/IconRight/IconRight.js +13 -0
  17. package/build/components/IconRight/IconRight.js.map +1 -0
  18. package/build/components/IconRight/index.d.ts +1 -0
  19. package/build/components/Navigation/Navigation.js +4 -8
  20. package/build/components/Navigation/Navigation.js.map +1 -1
  21. package/build/components/index.d.ts +2 -2
  22. package/build/contexts/DayPicker/DayPickerProvider.js +5 -5
  23. package/build/contexts/DayPicker/DayPickerProvider.js.map +1 -1
  24. package/build/contexts/SelectMultiple/SelectMultipleProvider.js +2 -55
  25. package/build/contexts/SelectMultiple/SelectMultipleProvider.js.map +1 -1
  26. package/build/contexts/SelectMultiple/SelectMultipleProviderInternal.d.ts +8 -0
  27. package/build/contexts/SelectMultiple/SelectMultipleProviderInternal.js +61 -0
  28. package/build/contexts/SelectMultiple/SelectMultipleProviderInternal.js.map +1 -0
  29. package/build/contexts/SelectRange/SelectRangeProvider.d.ts +1 -5
  30. package/build/contexts/SelectRange/SelectRangeProvider.js +3 -96
  31. package/build/contexts/SelectRange/SelectRangeProvider.js.map +1 -1
  32. package/build/contexts/SelectRange/SelectRangeProviderInternal.d.ts +8 -0
  33. package/build/contexts/SelectRange/SelectRangeProviderInternal.js +99 -0
  34. package/build/contexts/SelectRange/SelectRangeProviderInternal.js.map +1 -0
  35. package/build/contexts/SelectSingle/SelectSingleProvider.d.ts +1 -5
  36. package/build/contexts/SelectSingle/SelectSingleProvider.js +2 -26
  37. package/build/contexts/SelectSingle/SelectSingleProvider.js.map +1 -1
  38. package/build/contexts/SelectSingle/SelectSingleProviderInternal.d.ts +8 -0
  39. package/build/contexts/SelectSingle/SelectSingleProviderInternal.js +27 -0
  40. package/build/contexts/SelectSingle/SelectSingleProviderInternal.js.map +1 -0
  41. package/build/hooks/useInput/index.d.ts +0 -1
  42. package/build/hooks/useInput/useInput.d.ts +48 -3
  43. package/build/hooks/useInput/useInput.js +6 -6
  44. package/build/hooks/useInput/useInput.js.map +1 -1
  45. package/build/main.js +4 -4
  46. package/build/test/PageObjects.d.ts +4 -4
  47. package/build/test/customRender.d.ts +1 -1
  48. package/build/test/customRenderHook.d.ts +2 -2
  49. package/build/types/Components.d.ts +4 -4
  50. package/build/types/DayPickerCustomProps.d.ts +11 -0
  51. package/build/types/{DayPickerMultiple.d.ts → DayPickerMultipleProps.d.ts} +5 -6
  52. package/build/types/DayPickerProps.d.ts +209 -9
  53. package/build/types/DayPickerRangeProps.d.ts +17 -0
  54. package/build/types/DayPickerSingleProps.d.ts +14 -0
  55. package/build/types/Labels.d.ts +1 -2
  56. package/build/types/index.d.ts +5 -5
  57. package/build/types/isDayPickerCustom.d.ts +2 -2
  58. package/build/types/isDayPickerCustom.js.map +1 -1
  59. package/build/types/isDayPickerMultiple.d.ts +2 -2
  60. package/build/types/isDayPickerMultiple.js.map +1 -1
  61. package/build/types/isDayPickerRange.d.ts +2 -2
  62. package/build/types/isDayPickerRange.js.map +1 -1
  63. package/build/types/isDayPickerSingle.d.ts +2 -2
  64. package/build/types/isDayPickerSingle.js.map +1 -1
  65. package/dist/main.js +54 -59
  66. package/dist/main.js.map +1 -1
  67. package/package.json +3 -3
  68. package/build/components/IconNext/IconNext.js +0 -13
  69. package/build/components/IconNext/IconNext.js.map +0 -1
  70. package/build/components/IconNext/index.d.ts +0 -1
  71. package/build/components/IconPrevious/IconPrevious.js +0 -13
  72. package/build/components/IconPrevious/IconPrevious.js.map +0 -1
  73. package/build/components/IconPrevious/index.d.ts +0 -1
  74. package/build/hooks/useInput/types/UseInput.d.ts +0 -12
  75. package/build/hooks/useInput/types/UseInputDayPickerProps.d.ts +0 -14
  76. package/build/hooks/useInput/types/UseInputFieldProps.d.ts +0 -12
  77. package/build/hooks/useInput/types/UseInputOptions.d.ts +0 -35
  78. package/build/hooks/useInput/types/index.d.ts +0 -4
  79. package/build/types/DayPickerBase.d.ts +0 -238
  80. package/build/types/DayPickerCustom.d.ts +0 -7
  81. package/build/types/DayPickerRange.d.ts +0 -20
  82. package/build/types/DayPickerSingle.d.ts +0 -15
package/CHANGELOG.md CHANGED
@@ -16,7 +16,13 @@ with the previous versions.
16
16
 
17
17
  See the preview website at https://react-day-picker-next.netlify.app.
18
18
 
19
- ### v8.0.0-beta.30
19
+ ### v8.0.0-beta.32
20
+
21
+ - Fixed previous/next month navigation with RTL direction (68ad0adf7fb6935eb6d9809a6e72646e6194d51e)
22
+ - Updated `useInput` API (#1293)
23
+ - Removed `defaultSelected` prop (cd4f57906d98eb15b0b5a498112e74c2f6770c45)
24
+
25
+ ### v8.0.0-beta.31
20
26
 
21
27
  - Switched to rollup as module bundler
22
28
  - Added `custom` selection mode
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # React DayPicker
1
+ # React DayPicker (beta)
2
2
 
3
3
  DayPicker is a date picker component for [React](https://reactjs.org).
4
4
 
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { DayPickerProps } from './types';
2
+ import { DayPickerCustomProps, DayPickerMultipleProps, DayPickerProps, DayPickerRangeProps, DayPickerSingleProps } from './types';
3
3
  /**
4
4
  * DayPicker render a date picker component to let users pick dates from a
5
5
  * calendar. See http://react-day-picker.js.org for updated documentation and
@@ -85,4 +85,4 @@ import { DayPickerProps } from './types';
85
85
  * <DayPicker locale={es} />
86
86
  * ```
87
87
  */
88
- export declare function DayPicker(props: DayPickerProps): JSX.Element;
88
+ export declare function DayPicker(props: DayPickerProps | DayPickerSingleProps | DayPickerMultipleProps | DayPickerRangeProps | DayPickerCustomProps): JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"DayPicker.js","sources":["../src/DayPicker.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { DayPickerProps } from './types';\n\nimport { Root } from './components/Root';\nimport { ContextProvider } from './contexts/ContextProvider';\n\n/**\n * DayPicker render a date picker component to let users pick dates from a\n * calendar. See http://react-day-picker.js.org for updated documentation and\n * examples.\n *\n * ### Customization\n *\n * DayPicker offers different customization props. For example,\n *\n * - show multiple months using `numberOfMonths`\n * - display a dropdown to navigate the months via `captionLayout`\n * - display the week numbers with `showWeekNumbers`\n * - disable or hide days with `disabled` or `hidden`\n *\n * ### Controlling the months\n *\n * Change the initially displayed month using the `defaultMonth` prop. The\n * displayed months are controlled by DayPicker and stored in its internal\n * state. To control the months yourself, use `month` instead of `defaultMonth`\n * and use the `onMonthChange` event to set it.\n *\n * To limit the months the user can navigate to, use\n * `fromDate`/`fromMonth`/`fromYear` or `toDate`/`toMonth`/`toYear`.\n *\n * ### Selection modes\n *\n * DayPicker supports different selection mode that can be toggled using the\n * `mode` prop:\n *\n * - `mode=\"single\"`: only one day can be selected. Use `required` to make the\n * selection required. Use the `onSelect` event handler to get the selected\n * days.\n * - `mode=\"multiple\"`: users can select one or more days. Limit the amount of\n * days that can be selected with the `min` or the `max` props.\n * - `mode=\"range\"`: users can select a range of days. Limit the amount of days\n * in the range with the `min` or the `max` props.\n *\n * These selection modes should cover the most common use cases. In case you\n * need a more refined way of selecting days, use `mode=\"custom\"`. Use the\n * `selected` props and add the day event handlers to add/remove days from the\n * selection.\n *\n * ### Modifiers\n *\n * A _modifier_ represents different styles or states for the days displayed in\n * the calendar (like \"selected\" or \"disabled\"). Define custom modifiers using\n * the `modifiers` prop.\n *\n * ### Formatters and custom component\n *\n * You can customize how the content is displayed in the date picker by using\n * either the formatters or replacing the internal components.\n *\n * For the most common cases you want to use the `formatters` prop to change how\n * the content is formatted in the calendar. Use the `components` prop to\n * replace the internal components, like the navigation icons.\n *\n * ### Styling\n *\n * DayPicker comes with a default, basic style in `react-day-picker/style` –\n * use it as template for your own style.\n *\n * If you are using CSS modules, pass the imported styles object the\n * `classNames` props.\n *\n * You can also style the elements via inline-styles using the `styles` prop.\n *\n * ### Form fields\n *\n * If you need to bind the date picker to a form field, you can use the\n * `useInput` hooks for a basic behavior. See the `useInput` source as an\n * example to bind the date picker with form fields.\n *\n * ### Localization\n *\n * To localize DayPicker, import the locale from `date-fns` package and use the\n * `locale` prop.\n *\n * For example, to use Spanish locale:\n *\n * ```\n * import es from 'date-fns/locale/es';\n * <DayPicker locale={es} />\n * ```\n */\nexport function DayPicker(props: DayPickerProps): JSX.Element {\n return (\n <ContextProvider {...props}>\n <Root />\n </ContextProvider>\n );\n}\n"],"names":[],"mappings":";;;;;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAqFgB,SAAS,CAAC,KAAqB;IAC7C,QACE,oBAAC,eAAe,eAAK,KAAK;QACxB,oBAAC,IAAI,OAAG,CACQ,EAClB;AACJ;;;;"}
1
+ {"version":3,"file":"DayPicker.js","sources":["../src/DayPicker.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n DayPickerCustomProps,\n DayPickerMultipleProps,\n DayPickerProps,\n DayPickerRangeProps,\n DayPickerSingleProps\n} from './types';\n\nimport { Root } from './components/Root';\nimport { ContextProvider } from './contexts/ContextProvider';\n\n/**\n * DayPicker render a date picker component to let users pick dates from a\n * calendar. See http://react-day-picker.js.org for updated documentation and\n * examples.\n *\n * ### Customization\n *\n * DayPicker offers different customization props. For example,\n *\n * - show multiple months using `numberOfMonths`\n * - display a dropdown to navigate the months via `captionLayout`\n * - display the week numbers with `showWeekNumbers`\n * - disable or hide days with `disabled` or `hidden`\n *\n * ### Controlling the months\n *\n * Change the initially displayed month using the `defaultMonth` prop. The\n * displayed months are controlled by DayPicker and stored in its internal\n * state. To control the months yourself, use `month` instead of `defaultMonth`\n * and use the `onMonthChange` event to set it.\n *\n * To limit the months the user can navigate to, use\n * `fromDate`/`fromMonth`/`fromYear` or `toDate`/`toMonth`/`toYear`.\n *\n * ### Selection modes\n *\n * DayPicker supports different selection mode that can be toggled using the\n * `mode` prop:\n *\n * - `mode=\"single\"`: only one day can be selected. Use `required` to make the\n * selection required. Use the `onSelect` event handler to get the selected\n * days.\n * - `mode=\"multiple\"`: users can select one or more days. Limit the amount of\n * days that can be selected with the `min` or the `max` props.\n * - `mode=\"range\"`: users can select a range of days. Limit the amount of days\n * in the range with the `min` or the `max` props.\n *\n * These selection modes should cover the most common use cases. In case you\n * need a more refined way of selecting days, use `mode=\"custom\"`. Use the\n * `selected` props and add the day event handlers to add/remove days from the\n * selection.\n *\n * ### Modifiers\n *\n * A _modifier_ represents different styles or states for the days displayed in\n * the calendar (like \"selected\" or \"disabled\"). Define custom modifiers using\n * the `modifiers` prop.\n *\n * ### Formatters and custom component\n *\n * You can customize how the content is displayed in the date picker by using\n * either the formatters or replacing the internal components.\n *\n * For the most common cases you want to use the `formatters` prop to change how\n * the content is formatted in the calendar. Use the `components` prop to\n * replace the internal components, like the navigation icons.\n *\n * ### Styling\n *\n * DayPicker comes with a default, basic style in `react-day-picker/style` –\n * use it as template for your own style.\n *\n * If you are using CSS modules, pass the imported styles object the\n * `classNames` props.\n *\n * You can also style the elements via inline-styles using the `styles` prop.\n *\n * ### Form fields\n *\n * If you need to bind the date picker to a form field, you can use the\n * `useInput` hooks for a basic behavior. See the `useInput` source as an\n * example to bind the date picker with form fields.\n *\n * ### Localization\n *\n * To localize DayPicker, import the locale from `date-fns` package and use the\n * `locale` prop.\n *\n * For example, to use Spanish locale:\n *\n * ```\n * import es from 'date-fns/locale/es';\n * <DayPicker locale={es} />\n * ```\n */\nexport function DayPicker(\n props:\n | DayPickerProps\n | DayPickerSingleProps\n | DayPickerMultipleProps\n | DayPickerRangeProps\n | DayPickerCustomProps\n): JSX.Element {\n return (\n <ContextProvider {...props}>\n <Root />\n </ContextProvider>\n );\n}\n"],"names":[],"mappings":";;;;;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAqFgB,SAAS,CACvB,KAKwB;IAExB,QACE,oBAAC,eAAe,eAAK,KAAK;QACxB,oBAAC,IAAI,OAAG,CACQ,EAClB;AACJ;;;;"}
@@ -1,11 +1,11 @@
1
- import * as React from 'react';
1
+ import React__default from 'react';
2
2
  import { isSameMonth } from 'date-fns';
3
- import { MonthsDropdown } from '../MonthsDropdown/MonthsDropdown.js';
4
- import { Navigation } from '../Navigation/Navigation.js';
5
- import { YearsDropdown } from '../YearsDropdown/YearsDropdown.js';
6
3
  import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
7
4
  import '../../contexts/Navigation/NavigationContext.js';
8
5
  import { useNavigation } from '../../contexts/Navigation/useNavigation.js';
6
+ import { MonthsDropdown } from '../MonthsDropdown/MonthsDropdown.js';
7
+ import { Navigation } from '../Navigation/Navigation.js';
8
+ import { YearsDropdown } from '../YearsDropdown/YearsDropdown.js';
9
9
 
10
10
  /**
11
11
  * Render the caption of a month, which includes title and navigation buttons.
@@ -41,16 +41,16 @@ function Caption(props) {
41
41
  if (dir === 'rtl') {
42
42
  _a = [isFirst, isLast], isLast = _a[0], isFirst = _a[1];
43
43
  }
44
- var captionLabel = React.createElement(CaptionLabel, { displayMonth: displayMonth });
44
+ var captionLabel = React__default.createElement(CaptionLabel, { displayMonth: displayMonth });
45
45
  var hideNext = numberOfMonths > 1 && (isFirst || !isLast);
46
46
  var hidePrevious = numberOfMonths > 1 && (isLast || !isFirst);
47
- return (React.createElement("div", { className: classNames.caption, style: styles.caption },
47
+ return (React__default.createElement("div", { className: classNames.caption, style: styles.caption },
48
48
  disableNavigation && captionLabel,
49
- !disableNavigation && (React.createElement(React.Fragment, null, captionLayout === 'dropdown' ? (React.createElement("div", { className: classNames.caption_dropdowns, style: styles.caption_dropdowns },
50
- React.createElement(MonthsDropdown, { onChange: handleMonthChange, displayMonth: displayMonth }),
51
- React.createElement(YearsDropdown, { onChange: handleMonthChange, displayMonth: displayMonth }))) : (React.createElement(React.Fragment, null,
52
- React.createElement(CaptionLabel, { displayMonth: displayMonth }),
53
- React.createElement(Navigation, { displayMonth: displayMonth, hideNext: hideNext, hidePrevious: hidePrevious, nextMonth: nextMonth, previousMonth: previousMonth, onPreviousClick: handlePreviousClick, onNextClick: handleNextClick })))))));
49
+ !disableNavigation && (React__default.createElement(React__default.Fragment, null, captionLayout === 'dropdown' ? (React__default.createElement("div", { className: classNames.caption_dropdowns, style: styles.caption_dropdowns },
50
+ React__default.createElement(MonthsDropdown, { onChange: handleMonthChange, displayMonth: displayMonth }),
51
+ React__default.createElement(YearsDropdown, { onChange: handleMonthChange, displayMonth: displayMonth }))) : (React__default.createElement(React__default.Fragment, null,
52
+ React__default.createElement(CaptionLabel, { displayMonth: displayMonth }),
53
+ React__default.createElement(Navigation, { displayMonth: displayMonth, hideNext: hideNext, hidePrevious: hidePrevious, nextMonth: nextMonth, previousMonth: previousMonth, onPreviousClick: handlePreviousClick, onNextClick: handleNextClick })))))));
54
54
  }
55
55
 
56
56
  export { Caption };
@@ -1 +1 @@
1
- {"version":3,"file":"Caption.js","sources":["../../../src/components/Caption/Caption.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { isSameMonth } from 'date-fns';\n\nimport { MonthChangeEventHandler } from '../../types';\n\nimport { MonthsDropdown } from '../MonthsDropdown';\nimport { Navigation } from '../Navigation';\nimport { YearsDropdown } from '../YearsDropdown';\nimport { useDayPicker } from '../../contexts/DayPicker';\nimport { useNavigation } from '../../contexts/Navigation';\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 * 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 = (e) => {\n if (!previousMonth) return;\n goToMonth(previousMonth);\n onMonthChange?.(previousMonth);\n };\n\n const handleNextClick: React.MouseEventHandler = (e) => {\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":";;;;;;;;;AAkBA;;;;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,UAAC,CAAC;QACrD,IAAI,CAAC,aAAa;YAAE,OAAO;QAC3B,SAAS,CAAC,aAAa,CAAC,CAAC;QACzB,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,aAAa,CAAC,CAAC;KAChC,CAAC;IAEF,IAAM,eAAe,GAA4B,UAAC,CAAC;QACjD,IAAI,CAAC,SAAS;YAAE,OAAO;QACvB,SAAS,CAAC,SAAS,CAAC,CAAC;QACrB,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,SAAS,CAAC,CAAC;KAC5B,CAAC;IAEF,IAAM,iBAAiB,GAA4B,UAAC,QAAQ;QAC1D,SAAS,CAAC,QAAQ,CAAC,CAAC;QACpB,aAAa,aAAb,aAAa,uB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SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,mBAAmB,EACpC,WAAW,EAAE,eAAe,GAC5B,CACD,CACJ,CACA,CACJ,CACG,EACN;AACJ;;;;"}
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 { MonthChangeEventHandler } from '../../types';\nimport { MonthsDropdown } from '../MonthsDropdown';\nimport { Navigation } from '../Navigation';\nimport { YearsDropdown } from '../YearsDropdown';\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 * 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 = (e) => {\n if (!previousMonth) return;\n goToMonth(previousMonth);\n onMonthChange?.(previousMonth);\n };\n\n const handleNextClick: React.MouseEventHandler = (e) => {\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":["React"],"mappings":";;;;;;;;;AAiBA;;;;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,UAAC,CAAC;QACrD,IAAI,CAAC,aAAa;YAAE,OAAO;QAC3B,SAAS,CAAC,aAAa,CAAC,CAAC;QACzB,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,aAAa,CAAC,CAAC;KAChC,CAAC;IAEF,IAA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EAAE,iBAAiB,EAC3B,YAAY,EAAE,YAAY,GAC1B;YACFA,6BAAC,aAAa,IACZ,QAAQ,EAAE,iBAAiB,EAC3B,YAAY,EAAE,YAAY,GAC1B,CACE,KAENA;YACEA,6BAAC,YAAY,IAAC,YAAY,EAAE,YAAY,GAAI;YAC5CA,6BAAC,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;;;;"}
@@ -80,7 +80,7 @@ buttonRef) {
80
80
  var DayContent = context.components.DayContent;
81
81
  var children = (React__default.createElement(DayContent, { date: date, displayMonth: displayMonth, modifiers: modifiers }));
82
82
  var className = classNames.join(' ');
83
- if (!context.mode) {
83
+ if (!context.mode && !context.onDayClick) {
84
84
  return __assign(__assign({}, returnValue), { nonInteractiveProps: {
85
85
  style: style,
86
86
  className: className,
@@ -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 StyledComponentProps\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?: StyledComponentProps;\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) {\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":["React"],"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,iB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G,CAAC,CAAC;IAEhD,6BACK,WAAW,KACd,WAAW,EAAE;YACX,QAAQ,UAAA;YACR,cAAc,EAAE,QAAQ;YACxB,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,QAAQ;YAClB,SAAS,EAAE,SAAS;YACpB,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,WAAW;YACpB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,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 StyledComponentProps\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?: StyledComponentProps;\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":["React"],"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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EAAE,SAAS;YACpB,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,WAAW;YACpB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,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,13 +1,20 @@
1
1
  import * as React from 'react';
2
2
  import { isSameDay } from 'date-fns';
3
- import '../../../contexts/Focus/FocusContext.js';
4
- import '../../../contexts/DayPicker/DayPickerContext.js';
3
+ import 'date-fns/locale/en-US';
4
+ import { useDayPicker } from '../../../contexts/DayPicker/useDayPicker.js';
5
5
  import '../../../contexts/Navigation/NavigationContext.js';
6
+ import '../../Button/Button.js';
7
+ import '../../../contexts/SelectMultiple/SelectMultipleContext.js';
8
+ import '../../../contexts/SelectRange/SelectRangeContext.js';
9
+ import '../../../contexts/SelectSingle/SelectSingleContext.js';
10
+ import '../../../contexts/Focus/FocusContext.js';
6
11
  import { useFocus } from '../../../contexts/Focus/useFocus.js';
12
+ import '../../../contexts/DayPicker/DayPickerContext.js';
7
13
 
8
14
  /** Handle the focus for the day element. */
9
15
  function useDayFocus(date, buttonRef) {
10
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;
17
+ var dir = useDayPicker().dir;
11
18
  // Focus the HTML element if this is the focused day.
12
19
  React.useEffect(function () {
13
20
  var _a;
@@ -22,12 +29,12 @@ function useDayFocus(date, buttonRef) {
22
29
  case 'ArrowLeft':
23
30
  e.preventDefault();
24
31
  e.stopPropagation();
25
- focusDayBefore();
32
+ dir === 'rtl' ? focusDayAfter() : focusDayBefore();
26
33
  break;
27
34
  case 'ArrowRight':
28
35
  e.preventDefault();
29
36
  e.stopPropagation();
30
- focusDayAfter();
37
+ dir === 'rtl' ? focusDayBefore() : focusDayAfter();
31
38
  break;
32
39
  case 'ArrowDown':
33
40
  e.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"useDayFocus.js","sources":["../../../../src/components/Day/hooks/useDayFocus.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { isSameDay } from 'date-fns';\n\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\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 focusDayBefore();\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n 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":";;;;;;;AAMA;SACgB,WAAW,CACzB,IAAU,EACV,SAA6C;IAOvC,IAAA,KAUF,QAAQ,EAAE,EATZ,UA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ocus.js","sources":["../../../../src/components/Day/hooks/useDayFocus.ts"],"sourcesContent":["import * as 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":";;;;;;;;;;;;;AAOA;SACgB,WAAW,CACzB,IAAU,EACV,SAA6C;IAOvC,IAAA,KAUF,QAAQ,EAAE,EATZ,UAAU,QAAA,EACV,UAOC,EANC,aAAa,mBAAA,EACb,cAAc,oBAAA,EACd,iBAAiB,uBAAA,EACjB,kBAAkB,wBAAA,EAClB,IAAI,UAAA,EACJ,KAAK,WAEK,CAAC;IACP,IAAA,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';
3
3
  /**
4
4
  * Render the "previous month" button in the navigation.
5
5
  */
6
- export declare function IconPrevious(props: StyledComponentProps): JSX.Element;
6
+ export declare function IconLeft(props: StyledComponentProps): JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { __assign } from '../../_virtual/_tslib.js';
2
+ import React__default from 'react';
3
+
4
+ /**
5
+ * Render the "previous month" button in the navigation.
6
+ */
7
+ function IconLeft(props) {
8
+ return (React__default.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120", "data-testid": "iconLeft" }, props),
9
+ React__default.createElement("path", { d: "M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z", fill: "currentColor", fillRule: "nonzero" })));
10
+ }
11
+
12
+ export { IconLeft };
13
+ //# sourceMappingURL=IconLeft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconLeft.js","sources":["../../../src/components/IconLeft/IconLeft.tsx"],"sourcesContent":["import React from 'react';\n\nimport { StyledComponentProps } from '../../types';\n\n/**\n * Render the \"previous month\" button in the navigation.\n */\nexport function IconLeft(props: StyledComponentProps): JSX.Element {\n return (\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 120 120\"\n data-testid=\"iconLeft\"\n {...props}\n >\n <path\n d=\"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z\"\n fill=\"currentColor\"\n fillRule=\"nonzero\"\n ></path>\n </svg>\n );\n}\n"],"names":["React"],"mappings":";;;AAIA;;;SAGgB,QAAQ,CAAC,KAA2B;IAClD,QACEA,+CACE,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,MAAM,EACb,OAAO,EAAC,aAAa,iBACT,UAAU,IAClB,KAAK;QAETA,uCACE,CAAC,EAAC,ihBAAihB,EACnhB,IAAI,EAAC,cAAc,EACnB,QAAQ,EAAC,SAAS,GACZ,CACJ,EACN;AACJ;;;;"}
@@ -0,0 +1 @@
1
+ export * from './IconLeft';
@@ -3,4 +3,4 @@ import { StyledComponentProps } from '../../types';
3
3
  /**
4
4
  * Render the "next month" button in the navigation.
5
5
  */
6
- export declare function IconNext(props: StyledComponentProps): JSX.Element;
6
+ export declare function IconRight(props: StyledComponentProps): JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { __assign } from '../../_virtual/_tslib.js';
2
+ import React__default from 'react';
3
+
4
+ /**
5
+ * Render the "next month" button in the navigation.
6
+ */
7
+ function IconRight(props) {
8
+ return (React__default.createElement("svg", __assign({ width: "16px", height: "16px", viewBox: "0 0 120 120" }, props, { "data-testid": "iconRight" }),
9
+ React__default.createElement("path", { d: "M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z", fill: "currentColor" })));
10
+ }
11
+
12
+ export { IconRight };
13
+ //# sourceMappingURL=IconRight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconRight.js","sources":["../../../src/components/IconRight/IconRight.tsx"],"sourcesContent":["import React from 'react';\n\nimport { StyledComponentProps } from '../../types';\n\n/**\n * Render the \"next month\" button in the navigation.\n */\nexport function IconRight(props: StyledComponentProps): JSX.Element {\n return (\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 120 120\"\n {...props}\n data-testid=\"iconRight\"\n >\n <path\n d=\"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z\"\n fill=\"currentColor\"\n ></path>\n </svg>\n );\n}\n"],"names":["React"],"mappings":";;;AAIA;;;SAGgB,SAAS,CAAC,KAA2B;IACnD,QACEA,+CACE,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,MAAM,EACb,OAAO,EAAC,aAAa,IACjB,KAAK,mBACG,WAAW;QAEvBA,uCACE,CAAC,EAAC,ohBAAohB,EACthB,IAAI,EAAC,cAAc,GACb,CACJ,EACN;AACJ;;;;"}
@@ -0,0 +1 @@
1
+ export * from './IconRight';
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
- import { Button } from '../Button/Button.js';
3
2
  import { useDayPicker } from '../../contexts/DayPicker/useDayPicker.js';
3
+ import { Button } from '../Button/Button.js';
4
4
 
5
5
  /** A component rendering the navigation buttons or the drop-downs. */
6
6
  function Navigation(props) {
7
7
  var _a;
8
- var _b = useDayPicker(), dir = _b.dir, locale = _b.locale, classNames = _b.classNames, styles = _b.styles, _c = _b.labels, labelPrevious = _c.labelPrevious, labelNext = _c.labelNext, _d = _b.components, IconNext = _d.IconNext, IconPrevious = _d.IconPrevious;
8
+ var _b = useDayPicker(), dir = _b.dir, locale = _b.locale, classNames = _b.classNames, styles = _b.styles, _c = _b.labels, labelPrevious = _c.labelPrevious, labelNext = _c.labelNext, _d = _b.components, IconRight = _d.IconRight, IconLeft = _d.IconLeft;
9
9
  var onPreviousClick = props.onPreviousClick, onNextClick = props.onNextClick;
10
10
  if (dir === 'rtl') {
11
11
  _a = [onPreviousClick, onNextClick], onNextClick = _a[0], onPreviousClick = _a[1];
@@ -21,16 +21,12 @@ function Navigation(props) {
21
21
  classNames.nav_button,
22
22
  classNames.nav_button_next
23
23
  ].join(' ');
24
- var previousButton = (React.createElement(Button, { key: "prev", "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_previous, disabled: !previousMonth, onClick: onPreviousClick },
25
- React.createElement(IconPrevious, { className: classNames.nav_icon, style: styles.nav_icon })));
26
- var nextButton = (React.createElement(Button, { key: "next", "aria-label": nextLabel, className: nextClassName, disabled: !nextMonth, onClick: onNextClick, style: styles.nav_button_next },
27
- React.createElement(IconNext, { className: classNames.nav_icon, style: styles.nav_icon })));
28
24
  if (!nextMonth && !previousMonth) {
29
25
  return React.createElement(React.Fragment, null);
30
26
  }
31
27
  return (React.createElement("div", { className: classNames.nav, style: styles.nav },
32
- !props.hidePrevious && (dir === 'rtl' ? nextButton : previousButton),
33
- !props.hideNext && (dir === 'rtl' ? previousButton : nextButton)));
28
+ !props.hidePrevious && (React.createElement(Button, { "aria-label": previousLabel, className: previousClassName, style: styles.nav_button_next, disabled: !previousMonth, onClick: dir === 'rtl' ? onNextClick : onPreviousClick }, dir === 'rtl' ? (React.createElement(IconRight, { className: classNames.nav_icon, style: styles.nav_icon })) : (React.createElement(IconLeft, { className: classNames.nav_icon, style: styles.nav_icon })))),
29
+ !props.hideNext && (React.createElement(Button, { "aria-label": nextLabel, className: nextClassName, style: styles.nav_button_next, disabled: !nextMonth, onClick: dir === 'rtl' ? onPreviousClick : onNextClick }, dir === 'rtl' ? (React.createElement(IconLeft, { className: classNames.nav_icon, style: styles.nav_icon })) : (React.createElement(IconRight, { className: classNames.nav_icon, style: styles.nav_icon }))))));
34
30
  }
35
31
 
36
32
  export { Navigation };
@@ -1 +1 @@
1
- {"version":3,"file":"Navigation.js","sources":["../../../src/components/Navigation/Navigation.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Button } from '../Button';\nimport { useDayPicker } from '../../contexts/DayPicker';\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: { IconNext, IconPrevious }\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 const previousButton = (\n <Button\n key=\"prev\"\n aria-label={previousLabel}\n className={previousClassName}\n style={styles.nav_button_previous}\n disabled={!previousMonth}\n onClick={onPreviousClick}\n >\n <IconPrevious className={classNames.nav_icon} style={styles.nav_icon} />\n </Button>\n );\n\n const nextButton = (\n <Button\n key=\"next\"\n aria-label={nextLabel}\n className={nextClassName}\n disabled={!nextMonth}\n onClick={onNextClick}\n style={styles.nav_button_next}\n >\n <IconNext className={classNames.nav_icon} style={styles.nav_icon} />\n </Button>\n );\n if (!nextMonth && !previousMonth) {\n return <></>;\n }\n return (\n <div className={classNames.nav} style={styles.nav}>\n {!props.hidePrevious && (dir === 'rtl' ? nextButton : previousButton)}\n {!props.hideNext && (dir === 'rtl' ? previousButton : nextButton)}\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,kBAAsC,EAAxB,QAAQ,cAAA,EAAE,YAAY,kBACpB,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,KAAK,cAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;IAE3C,IAAM,aAAa,GAAG,aAAa,CAAC,aAAa,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;IAC/D,IAAM,iBAAiB,GAAG;QACxB,UAAU,CAAC,UAAU;QACrB,UAAU,CAAC,mBAAmB;KAC/B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,IAAM,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;IACnD,IAAM,aAAa,GAAG;QACpB,UAAU,CAAC,UAAU;QACrB,UAAU,CAAC,eAAe;KAC3B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,IAAM,cAAc,IAClB,oBAAC,MAAM,IACL,GAAG,EAAC,MAAM,gBACE,aAAa,EACzB,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,MAAM,CAAC,mBAAmB,EACjC,QAAQ,EAAE,CAAC,aAAa,EACxB,OAAO,EAAE,eAAe;QAExB,oBAAC,YAAY,IAAC,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,GAAI,CACjE,CACV,CAAC;IAEF,IAAM,UAAU,IACd,oBAAC,MAAM,IACL,GAAG,EAAC,MAAM,gBACE,SAAS,EACrB,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,CAAC,SAAS,EACpB,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,MAAM,CAAC,eAAe;QAE7B,oBAAC,QAAQ,IAAC,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,GAAI,CAC7D,CACV,CAAC;IACF,IAAI,CAAC,SAAS,IAAI,CAAC,aAAa,EAAE;QAChC,OAAO,yCAAK,CAAC;KACd;IACD,QACE,6BAAK,SAAS,EAAE,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG;QAC9C,CAAC,KAAK,CAAC,YAAY,KAAK,GAAG,KAAK,KAAK,GAAG,UAAU,GAAG,cAAc,CAAC;QACpE,CAAC,KAAK,CAAC,QAAQ,KAAK,GAAG,KAAK,KAAK,GAAG,cAAc,GAAG,UAAU,CAAC,CAC7D,EACN;AACJ;;;;"}
1
+ {"version":3,"file":"Navigation.js","sources":["../../../src/components/Navigation/Navigation.tsx"],"sourcesContent":["import * as 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,KAAK,cAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;IAE3C,IAAM,aAAa,GAAG,aAAa,CAAC,aAAa,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;IAC/D,IAAM,iBAAiB,GAAG;QACxB,UAAU,CAAC,UAAU;QACrB,UAAU,CAAC,mBAAmB;KAC/B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,IAAM,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;IACnD,IAAM,aAAa,GAAG;QACpB,UAAU,CAAC,UAAU;QACrB,UAAU,CAAC,eAAe;KAC3B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,IAAI,CAAC,SAAS,IAAI,CAAC,aAAa,EAAE;QAChC,OAAO,yCAAK,CAAC;KACd;IAED,QACE,6BAAK,SAAS,EAAE,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG;QAC9C,CAAC,KAAK,CAAC,YAAY,KAClB,oBAAC,MAAM,kBACO,aAAa,EACzB,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,MAAM,CAAC,eAAe,EAC7B,QAAQ,EAAE,CAAC,aAAa,EACxB,OAAO,EAAE,GAAG,KAAK,KAAK,GAAG,WAAW,GAAG,eAAe,IAErD,GAAG,KAAK,KAAK,IACZ,oBAAC,SAAS,IACR,SAAS,EAAE,UAAU,CAAC,QAAQ,EAC9B,KAAK,EAAE,MAAM,CAAC,QAAQ,GACtB,KAEF,oBAAC,QAAQ,IAAC,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,GAAI,CACrE,CACM,CACV;QACA,CAAC,KAAK,CAAC,QAAQ,KACd,oBAAC,MAAM,kBACO,SAAS,EACrB,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,MAAM,CAAC,eAAe,EAC7B,QAAQ,EAAE,CAAC,SAAS,EACpB,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;;;;"}
@@ -7,8 +7,8 @@ export * from './Dropdown';
7
7
  export * from './Footer';
8
8
  export * from './Head';
9
9
  export * from './IconDropdown';
10
- export * from './IconNext';
11
- export * from './IconPrevious';
10
+ export * from './IconRight';
11
+ export * from './IconLeft';
12
12
  export * from './MonthsDropdown';
13
13
  export * from './Navigation';
14
14
  export * from './Root';
@@ -11,20 +11,20 @@ import '../SelectRange/SelectRangeContext.js';
11
11
  import '../SelectSingle/SelectSingleContext.js';
12
12
  import { parseFromToProps } from './utils/parseFromToProps.js';
13
13
  import { parseModifierProps } from './utils/parseModifierProps.js';
14
- import '../Focus/FocusContext.js';
15
- import '../Navigation/NavigationContext.js';
16
14
  import { DayContent } from '../../components/DayContent/DayContent.js';
17
15
  import { Dropdown } from '../../components/Dropdown/Dropdown.js';
18
16
  import { Footer } from '../../components/Footer/Footer.js';
19
17
  import { Head } from '../../components/Head/Head.js';
20
18
  import { IconDropdown } from '../../components/IconDropdown/IconDropdown.js';
21
- import { IconNext } from '../../components/IconNext/IconNext.js';
22
- import { IconPrevious } from '../../components/IconPrevious/IconPrevious.js';
19
+ import { IconLeft } from '../../components/IconLeft/IconLeft.js';
20
+ import { IconRight } from '../../components/IconRight/IconRight.js';
23
21
  import { Row } from '../../components/Row/Row.js';
24
22
  import { WeekNumber } from '../../components/WeekNumber/WeekNumber.js';
25
23
  import { defaultClassNames } from './defaultClassNames.js';
26
24
  import * as index from './formatters/index.js';
27
25
  import * as index$1 from './labels/index.js';
26
+ import '../Focus/FocusContext.js';
27
+ import '../Navigation/NavigationContext.js';
28
28
 
29
29
  /**
30
30
  * The provider for the [[DayPickerContext]].
@@ -51,7 +51,7 @@ function DayPickerProvider(props) {
51
51
  modifiers.disabled.push({ after: toDate });
52
52
  }
53
53
  initialProps.toYear; initialProps.fromYear; initialProps.toMonth; initialProps.fromMonth; var contextProps = __rest(initialProps, ["toYear", "fromYear", "toMonth", "fromMonth"]);
54
- var context = __assign(__assign({}, contextProps), { captionLayout: captionLayout, fromDate: fromDate, toDate: toDate, today: today, locale: locale, modifierClassNames: (_e = initialProps.modifierClassNames) !== null && _e !== void 0 ? _e : {}, modifierPrefix: 'rdp-day_', modifiers: modifiers, numberOfMonths: numberOfMonths, styles: (_f = initialProps.styles) !== null && _f !== void 0 ? _f : {}, classNames: __assign(__assign({}, defaultClassNames), initialProps.classNames), formatters: __assign(__assign({}, index), initialProps.formatters), labels: __assign(__assign({}, index$1), initialProps.labels), components: __assign({ Caption: Caption, CaptionLabel: CaptionLabel, Day: Day, DayContent: DayContent, Dropdown: Dropdown, Footer: Footer, Head: Head, IconDropdown: IconDropdown, IconNext: IconNext, IconPrevious: IconPrevious, Row: Row, WeekNumber: WeekNumber }, initialProps.components) });
54
+ var context = __assign(__assign({}, contextProps), { captionLayout: captionLayout, fromDate: fromDate, toDate: toDate, today: today, locale: locale, modifierClassNames: (_e = initialProps.modifierClassNames) !== null && _e !== void 0 ? _e : {}, modifierPrefix: 'rdp-day_', modifiers: modifiers, numberOfMonths: numberOfMonths, styles: (_f = initialProps.styles) !== null && _f !== void 0 ? _f : {}, classNames: __assign(__assign({}, defaultClassNames), initialProps.classNames), formatters: __assign(__assign({}, index), initialProps.formatters), labels: __assign(__assign({}, index$1), initialProps.labels), components: __assign({ Caption: Caption, CaptionLabel: CaptionLabel, Day: Day, DayContent: DayContent, Dropdown: Dropdown, Footer: Footer, Head: Head, IconDropdown: IconDropdown, IconRight: IconRight, IconLeft: IconLeft, Row: Row, WeekNumber: WeekNumber }, initialProps.components) });
55
55
  return (React.createElement(DayPickerContext.Provider, { value: context }, children));
56
56
  }
57
57
 
@@ -1 +1 @@
1
- {"version":3,"file":"DayPickerProvider.js","sources":["../../../src/contexts/DayPicker/DayPickerProvider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport enUS from 'date-fns/locale/en-US';\n\nimport { DayPickerProps } from '../../types';\n\nimport { Caption } from '../../components/Caption';\nimport { CaptionLabel } from '../../components/CaptionLabel';\nimport { Day } from '../../components/Day';\nimport { DayContent } from '../../components/DayContent';\nimport { Dropdown } from '../../components/Dropdown';\nimport { Footer } from '../../components/Footer';\nimport { Head } from '../../components/Head';\nimport { IconDropdown } from '../../components/IconDropdown';\nimport { IconNext } from '../../components/IconNext';\nimport { IconPrevious } from '../../components/IconPrevious';\nimport { Row } from '../../components/Row';\nimport { WeekNumber } from '../../components/WeekNumber';\n\nimport { DayPickerContext, DayPickerContextValue } from './DayPickerContext';\nimport { defaultClassNames } from './defaultClassNames';\nimport * as formatters from './formatters';\nimport * as labels from './labels';\nimport { parseFromToProps, parseModifierProps } from './utils';\n\n/** Represent the props for the [[DayPickerProvider]]. */\nexport interface DayPickerProviderProps {\n /** The props passed to the DayPicker component. */\n initialProps: DayPickerProps;\n children?: React.ReactNode;\n}\n/**\n * The provider for the [[DayPickerContext]].\n */\nexport function DayPickerProvider(props: DayPickerProviderProps): JSX.Element {\n const { children, initialProps } = props;\n\n const locale = initialProps.locale ?? enUS;\n const numberOfMonths = initialProps.numberOfMonths ?? 1;\n const today = initialProps.today ?? new Date();\n\n // Limit navigation\n const { fromDate, toDate } = parseFromToProps(initialProps);\n\n // Default caption layout. If calendar navigation is unlimited, it must be\n // always `buttons` – as we cannot display infinite options in the dropdown.\n let captionLayout = initialProps.captionLayout ?? 'buttons';\n if (!fromDate && !toDate) captionLayout = 'buttons';\n\n const modifiers = parseModifierProps(initialProps);\n\n // Disable days before/after from/toDate\n if (fromDate) {\n modifiers.disabled.push({ before: fromDate });\n }\n if (toDate) {\n modifiers.disabled.push({ after: toDate });\n }\n\n const { toYear, fromYear, toMonth, fromMonth, ...contextProps } =\n initialProps;\n\n const context: DayPickerContextValue = {\n ...contextProps,\n\n captionLayout,\n\n fromDate,\n toDate,\n today,\n\n locale,\n\n modifierClassNames: initialProps.modifierClassNames ?? {},\n modifierPrefix: 'rdp-day_',\n modifiers: modifiers,\n numberOfMonths,\n\n styles: initialProps.styles ?? {},\n classNames: {\n ...defaultClassNames,\n ...initialProps.classNames\n },\n formatters: {\n ...formatters,\n ...initialProps.formatters\n },\n labels: {\n ...labels,\n ...initialProps.labels\n },\n components: {\n Caption: Caption,\n CaptionLabel: CaptionLabel,\n Day: Day,\n DayContent: DayContent,\n Dropdown: Dropdown,\n Footer: Footer,\n Head: Head,\n IconDropdown: IconDropdown,\n IconNext: IconNext,\n IconPrevious: IconPrevious,\n Row: Row,\n WeekNumber: WeekNumber,\n ...initialProps.components\n }\n };\n\n return (\n <DayPickerContext.Provider value={context}>\n {children}\n </DayPickerContext.Provider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D,cAAc,EAAE,UAAU,EAC1B,SAAS,EAAE,SAAS,EACpB,cAAc,gBAAA,EAEd,MAAM,EAAE,MAAA,YAAY,CAAC,MAAM,mCAAI,EAAE,EACjC,UAAU,wBACL,iBAAiB,GACjB,YAAY,CAAC,UAAU,GAE5B,UAAU,wBACLA,KAAU,GACV,YAAY,CAAC,UAAU,GAE5B,MAAM,wBACDC,OAAM,GACN,YAAY,CAAC,MAAM,GAExB,UAAU,aACR,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,IACnB,YAAY,CAAC,UAAU,IAE7B,CAAC;IAEF,QACE,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IACtC,QAAQ,CACiB,EAC5B;AACJ;;;;"}
1
+ {"version":3,"file":"DayPickerProvider.js","sources":["../../../src/contexts/DayPicker/DayPickerProvider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport enUS from 'date-fns/locale/en-US';\n\nimport { Caption } from '../../components/Caption';\nimport { CaptionLabel } from '../../components/CaptionLabel';\nimport { Day } from '../../components/Day';\nimport { DayContent } from '../../components/DayContent';\nimport { Dropdown } from '../../components/Dropdown';\nimport { Footer } from '../../components/Footer';\nimport { Head } from '../../components/Head';\nimport { IconDropdown } from '../../components/IconDropdown';\nimport { IconLeft } from '../../components/IconLeft';\nimport { IconRight } from '../../components/IconRight';\nimport { Row } from '../../components/Row';\nimport { WeekNumber } from '../../components/WeekNumber';\nimport { DayPickerProps } from '../../types';\nimport { DayPickerContext, DayPickerContextValue } from './DayPickerContext';\nimport { defaultClassNames } from './defaultClassNames';\nimport * as formatters from './formatters';\nimport * as labels from './labels';\nimport { parseFromToProps, parseModifierProps } from './utils';\n\n/** Represent the props for the [[DayPickerProvider]]. */\nexport interface DayPickerProviderProps {\n /** The props passed to the DayPicker component. */\n initialProps: DayPickerProps;\n children?: React.ReactNode;\n}\n/**\n * The provider for the [[DayPickerContext]].\n */\nexport function DayPickerProvider(props: DayPickerProviderProps): JSX.Element {\n const { children, initialProps } = props;\n\n const locale = initialProps.locale ?? enUS;\n const numberOfMonths = initialProps.numberOfMonths ?? 1;\n const today = initialProps.today ?? new Date();\n\n // Limit navigation\n const { fromDate, toDate } = parseFromToProps(initialProps);\n\n // Default caption layout. If calendar navigation is unlimited, it must be\n // always `buttons` – as we cannot display infinite options in the dropdown.\n let captionLayout = initialProps.captionLayout ?? 'buttons';\n if (!fromDate && !toDate) captionLayout = 'buttons';\n\n const modifiers = parseModifierProps(initialProps);\n\n // Disable days before/after from/toDate\n if (fromDate) {\n modifiers.disabled.push({ before: fromDate });\n }\n if (toDate) {\n modifiers.disabled.push({ after: toDate });\n }\n\n const { toYear, fromYear, toMonth, fromMonth, ...contextProps } =\n initialProps;\n\n const context: DayPickerContextValue = {\n ...contextProps,\n\n captionLayout,\n\n fromDate,\n toDate,\n today,\n\n locale,\n\n modifierClassNames: initialProps.modifierClassNames ?? {},\n modifierPrefix: 'rdp-day_',\n modifiers: modifiers,\n numberOfMonths,\n\n styles: initialProps.styles ?? {},\n classNames: {\n ...defaultClassNames,\n ...initialProps.classNames\n },\n formatters: {\n ...formatters,\n ...initialProps.formatters\n },\n labels: {\n ...labels,\n ...initialProps.labels\n },\n components: {\n Caption: Caption,\n CaptionLabel: CaptionLabel,\n Day: Day,\n DayContent: DayContent,\n Dropdown: Dropdown,\n Footer: Footer,\n Head: Head,\n IconDropdown: IconDropdown,\n IconRight: IconRight,\n IconLeft: IconLeft,\n Row: Row,\n WeekNumber: WeekNumber,\n ...initialProps.components\n }\n };\n\n return (\n <DayPickerContext.Provider value={context}>\n {children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,mCAAI,EAAE,EACzD,cAAc,EAAE,UAAU,EAC1B,SAAS,EAAE,SAAS,EACpB,cAAc,gBAAA,EAEd,MAAM,EAAE,MAAA,YAAY,CAAC,MAAM,mCAAI,EAAE,EACjC,UAAU,wBACL,iBAAiB,GACjB,YAAY,CAAC,UAAU,GAE5B,UAAU,wBACLA,KAAU,GACV,YAAY,CAAC,UAAU,GAE5B,MAAM,wBACDC,OAAM,GACN,YAAY,CAAC,MAAM,GAExB,UAAU,aACR,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,IACnB,YAAY,CAAC,UAAU,IAE7B,CAAC;IAEF,QACE,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IACtC,QAAQ,CACiB,EAC5B;AACJ;;;;"}
@@ -1,62 +1,9 @@
1
- import { __spreadArray } from '../../_virtual/_tslib.js';
2
1
  import * as React from 'react';
3
- import { isSameDay } from 'date-fns';
4
- import { useControlledValue } from '../../hooks/useControlledValue/useControlledValue.js';
2
+ import 'date-fns';
5
3
  import { isDayPickerMultiple } from '../../types/isDayPickerMultiple.js';
6
4
  import { SelectMultipleContext } from './SelectMultipleContext.js';
5
+ import { SelectMultipleProviderInternal } from './SelectMultipleProviderInternal.js';
7
6
 
8
- function SelectMultipleProviderInternal(_a) {
9
- var initialProps = _a.initialProps, children = _a.children;
10
- var _b = useControlledValue(initialProps.defaultSelected, initialProps.selected), selectedDays = _b[0], setSelectedDays = _b[1];
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 isMinSelected = Boolean(initialProps.min &&
15
- modifiers.selected &&
16
- selectedDays &&
17
- selectedDays.length === initialProps.min);
18
- if (isMinSelected) {
19
- return;
20
- }
21
- var isMaxSelected = Boolean(initialProps.max &&
22
- !modifiers.selected &&
23
- selectedDays &&
24
- selectedDays.length === initialProps.max);
25
- if (isMaxSelected) {
26
- return;
27
- }
28
- var days = selectedDays ? __spreadArray([], selectedDays, true) : [];
29
- if (modifiers.selected) {
30
- var index = days.findIndex(function (selectedDay) {
31
- return isSameDay(day, selectedDay);
32
- });
33
- days.splice(index, 1);
34
- }
35
- else {
36
- days.push(day);
37
- }
38
- setSelectedDays(days);
39
- (_b = initialProps.onSelect) === null || _b === void 0 ? void 0 : _b.call(initialProps, days, day, modifiers, e);
40
- };
41
- var modifiers = {
42
- selected: [],
43
- disabled: []
44
- };
45
- if (selectedDays) {
46
- modifiers.selected = selectedDays;
47
- modifiers.disabled = [
48
- function disableDay(day) {
49
- var isMaxSelected = initialProps.max && selectedDays.length > initialProps.max - 1;
50
- var isSelected = selectedDays.some(function (selectedDay) {
51
- return isSameDay(selectedDay, day);
52
- });
53
- return Boolean(isMaxSelected && !isSelected);
54
- }
55
- ];
56
- }
57
- var contextValue = { selected: selectedDays, handleDayClick: handleDayClick, modifiers: modifiers };
58
- return (React.createElement(SelectMultipleContext.Provider, { value: contextValue }, children));
59
- }
60
7
  /** Provides the values for the [[SelectMultipleContext]]. */
61
8
  function SelectMultipleProvider(props) {
62
9
  if (!isDayPickerMultiple(props.initialProps)) {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectMultipleProvider.js","sources":["../../../src/contexts/SelectMultiple/SelectMultipleProvider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { isSameDay } from 'date-fns';\n\nimport { useControlledValue } from '../../hooks/useControlledValue';\nimport {\n DayClickEventHandler,\n DayPickerBase,\n DayPickerMultiple,\n DayPickerProps,\n isDayPickerMultiple\n} from '../../types';\nimport {\n SelectMultipleContext,\n SelectMultipleContextValue,\n SelectMultipleModifiers\n} from './SelectMultipleContext';\n\nfunction SelectMultipleProviderInternal({\n initialProps,\n children\n}: {\n initialProps: DayPickerBase & DayPickerMultiple;\n children: React.ReactNode;\n}): JSX.Element {\n const [selectedDays, setSelectedDays] = useControlledValue(\n initialProps.defaultSelected,\n initialProps.selected\n );\n\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 selectedDays &&\n selectedDays.length === initialProps.min\n );\n if (isMinSelected) {\n return;\n }\n const isMaxSelected = Boolean(\n initialProps.max &&\n !modifiers.selected &&\n selectedDays &&\n selectedDays.length === initialProps.max\n );\n if (isMaxSelected) {\n return;\n }\n\n const days = selectedDays ? [...selectedDays] : [];\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 setSelectedDays(days);\n initialProps.onSelect?.(days, day, modifiers, e);\n };\n\n const modifiers: SelectMultipleModifiers = {\n selected: [],\n disabled: []\n };\n\n if (selectedDays) {\n modifiers.selected = selectedDays;\n modifiers.disabled = [\n function disableDay(day: Date) {\n const isMaxSelected =\n initialProps.max && selectedDays.length > initialProps.max - 1;\n const isSelected = selectedDays.some((selectedDay) =>\n isSameDay(selectedDay, day)\n );\n return Boolean(isMaxSelected && !isSelected);\n }\n ];\n }\n\n const contextValue = { selected: selectedDays, handleDayClick, modifiers };\n\n return (\n <SelectMultipleContext.Provider value={contextValue}>\n {children}\n </SelectMultipleContext.Provider>\n );\n}\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":";;;;;;;AAkBA,SAAS,8BAA8B,CAAC,EAMvC;QALC,YAAY,kBAAA,EACZ,QAAQ,cAAA;IAKF,IAAA,KAAkC,kBAAkB,CACxD,YAAY,CAAC,eAAe,EAC5B,YAAY,CAAC,QAAQ,CACtB,EAHM,YAAY,QAAA,EAAE,eAAe,QAGnC,CAAC;IAEF,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,YAAY;YACZ,YAAY,CAAC,MAAM,KAAK,YAAY,CAAC,GAAG,CAC3C,CAAC;QACF,IAAI,aAAa,EAAE;YACjB,OAAO;SACR;QACD,IAAM,aAAa,GAAG,OAAO,CAC3B,YAAY,CAAC,GAAG;YACd,CAAC,SAAS,CAAC,QAAQ;YACnB,YAAY;YACZ,YAAY,CAAC,MAAM,KAAK,YAAY,CAAC,GAAG,CAC3C,CAAC;QACF,IAAI,aAAa,EAAE;YACjB,OAAO;SACR;QAED,IAAM,IAAI,GAAG,YAAY,qBAAO,YAAY,UAAI,EAAE,CAAC;QACnD,IAAI,SAAS,CAAC,QAAQ,EAAE;YACtB,IAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,UAAC,WAAW;gBACvC,OAAA,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC;aAAA,CAC5B,CAAC;YACF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE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AAqB,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
+ {"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;;;;"}
@@ -0,0 +1,8 @@
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 {};