@transferwise/components 0.0.0-experimental-7089f72 → 0.0.0-experimental-26e03bf

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 (202) hide show
  1. package/build/dateLookup/DateLookup.js +165 -28
  2. package/build/dateLookup/DateLookup.js.map +1 -1
  3. package/build/{calendarInput/CalendarInput.messages.js → dateLookup/DateLookup.messages.js} +1 -1
  4. package/build/dateLookup/DateLookup.messages.js.map +1 -0
  5. package/build/{calendarInput/CalendarInput.messages.mjs → dateLookup/DateLookup.messages.mjs} +1 -1
  6. package/build/dateLookup/DateLookup.messages.mjs.map +1 -0
  7. package/build/dateLookup/DateLookup.mjs +166 -29
  8. package/build/dateLookup/DateLookup.mjs.map +1 -1
  9. package/build/{calendarInput → dateLookup}/dateHeader/DateHeader.js +4 -4
  10. package/build/dateLookup/dateHeader/DateHeader.js.map +1 -0
  11. package/build/{calendarInput → dateLookup}/dateHeader/DateHeader.mjs +1 -1
  12. package/build/dateLookup/dateHeader/DateHeader.mjs.map +1 -0
  13. package/build/{calendarInput → dateLookup}/dayCalendar/DayCalendar.js +2 -2
  14. package/build/dateLookup/dayCalendar/DayCalendar.js.map +1 -0
  15. package/build/{calendarInput → dateLookup}/dayCalendar/DayCalendar.mjs +1 -1
  16. package/build/dateLookup/dayCalendar/DayCalendar.mjs.map +1 -0
  17. package/build/dateLookup/dayCalendar/table/DayCalendarTable.js.map +1 -0
  18. package/build/dateLookup/dayCalendar/table/DayCalendarTable.mjs.map +1 -0
  19. package/build/dateLookup/getFocusableTime/getFocusableTime.js.map +1 -0
  20. package/build/dateLookup/getFocusableTime/getFocusableTime.mjs.map +1 -0
  21. package/build/dateLookup/getStartOfDay/getStartOfDay.js.map +1 -0
  22. package/build/dateLookup/getStartOfDay/getStartOfDay.mjs.map +1 -0
  23. package/build/{calendarInput → dateLookup}/monthCalendar/MonthCalendar.js +2 -2
  24. package/build/dateLookup/monthCalendar/MonthCalendar.js.map +1 -0
  25. package/build/{calendarInput → dateLookup}/monthCalendar/MonthCalendar.mjs +1 -1
  26. package/build/dateLookup/monthCalendar/MonthCalendar.mjs.map +1 -0
  27. package/build/dateLookup/monthCalendar/table/MonthCalendarTable.js.map +1 -0
  28. package/build/dateLookup/monthCalendar/table/MonthCalendarTable.mjs.map +1 -0
  29. package/build/{calendarInput → dateLookup}/tableLink/TableLink.js +2 -2
  30. package/build/dateLookup/tableLink/TableLink.js.map +1 -0
  31. package/build/{calendarInput → dateLookup}/tableLink/TableLink.mjs +1 -1
  32. package/build/dateLookup/tableLink/TableLink.mjs.map +1 -0
  33. package/build/{calendarInput → dateLookup}/yearCalendar/YearCalendar.js +2 -2
  34. package/build/dateLookup/yearCalendar/YearCalendar.js.map +1 -0
  35. package/build/{calendarInput → dateLookup}/yearCalendar/YearCalendar.mjs +1 -1
  36. package/build/dateLookup/yearCalendar/YearCalendar.mjs.map +1 -0
  37. package/build/dateLookup/yearCalendar/table/YearCalendarTable.js.map +1 -0
  38. package/build/dateLookup/yearCalendar/table/YearCalendarTable.mjs.map +1 -0
  39. package/build/index.js +0 -2
  40. package/build/index.js.map +1 -1
  41. package/build/index.mjs +0 -1
  42. package/build/index.mjs.map +1 -1
  43. package/build/main.css +29 -20
  44. package/build/prompt/InfoPrompt/InfoPrompt.js +1 -1
  45. package/build/prompt/InfoPrompt/InfoPrompt.js.map +1 -1
  46. package/build/prompt/InfoPrompt/InfoPrompt.mjs +2 -2
  47. package/build/prompt/InfoPrompt/InfoPrompt.mjs.map +1 -1
  48. package/build/styles/css/neptune.css +11 -11
  49. package/build/styles/dateLookup/DateLookup.css +90 -0
  50. package/build/styles/less/legacy-variables.less +1 -1
  51. package/build/styles/less/neptune-tokens.less +2 -2
  52. package/build/styles/main.css +29 -20
  53. package/build/styles/props/custom-media.css +1 -1
  54. package/build/styles/props/neptune-tokens.css +1 -1
  55. package/build/styles/styles/less/neptune.css +11 -11
  56. package/build/types/dateLookup/DateLookup.d.ts +25 -2
  57. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  58. package/build/types/{calendarInput/CalendarInput.messages.d.ts → dateLookup/DateLookup.messages.d.ts} +1 -1
  59. package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -0
  60. package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -0
  61. package/build/types/dateLookup/dateHeader/index.d.ts.map +1 -0
  62. package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +1 -0
  63. package/build/types/dateLookup/dayCalendar/index.d.ts.map +1 -0
  64. package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -0
  65. package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +1 -0
  66. package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts.map +1 -0
  67. package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +1 -0
  68. package/build/types/dateLookup/getStartOfDay/index.d.ts.map +1 -0
  69. package/build/types/{calendarInput → dateLookup}/monthCalendar/MonthCalendar.d.ts +1 -1
  70. package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +1 -0
  71. package/build/types/dateLookup/monthCalendar/index.d.ts.map +1 -0
  72. package/build/types/{calendarInput → dateLookup}/monthCalendar/table/MonthCalendarTable.d.ts +1 -1
  73. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -0
  74. package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +1 -0
  75. package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -0
  76. package/build/types/dateLookup/tableLink/index.d.ts.map +1 -0
  77. package/build/types/{calendarInput → dateLookup}/yearCalendar/YearCalendar.d.ts +1 -1
  78. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -0
  79. package/build/types/dateLookup/yearCalendar/index.d.ts.map +1 -0
  80. package/build/types/{calendarInput → dateLookup}/yearCalendar/table/YearCalendarTable.d.ts +1 -1
  81. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -0
  82. package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +1 -0
  83. package/build/types/index.d.ts +0 -2
  84. package/build/types/index.d.ts.map +1 -1
  85. package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts +3 -2
  86. package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts.map +1 -1
  87. package/package.json +3 -3
  88. package/src/dateLookup/DateLookup.css +90 -0
  89. package/src/dateLookup/DateLookup.less +91 -0
  90. package/src/dateLookup/DateLookup.test.tsx +124 -0
  91. package/src/dateLookup/DateLookup.tsx +157 -31
  92. package/src/{calendarInput → dateLookup}/dateHeader/DateHeader.tsx +1 -1
  93. package/src/{calendarInput → dateLookup}/dayCalendar/DayCalendar.tsx +1 -1
  94. package/src/{calendarInput → dateLookup}/monthCalendar/MonthCalendar.tsx +2 -2
  95. package/src/{calendarInput → dateLookup}/monthCalendar/table/MonthCalendarTable.tsx +1 -1
  96. package/src/{calendarInput → dateLookup}/tableLink/TableLink.tsx +1 -1
  97. package/src/{calendarInput → dateLookup}/yearCalendar/YearCalendar.tsx +2 -2
  98. package/src/{calendarInput → dateLookup}/yearCalendar/table/YearCalendarTable.tsx +1 -1
  99. package/src/index.ts +0 -2
  100. package/src/main.css +29 -20
  101. package/src/main.less +0 -1
  102. package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +42 -0
  103. package/src/prompt/InfoPrompt/InfoPrompt.test.tsx +65 -1
  104. package/src/prompt/InfoPrompt/InfoPrompt.tsx +15 -4
  105. package/src/styles/less/neptune.css +11 -11
  106. package/build/calendarInput/CalendarInput.js +0 -159
  107. package/build/calendarInput/CalendarInput.js.map +0 -1
  108. package/build/calendarInput/CalendarInput.messages.js.map +0 -1
  109. package/build/calendarInput/CalendarInput.messages.mjs.map +0 -1
  110. package/build/calendarInput/CalendarInput.mjs +0 -155
  111. package/build/calendarInput/CalendarInput.mjs.map +0 -1
  112. package/build/calendarInput/dateHeader/DateHeader.js.map +0 -1
  113. package/build/calendarInput/dateHeader/DateHeader.mjs.map +0 -1
  114. package/build/calendarInput/dayCalendar/DayCalendar.js.map +0 -1
  115. package/build/calendarInput/dayCalendar/DayCalendar.mjs.map +0 -1
  116. package/build/calendarInput/dayCalendar/table/DayCalendarTable.js.map +0 -1
  117. package/build/calendarInput/dayCalendar/table/DayCalendarTable.mjs.map +0 -1
  118. package/build/calendarInput/getFocusableTime/getFocusableTime.js.map +0 -1
  119. package/build/calendarInput/getFocusableTime/getFocusableTime.mjs.map +0 -1
  120. package/build/calendarInput/getStartOfDay/getStartOfDay.js.map +0 -1
  121. package/build/calendarInput/getStartOfDay/getStartOfDay.mjs.map +0 -1
  122. package/build/calendarInput/monthCalendar/MonthCalendar.js.map +0 -1
  123. package/build/calendarInput/monthCalendar/MonthCalendar.mjs.map +0 -1
  124. package/build/calendarInput/monthCalendar/table/MonthCalendarTable.js.map +0 -1
  125. package/build/calendarInput/monthCalendar/table/MonthCalendarTable.mjs.map +0 -1
  126. package/build/calendarInput/tableLink/TableLink.js.map +0 -1
  127. package/build/calendarInput/tableLink/TableLink.mjs.map +0 -1
  128. package/build/calendarInput/yearCalendar/YearCalendar.js.map +0 -1
  129. package/build/calendarInput/yearCalendar/YearCalendar.mjs.map +0 -1
  130. package/build/calendarInput/yearCalendar/table/YearCalendarTable.js.map +0 -1
  131. package/build/calendarInput/yearCalendar/table/YearCalendarTable.mjs.map +0 -1
  132. package/build/styles/calendarInput/CalendarInput.css +0 -83
  133. package/build/types/calendarInput/CalendarInput.d.ts +0 -13
  134. package/build/types/calendarInput/CalendarInput.d.ts.map +0 -1
  135. package/build/types/calendarInput/CalendarInput.messages.d.ts.map +0 -1
  136. package/build/types/calendarInput/dateHeader/DateHeader.d.ts.map +0 -1
  137. package/build/types/calendarInput/dateHeader/index.d.ts.map +0 -1
  138. package/build/types/calendarInput/dayCalendar/DayCalendar.d.ts.map +0 -1
  139. package/build/types/calendarInput/dayCalendar/index.d.ts.map +0 -1
  140. package/build/types/calendarInput/dayCalendar/table/DayCalendarTable.d.ts.map +0 -1
  141. package/build/types/calendarInput/dayCalendar/table/index.d.ts.map +0 -1
  142. package/build/types/calendarInput/getFocusableTime/getFocusableTime.d.ts.map +0 -1
  143. package/build/types/calendarInput/getStartOfDay/getStartOfDay.d.ts.map +0 -1
  144. package/build/types/calendarInput/getStartOfDay/index.d.ts.map +0 -1
  145. package/build/types/calendarInput/index.d.ts +0 -3
  146. package/build/types/calendarInput/index.d.ts.map +0 -1
  147. package/build/types/calendarInput/monthCalendar/MonthCalendar.d.ts.map +0 -1
  148. package/build/types/calendarInput/monthCalendar/index.d.ts.map +0 -1
  149. package/build/types/calendarInput/monthCalendar/table/MonthCalendarTable.d.ts.map +0 -1
  150. package/build/types/calendarInput/monthCalendar/table/index.d.ts.map +0 -1
  151. package/build/types/calendarInput/tableLink/TableLink.d.ts.map +0 -1
  152. package/build/types/calendarInput/tableLink/index.d.ts.map +0 -1
  153. package/build/types/calendarInput/yearCalendar/YearCalendar.d.ts.map +0 -1
  154. package/build/types/calendarInput/yearCalendar/index.d.ts.map +0 -1
  155. package/build/types/calendarInput/yearCalendar/table/YearCalendarTable.d.ts.map +0 -1
  156. package/build/types/calendarInput/yearCalendar/table/index.d.ts.map +0 -1
  157. package/src/calendarInput/CalendarInput.css +0 -83
  158. package/src/calendarInput/CalendarInput.less +0 -79
  159. package/src/calendarInput/CalendarInput.story.tsx +0 -64
  160. package/src/calendarInput/CalendarInput.test.tsx +0 -140
  161. package/src/calendarInput/CalendarInput.tsx +0 -165
  162. package/src/calendarInput/index.ts +0 -2
  163. /package/build/{calendarInput → dateLookup}/dayCalendar/table/DayCalendarTable.js +0 -0
  164. /package/build/{calendarInput → dateLookup}/dayCalendar/table/DayCalendarTable.mjs +0 -0
  165. /package/build/{calendarInput → dateLookup}/getFocusableTime/getFocusableTime.js +0 -0
  166. /package/build/{calendarInput → dateLookup}/getFocusableTime/getFocusableTime.mjs +0 -0
  167. /package/build/{calendarInput → dateLookup}/getStartOfDay/getStartOfDay.js +0 -0
  168. /package/build/{calendarInput → dateLookup}/getStartOfDay/getStartOfDay.mjs +0 -0
  169. /package/build/{calendarInput → dateLookup}/monthCalendar/table/MonthCalendarTable.js +0 -0
  170. /package/build/{calendarInput → dateLookup}/monthCalendar/table/MonthCalendarTable.mjs +0 -0
  171. /package/build/{calendarInput → dateLookup}/yearCalendar/table/YearCalendarTable.js +0 -0
  172. /package/build/{calendarInput → dateLookup}/yearCalendar/table/YearCalendarTable.mjs +0 -0
  173. /package/build/types/{calendarInput → dateLookup}/dateHeader/DateHeader.d.ts +0 -0
  174. /package/build/types/{calendarInput → dateLookup}/dateHeader/index.d.ts +0 -0
  175. /package/build/types/{calendarInput → dateLookup}/dayCalendar/DayCalendar.d.ts +0 -0
  176. /package/build/types/{calendarInput → dateLookup}/dayCalendar/index.d.ts +0 -0
  177. /package/build/types/{calendarInput → dateLookup}/dayCalendar/table/DayCalendarTable.d.ts +0 -0
  178. /package/build/types/{calendarInput → dateLookup}/dayCalendar/table/index.d.ts +0 -0
  179. /package/build/types/{calendarInput → dateLookup}/getFocusableTime/getFocusableTime.d.ts +0 -0
  180. /package/build/types/{calendarInput → dateLookup}/getStartOfDay/getStartOfDay.d.ts +0 -0
  181. /package/build/types/{calendarInput → dateLookup}/getStartOfDay/index.d.ts +0 -0
  182. /package/build/types/{calendarInput → dateLookup}/monthCalendar/index.d.ts +0 -0
  183. /package/build/types/{calendarInput → dateLookup}/monthCalendar/table/index.d.ts +0 -0
  184. /package/build/types/{calendarInput → dateLookup}/tableLink/TableLink.d.ts +0 -0
  185. /package/build/types/{calendarInput → dateLookup}/tableLink/index.d.ts +0 -0
  186. /package/build/types/{calendarInput → dateLookup}/yearCalendar/index.d.ts +0 -0
  187. /package/build/types/{calendarInput → dateLookup}/yearCalendar/table/index.d.ts +0 -0
  188. /package/src/{calendarInput/CalendarInput.messages.ts → dateLookup/DateLookup.messages.ts} +0 -0
  189. /package/src/{calendarInput → dateLookup}/dateHeader/index.ts +0 -0
  190. /package/src/{calendarInput → dateLookup}/dayCalendar/index.ts +0 -0
  191. /package/src/{calendarInput → dateLookup}/dayCalendar/table/DayCalendarTable.tsx +0 -0
  192. /package/src/{calendarInput → dateLookup}/dayCalendar/table/index.ts +0 -0
  193. /package/src/{calendarInput → dateLookup}/getFocusableTime/getFocusable.test.ts +0 -0
  194. /package/src/{calendarInput → dateLookup}/getFocusableTime/getFocusableTime.tsx +0 -0
  195. /package/src/{calendarInput → dateLookup}/getStartOfDay/getStartOfDay.test.js +0 -0
  196. /package/src/{calendarInput → dateLookup}/getStartOfDay/getStartOfDay.tsx +0 -0
  197. /package/src/{calendarInput → dateLookup}/getStartOfDay/index.ts +0 -0
  198. /package/src/{calendarInput → dateLookup}/monthCalendar/index.ts +0 -0
  199. /package/src/{calendarInput → dateLookup}/monthCalendar/table/index.ts +0 -0
  200. /package/src/{calendarInput → dateLookup}/tableLink/index.ts +0 -0
  201. /package/src/{calendarInput → dateLookup}/yearCalendar/index.ts +0 -0
  202. /package/src/{calendarInput → dateLookup}/yearCalendar/table/index.ts +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"CalendarInput.d.ts","sourceRoot":"","sources":["../../../src/calendarInput/CalendarInput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAOxC,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,WAAW,CAAC,EAAE,GAAG,WAAW,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACjC;AAED,QAAA,MAAM,aAAa,GAAI,sFAQpB,kBAAkB,gCAuIpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"CalendarInput.messages.d.ts","sourceRoot":"","sources":["../../../src/calendarInput/CalendarInput.messages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBAyCG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DateHeader.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/dateHeader/DateHeader.tsx"],"names":[],"mappings":"AAWA,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAmDzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/dateHeader/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DayCalendar.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/dayCalendar/DayCalendar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAM3C,UAAU,gBAAiB,SAAQ,qBAAqB;IACtD,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,GAAG,WAAW,EAAE,CAAC;IAC9B,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC/B,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,gBAAgB,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACnE;;;;AAiDD,wBAAuC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/dayCalendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DayCalendarTable.d.ts","sourceRoot":"","sources":["../../../../../src/calendarInput/dayCalendar/table/DayCalendarTable.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AASpE,UAAU,qBAAsB,SAAQ,qBAAqB;IAC3D,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC;;;;AA0ID,wBAA4C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/calendarInput/dayCalendar/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getFocusableTime.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/getFocusableTime/getFocusableTime.tsx"],"names":[],"mappings":"AAAA,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACpC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACjC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,GAAG,SAAS,CAM9E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getStartOfDay.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/getStartOfDay/getStartOfDay.tsx"],"names":[],"mappings":"AAIA,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,eAK9C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/getStartOfDay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,3 +0,0 @@
1
- export { default } from './CalendarInput';
2
- export type { CalendarInputProps } from './CalendarInput';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/calendarInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MonthCalendar.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/monthCalendar/MonthCalendar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAO/D,UAAU,kBAAmB,SAAQ,qBAAqB;IACxD,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,gBAAgB,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACrE;;;;AAgDD,wBAAyC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/monthCalendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MonthCalendarTable.d.ts","sourceRoot":"","sources":["../../../../../src/calendarInput/monthCalendar/table/MonthCalendarTable.tsx"],"names":[],"mappings":"AAMA,UAAU,uBAAuB;IAC/B,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAMD,QAAA,MAAM,kBAAkB,GAAI,8DAOzB,uBAAuB,gCAyDzB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/calendarInput/monthCalendar/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableLink.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/tableLink/TableLink.tsx"],"names":[],"mappings":"AAMA,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,QAAA,MAAM,SAAS,GAAI,gFAUhB,cAAc,gCA8ChB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/tableLink/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"YearCalendar.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/yearCalendar/YearCalendar.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAO/D,UAAU,iBAAkB,SAAQ,qBAAqB;IACvD,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,gBAAgB,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACpD;;;;AA6CD,wBAAwC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendarInput/yearCalendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"YearCalendarTable.d.ts","sourceRoot":"","sources":["../../../../../src/calendarInput/yearCalendar/table/YearCalendarTable.tsx"],"names":[],"mappings":"AAMA,UAAU,sBAAsB;IAC9B,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAMD,QAAA,MAAM,iBAAiB,GAAI,8DAOxB,sBAAsB,gCAqDxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/calendarInput/yearCalendar/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,83 +0,0 @@
1
- .tw-date-lookup-calendar {
2
- min-width: 300px;
3
- text-align: center;
4
- table-layout: fixed;
5
- border: none;
6
- background-color: inherit;
7
- }
8
- .tw-date-lookup-calendar thead {
9
- background-color: transparent;
10
- background-color: initial;
11
- }
12
- .tw-date-lookup-calendar > tbody > tr > td.weekend button {
13
- color: #5d7079;
14
- color: var(--color-content-secondary);
15
- }
16
- .tw-date-lookup-calendar > tbody > tr > td {
17
- border: none;
18
- padding: 4px;
19
- padding: var(--size-4);
20
- }
21
- @media (max-width: 320px) {
22
- .tw-date-lookup-calendar > tbody > tr > td {
23
- padding: 0;
24
- }
25
- }
26
- .tw-date-lookup-calendar > tbody > tr > td:has(.tw-date-lookup-day-option) {
27
- padding: 1px;
28
- }
29
- .tw-date-lookup-calendar > tbody > tr > td button {
30
- width: 100%;
31
- padding: 4px 0;
32
- padding: var(--size-4) 0;
33
- color: #0097c7;
34
- color: var(--color-content-accent);
35
- border: transparent;
36
- border-radius: 10px;
37
- border-radius: var(--radius-small);
38
- background-color: transparent;
39
- font-weight: 600;
40
- font-weight: var(--font-weight-semi-bold);
41
- color: #37517e;
42
- color: var(--color-content-primary);
43
- }
44
- @media (max-width: 320px) {
45
- .tw-date-lookup-calendar > tbody > tr > td button {
46
- padding: 0;
47
- }
48
- }
49
- .tw-date-lookup-calendar > tbody > tr > td button.tw-date-lookup-day-option {
50
- height: 40px;
51
- height: var(--size-40);
52
- border-radius: 9999px;
53
- border-radius: var(--radius-full);
54
- line-height: 40px;
55
- line-height: var(--size-40);
56
- width: 40px;
57
- width: var(--size-40);
58
- padding: 0;
59
- display: inline-flex;
60
- align-items: center;
61
- justify-content: center;
62
- }
63
- .tw-date-lookup-calendar > tbody > tr > td button.tw-date-lookup-day-option.today {
64
- -webkit-text-decoration: underline;
65
- text-decoration: underline;
66
- text-decoration-thickness: 2px;
67
- text-underline-offset: 4px;
68
- }
69
- .tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.show-focus,
70
- .tw-date-lookup-calendar > tbody > tr > td:hover button:not(.disabled):not(:disabled) {
71
- background-color: var(--color-background-screen-hover);
72
- }
73
- .tw-date-lookup-calendar > tbody > tr > td:not(.disabled):not(:disabled) button.active {
74
- background-color: var(--color-interactive-primary);
75
- color: var(--color-interactive-contrast);
76
- }
77
- .tw-date-lookup-calendar abbr {
78
- -webkit-text-decoration: none;
79
- text-decoration: none;
80
- }
81
- .tw-date-lookup-header-current-container {
82
- display: inline;
83
- }
@@ -1,79 +0,0 @@
1
- @import (reference) "./../styles/variables/neptune-tokens.less";
2
-
3
- .tw-date-lookup-calendar {
4
- min-width: 300px;
5
- text-align: center;
6
- table-layout: fixed;
7
- border: none;
8
-
9
- thead {
10
- background-color: unset;
11
- }
12
-
13
- > tbody > tr > td.weekend button {
14
- color: var(--color-content-secondary);
15
- }
16
-
17
- > tbody > tr > td {
18
- border: none;
19
- padding: var(--size-4);
20
- @media (--screen-400-zoom) {
21
- padding: 0;
22
- }
23
-
24
- &:has(.tw-date-lookup-day-option) {
25
- padding: 1px;
26
- }
27
-
28
- button {
29
- width: 100%;
30
- padding: var(--size-4) 0;
31
- @media (--screen-400-zoom) {
32
- padding: 0;
33
- }
34
- color: var(--color-content-accent);
35
- border: transparent;
36
- border-radius: var(--radius-small);
37
- background-color: transparent;
38
- font-weight: var(--font-weight-semi-bold);
39
- color: var(--color-content-primary);
40
-
41
- &.tw-date-lookup-day-option {
42
- height: var(--size-40);
43
- border-radius: var(--radius-full);
44
- line-height: var(--size-40);
45
- width: var(--size-40);
46
- padding: 0;
47
- display: inline-flex;
48
- align-items: center;
49
- justify-content: center;
50
-
51
- &.today {
52
- text-decoration: underline;
53
- text-decoration-thickness: 2px;
54
- text-underline-offset: 4px;
55
- }
56
- }
57
- }
58
-
59
- &:not(.disabled, :disabled) button.show-focus,
60
- &:hover button:not(.disabled, :disabled) {
61
- background-color: var(--color-background-screen-hover);
62
- }
63
-
64
- &:not(.disabled, :disabled) button.active {
65
- background-color: var(--color-interactive-primary);
66
- color: var(--color-interactive-contrast);
67
- }
68
- }
69
-
70
- abbr {
71
- text-decoration: none;
72
- }
73
-
74
- background-color: inherit;
75
- }
76
-
77
- .tw-date-lookup-header-current-container {
78
- display: inline;
79
- }
@@ -1,64 +0,0 @@
1
- import { useState } from 'react';
2
- import { StoryObj } from '@storybook/react-webpack5';
3
- import CalendarInput, { type CalendarInputProps } from './CalendarInput';
4
-
5
- export default {
6
- component: CalendarInput,
7
- title: 'Forms/CalendarInput',
8
- decorators: [
9
- (Story: React.ComponentType) => (
10
- <div style={{ maxWidth: 500, margin: '0 auto' }}>
11
- <Story />
12
- </div>
13
- ),
14
- ],
15
- argTypes: {
16
- monthFormat: { control: 'select', options: ['long', 'short'] },
17
- min: { control: 'date' },
18
- max: { control: 'date' },
19
- },
20
- };
21
-
22
- type Story = StoryObj<typeof CalendarInput>;
23
-
24
- const epoch = new Date('2011-01-01');
25
- const theFuture = new Date(epoch);
26
- theFuture.setUTCDate(epoch.getUTCDate() + 10);
27
- const thePast = new Date(epoch);
28
- thePast.setUTCDate(epoch.getUTCDate() - 10);
29
-
30
- export const Basic: Story = {
31
- render: (args: CalendarInputProps) => {
32
- const [value, setValue] = useState<Date | null>(epoch);
33
- return (
34
- <CalendarInput
35
- {...args}
36
- min={args.min ? new Date(args.min) : thePast}
37
- max={args.max ? new Date(args.max) : theFuture}
38
- value={value}
39
- onChange={(v) => setValue(v)}
40
- />
41
- );
42
- },
43
- args: {
44
- monthFormat: 'long',
45
- min: thePast,
46
- max: theFuture,
47
- },
48
- };
49
-
50
- export const WithoutConstraints: Story = {
51
- render: () => {
52
- const [value, setValue] = useState<Date | null>(epoch);
53
- return <CalendarInput value={value} onChange={(v) => setValue(v)} />;
54
- },
55
- };
56
-
57
- export const NullValue: Story = {
58
- render: () => {
59
- const [value, setValue] = useState<Date | null>(null);
60
- return (
61
- <CalendarInput value={value} min={thePast} max={theFuture} onChange={(v) => setValue(v)} />
62
- );
63
- },
64
- };
@@ -1,140 +0,0 @@
1
- import { mockMatchMedia, render, screen, userEvent } from '../test-utils';
2
- import CalendarInput from './CalendarInput';
3
-
4
- mockMatchMedia();
5
-
6
- const user = userEvent.setup();
7
-
8
- const initialValue = new Date(2000, 0, 1);
9
-
10
- describe('CalendarInput', () => {
11
- describe('in day view', () => {
12
- it.each([
13
- ['{ArrowLeft}', -1],
14
- ['{ArrowRight}', +1],
15
- ['{ArrowUp}', -7],
16
- ['{ArrowDown}', +7],
17
- ])("handles '%s' to step %d day(s)", async (text: string, step: number) => {
18
- const handleChange = jest.fn();
19
- render(<CalendarInput value={initialValue} onChange={handleChange} />);
20
-
21
- await user.click(screen.getByRole('button', { name: /selected day/iu }));
22
- await user.keyboard(text);
23
-
24
- const expected = new Date(initialValue);
25
- expected.setDate(initialValue.getDate() + step);
26
- expect(handleChange).toHaveBeenCalledWith(expected);
27
- });
28
-
29
- it('selects a day on click', async () => {
30
- const handleChange = jest.fn();
31
- render(<CalendarInput value={initialValue} onChange={handleChange} />);
32
-
33
- await user.click(screen.getByText('15'));
34
-
35
- expect(handleChange).toHaveBeenCalledWith(new Date(2000, 0, 15));
36
- });
37
-
38
- it('calls onSelect instead of onChange when clicking a day', async () => {
39
- const handleChange = jest.fn();
40
- const handleSelect = jest.fn();
41
- render(
42
- <CalendarInput value={initialValue} onChange={handleChange} onSelect={handleSelect} />,
43
- );
44
-
45
- await user.click(screen.getByText('15'));
46
-
47
- expect(handleSelect).toHaveBeenCalledWith(new Date(2000, 0, 15));
48
- expect(handleChange).not.toHaveBeenCalled();
49
- });
50
- });
51
-
52
- describe('in year view', () => {
53
- it.each([
54
- ['{ArrowLeft}', -1],
55
- ['{ArrowRight}', +1],
56
- ['{ArrowUp}', -4],
57
- ['{ArrowDown}', +4],
58
- ])("handles '%s' to step %d year(s)", async (text: string, step: number) => {
59
- const handleChange = jest.fn();
60
- render(<CalendarInput value={initialValue} onChange={handleChange} />);
61
-
62
- await user.click(screen.getByRole('button', { name: /year view/iu }));
63
- await user.keyboard(text);
64
-
65
- const expected = new Date(initialValue);
66
- expected.setFullYear(initialValue.getFullYear() + step);
67
- expect(handleChange).toHaveBeenCalledWith(expected);
68
- });
69
- });
70
-
71
- describe('in month view', () => {
72
- it.each([
73
- ['{ArrowLeft}', -1],
74
- ['{ArrowRight}', +1],
75
- ['{ArrowUp}', -4],
76
- ['{ArrowDown}', +4],
77
- ])("handles '%s' to step %d month(s)", async (text: string, step: number) => {
78
- const handleChange = jest.fn();
79
- render(<CalendarInput value={initialValue} onChange={handleChange} />);
80
-
81
- await user.click(screen.getByRole('button', { name: /year view/iu }));
82
- await user.keyboard(' ');
83
- await user.keyboard(text);
84
-
85
- const expected = new Date(initialValue);
86
- expected.setMonth(initialValue.getMonth() + step);
87
- expect(handleChange).toHaveBeenCalledWith(expected);
88
- });
89
- });
90
-
91
- describe('min/max clamping', () => {
92
- it('limits navigation to min value', async () => {
93
- const min = new Date(initialValue);
94
- min.setDate(min.getDate() - 1);
95
- const handleChange = jest.fn();
96
- render(<CalendarInput value={initialValue} min={min} onChange={handleChange} />);
97
-
98
- await user.click(screen.getByRole('button', { name: /selected day/iu }));
99
- await user.keyboard('{ArrowLeft}{ArrowLeft}');
100
-
101
- expect(handleChange).toHaveBeenLastCalledWith(min);
102
- });
103
-
104
- it('limits navigation to max value', async () => {
105
- const max = new Date(initialValue);
106
- max.setDate(max.getDate() + 1);
107
- const handleChange = jest.fn();
108
- render(<CalendarInput value={initialValue} max={max} onChange={handleChange} />);
109
-
110
- await user.click(screen.getByRole('button', { name: /selected day/iu }));
111
- await user.keyboard('{ArrowRight}{ArrowRight}');
112
-
113
- expect(handleChange).toHaveBeenLastCalledWith(max);
114
- });
115
-
116
- it('clamps value to range when value is outside min/max', () => {
117
- const min = new Date(2000, 0, 5);
118
- const max = new Date(2000, 0, 20);
119
- const handleChange = jest.fn();
120
- render(<CalendarInput value={initialValue} min={min} max={max} onChange={handleChange} />);
121
-
122
- expect(handleChange).toHaveBeenCalledWith(min);
123
- });
124
- });
125
-
126
- describe('view switching', () => {
127
- it('switches to year view and back to day view', async () => {
128
- render(<CalendarInput value={initialValue} onChange={jest.fn()} />);
129
-
130
- await user.click(screen.getByRole('button', { name: /year view/iu }));
131
- expect(screen.getByRole('button', { name: /selected year/iu })).toBeInTheDocument();
132
-
133
- await user.click(screen.getByRole('button', { name: /selected year/iu }));
134
- expect(screen.getByRole('button', { name: /selected month/iu })).toBeInTheDocument();
135
-
136
- await user.click(screen.getByRole('button', { name: /selected month/iu }));
137
- expect(screen.getByRole('button', { name: /next month/iu })).toBeInTheDocument();
138
- });
139
- });
140
- });
@@ -1,165 +0,0 @@
1
- import { useState, useCallback, useEffect, KeyboardEvent } from 'react';
2
-
3
- import { MonthFormat } from '../common';
4
- import { isWithinRange, moveToWithinRange, returnDateView } from '../common/dateUtils';
5
- import DayCalendar from './dayCalendar';
6
- import { getStartOfDay } from './getStartOfDay';
7
- import MonthCalendar from './monthCalendar';
8
- import YearCalendar from './yearCalendar';
9
-
10
- export interface CalendarInputProps {
11
- value: Date | null;
12
- min?: Date | null;
13
- max?: Date | null;
14
- monthFormat?: `${MonthFormat}`;
15
- placeholder?: string;
16
- onChange: (date: Date | null) => void;
17
- onSelect?: (date: Date) => void;
18
- }
19
-
20
- const CalendarInput = ({
21
- value,
22
- min: minProp = null,
23
- max: maxProp = null,
24
- monthFormat = MonthFormat.LONG,
25
- placeholder,
26
- onChange,
27
- onSelect,
28
- }: CalendarInputProps) => {
29
- const selectedDate = getStartOfDay(value);
30
- const min = getStartOfDay(minProp);
31
- const max = getStartOfDay(maxProp);
32
-
33
- useEffect(() => {
34
- if (selectedDate && !isWithinRange(selectedDate, min, max)) {
35
- onChange(moveToWithinRange(selectedDate, min, max));
36
- }
37
- }, [selectedDate?.getTime(), min?.getTime(), max?.getTime(), onChange]); // eslint-disable-line react-hooks/exhaustive-deps
38
-
39
- const dateView = returnDateView(selectedDate, min, max);
40
- const [viewMonth, setViewMonth] = useState(dateView.getMonth());
41
- const [viewYear, setViewYear] = useState(dateView.getFullYear());
42
- const [mode, setMode] = useState<'day' | 'month' | 'year'>('day');
43
-
44
- useEffect(() => {
45
- const view = returnDateView(selectedDate, min, max);
46
- // eslint-disable-next-line react-hooks/set-state-in-effect
47
- setViewMonth(view.getMonth());
48
-
49
- setViewYear(view.getFullYear());
50
- }, [selectedDate?.getTime(), min?.getTime(), max?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps
51
-
52
- const handleViewDateUpdate = useCallback(
53
- // eslint-disable-next-line react-hooks/preserve-manual-memoization
54
- ({ month, year }: { month?: number; year?: number }) => {
55
- if (month !== undefined) setViewMonth(month);
56
- if (year !== undefined) setViewYear(year);
57
- },
58
- [],
59
- );
60
-
61
- const switchToDays = useCallback(() => setMode('day'), []);
62
- const switchToMonths = useCallback(() => setMode('month'), []);
63
- const switchToYears = useCallback(() => setMode('year'), []);
64
-
65
- const handleSelectedDateUpdate = useCallback(
66
- (date: Date) => {
67
- if (onSelect) {
68
- onSelect(date);
69
- } else {
70
- onChange(date);
71
- }
72
- },
73
- [onChange, onSelect],
74
- );
75
-
76
- const adjustDate = useCallback(
77
- (daysToAdd: number, monthsToAdd: number, yearsToAdd: number) => {
78
- let date: Date | null;
79
- if (selectedDate) {
80
- date = new Date(
81
- mode === 'year' ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(),
82
- mode === 'month' ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(),
83
- mode === 'day' ? selectedDate.getDate() + daysToAdd : selectedDate.getDate(),
84
- );
85
- } else {
86
- date = getStartOfDay(new Date());
87
- }
88
- date &&= moveToWithinRange(date, min, max);
89
- if (date?.getTime() !== selectedDate?.getTime()) {
90
- onChange(date);
91
- }
92
- },
93
- [selectedDate, min, max, mode, onChange],
94
- );
95
-
96
- const handleKeyDown = useCallback(
97
- (event: KeyboardEvent<HTMLDivElement>) => {
98
- switch (event.key) {
99
- case 'ArrowLeft':
100
- adjustDate(-1, -1, -1);
101
- event.preventDefault();
102
- break;
103
- case 'ArrowUp':
104
- adjustDate(-7, -4, -4);
105
- event.preventDefault();
106
- break;
107
- case 'ArrowRight':
108
- adjustDate(1, 1, 1);
109
- event.preventDefault();
110
- break;
111
- case 'ArrowDown':
112
- adjustDate(7, 4, 4);
113
- event.preventDefault();
114
- break;
115
- default:
116
- break;
117
- }
118
- },
119
- [adjustDate],
120
- );
121
-
122
- return (
123
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
124
- <div onKeyDown={handleKeyDown}>
125
- {mode === 'day' && (
126
- <DayCalendar
127
- selectedDate={selectedDate}
128
- min={min}
129
- max={max}
130
- viewMonth={viewMonth}
131
- viewYear={viewYear}
132
- monthFormat={monthFormat}
133
- onSelect={handleSelectedDateUpdate}
134
- onLabelClick={switchToYears}
135
- onViewDateUpdate={handleViewDateUpdate}
136
- />
137
- )}
138
- {mode === 'month' && (
139
- <MonthCalendar
140
- selectedDate={selectedDate}
141
- min={min}
142
- max={max}
143
- viewYear={viewYear}
144
- {...(placeholder != null && { placeholder })}
145
- onSelect={switchToDays}
146
- onLabelClick={switchToYears}
147
- onViewDateUpdate={handleViewDateUpdate}
148
- />
149
- )}
150
- {mode === 'year' && (
151
- <YearCalendar
152
- selectedDate={selectedDate}
153
- min={min}
154
- max={max}
155
- viewYear={viewYear}
156
- {...(placeholder != null && { placeholder })}
157
- onSelect={switchToMonths}
158
- onViewDateUpdate={handleViewDateUpdate}
159
- />
160
- )}
161
- </div>
162
- );
163
- };
164
-
165
- export default CalendarInput;
@@ -1,2 +0,0 @@
1
- export { default } from './CalendarInput';
2
- export type { CalendarInputProps } from './CalendarInput';