@birdnet/advanced-react-dates 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/.babelrc +67 -0
  2. package/.eslintrc +66 -0
  3. package/.nvmrc +1 -0
  4. package/.nyc_output/4d8efcd220c2aec1f2b4ffd49d875001.json +1 -0
  5. package/.nyc_output/66d34779498a5d49bcf9d757dfc7fdb5.json +1 -0
  6. package/.nyc_output/8ca7e04140934515928bc7d4ae476b73.json +1 -0
  7. package/.nyc_output/afc270bb597bfc50e690436959c2ae54.json +1 -0
  8. package/.nycrc +19 -0
  9. package/.travis.yml +13 -0
  10. package/CHANGELOG.md +665 -0
  11. package/CLAUDE.md +56 -0
  12. package/INTHEWILD.md +9 -0
  13. package/LICENSE +21 -0
  14. package/README.md +421 -2
  15. package/constants.js +2 -0
  16. package/esm/components/CalendarDay.js +321 -0
  17. package/esm/components/CalendarIcon.js +11 -0
  18. package/esm/components/CalendarMonth.js +254 -0
  19. package/esm/components/CalendarMonthGrid.js +365 -0
  20. package/esm/components/CalendarWeek.js +11 -0
  21. package/esm/components/ChevronDown.js +11 -0
  22. package/esm/components/ChevronUp.js +11 -0
  23. package/esm/components/CloseButton.js +12 -0
  24. package/esm/components/CustomizableCalendarDay.js +341 -0
  25. package/esm/components/DateInput.js +344 -0
  26. package/esm/components/DateRangePicker.js +647 -0
  27. package/esm/components/DateRangePickerInput.js +341 -0
  28. package/esm/components/DateRangePickerInputController.js +348 -0
  29. package/esm/components/DayPicker.js +1167 -0
  30. package/esm/components/DayPickerKeyboardShortcuts.js +364 -0
  31. package/esm/components/DayPickerNavigation.js +314 -0
  32. package/esm/components/DayPickerRangeController.js +1202 -0
  33. package/esm/components/DayPickerSingleDateController.js +690 -0
  34. package/esm/components/KeyboardShortcutRow.js +69 -0
  35. package/esm/components/LeftArrow.js +11 -0
  36. package/esm/components/RightArrow.js +11 -0
  37. package/esm/components/SingleDatePicker.js +605 -0
  38. package/esm/components/SingleDatePickerInput.js +264 -0
  39. package/esm/components/SingleDatePickerInputController.js +260 -0
  40. package/esm/constants.js +28 -0
  41. package/esm/defaultPhrases.js +225 -0
  42. package/esm/index.js +20 -0
  43. package/esm/initialize.js +2 -0
  44. package/esm/shapes/AnchorDirectionShape.js +3 -0
  45. package/esm/shapes/CalendarInfoPositionShape.js +3 -0
  46. package/esm/shapes/DateRangePickerShape.js +101 -0
  47. package/esm/shapes/DayOfWeekShape.js +3 -0
  48. package/esm/shapes/DisabledShape.js +3 -0
  49. package/esm/shapes/FocusedInputShape.js +3 -0
  50. package/esm/shapes/IconPositionShape.js +3 -0
  51. package/esm/shapes/ModifiersShape.js +18 -0
  52. package/esm/shapes/NavPositionShape.js +3 -0
  53. package/esm/shapes/OpenDirectionShape.js +3 -0
  54. package/esm/shapes/OrientationShape.js +3 -0
  55. package/esm/shapes/ScrollableOrientationShape.js +3 -0
  56. package/esm/shapes/SingleDatePickerShape.js +90 -0
  57. package/esm/theme/DefaultTheme.js +176 -0
  58. package/esm/utils/calculateDimension.js +28 -0
  59. package/esm/utils/disableScroll.js +67 -0
  60. package/esm/utils/getActiveElement.js +3 -0
  61. package/esm/utils/getCalendarDaySettings.js +48 -0
  62. package/esm/utils/getCalendarMonthWeeks.js +37 -0
  63. package/esm/utils/getCalendarMonthWidth.js +4 -0
  64. package/esm/utils/getDetachedContainerStyles.js +36 -0
  65. package/esm/utils/getInputHeight.js +42 -0
  66. package/esm/utils/getNumberOfCalendarMonthWeeks.js +11 -0
  67. package/esm/utils/getPhrase.js +7 -0
  68. package/esm/utils/getPhrasePropTypes.js +9 -0
  69. package/esm/utils/getPooledMoment.js +8 -0
  70. package/esm/utils/getPreviousMonthMemoLast.js +9 -0
  71. package/esm/utils/getResponsiveContainerStyles.js +8 -0
  72. package/esm/utils/getSelectedDateOffset.js +8 -0
  73. package/esm/utils/getTransformStyles.js +8 -0
  74. package/esm/utils/getVisibleDays.js +42 -0
  75. package/esm/utils/isAfterDay.js +7 -0
  76. package/esm/utils/isBeforeDay.js +13 -0
  77. package/esm/utils/isDayVisible.js +38 -0
  78. package/esm/utils/isInclusivelyAfterDay.js +6 -0
  79. package/esm/utils/isInclusivelyBeforeDay.js +6 -0
  80. package/esm/utils/isNextDay.js +7 -0
  81. package/esm/utils/isNextMonth.js +6 -0
  82. package/esm/utils/isPrevMonth.js +6 -0
  83. package/esm/utils/isPreviousDay.js +7 -0
  84. package/esm/utils/isSameDay.js +7 -0
  85. package/esm/utils/isSameMonth.js +7 -0
  86. package/esm/utils/isTransitionEndSupported.js +3 -0
  87. package/esm/utils/modifiers.js +94 -0
  88. package/esm/utils/noflip.js +10 -0
  89. package/esm/utils/registerCSSInterfaceWithDefaultTheme.js +5 -0
  90. package/esm/utils/registerInterfaceWithDefaultTheme.js +6 -0
  91. package/esm/utils/toISODateString.js +12 -0
  92. package/esm/utils/toISOMonthString.js +12 -0
  93. package/esm/utils/toLocalizedDateString.js +8 -0
  94. package/esm/utils/toMomentObject.js +7 -0
  95. package/index.js +2 -0
  96. package/initialize.js +2 -0
  97. package/karma.conf.js +82 -0
  98. package/lib/components/CalendarDay.js +327 -0
  99. package/lib/components/CalendarIcon.js +18 -0
  100. package/lib/components/CalendarMonth.js +259 -0
  101. package/lib/components/CalendarMonthGrid.js +372 -0
  102. package/lib/components/CalendarWeek.js +18 -0
  103. package/lib/components/ChevronDown.js +18 -0
  104. package/lib/components/ChevronUp.js +18 -0
  105. package/lib/components/CloseButton.js +19 -0
  106. package/lib/components/CustomizableCalendarDay.js +347 -0
  107. package/lib/components/DateInput.js +351 -0
  108. package/lib/components/DateRangePicker.js +653 -0
  109. package/lib/components/DateRangePickerInput.js +348 -0
  110. package/lib/components/DateRangePickerInputController.js +354 -0
  111. package/lib/components/DayPicker.js +1175 -0
  112. package/lib/components/DayPickerKeyboardShortcuts.js +371 -0
  113. package/lib/components/DayPickerNavigation.js +321 -0
  114. package/lib/components/DayPickerRangeController.js +1208 -0
  115. package/lib/components/DayPickerSingleDateController.js +695 -0
  116. package/lib/components/KeyboardShortcutRow.js +76 -0
  117. package/lib/components/LeftArrow.js +18 -0
  118. package/lib/components/RightArrow.js +18 -0
  119. package/lib/components/SingleDatePicker.js +611 -0
  120. package/lib/components/SingleDatePickerInput.js +271 -0
  121. package/lib/components/SingleDatePickerInputController.js +266 -0
  122. package/lib/constants.js +34 -0
  123. package/lib/css/_datepicker.css +886 -0
  124. package/lib/defaultPhrases.js +231 -0
  125. package/lib/index.js +146 -0
  126. package/lib/initialize.js +5 -0
  127. package/lib/shapes/AnchorDirectionShape.js +10 -0
  128. package/lib/shapes/CalendarInfoPositionShape.js +10 -0
  129. package/lib/shapes/DateRangePickerShape.js +108 -0
  130. package/lib/shapes/DayOfWeekShape.js +10 -0
  131. package/lib/shapes/DisabledShape.js +10 -0
  132. package/lib/shapes/FocusedInputShape.js +10 -0
  133. package/lib/shapes/IconPositionShape.js +10 -0
  134. package/lib/shapes/ModifiersShape.js +25 -0
  135. package/lib/shapes/NavPositionShape.js +10 -0
  136. package/lib/shapes/OpenDirectionShape.js +10 -0
  137. package/lib/shapes/OrientationShape.js +10 -0
  138. package/lib/shapes/ScrollableOrientationShape.js +10 -0
  139. package/lib/shapes/SingleDatePickerShape.js +97 -0
  140. package/lib/theme/DefaultTheme.js +182 -0
  141. package/lib/utils/calculateDimension.js +34 -0
  142. package/lib/utils/disableScroll.js +75 -0
  143. package/lib/utils/getActiveElement.js +9 -0
  144. package/lib/utils/getCalendarDaySettings.js +55 -0
  145. package/lib/utils/getCalendarMonthWeeks.js +44 -0
  146. package/lib/utils/getCalendarMonthWidth.js +10 -0
  147. package/lib/utils/getDetachedContainerStyles.js +41 -0
  148. package/lib/utils/getInputHeight.js +48 -0
  149. package/lib/utils/getNumberOfCalendarMonthWeeks.js +18 -0
  150. package/lib/utils/getPhrase.js +13 -0
  151. package/lib/utils/getPhrasePropTypes.js +16 -0
  152. package/lib/utils/getPooledMoment.js +15 -0
  153. package/lib/utils/getPreviousMonthMemoLast.js +15 -0
  154. package/lib/utils/getResponsiveContainerStyles.js +15 -0
  155. package/lib/utils/getSelectedDateOffset.js +14 -0
  156. package/lib/utils/getTransformStyles.js +14 -0
  157. package/lib/utils/getVisibleDays.js +49 -0
  158. package/lib/utils/isAfterDay.js +14 -0
  159. package/lib/utils/isBeforeDay.js +20 -0
  160. package/lib/utils/isDayVisible.js +45 -0
  161. package/lib/utils/isInclusivelyAfterDay.js +13 -0
  162. package/lib/utils/isInclusivelyBeforeDay.js +13 -0
  163. package/lib/utils/isNextDay.js +14 -0
  164. package/lib/utils/isNextMonth.js +13 -0
  165. package/lib/utils/isPrevMonth.js +13 -0
  166. package/lib/utils/isPreviousDay.js +14 -0
  167. package/lib/utils/isSameDay.js +14 -0
  168. package/lib/utils/isSameMonth.js +14 -0
  169. package/lib/utils/isTransitionEndSupported.js +9 -0
  170. package/lib/utils/modifiers.js +102 -0
  171. package/lib/utils/noflip.js +16 -0
  172. package/lib/utils/registerCSSInterfaceWithDefaultTheme.js +12 -0
  173. package/lib/utils/registerInterfaceWithDefaultTheme.js +13 -0
  174. package/lib/utils/toISODateString.js +19 -0
  175. package/lib/utils/toISOMonthString.js +19 -0
  176. package/lib/utils/toLocalizedDateString.js +15 -0
  177. package/lib/utils/toMomentObject.js +14 -0
  178. package/package.json +141 -4
  179. package/scripts/.eslintrc +7 -0
  180. package/scripts/buildCSS.js +37 -0
  181. package/scripts/pure-component-fallback.js +70 -0
  182. package/scripts/renderAllComponents.jsx +25 -0
  183. package/src/components/CalendarDay.jsx +366 -0
  184. package/src/components/CalendarIcon.jsx +3 -0
  185. package/src/components/CalendarMonth.jsx +300 -0
  186. package/src/components/CalendarMonthGrid.jsx +427 -0
  187. package/src/components/CalendarWeek.jsx +17 -0
  188. package/src/components/ChevronDown.jsx +3 -0
  189. package/src/components/ChevronUp.jsx +3 -0
  190. package/src/components/CloseButton.jsx +3 -0
  191. package/src/components/CustomizableCalendarDay.jsx +382 -0
  192. package/src/components/DateInput.jsx +401 -0
  193. package/src/components/DateRangePicker.jsx +777 -0
  194. package/src/components/DateRangePickerInput.jsx +434 -0
  195. package/src/components/DateRangePickerInputController.jsx +379 -0
  196. package/src/components/DayPicker.jsx +1407 -0
  197. package/src/components/DayPickerKeyboardShortcuts.jsx +443 -0
  198. package/src/components/DayPickerNavigation.jsx +445 -0
  199. package/src/components/DayPickerRangeController.jsx +1409 -0
  200. package/src/components/DayPickerSingleDateController.jsx +769 -0
  201. package/src/components/KeyboardShortcutRow.jsx +93 -0
  202. package/src/components/LeftArrow.jsx +3 -0
  203. package/src/components/RightArrow.jsx +3 -0
  204. package/src/components/SingleDatePicker.jsx +731 -0
  205. package/src/components/SingleDatePickerInput.jsx +329 -0
  206. package/src/components/SingleDatePickerInputController.jsx +280 -0
  207. package/src/constants.js +37 -0
  208. package/src/defaultPhrases.js +215 -0
  209. package/src/index.js +20 -0
  210. package/src/initialize.js +3 -0
  211. package/src/shapes/AnchorDirectionShape.js +8 -0
  212. package/src/shapes/CalendarInfoPositionShape.js +15 -0
  213. package/src/shapes/DateRangePickerShape.js +111 -0
  214. package/src/shapes/DayOfWeekShape.js +5 -0
  215. package/src/shapes/DisabledShape.js +5 -0
  216. package/src/shapes/FocusedInputShape.js +8 -0
  217. package/src/shapes/IconPositionShape.js +8 -0
  218. package/src/shapes/ModifiersShape.js +20 -0
  219. package/src/shapes/NavPositionShape.js +8 -0
  220. package/src/shapes/OpenDirectionShape.js +8 -0
  221. package/src/shapes/OrientationShape.js +8 -0
  222. package/src/shapes/ScrollableOrientationShape.js +13 -0
  223. package/src/shapes/SingleDatePickerShape.js +100 -0
  224. package/src/svg/arrow-left.svg +1 -0
  225. package/src/svg/arrow-right.svg +1 -0
  226. package/src/svg/calendar.svg +1 -0
  227. package/src/svg/chevron-down.svg +1 -0
  228. package/src/svg/chevron-up.svg +1 -0
  229. package/src/svg/close.svg +1 -0
  230. package/src/theme/DefaultTheme.js +196 -0
  231. package/src/utils/calculateDimension.js +32 -0
  232. package/src/utils/disableScroll.js +65 -0
  233. package/src/utils/getActiveElement.js +3 -0
  234. package/src/utils/getCalendarDaySettings.js +61 -0
  235. package/src/utils/getCalendarMonthWeeks.js +49 -0
  236. package/src/utils/getCalendarMonthWidth.js +3 -0
  237. package/src/utils/getDetachedContainerStyles.js +39 -0
  238. package/src/utils/getInputHeight.js +67 -0
  239. package/src/utils/getNumberOfCalendarMonthWeeks.js +15 -0
  240. package/src/utils/getPhrase.jsx +9 -0
  241. package/src/utils/getPhrasePropTypes.js +9 -0
  242. package/src/utils/getPooledMoment.js +10 -0
  243. package/src/utils/getPreviousMonthMemoLast.js +11 -0
  244. package/src/utils/getResponsiveContainerStyles.js +18 -0
  245. package/src/utils/getSelectedDateOffset.js +6 -0
  246. package/src/utils/getTransformStyles.js +8 -0
  247. package/src/utils/getVisibleDays.js +54 -0
  248. package/src/utils/isAfterDay.js +9 -0
  249. package/src/utils/isBeforeDay.js +18 -0
  250. package/src/utils/isDayVisible.js +57 -0
  251. package/src/utils/isInclusivelyAfterDay.js +8 -0
  252. package/src/utils/isInclusivelyBeforeDay.js +8 -0
  253. package/src/utils/isNextDay.js +9 -0
  254. package/src/utils/isNextMonth.js +8 -0
  255. package/src/utils/isPrevMonth.js +8 -0
  256. package/src/utils/isPreviousDay.js +9 -0
  257. package/src/utils/isSameDay.js +10 -0
  258. package/src/utils/isSameMonth.js +9 -0
  259. package/src/utils/isTransitionEndSupported.js +3 -0
  260. package/src/utils/modifiers.js +116 -0
  261. package/src/utils/noflip.js +11 -0
  262. package/src/utils/registerCSSInterfaceWithDefaultTheme.js +7 -0
  263. package/src/utils/registerInterfaceWithDefaultTheme.js +7 -0
  264. package/src/utils/toISODateString.js +14 -0
  265. package/src/utils/toISOMonthString.js +14 -0
  266. package/src/utils/toLocalizedDateString.js +12 -0
  267. package/src/utils/toMomentObject.js +12 -0
@@ -0,0 +1,264 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ import React from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import { forbidExtraProps, nonNegativeInteger } from 'airbnb-prop-types';
8
+ import { withStyles, withStylesPropTypes } from 'react-with-styles';
9
+ import { SingleDatePickerInputPhrases } from '../defaultPhrases';
10
+ import getPhrasePropTypes from '../utils/getPhrasePropTypes';
11
+ import noflip from '../utils/noflip';
12
+ import DateInput from './DateInput';
13
+ import IconPositionShape from '../shapes/IconPositionShape';
14
+ import CloseButton from './CloseButton';
15
+ import CalendarIcon from './CalendarIcon';
16
+ import openDirectionShape from '../shapes/OpenDirectionShape';
17
+ import { ICON_BEFORE_POSITION, ICON_AFTER_POSITION, OPEN_DOWN } from '../constants';
18
+ var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps(_objectSpread(_objectSpread({}, withStylesPropTypes), {}, {
19
+ id: PropTypes.string.isRequired,
20
+ children: PropTypes.node,
21
+ placeholder: PropTypes.string,
22
+ ariaLabel: PropTypes.string,
23
+ autoComplete: PropTypes.string,
24
+ titleText: PropTypes.string,
25
+ displayValue: PropTypes.string,
26
+ screenReaderMessage: PropTypes.string,
27
+ focused: PropTypes.bool,
28
+ isFocused: PropTypes.bool,
29
+ // describes actual DOM focus
30
+ disabled: PropTypes.bool,
31
+ required: PropTypes.bool,
32
+ readOnly: PropTypes.bool,
33
+ openDirection: openDirectionShape,
34
+ showCaret: PropTypes.bool,
35
+ showClearDate: PropTypes.bool,
36
+ customCloseIcon: PropTypes.node,
37
+ showDefaultInputIcon: PropTypes.bool,
38
+ inputIconPosition: IconPositionShape,
39
+ customInputIcon: PropTypes.node,
40
+ isRTL: PropTypes.bool,
41
+ noBorder: PropTypes.bool,
42
+ block: PropTypes.bool,
43
+ small: PropTypes.bool,
44
+ regular: PropTypes.bool,
45
+ verticalSpacing: nonNegativeInteger,
46
+ onChange: PropTypes.func,
47
+ onClearDate: PropTypes.func,
48
+ onFocus: PropTypes.func,
49
+ onKeyDownShiftTab: PropTypes.func,
50
+ onKeyDownTab: PropTypes.func,
51
+ onKeyDownArrowDown: PropTypes.func,
52
+ onKeyDownQuestionMark: PropTypes.func,
53
+ // i18n
54
+ phrases: PropTypes.shape(getPhrasePropTypes(SingleDatePickerInputPhrases))
55
+ })) : {};
56
+ var defaultProps = {
57
+ children: null,
58
+ placeholder: 'Select Date',
59
+ ariaLabel: undefined,
60
+ autoComplete: 'off',
61
+ titleText: undefined,
62
+ displayValue: '',
63
+ screenReaderMessage: '',
64
+ focused: false,
65
+ isFocused: false,
66
+ disabled: false,
67
+ required: false,
68
+ readOnly: false,
69
+ openDirection: OPEN_DOWN,
70
+ showCaret: false,
71
+ showClearDate: false,
72
+ showDefaultInputIcon: false,
73
+ inputIconPosition: ICON_BEFORE_POSITION,
74
+ customCloseIcon: null,
75
+ customInputIcon: null,
76
+ isRTL: false,
77
+ noBorder: false,
78
+ block: false,
79
+ small: false,
80
+ regular: false,
81
+ verticalSpacing: undefined,
82
+ onChange: function onChange() {},
83
+ onClearDate: function onClearDate() {},
84
+ onFocus: function onFocus() {},
85
+ onKeyDownShiftTab: function onKeyDownShiftTab() {},
86
+ onKeyDownTab: function onKeyDownTab() {},
87
+ onKeyDownArrowDown: function onKeyDownArrowDown() {},
88
+ onKeyDownQuestionMark: function onKeyDownQuestionMark() {},
89
+ // i18n
90
+ phrases: SingleDatePickerInputPhrases
91
+ };
92
+ function SingleDatePickerInput(_ref) {
93
+ var id = _ref.id,
94
+ children = _ref.children,
95
+ placeholder = _ref.placeholder,
96
+ ariaLabel = _ref.ariaLabel,
97
+ autoComplete = _ref.autoComplete,
98
+ titleText = _ref.titleText,
99
+ displayValue = _ref.displayValue,
100
+ focused = _ref.focused,
101
+ isFocused = _ref.isFocused,
102
+ disabled = _ref.disabled,
103
+ required = _ref.required,
104
+ readOnly = _ref.readOnly,
105
+ showCaret = _ref.showCaret,
106
+ showClearDate = _ref.showClearDate,
107
+ showDefaultInputIcon = _ref.showDefaultInputIcon,
108
+ inputIconPosition = _ref.inputIconPosition,
109
+ phrases = _ref.phrases,
110
+ onClearDate = _ref.onClearDate,
111
+ onChange = _ref.onChange,
112
+ onFocus = _ref.onFocus,
113
+ onKeyDownShiftTab = _ref.onKeyDownShiftTab,
114
+ onKeyDownTab = _ref.onKeyDownTab,
115
+ onKeyDownArrowDown = _ref.onKeyDownArrowDown,
116
+ onKeyDownQuestionMark = _ref.onKeyDownQuestionMark,
117
+ screenReaderMessage = _ref.screenReaderMessage,
118
+ customCloseIcon = _ref.customCloseIcon,
119
+ customInputIcon = _ref.customInputIcon,
120
+ openDirection = _ref.openDirection,
121
+ isRTL = _ref.isRTL,
122
+ noBorder = _ref.noBorder,
123
+ block = _ref.block,
124
+ small = _ref.small,
125
+ regular = _ref.regular,
126
+ verticalSpacing = _ref.verticalSpacing,
127
+ css = _ref.css,
128
+ styles = _ref.styles;
129
+ var calendarIcon = customInputIcon || /*#__PURE__*/React.createElement(CalendarIcon, css(styles.SingleDatePickerInput_calendarIcon_svg));
130
+ var closeIcon = customCloseIcon || /*#__PURE__*/React.createElement(CloseButton, css(styles.SingleDatePickerInput_clearDate_svg, small && styles.SingleDatePickerInput_clearDate_svg__small));
131
+ var screenReaderText = screenReaderMessage || phrases.keyboardForwardNavigationInstructions;
132
+ var inputIcon = (showDefaultInputIcon || customInputIcon !== null) && /*#__PURE__*/React.createElement("button", _extends({}, css(styles.SingleDatePickerInput_calendarIcon), {
133
+ type: "button",
134
+ disabled: disabled,
135
+ "aria-label": phrases.focusStartDate,
136
+ onClick: onFocus,
137
+ tabIndex: "-1"
138
+ }), calendarIcon);
139
+ return /*#__PURE__*/React.createElement("div", css(styles.SingleDatePickerInput, disabled && styles.SingleDatePickerInput__disabled, isRTL && styles.SingleDatePickerInput__rtl, !noBorder && styles.SingleDatePickerInput__withBorder, block && styles.SingleDatePickerInput__block, showClearDate && styles.SingleDatePickerInput__showClearDate), inputIconPosition === ICON_BEFORE_POSITION && inputIcon, /*#__PURE__*/React.createElement(DateInput, {
140
+ id: id,
141
+ placeholder: placeholder,
142
+ ariaLabel: ariaLabel,
143
+ autoComplete: autoComplete,
144
+ titleText: titleText,
145
+ displayValue: displayValue,
146
+ screenReaderMessage: screenReaderText,
147
+ focused: focused,
148
+ isFocused: isFocused,
149
+ disabled: disabled,
150
+ required: required,
151
+ readOnly: readOnly,
152
+ showCaret: showCaret,
153
+ onChange: onChange,
154
+ onFocus: onFocus,
155
+ onKeyDownShiftTab: onKeyDownShiftTab,
156
+ onKeyDownTab: onKeyDownTab,
157
+ onKeyDownArrowDown: onKeyDownArrowDown,
158
+ onKeyDownQuestionMark: onKeyDownQuestionMark,
159
+ openDirection: openDirection,
160
+ verticalSpacing: verticalSpacing,
161
+ small: small,
162
+ regular: regular,
163
+ block: block
164
+ }), children, showClearDate && /*#__PURE__*/React.createElement("button", _extends({}, css(styles.SingleDatePickerInput_clearDate, small && styles.SingleDatePickerInput_clearDate__small, !customCloseIcon && styles.SingleDatePickerInput_clearDate__default, !displayValue && styles.SingleDatePickerInput_clearDate__hide), {
165
+ type: "button",
166
+ "aria-label": phrases.clearDate,
167
+ disabled: disabled,
168
+ onClick: onClearDate
169
+ }), closeIcon), inputIconPosition === ICON_AFTER_POSITION && inputIcon);
170
+ }
171
+ SingleDatePickerInput.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
172
+ SingleDatePickerInput.defaultProps = defaultProps;
173
+ export default withStyles(function (_ref2) {
174
+ var _ref2$reactDates = _ref2.reactDates,
175
+ border = _ref2$reactDates.border,
176
+ color = _ref2$reactDates.color;
177
+ return {
178
+ SingleDatePickerInput: {
179
+ display: 'inline-block',
180
+ backgroundColor: color.background
181
+ },
182
+ SingleDatePickerInput__withBorder: {
183
+ borderColor: color.border,
184
+ borderWidth: border.pickerInput.borderWidth,
185
+ borderStyle: border.pickerInput.borderStyle,
186
+ borderRadius: border.pickerInput.borderRadius
187
+ },
188
+ SingleDatePickerInput__rtl: {
189
+ direction: noflip('rtl')
190
+ },
191
+ SingleDatePickerInput__disabled: {
192
+ backgroundColor: color.disabled
193
+ },
194
+ SingleDatePickerInput__block: {
195
+ display: 'block'
196
+ },
197
+ SingleDatePickerInput__showClearDate: {
198
+ paddingRight: 30 // TODO: should be noflip wrapped and handled by an isRTL prop
199
+ },
200
+ SingleDatePickerInput_clearDate: {
201
+ background: 'none',
202
+ border: 0,
203
+ color: 'inherit',
204
+ font: 'inherit',
205
+ lineHeight: 'normal',
206
+ overflow: 'visible',
207
+ cursor: 'pointer',
208
+ padding: 10,
209
+ margin: '0 10px 0 5px',
210
+ // TODO: should be noflip wrapped and handled by an isRTL prop
211
+ position: 'absolute',
212
+ right: 0,
213
+ // TODO: should be noflip wrapped and handled by an isRTL prop
214
+ top: '50%',
215
+ transform: 'translateY(-50%)'
216
+ },
217
+ SingleDatePickerInput_clearDate__default: {
218
+ ':focus': {
219
+ background: color.core.border,
220
+ borderRadius: '50%'
221
+ },
222
+ ':hover': {
223
+ background: color.core.border,
224
+ borderRadius: '50%'
225
+ }
226
+ },
227
+ SingleDatePickerInput_clearDate__small: {
228
+ padding: 6
229
+ },
230
+ SingleDatePickerInput_clearDate__hide: {
231
+ visibility: 'hidden'
232
+ },
233
+ SingleDatePickerInput_clearDate_svg: {
234
+ fill: color.core.grayLight,
235
+ height: 12,
236
+ width: 15,
237
+ verticalAlign: 'middle'
238
+ },
239
+ SingleDatePickerInput_clearDate_svg__small: {
240
+ height: 9
241
+ },
242
+ SingleDatePickerInput_calendarIcon: {
243
+ background: 'none',
244
+ border: 0,
245
+ color: 'inherit',
246
+ font: 'inherit',
247
+ lineHeight: 'normal',
248
+ overflow: 'visible',
249
+ cursor: 'pointer',
250
+ display: 'inline-block',
251
+ verticalAlign: 'middle',
252
+ padding: 10,
253
+ margin: '0 5px 0 10px' // TODO: should be noflip wrapped and handled by an isRTL prop
254
+ },
255
+ SingleDatePickerInput_calendarIcon_svg: {
256
+ fill: color.core.grayLight,
257
+ height: 15,
258
+ width: 14,
259
+ verticalAlign: 'middle'
260
+ }
261
+ };
262
+ }, {
263
+ pureComponent: typeof React.PureComponent !== 'undefined'
264
+ })(SingleDatePickerInput);
@@ -0,0 +1,260 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
2
+ import shallowEqual from "enzyme-shallow-equal";
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import moment from 'moment';
6
+ import momentPropTypes from 'react-moment-proptypes';
7
+ import { forbidExtraProps, nonNegativeInteger } from 'airbnb-prop-types';
8
+ import openDirectionShape from '../shapes/OpenDirectionShape';
9
+ import { SingleDatePickerInputPhrases } from '../defaultPhrases';
10
+ import getPhrasePropTypes from '../utils/getPhrasePropTypes';
11
+ import SingleDatePickerInput from './SingleDatePickerInput';
12
+ import IconPositionShape from '../shapes/IconPositionShape';
13
+ import DisabledShape from '../shapes/DisabledShape';
14
+ import toMomentObject from '../utils/toMomentObject';
15
+ import toLocalizedDateString from '../utils/toLocalizedDateString';
16
+ import isInclusivelyAfterDay from '../utils/isInclusivelyAfterDay';
17
+ import { ICON_BEFORE_POSITION, OPEN_DOWN } from '../constants';
18
+ var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps({
19
+ children: PropTypes.node,
20
+ date: momentPropTypes.momentObj,
21
+ onDateChange: PropTypes.func.isRequired,
22
+ focused: PropTypes.bool,
23
+ onFocusChange: PropTypes.func.isRequired,
24
+ id: PropTypes.string.isRequired,
25
+ placeholder: PropTypes.string,
26
+ ariaLabel: PropTypes.string,
27
+ autoComplete: PropTypes.string,
28
+ titleText: PropTypes.string,
29
+ screenReaderMessage: PropTypes.string,
30
+ showClearDate: PropTypes.bool,
31
+ showCaret: PropTypes.bool,
32
+ showDefaultInputIcon: PropTypes.bool,
33
+ inputIconPosition: IconPositionShape,
34
+ disabled: DisabledShape,
35
+ required: PropTypes.bool,
36
+ readOnly: PropTypes.bool,
37
+ openDirection: openDirectionShape,
38
+ noBorder: PropTypes.bool,
39
+ block: PropTypes.bool,
40
+ small: PropTypes.bool,
41
+ regular: PropTypes.bool,
42
+ verticalSpacing: nonNegativeInteger,
43
+ keepOpenOnDateSelect: PropTypes.bool,
44
+ reopenPickerOnClearDate: PropTypes.bool,
45
+ isOutsideRange: PropTypes.func,
46
+ isDayBlocked: PropTypes.func,
47
+ displayFormat: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
48
+ onClose: PropTypes.func,
49
+ onKeyDownArrowDown: PropTypes.func,
50
+ onKeyDownQuestionMark: PropTypes.func,
51
+ customInputIcon: PropTypes.node,
52
+ customCloseIcon: PropTypes.node,
53
+ // accessibility
54
+ isFocused: PropTypes.bool,
55
+ // i18n
56
+ phrases: PropTypes.shape(getPhrasePropTypes(SingleDatePickerInputPhrases)),
57
+ isRTL: PropTypes.bool
58
+ }) : {};
59
+ var defaultProps = {
60
+ children: null,
61
+ date: null,
62
+ focused: false,
63
+ placeholder: '',
64
+ ariaLabel: undefined,
65
+ autoComplete: 'off',
66
+ titleText: undefined,
67
+ screenReaderMessage: 'Date',
68
+ showClearDate: false,
69
+ showCaret: false,
70
+ showDefaultInputIcon: false,
71
+ inputIconPosition: ICON_BEFORE_POSITION,
72
+ disabled: false,
73
+ required: false,
74
+ readOnly: false,
75
+ openDirection: OPEN_DOWN,
76
+ noBorder: false,
77
+ block: false,
78
+ small: false,
79
+ regular: false,
80
+ verticalSpacing: undefined,
81
+ keepOpenOnDateSelect: false,
82
+ reopenPickerOnClearDate: false,
83
+ isOutsideRange: function isOutsideRange(day) {
84
+ return !isInclusivelyAfterDay(day, moment());
85
+ },
86
+ isDayBlocked: function isDayBlocked() {
87
+ return false;
88
+ },
89
+ displayFormat: function displayFormat() {
90
+ return moment.localeData().longDateFormat('L');
91
+ },
92
+ onClose: function onClose() {},
93
+ onKeyDownArrowDown: function onKeyDownArrowDown() {},
94
+ onKeyDownQuestionMark: function onKeyDownQuestionMark() {},
95
+ customInputIcon: null,
96
+ customCloseIcon: null,
97
+ // accessibility
98
+ isFocused: false,
99
+ // i18n
100
+ phrases: SingleDatePickerInputPhrases,
101
+ isRTL: false
102
+ };
103
+ var SingleDatePickerInputController = /*#__PURE__*/function (_ref2, _ref) {
104
+ function SingleDatePickerInputController(props) {
105
+ var _this;
106
+ _this = _ref2.call(this, props) || this;
107
+ _this.onChange = _this.onChange.bind(_this);
108
+ _this.onFocus = _this.onFocus.bind(_this);
109
+ _this.onClearFocus = _this.onClearFocus.bind(_this);
110
+ _this.clearDate = _this.clearDate.bind(_this);
111
+ return _this;
112
+ }
113
+ _inheritsLoose(SingleDatePickerInputController, _ref2);
114
+ var _proto = SingleDatePickerInputController.prototype;
115
+ _proto[_ref] = function (nextProps, nextState) {
116
+ return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
117
+ };
118
+ _proto.onChange = function onChange(dateString) {
119
+ var _this$props = this.props,
120
+ isOutsideRange = _this$props.isOutsideRange,
121
+ isDayBlocked = _this$props.isDayBlocked,
122
+ keepOpenOnDateSelect = _this$props.keepOpenOnDateSelect,
123
+ onDateChange = _this$props.onDateChange,
124
+ onFocusChange = _this$props.onFocusChange,
125
+ onClose = _this$props.onClose;
126
+ var newDate = toMomentObject(dateString, this.getDisplayFormat());
127
+ var isValid = newDate && !isOutsideRange(newDate) && !isDayBlocked(newDate);
128
+ if (isValid) {
129
+ onDateChange(newDate);
130
+ if (!keepOpenOnDateSelect) {
131
+ onFocusChange({
132
+ focused: false
133
+ });
134
+ onClose({
135
+ date: newDate
136
+ });
137
+ }
138
+ } else {
139
+ onDateChange(null);
140
+ }
141
+ };
142
+ _proto.onFocus = function onFocus() {
143
+ var _this$props2 = this.props,
144
+ onFocusChange = _this$props2.onFocusChange,
145
+ disabled = _this$props2.disabled;
146
+ if (!disabled) {
147
+ onFocusChange({
148
+ focused: true
149
+ });
150
+ }
151
+ };
152
+ _proto.onClearFocus = function onClearFocus() {
153
+ var _this$props3 = this.props,
154
+ focused = _this$props3.focused,
155
+ onFocusChange = _this$props3.onFocusChange,
156
+ onClose = _this$props3.onClose,
157
+ date = _this$props3.date;
158
+ if (!focused) return;
159
+ onFocusChange({
160
+ focused: false
161
+ });
162
+ onClose({
163
+ date: date
164
+ });
165
+ };
166
+ _proto.getDisplayFormat = function getDisplayFormat() {
167
+ var displayFormat = this.props.displayFormat;
168
+ return typeof displayFormat === 'string' ? displayFormat : displayFormat();
169
+ };
170
+ _proto.getDateString = function getDateString(date) {
171
+ var displayFormat = this.getDisplayFormat();
172
+ if (date && displayFormat) {
173
+ return date && date.format(displayFormat);
174
+ }
175
+ return toLocalizedDateString(date);
176
+ };
177
+ _proto.clearDate = function clearDate() {
178
+ var _this$props4 = this.props,
179
+ onDateChange = _this$props4.onDateChange,
180
+ reopenPickerOnClearDate = _this$props4.reopenPickerOnClearDate,
181
+ onFocusChange = _this$props4.onFocusChange;
182
+ onDateChange(null);
183
+ if (reopenPickerOnClearDate) {
184
+ onFocusChange({
185
+ focused: true
186
+ });
187
+ }
188
+ };
189
+ _proto.render = function render() {
190
+ var _this$props5 = this.props,
191
+ children = _this$props5.children,
192
+ id = _this$props5.id,
193
+ placeholder = _this$props5.placeholder,
194
+ ariaLabel = _this$props5.ariaLabel,
195
+ autoComplete = _this$props5.autoComplete,
196
+ titleText = _this$props5.titleText,
197
+ disabled = _this$props5.disabled,
198
+ focused = _this$props5.focused,
199
+ isFocused = _this$props5.isFocused,
200
+ required = _this$props5.required,
201
+ readOnly = _this$props5.readOnly,
202
+ openDirection = _this$props5.openDirection,
203
+ showClearDate = _this$props5.showClearDate,
204
+ showCaret = _this$props5.showCaret,
205
+ showDefaultInputIcon = _this$props5.showDefaultInputIcon,
206
+ inputIconPosition = _this$props5.inputIconPosition,
207
+ customCloseIcon = _this$props5.customCloseIcon,
208
+ customInputIcon = _this$props5.customInputIcon,
209
+ date = _this$props5.date,
210
+ phrases = _this$props5.phrases,
211
+ onKeyDownArrowDown = _this$props5.onKeyDownArrowDown,
212
+ onKeyDownQuestionMark = _this$props5.onKeyDownQuestionMark,
213
+ screenReaderMessage = _this$props5.screenReaderMessage,
214
+ isRTL = _this$props5.isRTL,
215
+ noBorder = _this$props5.noBorder,
216
+ block = _this$props5.block,
217
+ small = _this$props5.small,
218
+ regular = _this$props5.regular,
219
+ verticalSpacing = _this$props5.verticalSpacing;
220
+ var displayValue = this.getDateString(date);
221
+ return /*#__PURE__*/React.createElement(SingleDatePickerInput, {
222
+ id: id,
223
+ placeholder: placeholder,
224
+ ariaLabel: ariaLabel,
225
+ autoComplete: autoComplete,
226
+ titleText: titleText,
227
+ focused: focused,
228
+ isFocused: isFocused,
229
+ disabled: disabled,
230
+ required: required,
231
+ readOnly: readOnly,
232
+ openDirection: openDirection,
233
+ showCaret: showCaret,
234
+ onClearDate: this.clearDate,
235
+ showClearDate: showClearDate,
236
+ showDefaultInputIcon: showDefaultInputIcon,
237
+ inputIconPosition: inputIconPosition,
238
+ customCloseIcon: customCloseIcon,
239
+ customInputIcon: customInputIcon,
240
+ displayValue: displayValue,
241
+ onChange: this.onChange,
242
+ onFocus: this.onFocus,
243
+ onKeyDownShiftTab: this.onClearFocus,
244
+ onKeyDownArrowDown: onKeyDownArrowDown,
245
+ onKeyDownQuestionMark: onKeyDownQuestionMark,
246
+ screenReaderMessage: screenReaderMessage,
247
+ phrases: phrases,
248
+ isRTL: isRTL,
249
+ noBorder: noBorder,
250
+ block: block,
251
+ small: small,
252
+ regular: regular,
253
+ verticalSpacing: verticalSpacing
254
+ }, children);
255
+ };
256
+ return SingleDatePickerInputController;
257
+ }(React.PureComponent || React.Component, !React.PureComponent && "shouldComponentUpdate");
258
+ export { SingleDatePickerInputController as default };
259
+ SingleDatePickerInputController.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
260
+ SingleDatePickerInputController.defaultProps = defaultProps;
@@ -0,0 +1,28 @@
1
+ export var DISPLAY_FORMAT = 'L';
2
+ export var ISO_FORMAT = 'YYYY-MM-DD';
3
+ export var ISO_MONTH_FORMAT = 'YYYY-MM'; // TODO delete this line of dead code on next breaking change
4
+
5
+ export var START_DATE = 'startDate';
6
+ export var END_DATE = 'endDate';
7
+ export var HORIZONTAL_ORIENTATION = 'horizontal';
8
+ export var VERTICAL_ORIENTATION = 'vertical';
9
+ export var VERTICAL_SCROLLABLE = 'verticalScrollable';
10
+ export var NAV_POSITION_BOTTOM = 'navPositionBottom';
11
+ export var NAV_POSITION_TOP = 'navPositionTop';
12
+ export var ICON_BEFORE_POSITION = 'before';
13
+ export var ICON_AFTER_POSITION = 'after';
14
+ export var INFO_POSITION_TOP = 'top';
15
+ export var INFO_POSITION_BOTTOM = 'bottom';
16
+ export var INFO_POSITION_BEFORE = 'before';
17
+ export var INFO_POSITION_AFTER = 'after';
18
+ export var ANCHOR_LEFT = 'left';
19
+ export var ANCHOR_RIGHT = 'right';
20
+ export var OPEN_DOWN = 'down';
21
+ export var OPEN_UP = 'up';
22
+ export var DAY_SIZE = 39;
23
+ export var BLOCKED_MODIFIER = 'blocked';
24
+ export var WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
25
+ export var FANG_WIDTH_PX = 20;
26
+ export var FANG_HEIGHT_PX = 10;
27
+ export var DEFAULT_VERTICAL_SPACING = 22;
28
+ export var MODIFIER_KEY_NAMES = new Set(['Shift', 'Control', 'Alt', 'Meta']);