@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,176 @@
1
+ var core = {
2
+ white: '#fff',
3
+ gray: '#484848',
4
+ grayLight: '#82888a',
5
+ grayLighter: '#cacccd',
6
+ grayLightest: '#f2f2f2',
7
+ borderMedium: '#c4c4c4',
8
+ border: '#dbdbdb',
9
+ borderLight: '#e4e7e7',
10
+ borderLighter: '#eceeee',
11
+ borderBright: '#f4f5f5',
12
+ primary: '#00a699',
13
+ primaryShade_1: '#33dacd',
14
+ primaryShade_2: '#66e2da',
15
+ primaryShade_3: '#80e8e0',
16
+ primaryShade_4: '#b2f1ec',
17
+ primary_dark: '#008489',
18
+ secondary: '#007a87',
19
+ yellow: '#ffe8bc',
20
+ yellow_dark: '#ffce71'
21
+ };
22
+ export default {
23
+ reactDates: {
24
+ zIndex: 0,
25
+ border: {
26
+ input: {
27
+ border: 0,
28
+ borderTop: 0,
29
+ borderRight: 0,
30
+ borderBottom: '2px solid transparent',
31
+ borderLeft: 0,
32
+ outlineFocused: 0,
33
+ borderFocused: 0,
34
+ borderTopFocused: 0,
35
+ borderLeftFocused: 0,
36
+ borderBottomFocused: "2px solid ".concat(core.primary_dark),
37
+ borderRightFocused: 0,
38
+ borderRadius: 0
39
+ },
40
+ pickerInput: {
41
+ borderWidth: 1,
42
+ borderStyle: 'solid',
43
+ borderRadius: 2
44
+ }
45
+ },
46
+ color: {
47
+ core: core,
48
+ disabled: core.grayLightest,
49
+ background: core.white,
50
+ backgroundDark: '#f2f2f2',
51
+ backgroundFocused: core.white,
52
+ border: 'rgb(219, 219, 219)',
53
+ text: core.gray,
54
+ textDisabled: core.border,
55
+ textFocused: '#007a87',
56
+ placeholderText: '#757575',
57
+ outside: {
58
+ backgroundColor: core.white,
59
+ backgroundColor_active: core.white,
60
+ backgroundColor_hover: core.white,
61
+ color: core.gray,
62
+ color_active: core.gray,
63
+ color_hover: core.gray
64
+ },
65
+ highlighted: {
66
+ backgroundColor: core.yellow,
67
+ backgroundColor_active: core.yellow_dark,
68
+ backgroundColor_hover: core.yellow_dark,
69
+ color: core.gray,
70
+ color_active: core.gray,
71
+ color_hover: core.gray
72
+ },
73
+ minimumNights: {
74
+ backgroundColor: core.white,
75
+ backgroundColor_active: core.white,
76
+ backgroundColor_hover: core.white,
77
+ borderColor: core.borderLighter,
78
+ color: core.grayLighter,
79
+ color_active: core.grayLighter,
80
+ color_hover: core.grayLighter
81
+ },
82
+ hoveredSpan: {
83
+ backgroundColor: core.primaryShade_4,
84
+ backgroundColor_active: core.primaryShade_3,
85
+ backgroundColor_hover: core.primaryShade_4,
86
+ borderColor: core.primaryShade_3,
87
+ borderColor_active: core.primaryShade_3,
88
+ borderColor_hover: core.primaryShade_3,
89
+ color: core.secondary,
90
+ color_active: core.secondary,
91
+ color_hover: core.secondary
92
+ },
93
+ selectedSpan: {
94
+ backgroundColor: core.primaryShade_2,
95
+ backgroundColor_active: core.primaryShade_1,
96
+ backgroundColor_hover: core.primaryShade_1,
97
+ borderColor: core.primaryShade_1,
98
+ borderColor_active: core.primary,
99
+ borderColor_hover: core.primary,
100
+ color: core.white,
101
+ color_active: core.white,
102
+ color_hover: core.white
103
+ },
104
+ selected: {
105
+ backgroundColor: core.primary,
106
+ backgroundColor_active: core.primary,
107
+ backgroundColor_hover: core.primary,
108
+ borderColor: core.primary,
109
+ borderColor_active: core.primary,
110
+ borderColor_hover: core.primary,
111
+ color: core.white,
112
+ color_active: core.white,
113
+ color_hover: core.white
114
+ },
115
+ blocked_calendar: {
116
+ backgroundColor: core.grayLighter,
117
+ backgroundColor_active: core.grayLighter,
118
+ backgroundColor_hover: core.grayLighter,
119
+ borderColor: core.grayLighter,
120
+ borderColor_active: core.grayLighter,
121
+ borderColor_hover: core.grayLighter,
122
+ color: core.grayLight,
123
+ color_active: core.grayLight,
124
+ color_hover: core.grayLight
125
+ },
126
+ blocked_out_of_range: {
127
+ backgroundColor: core.white,
128
+ backgroundColor_active: core.white,
129
+ backgroundColor_hover: core.white,
130
+ borderColor: core.borderLight,
131
+ borderColor_active: core.borderLight,
132
+ borderColor_hover: core.borderLight,
133
+ color: core.grayLighter,
134
+ color_active: core.grayLighter,
135
+ color_hover: core.grayLighter
136
+ }
137
+ },
138
+ spacing: {
139
+ dayPickerHorizontalPadding: 9,
140
+ captionPaddingTop: 22,
141
+ captionPaddingBottom: 37,
142
+ inputPadding: 0,
143
+ displayTextPaddingVertical: undefined,
144
+ displayTextPaddingTop: 11,
145
+ displayTextPaddingBottom: 9,
146
+ displayTextPaddingHorizontal: undefined,
147
+ displayTextPaddingLeft: 11,
148
+ displayTextPaddingRight: 11,
149
+ displayTextPaddingVertical_small: undefined,
150
+ displayTextPaddingTop_small: 7,
151
+ displayTextPaddingBottom_small: 5,
152
+ displayTextPaddingHorizontal_small: undefined,
153
+ displayTextPaddingLeft_small: 7,
154
+ displayTextPaddingRight_small: 7
155
+ },
156
+ sizing: {
157
+ inputWidth: 130,
158
+ inputWidth_small: 97,
159
+ arrowWidth: 24
160
+ },
161
+ noScrollBarOnVerticalScrollable: false,
162
+ font: {
163
+ size: 14,
164
+ captionSize: 18,
165
+ input: {
166
+ size: 19,
167
+ weight: 200,
168
+ lineHeight: '24px',
169
+ size_small: 15,
170
+ lineHeight_small: '18px',
171
+ letterSpacing_small: '0.2px',
172
+ styleDisabled: 'italic'
173
+ }
174
+ }
175
+ }
176
+ };
@@ -0,0 +1,28 @@
1
+ export default function calculateDimension(el, axis) {
2
+ var borderBox = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3
+ var withMargin = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
4
+ if (!el) {
5
+ return 0;
6
+ }
7
+ var axisStart = axis === 'width' ? 'Left' : 'Top';
8
+ var axisEnd = axis === 'width' ? 'Right' : 'Bottom';
9
+
10
+ // Only read styles if we need to
11
+ var style = !borderBox || withMargin ? window.getComputedStyle(el) : null;
12
+
13
+ // Offset includes border and padding
14
+ var offsetWidth = el.offsetWidth,
15
+ offsetHeight = el.offsetHeight;
16
+ var size = axis === 'width' ? offsetWidth : offsetHeight;
17
+
18
+ // Get the inner size
19
+ if (!borderBox) {
20
+ size -= parseFloat(style["padding".concat(axisStart)]) + parseFloat(style["padding".concat(axisEnd)]) + parseFloat(style["border".concat(axisStart, "Width")]) + parseFloat(style["border".concat(axisEnd, "Width")]);
21
+ }
22
+
23
+ // Apply margin
24
+ if (withMargin) {
25
+ size += parseFloat(style["margin".concat(axisStart)]) + parseFloat(style["margin".concat(axisEnd)]);
26
+ }
27
+ return size;
28
+ }
@@ -0,0 +1,67 @@
1
+ var getScrollingRoot = function getScrollingRoot() {
2
+ return document.scrollingElement || document.documentElement;
3
+ };
4
+
5
+ /**
6
+ * Recursively finds the scroll parent of a node. The scroll parrent of a node
7
+ * is the closest node that is scrollable. A node is scrollable if:
8
+ * - it is allowed to scroll via CSS ('overflow-y' not visible or hidden);
9
+ * - and its children/content are "bigger" than the node's box height.
10
+ *
11
+ * The root of the document always scrolls by default.
12
+ *
13
+ * @param {HTMLElement} node Any DOM element.
14
+ * @return {HTMLElement} The scroll parent element.
15
+ */
16
+ export function getScrollParent(node) {
17
+ var parent = node.parentElement;
18
+ if (parent == null) return getScrollingRoot();
19
+ var _window$getComputedSt = window.getComputedStyle(parent),
20
+ overflowY = _window$getComputedSt.overflowY;
21
+ var canScroll = overflowY !== 'visible' && overflowY !== 'hidden';
22
+ if (canScroll && parent.scrollHeight > parent.clientHeight) {
23
+ return parent;
24
+ }
25
+ return getScrollParent(parent);
26
+ }
27
+
28
+ /**
29
+ * Recursively traverses the tree upwards from the given node, capturing all
30
+ * ancestor nodes that scroll along with their current 'overflow-y' CSS
31
+ * property.
32
+ *
33
+ * @param {HTMLElement} node Any DOM element.
34
+ * @param {Map<HTMLElement,string>} [acc] Accumulator map.
35
+ * @return {Map<HTMLElement,string>} Map of ancestors with their 'overflow-y' value.
36
+ */
37
+ export function getScrollAncestorsOverflowY(node) {
38
+ var acc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Map();
39
+ var scrollingRoot = getScrollingRoot();
40
+ var scrollParent = getScrollParent(node);
41
+ acc.set(scrollParent, scrollParent.style.overflowY);
42
+ if (scrollParent === scrollingRoot) return acc;
43
+ return getScrollAncestorsOverflowY(scrollParent, acc);
44
+ }
45
+
46
+ /**
47
+ * Disabling the scroll on a node involves finding all the scrollable ancestors
48
+ * and set their 'overflow-y' CSS property to 'hidden'. When all ancestors have
49
+ * 'overflow-y: hidden' (up to the document element) there is no scroll
50
+ * container, thus all the scroll outside of the node is disabled. In order to
51
+ * enable scroll again, we store the previous value of the 'overflow-y' for
52
+ * every ancestor in a closure and reset it back.
53
+ *
54
+ * @param {HTMLElement} node Any DOM element.
55
+ */
56
+ export default function disableScroll(node) {
57
+ var scrollAncestorsOverflowY = getScrollAncestorsOverflowY(node);
58
+ var toggle = function toggle(on) {
59
+ return scrollAncestorsOverflowY.forEach(function (overflowY, ancestor) {
60
+ ancestor.style.setProperty('overflow-y', on ? 'hidden' : overflowY);
61
+ });
62
+ };
63
+ toggle(true);
64
+ return function () {
65
+ return toggle(false);
66
+ };
67
+ }
@@ -0,0 +1,3 @@
1
+ export default function getActiveElement() {
2
+ return typeof document !== 'undefined' && document.activeElement;
3
+ }
@@ -0,0 +1,48 @@
1
+ import getPhrase from './getPhrase';
2
+ import { BLOCKED_MODIFIER } from '../constants';
3
+ function isSelected(modifiers) {
4
+ return modifiers.has('selected') || modifiers.has('selected-span') || modifiers.has('selected-start') || modifiers.has('selected-end');
5
+ }
6
+ function shouldUseDefaultCursor(modifiers) {
7
+ return modifiers.has('blocked-minimum-nights') || modifiers.has('blocked-calendar') || modifiers.has('blocked-out-of-range');
8
+ }
9
+ function isHoveredSpan(modifiers) {
10
+ if (isSelected(modifiers)) return false;
11
+ return modifiers.has('hovered-span') || modifiers.has('after-hovered-start') || modifiers.has('before-hovered-end');
12
+ }
13
+ function getAriaLabel(phrases, modifiers, day, ariaLabelFormat) {
14
+ var chooseAvailableDate = phrases.chooseAvailableDate,
15
+ dateIsUnavailable = phrases.dateIsUnavailable,
16
+ dateIsSelected = phrases.dateIsSelected,
17
+ dateIsSelectedAsStartDate = phrases.dateIsSelectedAsStartDate,
18
+ dateIsSelectedAsEndDate = phrases.dateIsSelectedAsEndDate;
19
+ var formattedDate = {
20
+ date: day.format(ariaLabelFormat)
21
+ };
22
+ if (modifiers.has('selected-start') && dateIsSelectedAsStartDate) {
23
+ return getPhrase(dateIsSelectedAsStartDate, formattedDate);
24
+ }
25
+ if (modifiers.has('selected-end') && dateIsSelectedAsEndDate) {
26
+ return getPhrase(dateIsSelectedAsEndDate, formattedDate);
27
+ }
28
+ if (isSelected(modifiers) && dateIsSelected) {
29
+ return getPhrase(dateIsSelected, formattedDate);
30
+ }
31
+ if (modifiers.has(BLOCKED_MODIFIER)) {
32
+ return getPhrase(dateIsUnavailable, formattedDate);
33
+ }
34
+ return getPhrase(chooseAvailableDate, formattedDate);
35
+ }
36
+ export default function getCalendarDaySettings(day, ariaLabelFormat, daySize, modifiers, phrases) {
37
+ return {
38
+ ariaLabel: getAriaLabel(phrases, modifiers, day, ariaLabelFormat),
39
+ hoveredSpan: isHoveredSpan(modifiers),
40
+ isOutsideRange: modifiers.has('blocked-out-of-range'),
41
+ selected: isSelected(modifiers),
42
+ useDefaultCursor: shouldUseDefaultCursor(modifiers),
43
+ daySizeStyles: {
44
+ width: daySize,
45
+ height: daySize - 1
46
+ }
47
+ };
48
+ }
@@ -0,0 +1,37 @@
1
+ import moment from 'moment';
2
+ import { WEEKDAYS } from '../constants';
3
+ export default function getCalendarMonthWeeks(month, enableOutsideDays) {
4
+ var firstDayOfWeek = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : moment.localeData().firstDayOfWeek();
5
+ if (!moment.isMoment(month) || !month.isValid()) {
6
+ throw new TypeError('`month` must be a valid moment object');
7
+ }
8
+ if (WEEKDAYS.indexOf(firstDayOfWeek) === -1) {
9
+ throw new TypeError('`firstDayOfWeek` must be an integer between 0 and 6');
10
+ }
11
+
12
+ // set utc offset to get correct dates in future (when timezone changes)
13
+ var firstOfMonth = month.clone().startOf('month').hour(12);
14
+ var lastOfMonth = month.clone().endOf('month').hour(12);
15
+
16
+ // calculate the exact first and last days to fill the entire matrix
17
+ // (considering days outside month)
18
+ var prevDays = (firstOfMonth.day() + 7 - firstDayOfWeek) % 7;
19
+ var nextDays = (firstDayOfWeek + 6 - lastOfMonth.day()) % 7;
20
+ var firstDay = firstOfMonth.clone().subtract(prevDays, 'day');
21
+ var lastDay = lastOfMonth.clone().add(nextDays, 'day');
22
+ var totalDays = lastDay.diff(firstDay, 'days') + 1;
23
+ var currentDay = firstDay.clone();
24
+ var weeksInMonth = [];
25
+ for (var i = 0; i < totalDays; i += 1) {
26
+ if (i % 7 === 0) {
27
+ weeksInMonth.push([]);
28
+ }
29
+ var day = null;
30
+ if (i >= prevDays && i < totalDays - nextDays || enableOutsideDays) {
31
+ day = currentDay.clone();
32
+ }
33
+ weeksInMonth[weeksInMonth.length - 1].push(day);
34
+ currentDay.add(1, 'day');
35
+ }
36
+ return weeksInMonth;
37
+ }
@@ -0,0 +1,4 @@
1
+ export default function getCalendarMonthWidth(daySize) {
2
+ var calendarMonthPadding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3
+ return 7 * daySize + 2 * calendarMonthPadding + 1;
4
+ }
@@ -0,0 +1,36 @@
1
+ import { OPEN_UP, ANCHOR_RIGHT } from '../constants';
2
+
3
+ /**
4
+ * Calculate and return a CSS transform style to position a detached element
5
+ * next to a reference element. The open and anchor direction indicate wether
6
+ * it should be positioned above/below and/or to the left/right of the
7
+ * reference element.
8
+ *
9
+ * Assuming r(0,0), r(1,1), d(0,0), d(1,1) for the bottom-left and top-right
10
+ * corners of the reference and detached elements, respectively:
11
+ * - openDirection = DOWN, anchorDirection = LEFT => d(0,1) == r(0,1)
12
+ * - openDirection = UP, anchorDirection = LEFT => d(0,0) == r(0,0)
13
+ * - openDirection = DOWN, anchorDirection = RIGHT => d(1,1) == r(1,1)
14
+ * - openDirection = UP, anchorDirection = RIGHT => d(1,0) == r(1,0)
15
+ *
16
+ * By using a CSS transform, we allow to further position it using
17
+ * top/bottom CSS properties for the anchor gutter.
18
+ *
19
+ * @param {string} openDirection The vertical positioning of the popup
20
+ * @param {string} anchorDirection The horizontal position of the popup
21
+ * @param {HTMLElement} referenceEl The reference element
22
+ */
23
+ export default function getDetachedContainerStyles(openDirection, anchorDirection, referenceEl) {
24
+ var referenceRect = referenceEl.getBoundingClientRect();
25
+ var offsetX = referenceRect.left;
26
+ var offsetY = referenceRect.top;
27
+ if (openDirection === OPEN_UP) {
28
+ offsetY = -(window.innerHeight - referenceRect.bottom);
29
+ }
30
+ if (anchorDirection === ANCHOR_RIGHT) {
31
+ offsetX = -(window.innerWidth - referenceRect.right);
32
+ }
33
+ return {
34
+ transform: "translate3d(".concat(Math.round(offsetX), "px, ").concat(Math.round(offsetY), "px, 0)")
35
+ };
36
+ }
@@ -0,0 +1,42 @@
1
+ /* eslint-disable camelcase */
2
+
3
+ function getPadding(vertical, top, bottom) {
4
+ var isTopDefined = typeof top === 'number';
5
+ var isBottomDefined = typeof bottom === 'number';
6
+ var isVerticalDefined = typeof vertical === 'number';
7
+ if (isTopDefined && isBottomDefined) {
8
+ return top + bottom;
9
+ }
10
+ if (isTopDefined && isVerticalDefined) {
11
+ return top + vertical;
12
+ }
13
+ if (isTopDefined) {
14
+ return top;
15
+ }
16
+ if (isBottomDefined && isVerticalDefined) {
17
+ return bottom + vertical;
18
+ }
19
+ if (isBottomDefined) {
20
+ return bottom;
21
+ }
22
+ if (isVerticalDefined) {
23
+ return 2 * vertical;
24
+ }
25
+ return 0;
26
+ }
27
+ export default function getInputHeight(_ref, small) {
28
+ var _ref$font$input = _ref.font.input,
29
+ lineHeight = _ref$font$input.lineHeight,
30
+ lineHeight_small = _ref$font$input.lineHeight_small,
31
+ _ref$spacing = _ref.spacing,
32
+ inputPadding = _ref$spacing.inputPadding,
33
+ displayTextPaddingVertical = _ref$spacing.displayTextPaddingVertical,
34
+ displayTextPaddingTop = _ref$spacing.displayTextPaddingTop,
35
+ displayTextPaddingBottom = _ref$spacing.displayTextPaddingBottom,
36
+ displayTextPaddingVertical_small = _ref$spacing.displayTextPaddingVertical_small,
37
+ displayTextPaddingTop_small = _ref$spacing.displayTextPaddingTop_small,
38
+ displayTextPaddingBottom_small = _ref$spacing.displayTextPaddingBottom_small;
39
+ var calcLineHeight = small ? lineHeight_small : lineHeight;
40
+ var padding = small ? getPadding(displayTextPaddingVertical_small, displayTextPaddingTop_small, displayTextPaddingBottom_small) : getPadding(displayTextPaddingVertical, displayTextPaddingTop, displayTextPaddingBottom);
41
+ return parseInt(calcLineHeight, 10) + 2 * inputPadding + padding;
42
+ }
@@ -0,0 +1,11 @@
1
+ import moment from 'moment';
2
+ function getBlankDaysBeforeFirstDay(firstDayOfMonth, firstDayOfWeek) {
3
+ var weekDayDiff = firstDayOfMonth.day() - firstDayOfWeek;
4
+ return (weekDayDiff + 7) % 7;
5
+ }
6
+ export default function getNumberOfCalendarMonthWeeks(month) {
7
+ var firstDayOfWeek = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : moment.localeData().firstDayOfWeek();
8
+ var firstDayOfMonth = month.clone().startOf('month').hour(12);
9
+ var numBlankDays = getBlankDaysBeforeFirstDay(firstDayOfMonth, firstDayOfWeek);
10
+ return Math.ceil((numBlankDays + month.daysInMonth()) / 7);
11
+ }
@@ -0,0 +1,7 @@
1
+ export default function getPhrase(phrase, args) {
2
+ if (typeof phrase === 'string') return phrase;
3
+ if (typeof phrase === 'function') {
4
+ return phrase(args);
5
+ }
6
+ return '';
7
+ }
@@ -0,0 +1,9 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ 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; }
3
+ 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; }
4
+ import PropTypes from 'prop-types';
5
+ export default function getPhrasePropTypes(defaultPhrases) {
6
+ return Object.keys(defaultPhrases).reduce(function (phrases, key) {
7
+ return _objectSpread(_objectSpread({}, phrases), {}, _defineProperty({}, key, PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.node])));
8
+ }, {});
9
+ }
@@ -0,0 +1,8 @@
1
+ import moment from 'moment';
2
+ var momentPool = new Map();
3
+ export default function getPooledMoment(dayString) {
4
+ if (!momentPool.has(dayString)) {
5
+ momentPool.set(dayString, moment(dayString));
6
+ }
7
+ return momentPool.get(dayString);
8
+ }
@@ -0,0 +1,9 @@
1
+ var getPreviousMonthMemoKey;
2
+ var getPreviousMonthMemoValue;
3
+ export default function getPreviousMonthMemoLast(month) {
4
+ if (month !== getPreviousMonthMemoKey) {
5
+ getPreviousMonthMemoKey = month;
6
+ getPreviousMonthMemoValue = month.clone().subtract(1, 'month');
7
+ }
8
+ return getPreviousMonthMemoValue;
9
+ }
@@ -0,0 +1,8 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { ANCHOR_LEFT } from '../constants';
3
+ export default function getResponsiveContainerStyles(anchorDirection, currentOffset, containerEdge, margin) {
4
+ var windowWidth = typeof window !== 'undefined' ? window.innerWidth : 0;
5
+ var calculatedOffset = anchorDirection === ANCHOR_LEFT ? windowWidth - containerEdge : containerEdge;
6
+ var calculatedMargin = margin || 0;
7
+ return _defineProperty({}, anchorDirection, Math.min(currentOffset + calculatedOffset - calculatedMargin, 0));
8
+ }
@@ -0,0 +1,8 @@
1
+ var defaultModifier = function defaultModifier(day) {
2
+ return day;
3
+ };
4
+ export default function getSelectedDateOffset(fn, day) {
5
+ var modifier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultModifier;
6
+ if (!fn) return day;
7
+ return modifier(fn(day.clone()));
8
+ }
@@ -0,0 +1,8 @@
1
+ export default function getTransformStyles(transformValue) {
2
+ return {
3
+ transform: transformValue,
4
+ msTransform: transformValue,
5
+ MozTransform: transformValue,
6
+ WebkitTransform: transformValue
7
+ };
8
+ }
@@ -0,0 +1,42 @@
1
+ import moment from 'moment';
2
+ import toISOMonthString from './toISOMonthString';
3
+ export default function getVisibleDays(month, numberOfMonths, enableOutsideDays, withoutTransitionMonths) {
4
+ if (!moment.isMoment(month)) return {};
5
+ var visibleDaysByMonth = {};
6
+ var currentMonth = withoutTransitionMonths ? month.clone() : month.clone().subtract(1, 'month');
7
+ for (var i = 0; i < (withoutTransitionMonths ? numberOfMonths : numberOfMonths + 2); i += 1) {
8
+ var visibleDays = [];
9
+
10
+ // set utc offset to get correct dates in future (when timezone changes)
11
+ var baseDate = currentMonth.clone();
12
+ var firstOfMonth = baseDate.clone().startOf('month').hour(12);
13
+ var lastOfMonth = baseDate.clone().endOf('month').hour(12);
14
+ var currentDay = firstOfMonth.clone();
15
+
16
+ // days belonging to the previous month
17
+ if (enableOutsideDays) {
18
+ for (var j = 0; j < currentDay.weekday(); j += 1) {
19
+ var prevDay = currentDay.clone().subtract(j + 1, 'day');
20
+ visibleDays.unshift(prevDay);
21
+ }
22
+ }
23
+ while (currentDay < lastOfMonth) {
24
+ visibleDays.push(currentDay.clone());
25
+ currentDay.add(1, 'day');
26
+ }
27
+ if (enableOutsideDays) {
28
+ // weekday() returns the index of the day of the week according to the locale
29
+ // this means if the week starts on Monday, weekday() will return 0 for a Monday date, not 1
30
+ if (currentDay.weekday() !== 0) {
31
+ // days belonging to the next month
32
+ for (var k = currentDay.weekday(), count = 0; k < 7; k += 1, count += 1) {
33
+ var nextDay = currentDay.clone().add(count, 'day');
34
+ visibleDays.push(nextDay);
35
+ }
36
+ }
37
+ }
38
+ visibleDaysByMonth[toISOMonthString(currentMonth)] = visibleDays;
39
+ currentMonth = currentMonth.clone().add(1, 'month');
40
+ }
41
+ return visibleDaysByMonth;
42
+ }
@@ -0,0 +1,7 @@
1
+ import moment from 'moment';
2
+ import isBeforeDay from './isBeforeDay';
3
+ import isSameDay from './isSameDay';
4
+ export default function isAfterDay(a, b) {
5
+ if (!moment.isMoment(a) || !moment.isMoment(b)) return false;
6
+ return !isBeforeDay(a, b) && !isSameDay(a, b);
7
+ }
@@ -0,0 +1,13 @@
1
+ import moment from 'moment';
2
+ export default function isBeforeDay(a, b) {
3
+ if (!moment.isMoment(a) || !moment.isMoment(b)) return false;
4
+ var aYear = a.year();
5
+ var aMonth = a.month();
6
+ var bYear = b.year();
7
+ var bMonth = b.month();
8
+ var isSameYear = aYear === bYear;
9
+ var isSameMonth = aMonth === bMonth;
10
+ if (isSameYear && isSameMonth) return a.date() < b.date();
11
+ if (isSameYear) return aMonth < bMonth;
12
+ return aYear < bYear;
13
+ }
@@ -0,0 +1,38 @@
1
+ import moment from 'moment';
2
+ import isBeforeDay from './isBeforeDay';
3
+ import isAfterDay from './isAfterDay';
4
+ import toISOMonthString from './toISOMonthString';
5
+ var startCacheOutsideDays = new Map();
6
+ var endCacheOutsideDays = new Map();
7
+ var startCacheInsideDays = new Map();
8
+ var endCacheInsideDays = new Map();
9
+ export default function isDayVisible(day, month, numberOfMonths, enableOutsideDays) {
10
+ if (!moment.isMoment(day)) return false;
11
+
12
+ // Cloning is a little expensive, so we want to do it as little as possible.
13
+
14
+ var startKey = toISOMonthString(month);
15
+ // eslint-disable-next-line prefer-template
16
+ var endKey = startKey + '+' + numberOfMonths;
17
+ if (enableOutsideDays) {
18
+ if (!startCacheOutsideDays.has(startKey)) {
19
+ startCacheOutsideDays.set(startKey, month.clone().startOf('month').startOf('week').hour(12));
20
+ }
21
+ if (isBeforeDay(day, startCacheOutsideDays.get(startKey))) return false;
22
+ if (!endCacheOutsideDays.has(endKey)) {
23
+ endCacheOutsideDays.set(endKey, month.clone().endOf('week').add(numberOfMonths - 1, 'months').endOf('month').endOf('week').hour(12));
24
+ }
25
+ return !isAfterDay(day, endCacheOutsideDays.get(endKey));
26
+ }
27
+
28
+ // !enableOutsideDays
29
+
30
+ if (!startCacheInsideDays.has(startKey)) {
31
+ startCacheInsideDays.set(startKey, month.clone().startOf('month').hour(12));
32
+ }
33
+ if (isBeforeDay(day, startCacheInsideDays.get(startKey))) return false;
34
+ if (!endCacheInsideDays.has(endKey)) {
35
+ endCacheInsideDays.set(endKey, month.clone().add(numberOfMonths - 1, 'months').endOf('month').hour(12));
36
+ }
37
+ return !isAfterDay(day, endCacheInsideDays.get(endKey));
38
+ }
@@ -0,0 +1,6 @@
1
+ import moment from 'moment';
2
+ import isBeforeDay from './isBeforeDay';
3
+ export default function isInclusivelyAfterDay(a, b) {
4
+ if (!moment.isMoment(a) || !moment.isMoment(b)) return false;
5
+ return !isBeforeDay(a, b);
6
+ }
@@ -0,0 +1,6 @@
1
+ import moment from 'moment';
2
+ import isAfterDay from './isAfterDay';
3
+ export default function isInclusivelyBeforeDay(a, b) {
4
+ if (!moment.isMoment(a) || !moment.isMoment(b)) return false;
5
+ return !isAfterDay(a, b);
6
+ }
@@ -0,0 +1,7 @@
1
+ import moment from 'moment';
2
+ import isSameDay from './isSameDay';
3
+ export default function isNextDay(a, b) {
4
+ if (!moment.isMoment(a) || !moment.isMoment(b)) return false;
5
+ var nextDay = moment(a).add(1, 'day');
6
+ return isSameDay(nextDay, b);
7
+ }