@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
package/package.json CHANGED
@@ -1,6 +1,143 @@
1
1
  {
2
2
  "name": "@birdnet/advanced-react-dates",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "An advanced, responsive, and accessible date range picker based on Airbnb's react-dates",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "prebuild": "npm run clean",
8
+ "build": "npm run build:cjs && npm run build:esm && npm run build:css -- --optimize",
9
+ "postbuild": "npm run build:test",
10
+ "build:cjs": "BABEL_ENV=cjs babel src/ -d lib/",
11
+ "build:esm": "BABEL_ENV=esm babel src/ -d esm/",
12
+ "build:test": "BABEL_ENV=test babel test/ -d test-build/",
13
+ "prebuild:css": "rimraf lib/css && mkdirp lib/css",
14
+ "build:css": "node scripts/buildCSS.js",
15
+ "clean": "rimraf lib esm test-build",
16
+ "lint": "eslint --ext .js,.jsx src test",
17
+ "mocha": "mocha ./test-build/_helpers",
18
+ "storybook:uninstall": "npm uninstall --no-save @storybook/react && rimraf node_modules/@storybook node_modules/react-modal node_modules/react-dom-factories",
19
+ "react": "NPM_CONFIG_LEGACY_PEER_DEPS=true enzyme-adapter-react-install 16",
20
+ "pretest": "npm run --silent lint",
21
+ "tests-only": "cross-env NODE_ENV=test nyc npm run mocha --silent",
22
+ "pretests-karma": "npm run react",
23
+ "tests-karma": "karma start",
24
+ "test": "npm run react && npm run build && npm run build:test && npm run tests-only",
25
+ "storybook": "start-storybook -p 6006",
26
+ "storybook:css": "npm run build:css && start-storybook -p 6006 -c .storybook-css",
27
+ "tag": "git tag v$npm_package_version",
28
+ "gh-pages:clean": "rimraf _gh-pages",
29
+ "gh-pages:build": "$(npm bin)/build-storybook -o _gh-pages",
30
+ "gh-pages:publish": "$(npm bin)/git-directory-deploy --directory _gh-pages",
31
+ "gh-pages": "npm run gh-pages:clean && npm run gh-pages:build && npm run gh-pages:publish",
32
+ "version:patch": "npm --no-git-tag-version version patch",
33
+ "version:minor": "npm --no-git-tag-version version minor",
34
+ "version:major": "npm --no-git-tag-version version major",
35
+ "preversion": "npm run test && npm run check-changelog && npm run check-only-changelog-changed",
36
+ "postversion": "git commit package.json CHANGELOG.md -m \"Version $npm_package_version\" && npm run tag && git push && git push --tags && npm publish --registry=https://registry.npmjs.org/",
37
+ "prepublish": "in-publish && safe-publish-latest && npm run build || not-in-publish",
38
+ "postpublish": "[ \"${npm_config_tag:-latest}\" != latest ] || npm run gh-pages",
39
+ "check-changelog": "expr $(git status --porcelain 2>/dev/null| grep \"^\\s*M.*CHANGELOG.md\" | wc -l) >/dev/null || (echo 'Please edit CHANGELOG.md' && exit 1)",
40
+ "check-only-changelog-changed": "(expr $(git status --porcelain 2>/dev/null| grep -v \"CHANGELOG.md\" | wc -l) >/dev/null && echo 'Only CHANGELOG.md may have uncommitted changes' && exit 1) || exit 0"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/krisldz/advanced-react-dates.git"
45
+ },
46
+ "author": "Maja Wichrowska <maja.wichrowska@airbnb.com> / Krzysztof Sokołowski <k.sokolowski@birdnet.pl>",
47
+ "license": "MIT",
48
+ "bugs": {
49
+ "url": "https://github.com/krisldz/advanced-react-dates/issues"
50
+ },
51
+ "homepage": "https://github.com/krisldz/advanced-react-dates#readme",
52
+ "devDependencies": {
53
+ "@babel/cli": "^7.16.8",
54
+ "@babel/core": "^7.16.12",
55
+ "@babel/eslint-parser": "^7.16.5",
56
+ "@babel/register": "^7.16.9",
57
+ "@babel/runtime": "^7.16.7",
58
+ "@storybook/addon-actions": "^5.3.21",
59
+ "@storybook/addon-info": "^5.3.21",
60
+ "@storybook/addon-links": "^5.3.21",
61
+ "@storybook/addon-options": "^5.3.21",
62
+ "@storybook/addons": "^5.3.21",
63
+ "@storybook/react": "^5.3.21",
64
+ "@welldone-software/why-did-you-render": "^3.6.0",
65
+ "airbnb-js-shims": "^2.2.1",
66
+ "aphrodite": "^2.4.0",
67
+ "babel-loader": "^8.2.2",
68
+ "babel-plugin-import-path-replace": "^0.1.0",
69
+ "babel-plugin-inline-react-svg": "^1.1.2",
70
+ "babel-plugin-inline-svg": "^1.2.0",
71
+ "babel-plugin-istanbul": "^5.2.0",
72
+ "babel-plugin-transform-replace-object-assign": "^2.0.0",
73
+ "babel-preset-airbnb": "^4.5.0",
74
+ "chai": "^4.2.0",
75
+ "cheerio": "=1.0.0-rc.3",
76
+ "clean-css": "^4.2.3",
77
+ "cross-env": "^5.2.1",
78
+ "enzyme": "^3.11.0",
79
+ "enzyme-adapter-react-helper": "^1.3.9",
80
+ "eslint": "^8.7.0",
81
+ "eslint-config-airbnb": "^19.0.4",
82
+ "eslint-plugin-import": "^2.25.4",
83
+ "eslint-plugin-jsx-a11y": "^6.5.1",
84
+ "eslint-plugin-react": "^7.28.0",
85
+ "eslint-plugin-react-hooks": "^4.3.0",
86
+ "eslint-plugin-react-with-styles": "^2.4.0",
87
+ "git-directory-deploy": "^1.5.1",
88
+ "imports-loader": "^0.8.0",
89
+ "in-publish": "^2.0.1",
90
+ "karma": "^6.3.11",
91
+ "karma-chai": "^0.1.0",
92
+ "karma-firefox-launcher": "^1.2.0",
93
+ "karma-mocha": "^2.0.1",
94
+ "karma-sinon": "^1.0.5",
95
+ "karma-webpack": "^4.0.2",
96
+ "mkdirp": "^0.5.5",
97
+ "mocha": "^3.5.3",
98
+ "mocha-wrap": "^2.1.2",
99
+ "moment": "^2.29.1",
100
+ "moment-jalaali": "^0.7.4",
101
+ "nyc": "^10.3.2",
102
+ "raw-loader": "^0.5.1",
103
+ "react": "^0.14 || ^15.5.4 || ^16.1.1",
104
+ "react-dom": "^0.14 || ^15.5.4 || ^16.1.1",
105
+ "react-with-styles-interface-aphrodite": "^6.0.1",
106
+ "react-with-styles-interface-css-compiler": "^2.2.0",
107
+ "rimraf": "^2.7.1",
108
+ "safe-publish-latest": "^1.1.4",
109
+ "sass-loader": "^7.3.1",
110
+ "sinon": "^7.5.0",
111
+ "sinon-sandbox": "^2.0.6",
112
+ "style-loader": "^0.20.3",
113
+ "typescript": "*",
114
+ "webpack": "^4.46.0"
115
+ },
116
+ "dependencies": {
117
+ "airbnb-prop-types": "^2.16.0",
118
+ "color2k": "~1.1.1",
119
+ "consolidated-events": "^1.1.1 || ^2.0.0",
120
+ "enzyme-shallow-equal": "^1.0.4",
121
+ "is-touch-device": "^1.0.1",
122
+ "lodash": "^4.1.1",
123
+ "object.assign": "^4.1.2",
124
+ "object.values": "^1.1.5",
125
+ "prop-types": "^15.7.2",
126
+ "raf": "^3.4.1",
127
+ "react-moment-proptypes": "^1.8.1",
128
+ "react-outside-click-handler": "^1.3.0",
129
+ "react-portal": "^4.2.1",
130
+ "react-with-direction": "^1.4.0",
131
+ "react-with-styles": "~4.1.0",
132
+ "react-with-styles-interface-css": "^6.0.0"
133
+ },
134
+ "peerDependencies": {
135
+ "@babel/runtime": "^7.0.0",
136
+ "moment": "^2.18.1",
137
+ "react": "^0.14 || ^15.5.4 || ^16.1.1",
138
+ "react-dom": "^0.14 || ^15.5.4 || ^16.1.1"
139
+ },
140
+ "engines": {
141
+ "node": ">=0.10"
142
+ }
143
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "rules": {
3
+ "import/no-extraneous-dependencies": [2, {
4
+ "devDependencies": true
5
+ }],
6
+ }
7
+ }
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const CleanCSS = require('clean-css');
5
+
6
+ const compileCSS = require('react-with-styles-interface-css-compiler');
7
+
8
+ const registerMaxSpecificity = require('react-with-styles-interface-css/dist/utils/registerMaxSpecificity').default;
9
+ const registerCSSInterfaceWithDefaultTheme = require('../src/utils/registerCSSInterfaceWithDefaultTheme').default;
10
+
11
+ console.error = msg => { throw new SyntaxError(msg); };
12
+ console.warn = msg => { throw new SyntaxError(msg); };
13
+
14
+ const args = process.argv.slice(2);
15
+ const optimizeForProduction = args.includes('-o') || args.includes('--optimize');
16
+
17
+ registerMaxSpecificity(0);
18
+ registerCSSInterfaceWithDefaultTheme();
19
+
20
+ const path = './scripts/renderAllComponents.jsx';
21
+ const CSS = compileCSS(path);
22
+
23
+ if (CSS === '') {
24
+ throw new Error('Failed to compile CSS');
25
+ } else {
26
+ console.log('CSS compilation complete.');
27
+ }
28
+
29
+ const format = new CleanCSS({
30
+ level: optimizeForProduction ? 2 : 0,
31
+ format: 'beautify',
32
+ inline: ['none'],
33
+ });
34
+ const { styles: formattedCSS } = format.minify(CSS);
35
+
36
+ const outputFilePath = optimizeForProduction ? './lib/css/_datepicker.css' : './css/styles.css';
37
+ fs.writeFileSync(outputFilePath, formattedCSS, 'utf8');
@@ -0,0 +1,70 @@
1
+ module.exports = function pureComponentFallback({ types: t, template }) {
2
+ const buildPureOrNormalSuperclass = () => t.LogicalExpression('||',
3
+ t.memberExpression(t.identifier('React'), t.identifier('PureComponent')),
4
+ t.memberExpression(t.identifier('React'), t.identifier('Component')));
5
+
6
+ const buildShouldComponentUpdate = () => {
7
+ const method = t.classMethod(
8
+ 'method',
9
+ t.logicalExpression(
10
+ '&&',
11
+ t.unaryExpression('!', t.memberExpression(t.identifier('React'), t.identifier('PureComponent'))),
12
+ t.stringLiteral('shouldComponentUpdate')
13
+ ),
14
+ [t.identifier('nextProps'), t.identifier('nextState')],
15
+ t.blockStatement([template('return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);')()]),
16
+ true
17
+ );
18
+ return method;
19
+ };
20
+
21
+ function superclassIsPureComponent(path) {
22
+ const superclass = path.get('superClass');
23
+ // check for PureComponent
24
+ if (t.isIdentifier(superclass)) {
25
+ return superclass.node.name === 'PureComponent';
26
+ }
27
+
28
+ if (t.isMemberExpression(superclass)) {
29
+ // Check for React.PureComponent
30
+ return superclass.get('object').node.name === 'React'
31
+ && superclass.get('property').node.name === 'PureComponent';
32
+ }
33
+
34
+ return false;
35
+ }
36
+
37
+ return {
38
+ visitor: {
39
+ Program: {
40
+ exit({ node }, { file }) {
41
+ if (file.get('addShallowEqualImport')) {
42
+ const shallowEqualImportDeclaration = t.importDeclaration([
43
+ t.importDefaultSpecifier(t.identifier('shallowEqual')),
44
+ ], t.stringLiteral('enzyme-shallow-equal'));
45
+ node.body.unshift(shallowEqualImportDeclaration);
46
+ }
47
+ },
48
+ },
49
+
50
+ ClassDeclaration(path, { file }) {
51
+ if (superclassIsPureComponent(path)) {
52
+ const superclassPath = path.get('superClass');
53
+
54
+ // Replace the superclass
55
+ superclassPath.replaceWith(buildPureOrNormalSuperclass());
56
+
57
+ // Only add an SCU if one doesn't already exist
58
+ const existingSCU = path.get('body').get('body').find((
59
+ p => p.isClassMethod() && p.get('key').node.name === 'shouldComponentUpdate'
60
+ ));
61
+
62
+ if (!existingSCU) {
63
+ file.set('addShallowEqualImport', true);
64
+ path.get('body').unshiftContainer('body', buildShouldComponentUpdate());
65
+ }
66
+ }
67
+ },
68
+ },
69
+ };
70
+ };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+
4
+ import DateRangePickerWrapper from '../examples/DateRangePickerWrapper';
5
+ import SingleDatePickerWrapper from '../examples/SingleDatePickerWrapper';
6
+ import PresetDateRangePickerWrapper from '../examples/PresetDateRangePicker';
7
+
8
+ if (!document.getElementById('root')) {
9
+ // Make sure the #root element is defined
10
+ const root = document.createElement('div');
11
+ root.id = 'root';
12
+ document.body.appendChild(root);
13
+ }
14
+
15
+ function App() {
16
+ return (
17
+ <div>
18
+ <DateRangePickerWrapper autoFocus />
19
+ <SingleDatePickerWrapper autoFocus />
20
+ <PresetDateRangePickerWrapper autoFocus />
21
+ </div>
22
+ );
23
+ }
24
+
25
+ ReactDOM.render(<App />, document.querySelector('#root'));
@@ -0,0 +1,366 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import momentPropTypes from 'react-moment-proptypes';
4
+ import { forbidExtraProps, nonNegativeInteger } from 'airbnb-prop-types';
5
+ import { withStyles, withStylesPropTypes } from 'react-with-styles';
6
+ import moment from 'moment';
7
+ import raf from 'raf';
8
+
9
+ import { CalendarDayPhrases } from '../defaultPhrases';
10
+ import getPhrasePropTypes from '../utils/getPhrasePropTypes';
11
+ import getCalendarDaySettings from '../utils/getCalendarDaySettings';
12
+ import ModifiersShape from '../shapes/ModifiersShape';
13
+
14
+ import { DAY_SIZE } from '../constants';
15
+
16
+ const propTypes = forbidExtraProps({
17
+ ...withStylesPropTypes,
18
+ day: momentPropTypes.momentObj,
19
+ daySize: nonNegativeInteger,
20
+ isOutsideDay: PropTypes.bool,
21
+ modifiers: ModifiersShape,
22
+ isFocused: PropTypes.bool,
23
+ tabIndex: PropTypes.oneOf([0, -1]),
24
+ onDayClick: PropTypes.func,
25
+ onDayMouseEnter: PropTypes.func,
26
+ onDayMouseLeave: PropTypes.func,
27
+ renderDayContents: PropTypes.func,
28
+ ariaLabelFormat: PropTypes.string,
29
+
30
+ // internationalization
31
+ phrases: PropTypes.shape(getPhrasePropTypes(CalendarDayPhrases)),
32
+ });
33
+
34
+ const defaultProps = {
35
+ day: moment(),
36
+ daySize: DAY_SIZE,
37
+ isOutsideDay: false,
38
+ modifiers: new Set(),
39
+ isFocused: false,
40
+ tabIndex: -1,
41
+ onDayClick() {},
42
+ onDayMouseEnter() {},
43
+ onDayMouseLeave() {},
44
+ renderDayContents: null,
45
+ ariaLabelFormat: 'dddd, LL',
46
+
47
+ // internationalization
48
+ phrases: CalendarDayPhrases,
49
+ };
50
+
51
+ class CalendarDay extends React.PureComponent {
52
+ constructor(...args) {
53
+ super(...args);
54
+
55
+ this.setButtonRef = this.setButtonRef.bind(this);
56
+ }
57
+
58
+ componentDidUpdate(prevProps) {
59
+ const { isFocused, tabIndex } = this.props;
60
+ if (tabIndex === 0) {
61
+ if (isFocused || tabIndex !== prevProps.tabIndex) {
62
+ raf(() => {
63
+ if (this.buttonRef) {
64
+ this.buttonRef.focus();
65
+ }
66
+ });
67
+ }
68
+ }
69
+ }
70
+
71
+ onDayClick(day, e) {
72
+ const { onDayClick } = this.props;
73
+ onDayClick(day, e);
74
+ }
75
+
76
+ onDayMouseEnter(day, e) {
77
+ const { onDayMouseEnter } = this.props;
78
+ onDayMouseEnter(day, e);
79
+ }
80
+
81
+ onDayMouseLeave(day, e) {
82
+ const { onDayMouseLeave } = this.props;
83
+ onDayMouseLeave(day, e);
84
+ }
85
+
86
+ onKeyDown(day, e) {
87
+ const { onDayClick } = this.props;
88
+
89
+ const { key } = e;
90
+ if (key === 'Enter' || key === ' ') {
91
+ onDayClick(day, e);
92
+ }
93
+ }
94
+
95
+ setButtonRef(ref) {
96
+ this.buttonRef = ref;
97
+ }
98
+
99
+ render() {
100
+ const {
101
+ day,
102
+ ariaLabelFormat,
103
+ daySize,
104
+ isOutsideDay,
105
+ modifiers,
106
+ renderDayContents,
107
+ tabIndex,
108
+ css,
109
+ styles,
110
+ phrases,
111
+ } = this.props;
112
+
113
+ // empty placeholder cell (no day to render); nothing to label
114
+ // eslint-disable-next-line jsx-a11y/control-has-associated-label
115
+ if (!day) return <td />;
116
+
117
+ const {
118
+ daySizeStyles,
119
+ useDefaultCursor,
120
+ selected,
121
+ hoveredSpan,
122
+ isOutsideRange,
123
+ ariaLabel,
124
+ } = getCalendarDaySettings(day, ariaLabelFormat, daySize, modifiers, phrases);
125
+
126
+ return (
127
+ <td
128
+ {...css(
129
+ styles.CalendarDay,
130
+ useDefaultCursor && styles.CalendarDay__defaultCursor,
131
+ styles.CalendarDay__default,
132
+ isOutsideDay && styles.CalendarDay__outside,
133
+ modifiers.has('today') && styles.CalendarDay__today,
134
+ modifiers.has('first-day-of-week') && styles.CalendarDay__firstDayOfWeek,
135
+ modifiers.has('last-day-of-week') && styles.CalendarDay__lastDayOfWeek,
136
+ modifiers.has('hovered-offset') && styles.CalendarDay__hovered_offset,
137
+ modifiers.has('hovered-start-first-possible-end') && styles.CalendarDay__hovered_start_first_possible_end,
138
+ modifiers.has('hovered-start-blocked-minimum-nights') && styles.CalendarDay__hovered_start_blocked_min_nights,
139
+ modifiers.has('highlighted-calendar') && styles.CalendarDay__highlighted_calendar,
140
+ modifiers.has('blocked-minimum-nights') && styles.CalendarDay__blocked_minimum_nights,
141
+ modifiers.has('blocked-calendar') && styles.CalendarDay__blocked_calendar,
142
+ hoveredSpan && styles.CalendarDay__hovered_span,
143
+ modifiers.has('after-hovered-start') && styles.CalendarDay__after_hovered_start,
144
+ modifiers.has('selected-span') && styles.CalendarDay__selected_span,
145
+ modifiers.has('selected-start') && styles.CalendarDay__selected_start,
146
+ modifiers.has('selected-end') && styles.CalendarDay__selected_end,
147
+ selected && !modifiers.has('selected-span') && styles.CalendarDay__selected,
148
+ modifiers.has('before-hovered-end') && styles.CalendarDay__before_hovered_end,
149
+ modifiers.has('no-selected-start-before-selected-end') && styles.CalendarDay__no_selected_start_before_selected_end,
150
+ modifiers.has('selected-start-in-hovered-span') && styles.CalendarDay__selected_start_in_hovered_span,
151
+ modifiers.has('selected-end-in-hovered-span') && styles.CalendarDay__selected_end_in_hovered_span,
152
+ modifiers.has('selected-start-no-selected-end') && styles.CalendarDay__selected_start_no_selected_end,
153
+ modifiers.has('selected-end-no-selected-start') && styles.CalendarDay__selected_end_no_selected_start,
154
+ isOutsideRange && styles.CalendarDay__blocked_out_of_range,
155
+ daySizeStyles,
156
+ )}
157
+ role="button" // eslint-disable-line jsx-a11y/no-noninteractive-element-to-interactive-role
158
+ ref={this.setButtonRef}
159
+ aria-disabled={modifiers.has('blocked')}
160
+ {...(modifiers.has('today') ? { 'aria-current': 'date' } : {})}
161
+ aria-label={ariaLabel}
162
+ onMouseEnter={(e) => { this.onDayMouseEnter(day, e); }}
163
+ onMouseLeave={(e) => { this.onDayMouseLeave(day, e); }}
164
+ onMouseUp={(e) => { e.currentTarget.blur(); }}
165
+ onClick={(e) => { this.onDayClick(day, e); }}
166
+ onKeyDown={(e) => { this.onKeyDown(day, e); }}
167
+ tabIndex={tabIndex}
168
+ >
169
+ {renderDayContents ? renderDayContents(day, modifiers) : day.format('D')}
170
+ </td>
171
+ );
172
+ }
173
+ }
174
+
175
+ CalendarDay.propTypes = propTypes;
176
+ CalendarDay.defaultProps = defaultProps;
177
+
178
+ export { CalendarDay as PureCalendarDay };
179
+ export default withStyles(({ reactDates: { color, font } }) => ({
180
+ CalendarDay: {
181
+ boxSizing: 'border-box',
182
+ cursor: 'pointer',
183
+ fontSize: font.size,
184
+ textAlign: 'center',
185
+
186
+ ':active': {
187
+ outline: 0,
188
+ },
189
+ },
190
+
191
+ CalendarDay__defaultCursor: {
192
+ cursor: 'default',
193
+ },
194
+
195
+ CalendarDay__default: {
196
+ border: `1px solid ${color.core.borderLight}`,
197
+ color: color.text,
198
+ background: color.background,
199
+
200
+ ':hover': {
201
+ background: color.core.borderLight,
202
+ border: `1px solid ${color.core.borderLight}`,
203
+ color: 'inherit',
204
+ },
205
+ },
206
+
207
+ CalendarDay__hovered_offset: {
208
+ background: color.core.borderBright,
209
+ border: `1px double ${color.core.borderLight}`,
210
+ color: 'inherit',
211
+ },
212
+
213
+ CalendarDay__outside: {
214
+ border: 0,
215
+ background: color.outside.backgroundColor,
216
+ color: color.outside.color,
217
+
218
+ ':hover': {
219
+ border: 0,
220
+ },
221
+ },
222
+
223
+ CalendarDay__blocked_minimum_nights: {
224
+ background: color.minimumNights.backgroundColor,
225
+ border: `1px solid ${color.minimumNights.borderColor}`,
226
+ color: color.minimumNights.color,
227
+
228
+ ':hover': {
229
+ background: color.minimumNights.backgroundColor_hover,
230
+ color: color.minimumNights.color_active,
231
+ },
232
+
233
+ ':active': {
234
+ background: color.minimumNights.backgroundColor_active,
235
+ color: color.minimumNights.color_active,
236
+ },
237
+ },
238
+
239
+ CalendarDay__highlighted_calendar: {
240
+ background: color.highlighted.backgroundColor,
241
+ color: color.highlighted.color,
242
+
243
+ ':hover': {
244
+ background: color.highlighted.backgroundColor_hover,
245
+ color: color.highlighted.color_active,
246
+ },
247
+
248
+ ':active': {
249
+ background: color.highlighted.backgroundColor_active,
250
+ color: color.highlighted.color_active,
251
+ },
252
+ },
253
+
254
+ CalendarDay__selected_span: {
255
+ background: color.selectedSpan.backgroundColor,
256
+ border: `1px double ${color.selectedSpan.borderColor}`,
257
+ color: color.selectedSpan.color,
258
+
259
+ ':hover': {
260
+ background: color.selectedSpan.backgroundColor_hover,
261
+ border: `1px double ${color.selectedSpan.borderColor}`,
262
+ color: color.selectedSpan.color_active,
263
+ },
264
+
265
+ ':active': {
266
+ background: color.selectedSpan.backgroundColor_active,
267
+ border: `1px double ${color.selectedSpan.borderColor}`,
268
+ color: color.selectedSpan.color_active,
269
+ },
270
+ },
271
+
272
+ CalendarDay__selected: {
273
+ background: color.selected.backgroundColor,
274
+ border: `1px double ${color.selected.borderColor}`,
275
+ color: color.selected.color,
276
+
277
+ ':hover': {
278
+ background: color.selected.backgroundColor_hover,
279
+ border: `1px double ${color.selected.borderColor}`,
280
+ color: color.selected.color_active,
281
+ },
282
+
283
+ ':active': {
284
+ background: color.selected.backgroundColor_active,
285
+ border: `1px double ${color.selected.borderColor}`,
286
+ color: color.selected.color_active,
287
+ },
288
+ },
289
+
290
+ CalendarDay__hovered_span: {
291
+ background: color.hoveredSpan.backgroundColor,
292
+ border: `1px double ${color.hoveredSpan.borderColor}`,
293
+ color: color.hoveredSpan.color,
294
+
295
+ ':hover': {
296
+ background: color.hoveredSpan.backgroundColor_hover,
297
+ border: `1px double ${color.hoveredSpan.borderColor}`,
298
+ color: color.hoveredSpan.color_active,
299
+ },
300
+
301
+ ':active': {
302
+ background: color.hoveredSpan.backgroundColor_active,
303
+ border: `1px double ${color.hoveredSpan.borderColor}`,
304
+ color: color.hoveredSpan.color_active,
305
+ },
306
+ },
307
+
308
+ CalendarDay__blocked_calendar: {
309
+ background: color.blocked_calendar.backgroundColor,
310
+ border: `1px solid ${color.blocked_calendar.borderColor}`,
311
+ color: color.blocked_calendar.color,
312
+
313
+ ':hover': {
314
+ background: color.blocked_calendar.backgroundColor_hover,
315
+ border: `1px solid ${color.blocked_calendar.borderColor}`,
316
+ color: color.blocked_calendar.color_active,
317
+ },
318
+
319
+ ':active': {
320
+ background: color.blocked_calendar.backgroundColor_active,
321
+ border: `1px solid ${color.blocked_calendar.borderColor}`,
322
+ color: color.blocked_calendar.color_active,
323
+ },
324
+ },
325
+
326
+ CalendarDay__blocked_out_of_range: {
327
+ background: color.blocked_out_of_range.backgroundColor,
328
+ border: `1px solid ${color.blocked_out_of_range.borderColor}`,
329
+ color: color.blocked_out_of_range.color,
330
+
331
+ ':hover': {
332
+ background: color.blocked_out_of_range.backgroundColor_hover,
333
+ border: `1px solid ${color.blocked_out_of_range.borderColor}`,
334
+ color: color.blocked_out_of_range.color_active,
335
+ },
336
+
337
+ ':active': {
338
+ background: color.blocked_out_of_range.backgroundColor_active,
339
+ border: `1px solid ${color.blocked_out_of_range.borderColor}`,
340
+ color: color.blocked_out_of_range.color_active,
341
+ },
342
+ },
343
+
344
+ CalendarDay__hovered_start_first_possible_end: {
345
+ background: color.core.borderLighter,
346
+ border: `1px double ${color.core.borderLighter}`,
347
+ },
348
+
349
+ CalendarDay__hovered_start_blocked_min_nights: {
350
+ background: color.core.borderLighter,
351
+ border: `1px double ${color.core.borderLight}`,
352
+ },
353
+
354
+ CalendarDay__selected_start: {},
355
+ CalendarDay__selected_end: {},
356
+ CalendarDay__today: {},
357
+ CalendarDay__firstDayOfWeek: {},
358
+ CalendarDay__lastDayOfWeek: {},
359
+ CalendarDay__after_hovered_start: {},
360
+ CalendarDay__before_hovered_end: {},
361
+ CalendarDay__no_selected_start_before_selected_end: {},
362
+ CalendarDay__selected_start_in_hovered_span: {},
363
+ CalendarDay__selected_end_in_hovered_span: {},
364
+ CalendarDay__selected_start_no_selected_end: {},
365
+ CalendarDay__selected_end_no_selected_start: {},
366
+ }), { pureComponent: typeof React.PureComponent !== 'undefined' })(CalendarDay);
@@ -0,0 +1,3 @@
1
+ import CalendarIcon from '../svg/calendar.svg';
2
+
3
+ export default CalendarIcon;