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