guestbell-forms 3.0.38 → 3.0.40

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 (336) hide show
  1. package/.env.bat +1 -0
  2. package/.eslintrc.json +21 -14
  3. package/build/components/base/input/BaseInput.d.ts +99 -99
  4. package/build/components/base/input/BaseInput.js +4 -0
  5. package/build/components/base/input/BaseInput.js.map +1 -1
  6. package/build/components/base/input/index.d.ts +1 -1
  7. package/build/components/bookingCalendar/BookingCalendar.d.ts +45 -46
  8. package/build/components/bookingCalendar/BookingCalendar.js +4 -5
  9. package/build/components/bookingCalendar/BookingCalendar.js.map +1 -1
  10. package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.d.ts +17 -17
  11. package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.js +12 -12
  12. package/build/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.js.map +1 -1
  13. package/build/components/bookingCalendar/bookingCalendarControls/classes.d.ts +9 -9
  14. package/build/components/bookingCalendar/bookingCalendarControls/index.d.ts +2 -2
  15. package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.d.ts +13 -13
  16. package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.js +3 -3
  17. package/build/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.js.map +1 -1
  18. package/build/components/bookingCalendar/bookingCalendarDatePicker/classes.d.ts +5 -5
  19. package/build/components/bookingCalendar/bookingCalendarDatePicker/index.d.ts +2 -2
  20. package/build/components/bookingCalendar/bookingCalendarGrid/BookingCalendarGrid.d.ts +10 -10
  21. package/build/components/bookingCalendar/bookingCalendarGrid/classes.d.ts +5 -5
  22. package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.d.ts +57 -57
  23. package/build/components/bookingCalendar/bookingCalendarItem/classes.d.ts +4 -4
  24. package/build/components/bookingCalendar/bookingCalendarItem/index.d.ts +2 -2
  25. package/build/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.d.ts +16 -16
  26. package/build/components/bookingCalendar/bookingCalendarLane/classes.d.ts +4 -4
  27. package/build/components/bookingCalendar/bookingCalendarLane/index.d.ts +2 -2
  28. package/build/components/bookingCalendar/bookingCalendarLaneHeader/BookingCalendarLaneHeader.d.ts +7 -7
  29. package/build/components/bookingCalendar/bookingCalendarLaneHeader/classes.d.ts +4 -4
  30. package/build/components/bookingCalendar/bookingCalendarLaneHeader/index.d.ts +1 -1
  31. package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.d.ts +11 -11
  32. package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.js +3 -3
  33. package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.js.map +1 -1
  34. package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.d.ts +4 -5
  35. package/build/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.js.map +1 -1
  36. package/build/components/bookingCalendar/bookingCalendarLanesHeader/classes.d.ts +5 -5
  37. package/build/components/bookingCalendar/bookingCalendarLanesHeader/index.d.ts +2 -2
  38. package/build/components/bookingCalendar/bookingCalendarRenderItem/BookingCalendarRenderItem.d.ts +9 -9
  39. package/build/components/bookingCalendar/bookingCalendarRenderItem/classes.d.ts +6 -6
  40. package/build/components/bookingCalendar/bookingCalendarRenderItem/index.d.ts +1 -1
  41. package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.d.ts +38 -37
  42. package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js +2 -0
  43. package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js.map +1 -1
  44. package/build/components/bookingCalendar/bookingCalendarTimeAxis/BookingCalendarTimeAxis.d.ts +11 -11
  45. package/build/components/bookingCalendar/bookingCalendarTimeAxis/classes.d.ts +5 -5
  46. package/build/components/bookingCalendar/classes.d.ts +11 -11
  47. package/build/components/bookingCalendar/common.d.ts +23 -23
  48. package/build/components/bookingCalendar/common.js +3 -4
  49. package/build/components/bookingCalendar/common.js.map +1 -1
  50. package/build/components/bookingCalendar/index.d.ts +3 -3
  51. package/build/components/bookingCalendar/utils.d.ts +52 -50
  52. package/build/components/bookingCalendar/utils.js.map +1 -1
  53. package/build/components/button/Button.d.ts +81 -81
  54. package/build/components/button/Button.js +1 -0
  55. package/build/components/button/Button.js.map +1 -1
  56. package/build/components/button/index.d.ts +2 -2
  57. package/build/components/checkbox/Checkbox.d.ts +23 -23
  58. package/build/components/checkbox/index.d.ts +2 -2
  59. package/build/components/dropdown/Dropdown.d.ts +44 -44
  60. package/build/components/dropdown/index.d.ts +2 -2
  61. package/build/components/dynamicSubmit/DynamicSubmit.d.ts +54 -54
  62. package/build/components/dynamicSubmit/DynamicSubmit.js.map +1 -1
  63. package/build/components/dynamicSubmit/index.d.ts +2 -2
  64. package/build/components/externalValidationComponent/ExternalValidationComponent.d.ts +15 -15
  65. package/build/components/externalValidationComponent/index.d.ts +2 -2
  66. package/build/components/form/Form.d.ts +47 -47
  67. package/build/components/form/FormContext.d.ts +30 -30
  68. package/build/components/form/FormValidationSummary.d.ts +38 -38
  69. package/build/components/form/FormValidationSummary.js.map +1 -1
  70. package/build/components/form/index.d.ts +5 -5
  71. package/build/components/form/withFormContext.d.ts +3 -3
  72. package/build/components/inputGroup/InputGroup.d.ts +15 -17
  73. package/build/components/inputGroup/index.d.ts +2 -2
  74. package/build/components/inputHeader/InputHeader.d.ts +97 -97
  75. package/build/components/inputHeader/InputHeader.js.map +1 -1
  76. package/build/components/inputHeader/InputHeaderContext.d.ts +24 -24
  77. package/build/components/inputHeader/index.d.ts +2 -2
  78. package/build/components/inputHeader/withInputHeaderContext.d.ts +3 -3
  79. package/build/components/money/Money.d.ts +78 -78
  80. package/build/components/money/Money.js.map +1 -1
  81. package/build/components/money/index.d.ts +2 -2
  82. package/build/components/numberInput/NumberInput.d.ts +28 -28
  83. package/build/components/numberInput/index.d.ts +2 -2
  84. package/build/components/openingHours/openingHoursDay/OpeningHoursDay.d.ts +84 -84
  85. package/build/components/openingHours/openingHoursDay/OpeningHoursDay.js +3 -3
  86. package/build/components/openingHours/openingHoursDay/OpeningHoursDay.js.map +1 -1
  87. package/build/components/openingHours/openingHoursDay/index.d.ts +2 -2
  88. package/build/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.d.ts +92 -90
  89. package/build/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.js.map +1 -1
  90. package/build/components/openingHours/openingHoursSpecial/index.d.ts +2 -2
  91. package/build/components/openingHours/openingHoursWeek/OpeningHoursWeek.d.ts +109 -109
  92. package/build/components/openingHours/openingHoursWeek/index.d.ts +2 -2
  93. package/build/components/openingHours/utils/OpeningHoursUtil.d.ts +21 -21
  94. package/build/components/radio/Radio.d.ts +20 -20
  95. package/build/components/radio/index.d.ts +2 -2
  96. package/build/components/radioContainer/RadioContainer.d.ts +17 -16
  97. package/build/components/radioContainer/RadioContainer.js.map +1 -1
  98. package/build/components/radioContainer/index.d.ts +2 -2
  99. package/build/components/select/Select.d.ts +79 -79
  100. package/build/components/select/index.d.ts +2 -2
  101. package/build/components/submit/Submit.d.ts +137 -137
  102. package/build/components/submit/index.d.ts +2 -2
  103. package/build/components/submit/subComponents/SubmitValidationSummary.d.ts +5 -5
  104. package/build/components/tags/Tags.d.ts +92 -92
  105. package/build/components/tags/Tags.js +2 -0
  106. package/build/components/tags/Tags.js.map +1 -1
  107. package/build/components/tags/index.d.ts +2 -2
  108. package/build/components/tags/subComponents/TagsSuggestions.d.ts +34 -34
  109. package/build/components/tags/subComponents/TagsSuggestions.js +2 -2
  110. package/build/components/tags/subComponents/TagsSuggestions.js.map +1 -1
  111. package/build/components/text/Text.d.ts +31 -31
  112. package/build/components/text/index.d.ts +2 -2
  113. package/build/components/textArea/TextArea.d.ts +28 -28
  114. package/build/components/textArea/TextArea.js +1 -0
  115. package/build/components/textArea/TextArea.js.map +1 -1
  116. package/build/components/textArea/index.d.ts +2 -2
  117. package/build/components/themeProvider/ThemeContext.d.ts +9 -9
  118. package/build/components/themeProvider/ThemeProvider.d.ts +8 -7
  119. package/build/components/themeProvider/ThemeProvider.js.map +1 -1
  120. package/build/components/themeProvider/index.d.ts +4 -4
  121. package/build/components/themeProvider/withThemeContext.d.ts +4 -4
  122. package/build/components/time/Time.d.ts +32 -32
  123. package/build/components/time/Time.js +3 -3
  124. package/build/components/time/Time.js.map +1 -1
  125. package/build/components/time/index.d.ts +2 -2
  126. package/build/components/timeSpan/TimeSpan.d.ts +46 -46
  127. package/build/components/timeSpan/TimeSpan.js +6 -6
  128. package/build/components/timeSpan/TimeSpan.js.map +1 -1
  129. package/build/components/timeSpan/index.d.ts +2 -2
  130. package/build/components/utils/Guid.d.ts +2 -2
  131. package/build/components/utils/ShallowEqual.d.ts +16 -16
  132. package/build/components/utils/TimeUtil.d.ts +6 -6
  133. package/build/components/utils/Typescript.d.ts +5 -5
  134. package/build/dist/guestbell-forms.css +157 -171
  135. package/build/dist/guestbell-forms.css.map +1 -1
  136. package/build/dist/guestbell-forms.js +15 -24
  137. package/build/dist/guestbell-forms.js.map +1 -1
  138. package/build/dist/guestbell-forms.min.css +1 -1
  139. package/build/dist/guestbell-forms.min.js +1 -1
  140. package/build/dist/guestbell-forms.min.js.map +1 -1
  141. package/build/dist/report.html +3 -3
  142. package/build/index.d.ts +24 -24
  143. package/build/scss/components/bookingCalendar/bookingCalendar.scss +30 -7
  144. package/build/scss/components/inputHeader/inputHeader.scss +7 -1
  145. package/build/types/ElementOverrideProp.d.ts +3 -3
  146. package/build/types/Theme.d.ts +4 -4
  147. package/build/types/ThemeOverrides.d.ts +45 -45
  148. package/build/validators/EmailValidator.d.ts +4 -4
  149. package/build/validators/LatitudeValidator.d.ts +4 -4
  150. package/build/validators/LongitudeValidator.d.ts +4 -4
  151. package/build/validators/NumberValidator.d.ts +12 -12
  152. package/build/validators/NumberValidator.js +1 -0
  153. package/build/validators/NumberValidator.js.map +1 -1
  154. package/build/validators/UrlValidator.d.ts +4 -4
  155. package/build/validators/base.d.ts +4 -4
  156. package/build/validators/index.d.ts +6 -6
  157. package/package.json +130 -136
  158. package/src/lib/components/base/input/BaseInput.tsx +526 -0
  159. package/src/lib/components/base/input/index.tsx +1 -0
  160. package/src/lib/components/bookingCalendar/BookingCalendar.tsx +327 -0
  161. package/src/lib/components/bookingCalendar/bookingCalendarControls/BookingCalendarControls.tsx +249 -0
  162. package/src/lib/components/bookingCalendar/bookingCalendarControls/classes.ts +20 -0
  163. package/src/lib/components/bookingCalendar/bookingCalendarControls/index.ts +2 -0
  164. package/src/lib/components/bookingCalendar/bookingCalendarDatePicker/BookingCalendarDatePicker.tsx +104 -0
  165. package/src/lib/components/bookingCalendar/bookingCalendarDatePicker/classes.ts +9 -0
  166. package/src/lib/components/bookingCalendar/bookingCalendarDatePicker/index.ts +2 -0
  167. package/src/lib/components/bookingCalendar/bookingCalendarGrid/BookingCalendarGrid.tsx +56 -0
  168. package/src/lib/components/bookingCalendar/bookingCalendarGrid/classes.ts +9 -0
  169. package/src/lib/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.tsx +97 -0
  170. package/src/lib/components/bookingCalendar/bookingCalendarItem/classes.ts +7 -0
  171. package/src/lib/components/bookingCalendar/bookingCalendarItem/index.ts +2 -0
  172. package/src/lib/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.tsx +69 -0
  173. package/src/lib/components/bookingCalendar/bookingCalendarLane/classes.ts +7 -0
  174. package/src/lib/components/bookingCalendar/bookingCalendarLane/index.ts +2 -0
  175. package/src/lib/components/bookingCalendar/bookingCalendarLaneHeader/BookingCalendarLaneHeader.tsx +28 -0
  176. package/src/lib/components/bookingCalendar/bookingCalendarLaneHeader/classes.ts +7 -0
  177. package/src/lib/components/bookingCalendar/bookingCalendarLaneHeader/index.ts +1 -0
  178. package/src/lib/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeader.tsx +57 -0
  179. package/src/lib/components/bookingCalendar/bookingCalendarLanesHeader/BookingCalendarLanesHeaderRenderItem.tsx +53 -0
  180. package/src/lib/components/bookingCalendar/bookingCalendarLanesHeader/classes.ts +9 -0
  181. package/src/lib/components/bookingCalendar/bookingCalendarLanesHeader/index.ts +2 -0
  182. package/src/lib/components/bookingCalendar/bookingCalendarRenderItem/BookingCalendarRenderItem.tsx +57 -0
  183. package/src/lib/components/bookingCalendar/bookingCalendarRenderItem/classes.ts +11 -0
  184. package/src/lib/components/bookingCalendar/bookingCalendarRenderItem/index.ts +1 -0
  185. package/src/lib/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.tsx +217 -0
  186. package/src/lib/components/bookingCalendar/bookingCalendarTimeAxis/BookingCalendarTimeAxis.tsx +53 -0
  187. package/src/lib/components/bookingCalendar/bookingCalendarTimeAxis/classes.ts +9 -0
  188. package/src/lib/components/bookingCalendar/classes.ts +21 -0
  189. package/src/lib/components/bookingCalendar/common.ts +61 -0
  190. package/src/lib/components/bookingCalendar/index.ts +3 -0
  191. package/src/lib/components/bookingCalendar/utils.ts +348 -0
  192. package/src/lib/components/button/Button.tsx +193 -0
  193. package/src/lib/components/button/index.tsx +2 -0
  194. package/src/lib/components/checkbox/Checkbox.tsx +178 -0
  195. package/src/lib/components/checkbox/index.tsx +2 -0
  196. package/src/lib/components/dropdown/Dropdown.tsx +135 -0
  197. package/src/lib/components/dropdown/index.tsx +2 -0
  198. package/src/lib/components/dynamicSubmit/DynamicSubmit.tsx +153 -0
  199. package/src/lib/components/dynamicSubmit/index.tsx +2 -0
  200. package/src/lib/components/externalValidationComponent/ExternalValidationComponent.tsx +78 -0
  201. package/src/lib/components/externalValidationComponent/index.tsx +2 -0
  202. package/src/lib/components/form/Form.tsx +276 -0
  203. package/src/lib/components/form/FormContext.ts +49 -0
  204. package/src/lib/components/form/FormValidationSummary.tsx +122 -0
  205. package/src/lib/components/form/index.tsx +5 -0
  206. package/src/lib/components/form/withFormContext.tsx +20 -0
  207. package/src/lib/components/inputGroup/InputGroup.tsx +60 -0
  208. package/src/lib/components/inputGroup/index.tsx +2 -0
  209. package/src/lib/components/inputHeader/InputHeader.tsx +448 -0
  210. package/src/lib/components/inputHeader/InputHeaderContext.ts +42 -0
  211. package/src/lib/components/inputHeader/index.tsx +2 -0
  212. package/src/lib/components/inputHeader/withInputHeaderContext.tsx +24 -0
  213. package/src/lib/components/money/Money.tsx +298 -0
  214. package/src/lib/components/money/index.tsx +2 -0
  215. package/src/lib/components/numberInput/NumberInput.tsx +186 -0
  216. package/src/lib/components/numberInput/index.tsx +2 -0
  217. package/src/lib/components/openingHours/openingHoursDay/OpeningHoursDay.tsx +394 -0
  218. package/src/lib/components/openingHours/openingHoursDay/index.tsx +2 -0
  219. package/src/lib/components/openingHours/openingHoursSpecial/OpeningHoursSpecial.tsx +227 -0
  220. package/src/lib/components/openingHours/openingHoursSpecial/index.tsx +2 -0
  221. package/src/lib/components/openingHours/openingHoursWeek/OpeningHoursWeek.tsx +283 -0
  222. package/src/lib/components/openingHours/openingHoursWeek/index.tsx +2 -0
  223. package/src/lib/components/openingHours/utils/OpeningHoursUtil.tsx +111 -0
  224. package/src/lib/components/radio/Radio.tsx +87 -0
  225. package/src/lib/components/radio/index.tsx +2 -0
  226. package/src/lib/components/radioContainer/RadioContainer.tsx +50 -0
  227. package/src/lib/components/radioContainer/index.tsx +2 -0
  228. package/src/lib/components/select/Select.tsx +335 -0
  229. package/src/lib/components/select/index.tsx +2 -0
  230. package/src/lib/components/submit/Submit.tsx +117 -0
  231. package/src/lib/components/submit/index.tsx +2 -0
  232. package/src/lib/components/submit/subComponents/SubmitValidationSummary.tsx +55 -0
  233. package/src/lib/components/tags/Tags.tsx +702 -0
  234. package/src/lib/components/tags/index.tsx +2 -0
  235. package/src/lib/components/tags/subComponents/TagsSuggestions.tsx +150 -0
  236. package/src/lib/components/text/Text.tsx +200 -0
  237. package/src/lib/components/text/index.tsx +2 -0
  238. package/src/lib/components/textArea/TextArea.tsx +109 -0
  239. package/src/lib/components/textArea/index.tsx +2 -0
  240. package/src/lib/components/themeProvider/ThemeContext.ts +16 -0
  241. package/src/lib/components/themeProvider/ThemeProvider.tsx +21 -0
  242. package/src/lib/components/themeProvider/index.tsx +4 -0
  243. package/src/lib/components/themeProvider/withThemeContext.tsx +30 -0
  244. package/src/lib/components/time/Time.tsx +296 -0
  245. package/src/lib/components/time/index.tsx +2 -0
  246. package/src/lib/components/timeSpan/TimeSpan.tsx +378 -0
  247. package/src/lib/components/timeSpan/index.tsx +2 -0
  248. package/src/lib/components/utils/Guid.ts +9 -0
  249. package/src/lib/components/utils/ShallowEqual.ts +75 -0
  250. package/src/lib/components/utils/TimeUtil.ts +22 -0
  251. package/src/lib/components/utils/Typescript.ts +11 -0
  252. package/src/lib/declarations/import.d.ts +1 -0
  253. package/src/lib/index.ts +24 -0
  254. package/src/lib/scss/components/base/index.scss +1 -0
  255. package/src/lib/scss/components/base/input/index.scss +1 -0
  256. package/src/lib/scss/components/base/input/input.scss +237 -0
  257. package/src/lib/scss/components/bookingCalendar/bookingCalendar.scss +272 -0
  258. package/src/lib/scss/components/bookingCalendar/index.scss +1 -0
  259. package/src/lib/scss/components/button/buttons.scss +161 -0
  260. package/src/lib/scss/components/button/index.scss +1 -0
  261. package/src/lib/scss/components/checkbox/checkbox.scss +115 -0
  262. package/src/lib/scss/components/checkbox/index.scss +1 -0
  263. package/src/lib/scss/components/dropdown/dropdown.scss +111 -0
  264. package/src/lib/scss/components/dropdown/index.scss +1 -0
  265. package/src/lib/scss/components/dynamicSubmit/dynamicSubmit.scss +1 -0
  266. package/src/lib/scss/components/dynamicSubmit/index.scss +1 -0
  267. package/src/lib/scss/components/form/form.scss +1 -0
  268. package/src/lib/scss/components/form/formValidationSummary.scss +55 -0
  269. package/src/lib/scss/components/form/index.scss +2 -0
  270. package/src/lib/scss/components/index.scss +21 -0
  271. package/src/lib/scss/components/inputGroup/index.scss +1 -0
  272. package/src/lib/scss/components/inputGroup/inputGroup.scss +67 -0
  273. package/src/lib/scss/components/inputHeader/index.scss +1 -0
  274. package/src/lib/scss/components/inputHeader/inputHeader.scss +132 -0
  275. package/src/lib/scss/components/money/index.scss +1 -0
  276. package/src/lib/scss/components/money/money.scss +51 -0
  277. package/src/lib/scss/components/numberInput/index.scss +1 -0
  278. package/src/lib/scss/components/numberInput/numberInput.scss +116 -0
  279. package/src/lib/scss/components/openingHours/index.scss +3 -0
  280. package/src/lib/scss/components/openingHours/openingHoursDay/index.scss +1 -0
  281. package/src/lib/scss/components/openingHours/openingHoursDay/openingHoursDay.scss +127 -0
  282. package/src/lib/scss/components/openingHours/openingHoursSpecial/index.scss +1 -0
  283. package/src/lib/scss/components/openingHours/openingHoursSpecial/openingHoursSpecial.scss +93 -0
  284. package/src/lib/scss/components/openingHours/openingHoursWeek/index.scss +1 -0
  285. package/src/lib/scss/components/openingHours/openingHoursWeek/openingHoursWeek.scss +23 -0
  286. package/src/lib/scss/components/radio/index.scss +1 -0
  287. package/src/lib/scss/components/radio/radio.scss +68 -0
  288. package/src/lib/scss/components/radioContainer/index.scss +1 -0
  289. package/src/lib/scss/components/radioContainer/radioContainer.scss +15 -0
  290. package/src/lib/scss/components/select/index.scss +1 -0
  291. package/src/lib/scss/components/select/select.scss +64 -0
  292. package/src/lib/scss/components/submit/index.scss +1 -0
  293. package/src/lib/scss/components/submit/submitValidationSummary.scss +35 -0
  294. package/src/lib/scss/components/tags/index.scss +1 -0
  295. package/src/lib/scss/components/tags/tags.scss +128 -0
  296. package/src/lib/scss/components/text/index.scss +1 -0
  297. package/src/lib/scss/components/text/text.scss +42 -0
  298. package/src/lib/scss/components/textArea/index.scss +1 -0
  299. package/src/lib/scss/components/textArea/textArea.scss +32 -0
  300. package/src/lib/scss/components/time/index.scss +1 -0
  301. package/src/lib/scss/components/time/time.scss +111 -0
  302. package/src/lib/scss/components/timeSpan/index.scss +1 -0
  303. package/src/lib/scss/components/timeSpan/timeSpan.scss +115 -0
  304. package/src/lib/scss/index.scss +8 -0
  305. package/src/lib/scss/styles/base.scss +7 -0
  306. package/src/lib/scss/styles/index.scss +2 -0
  307. package/src/lib/scss/styles/react-tippy.scss +4 -0
  308. package/src/lib/scss/variables/_buttons.scss +6 -0
  309. package/src/lib/scss/variables/_colors.scss +1 -0
  310. package/src/lib/scss/variables/_common.scss +12 -0
  311. package/src/lib/tsconfig.json +19 -0
  312. package/src/lib/types/ElementOverrideProp.ts +3 -0
  313. package/src/lib/types/Theme.ts +5 -0
  314. package/src/lib/types/ThemeOverrides.ts +46 -0
  315. package/src/lib/validators/EmailValidator.ts +15 -0
  316. package/src/lib/validators/LatitudeValidator.ts +25 -0
  317. package/src/lib/validators/LongitudeValidator.ts +25 -0
  318. package/src/lib/validators/NumberValidator.ts +50 -0
  319. package/src/lib/validators/UrlValidator.ts +20 -0
  320. package/src/lib/validators/base.ts +15 -0
  321. package/src/lib/validators/index.ts +6 -0
  322. package/src/stories/Basic.stories.ts +17 -0
  323. package/src/stories/Basic.tsx +1065 -0
  324. package/src/stories/Schedule.stories.ts +16 -0
  325. package/src/stories/Schedule.tsx +73 -0
  326. package/src/stories/ValidationPage.tsx +417 -0
  327. package/tsconfig.json +9 -22
  328. package/typedoc.json +6 -0
  329. package/webpack/webpack.config.base.js +139 -0
  330. package/webpack/webpack.config.dev.js +78 -0
  331. package/webpack/webpack.config.gh-pages.js +78 -0
  332. package/webpack/webpack.config.js +21 -0
  333. package/webpack/webpack.config.min.js +100 -0
  334. package/.vscode/launch.json +0 -15
  335. package/.vscode/settings.json +0 -27
  336. package/.vscode/tasks.json +0 -12
@@ -0,0 +1,296 @@
1
+ import * as ArrowIcon from 'material-design-icons/hardware/svg/production/ic_keyboard_arrow_down_24px.svg';
2
+
3
+ // Libs
4
+ import * as React from 'react';
5
+
6
+ // Misc
7
+ import InputGroup from '../inputGroup/InputGroup';
8
+ import {
9
+ BaseInputProps,
10
+ BaseInputState,
11
+ BaseInput,
12
+ } from '../base/input/BaseInput';
13
+ import { withFormContext } from '../form/withFormContext';
14
+ import TimeUtil from '../utils/TimeUtil';
15
+ import moment, { Duration } from 'moment';
16
+ import { withThemeContext } from '../themeProvider/withThemeContext';
17
+ import classNames from 'classnames';
18
+
19
+ export interface TimeProps extends BaseInputProps<HTMLInputElement> {
20
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
21
+ timeChange: (time: Duration) => void;
22
+ time: Duration;
23
+ min?: Duration;
24
+ max?: Duration;
25
+ showDateDiff?: boolean;
26
+ }
27
+
28
+ export interface TimeState extends BaseInputState {
29
+ hoursText?: string;
30
+ minutesText?: string;
31
+ }
32
+
33
+ export class TimeRaw extends BaseInput<TimeProps, TimeState, HTMLInputElement> {
34
+ public static defaultProps = Object.assign({}, BaseInput.defaultProps, {
35
+ type: 'time',
36
+ placeholder: '',
37
+ }) as unknown as TimeProps;
38
+
39
+ constructor(props: TimeProps) {
40
+ super(props);
41
+ this.handleHoursChange = this.handleHoursChange.bind(this);
42
+ this.handleMinutesChange = this.handleMinutesChange.bind(this);
43
+ }
44
+
45
+ public render() {
46
+ let hours = this.props.time?.hours?.() ?? 0;
47
+ let minutes = this.props.time?.minutes?.() ?? 0;
48
+ if (minutes < 0) {
49
+ hours--;
50
+ }
51
+ minutes = (minutes + 60) % 60;
52
+ hours = (hours + 24) % 24;
53
+ var mid = 'AM';
54
+ if (hours % 24 >= 12) {
55
+ hours = hours % 12;
56
+ mid = 'PM';
57
+ }
58
+ if (hours % 12 === 0) {
59
+ // At 00 hours we need to show 12 am
60
+ hours = 12;
61
+ }
62
+ if (this.props.showDateDiff && this.props.min) {
63
+ const diffDays = TimeUtil.dayDiff(this.props.min, this.props.time);
64
+ if (diffDays > 0) {
65
+ mid += ' +' + diffDays.toString();
66
+ }
67
+ }
68
+ return (
69
+ <InputGroup
70
+ title={this.props.title}
71
+ tooltip={this.props.tooltip}
72
+ className={this.props.inputGroupClassName}
73
+ >
74
+ <div
75
+ {...(this.props.id && {
76
+ id: this.props.id,
77
+ })}
78
+ className={classNames(
79
+ 'input__base time-input',
80
+ this.getValidationClass(),
81
+ this.props.className
82
+ )}
83
+ ref={this.containerRef}
84
+ >
85
+ <div className="">
86
+ <div className="time-input__arrows__container">
87
+ <button
88
+ className="plus"
89
+ onClick={this.addHourClick}
90
+ {...(this.props.id && {
91
+ id: this.props.id + '-add-hours-button',
92
+ })}
93
+ tabIndex={0}
94
+ >
95
+ <ArrowIcon />
96
+ </button>
97
+ <div className="input-padding">
98
+ <input
99
+ {...(this.props.id && {
100
+ id: this.props.id + '-hours-input',
101
+ })}
102
+ disabled={this.getDisabled()}
103
+ required={this.props.required}
104
+ className={
105
+ 'time-input__time ' + (this.state.value ? 'filled' : '')
106
+ }
107
+ onChange={this.onHoursChanged}
108
+ value={
109
+ this.state.hoursText !== undefined
110
+ ? this.state.hoursText
111
+ : hours
112
+ }
113
+ onBlur={this.onBlur}
114
+ onFocus={this.handleFocus}
115
+ type="number"
116
+ />
117
+ <span className="highlight" />
118
+ </div>
119
+ <button
120
+ className="minus"
121
+ onClick={this.removeHourClick}
122
+ {...(this.props.id && {
123
+ id: this.props.id + '-subtract-hours-button',
124
+ })}
125
+ tabIndex={0}
126
+ >
127
+ <ArrowIcon />
128
+ </button>
129
+ </div>
130
+ </div>
131
+ <span className="">:</span>
132
+ <div className="">
133
+ <div className="time-input__arrows__container">
134
+ <button
135
+ className="plus"
136
+ onClick={this.addMinuteClick}
137
+ {...(this.props.id && {
138
+ id: this.props.id + '-add-minutes-button',
139
+ })}
140
+ tabIndex={0}
141
+ >
142
+ <ArrowIcon />
143
+ </button>
144
+ <div className="input-padding">
145
+ <input
146
+ {...(this.props.id && {
147
+ id: this.props.id + '-minutes-input',
148
+ })}
149
+ disabled={this.getDisabled()}
150
+ required={this.props.required}
151
+ className={
152
+ 'time-input__time ' + (this.state.value ? 'filled' : '')
153
+ }
154
+ onChange={this.onMinutesChanged}
155
+ value={
156
+ this.state.minutesText !== undefined
157
+ ? this.state.minutesText
158
+ : minutes < 10
159
+ ? '0' + minutes.toString()
160
+ : minutes.toString()
161
+ }
162
+ onBlur={this.onBlur}
163
+ onFocus={this.handleFocus}
164
+ type="number"
165
+ />
166
+ <span className="highlight" />
167
+ </div>
168
+ <button
169
+ className="minus"
170
+ onClick={this.removeMinuteClick}
171
+ {...(this.props.id && {
172
+ id: this.props.id + '-subtract-minutes-button',
173
+ })}
174
+ tabIndex={0}
175
+ >
176
+ <ArrowIcon />
177
+ </button>
178
+ </div>
179
+ </div>
180
+ {this.renderDefaultValidation()}
181
+ <span className="time-input__am-pm">{mid}</span>
182
+ <span className="highlight" />
183
+ <span className={'bar ' + (this.state.focused ? 'focused' : '')} />
184
+ {this.props.label && (
185
+ <label className={classNames('time-input__label label--focused')}>
186
+ {this.renderLabel()}
187
+ </label>
188
+ )}
189
+ </div>
190
+ </InputGroup>
191
+ );
192
+ }
193
+
194
+ private onBlur = () => {
195
+ if (this.state.hoursText) {
196
+ this.handleHoursChange(this.state.hoursText);
197
+ }
198
+ if (this.state.minutesText) {
199
+ this.handleMinutesChange(this.state.minutesText);
200
+ }
201
+ this.setState({ minutesText: undefined, hoursText: undefined }, () =>
202
+ this.handleBlur()
203
+ );
204
+ };
205
+
206
+ private onMinutesChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
207
+ // this.handleMinutesChange(e.target.value);
208
+ this.setState({ minutesText: e.target.value });
209
+ };
210
+
211
+ private removeMinuteClick = (e: React.MouseEvent<HTMLButtonElement>) => {
212
+ e.preventDefault();
213
+ this.handleMinutesChange(
214
+ ((this.props.time?.minutes?.() ?? 0) - 1).toString()
215
+ );
216
+ };
217
+
218
+ private addMinuteClick = (e: React.MouseEvent<HTMLButtonElement>) => {
219
+ e.preventDefault();
220
+ this.handleMinutesChange(
221
+ ((this.props.time?.minutes?.() ?? 0) + 1).toString()
222
+ );
223
+ };
224
+
225
+ private removeHourClick = (e: React.MouseEvent<HTMLButtonElement>) => {
226
+ e.preventDefault();
227
+ this.handleHoursChange(((this.props.time?.hours?.() ?? 0) - 1).toString());
228
+ };
229
+
230
+ private onHoursChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
231
+ // this.handleHoursChange(e.target.value);
232
+ this.setState({ hoursText: e.target.value });
233
+ };
234
+
235
+ private addHourClick = (e: React.MouseEvent<HTMLButtonElement>) => {
236
+ e.preventDefault();
237
+ this.handleHoursChange(((this.props.time?.hours?.() ?? 0) + 1).toString());
238
+ };
239
+
240
+ private handleLimits(time: Duration) {
241
+ if (this.props.min) {
242
+ if (
243
+ (time?.asMilliseconds?.() ?? 0) - this.props.min.asMilliseconds() <=
244
+ 0
245
+ ) {
246
+ this.props.timeChange(this.props.min.clone());
247
+ return;
248
+ }
249
+ }
250
+ if (this.props.max) {
251
+ if (
252
+ this.props.max.asMilliseconds() - (time?.asMilliseconds?.() ?? 0) <=
253
+ 0
254
+ ) {
255
+ this.props.timeChange(this.props.max.clone());
256
+ return;
257
+ }
258
+ }
259
+ this.props.timeChange(time);
260
+ }
261
+
262
+ private handleHoursChange(hoursString: string) {
263
+ let num = Number(hoursString);
264
+ if (hoursString === '') {
265
+ num = 0;
266
+ }
267
+ if (!isNaN(num)) {
268
+ let newTime: Duration = moment
269
+ .duration(this.props.time?.asMilliseconds?.() ?? 0, 'milliseconds')
270
+ .subtract(this.props.time?.hours?.() ?? 0, 'hours')
271
+ .add(num, 'hours');
272
+ this.handleLimits(newTime);
273
+ }
274
+ }
275
+
276
+ private handleMinutesChange(minutesString: string) {
277
+ let num = Number(minutesString);
278
+ if (minutesString === '') {
279
+ num = 0;
280
+ }
281
+ if (!isNaN(num)) {
282
+ let newTime: Duration = moment
283
+ .duration(this.props.time?.asMilliseconds?.() ?? 0, 'milliseconds')
284
+ .subtract(this.props.time?.minutes?.() ?? 0, 'minutes')
285
+ .add(num, 'minutes');
286
+ this.handleLimits(newTime);
287
+ }
288
+ }
289
+ }
290
+
291
+ export const Time = withThemeContext<TimeProps, InstanceType<typeof TimeRaw>>(
292
+ withFormContext<TimeProps>(TimeRaw),
293
+ 'time'
294
+ );
295
+
296
+ export default Time;
@@ -0,0 +1,2 @@
1
+ export * from './Time';
2
+ export { default } from './Time';
@@ -0,0 +1,378 @@
1
+ import * as ArrowIcon from 'material-design-icons/hardware/svg/production/ic_keyboard_arrow_down_24px.svg';
2
+
3
+ // Libs
4
+ import * as React from 'react';
5
+
6
+ // Misc
7
+ import InputGroup from '../inputGroup/InputGroup';
8
+ import {
9
+ BaseInputProps,
10
+ BaseInputState,
11
+ BaseInput,
12
+ } from '../base/input/BaseInput';
13
+ import { withFormContext } from '../form/withFormContext';
14
+ import moment, { Duration } from 'moment';
15
+ import { withThemeContext } from '../themeProvider/withThemeContext';
16
+ import classNames from 'classnames';
17
+
18
+ export enum TimeSpanUnit {
19
+ Dynamic = 0,
20
+ Millisecond = 1,
21
+ Second = 2,
22
+ Minute = 4,
23
+ Hour = 8,
24
+ Day = 16,
25
+ Year = 32,
26
+ }
27
+
28
+ export const allTimeSpanUnits: TimeSpanUnit =
29
+ TimeSpanUnit.Day |
30
+ TimeSpanUnit.Hour |
31
+ TimeSpanUnit.Millisecond |
32
+ TimeSpanUnit.Minute |
33
+ TimeSpanUnit.Second |
34
+ TimeSpanUnit.Year;
35
+
36
+ function getValues<T>(enumeration: T): T[keyof T][] {
37
+ var values: T[keyof T][] = [];
38
+ for (var value in enumeration) {
39
+ if (isNaN(Number(value))) {
40
+ values.push(enumeration[value]);
41
+ }
42
+ }
43
+ return values;
44
+ }
45
+
46
+ const allUnits = getValues(TimeSpanUnit);
47
+
48
+ export interface TimeSpanProps extends BaseInputProps<HTMLInputElement> {
49
+ onChange?: never;
50
+ timeSpanChange: (time: Duration) => void;
51
+ timeSpan: Duration;
52
+ min?: Duration;
53
+ max?: Duration;
54
+ initialUnits?: TimeSpanUnit;
55
+ units?: TimeSpanUnit;
56
+ validUnits?: TimeSpanUnit;
57
+ unitToString?: (unit: TimeSpanUnit) => string;
58
+ }
59
+
60
+ export interface TimeSpanState extends BaseInputState {
61
+ currentUnitText: string;
62
+ currentUnit: TimeSpanUnit | undefined;
63
+ }
64
+
65
+ export class TimeSpanRaw extends BaseInput<
66
+ TimeSpanProps,
67
+ TimeSpanState,
68
+ HTMLInputElement
69
+ > {
70
+ public static defaultProps = Object.assign({}, BaseInput.defaultProps, {
71
+ type: 'time',
72
+ placeholder: '',
73
+ validUnits: allTimeSpanUnits,
74
+ initialUnits: allTimeSpanUnits,
75
+ units: TimeSpanUnit.Dynamic,
76
+ unitToString: (unit: TimeSpanUnit) => {
77
+ switch (unit) {
78
+ case TimeSpanUnit.Millisecond:
79
+ return 'ms';
80
+ case TimeSpanUnit.Second:
81
+ return 's';
82
+ case TimeSpanUnit.Minute:
83
+ return 'm';
84
+ case TimeSpanUnit.Hour:
85
+ return 'h';
86
+ case TimeSpanUnit.Day:
87
+ return 'd';
88
+ case TimeSpanUnit.Year:
89
+ return 'y';
90
+ default:
91
+ return '';
92
+ }
93
+ },
94
+ min: moment.duration(0),
95
+ }) as unknown as TimeSpanProps;
96
+
97
+ constructor(props: TimeSpanProps) {
98
+ super(props);
99
+ this.removeUnitClick = this.removeUnitClick.bind(this);
100
+ this.addUnitClick = this.addUnitClick.bind(this);
101
+ this.onUnitChanged = this.onUnitChanged.bind(this);
102
+ }
103
+
104
+ public render() {
105
+ const { timeSpan, validUnits, initialUnits, units: _units } = this.props;
106
+ const units = _units || this.getUnits(timeSpan, validUnits, initialUnits);
107
+ const unitsArr = allUnits.filter((u) => (units & u) !== 0).reverse();
108
+ return (
109
+ <InputGroup
110
+ title={this.props.title}
111
+ tooltip={this.props.tooltip}
112
+ className={this.props.inputGroupClassName}
113
+ >
114
+ <div
115
+ {...(this.props.id && {
116
+ id: this.props.id,
117
+ })}
118
+ className={
119
+ 'input__base timeSpan-input ' +
120
+ this.getValidationClass() +
121
+ ' ' +
122
+ (this.props.className ? this.props.className : '')
123
+ }
124
+ ref={this.containerRef}
125
+ >
126
+ {unitsArr.map((unit) => (
127
+ <div className="" key={unit}>
128
+ <div className="timeSpan-input__arrows__container">
129
+ <button
130
+ className="plus"
131
+ onClick={this.addUnitClick}
132
+ {...(this.props.id && {
133
+ id: this.props.id + '-add-hours-button',
134
+ })}
135
+ data-unit={unit}
136
+ tabIndex={0}
137
+ >
138
+ <ArrowIcon />
139
+ </button>
140
+ <div className="input-padding">
141
+ <input
142
+ {...(this.props.id && {
143
+ id: this.props.id + '-' + unit + '-input',
144
+ })}
145
+ disabled={this.getDisabled()}
146
+ required={this.props.required}
147
+ className={classNames('timeSpan-input__time', {
148
+ filled: this.state.value,
149
+ 'timeSpan-input__time--ms':
150
+ unit === TimeSpanUnit.Millisecond,
151
+ })}
152
+ onChange={this.onUnitChanged}
153
+ value={
154
+ this.state.currentUnit === unit
155
+ ? this.state.currentUnitText
156
+ : this.getValue(timeSpan, unit)
157
+ }
158
+ onBlur={this.onBlur}
159
+ onFocus={this.handleFocus}
160
+ type="number"
161
+ data-unit={unit}
162
+ onKeyDown={this.onKeyDown}
163
+ />
164
+ <span className="highlight" />
165
+ </div>
166
+ <button
167
+ className="minus"
168
+ onClick={this.removeUnitClick}
169
+ {...(this.props.id && {
170
+ id: this.props.id + '-subtract-hours-button',
171
+ })}
172
+ data-unit={unit}
173
+ tabIndex={0}
174
+ >
175
+ <ArrowIcon />
176
+ </button>
177
+ </div>
178
+ {this.props.unitToString(unit)}
179
+ </div>
180
+ ))}
181
+ {this.renderDefaultValidation()}
182
+ <span className="highlight" />
183
+ <span className={'bar ' + (this.state.focused ? 'focused' : '')} />
184
+ {this.props.label && (
185
+ <label
186
+ className={classNames('timeSpan-input__label label--focused')}
187
+ >
188
+ {this.renderLabel()}
189
+ </label>
190
+ )}
191
+ </div>
192
+ </InputGroup>
193
+ );
194
+ }
195
+
196
+ private getUnits(
197
+ time: Duration,
198
+ validUnits: TimeSpanUnit,
199
+ initialUnits: TimeSpanUnit
200
+ ) {
201
+ if (time === null || time === undefined) {
202
+ return initialUnits;
203
+ }
204
+ const ms = time.asMilliseconds();
205
+ let units: TimeSpanUnit = TimeSpanUnit.Millisecond | TimeSpanUnit.Second;
206
+ if (ms >= 1000) {
207
+ units += TimeSpanUnit.Minute;
208
+ }
209
+ if (ms >= 60000) {
210
+ units += TimeSpanUnit.Hour;
211
+ }
212
+ if (ms >= 60 * 60000) {
213
+ units += TimeSpanUnit.Day;
214
+ }
215
+ if (ms >= 24 * 60 * 60000) {
216
+ units += TimeSpanUnit.Year;
217
+ }
218
+ const tagMask = allTimeSpanUnits & ~validUnits;
219
+ units &= ~tagMask;
220
+ return units || initialUnits;
221
+ }
222
+
223
+ private getValue(time: Duration, unit: TimeSpanUnit) {
224
+ if (!time || !unit) {
225
+ return 0;
226
+ }
227
+ switch (unit) {
228
+ case TimeSpanUnit.Millisecond:
229
+ return Math.floor(time.get('millisecond'));
230
+ case TimeSpanUnit.Second:
231
+ return Math.floor(time.get('second'));
232
+ case TimeSpanUnit.Minute:
233
+ return Math.floor(time.get('minute'));
234
+ case TimeSpanUnit.Hour:
235
+ return Math.floor(time.get('hour'));
236
+ case TimeSpanUnit.Day:
237
+ return Math.floor(time.get('day'));
238
+ case TimeSpanUnit.Year:
239
+ return Math.floor(time.get('year'));
240
+ default:
241
+ return 0;
242
+ }
243
+ }
244
+
245
+ private oneUnitInMs(unit: TimeSpanUnit) {
246
+ if (!unit) {
247
+ return 0;
248
+ }
249
+ switch (unit) {
250
+ case TimeSpanUnit.Millisecond:
251
+ return 1;
252
+ case TimeSpanUnit.Second:
253
+ return 1000;
254
+ case TimeSpanUnit.Minute:
255
+ return 60000;
256
+ case TimeSpanUnit.Hour:
257
+ return 3600000;
258
+ case TimeSpanUnit.Day:
259
+ return 24 * 3600000;
260
+ case TimeSpanUnit.Year:
261
+ return 24 * 365 * 3600000;
262
+ default:
263
+ return 0;
264
+ }
265
+ }
266
+
267
+ private maxOfUnit(unit: TimeSpanUnit) {
268
+ if (!unit) {
269
+ return 0;
270
+ }
271
+ switch (unit) {
272
+ case TimeSpanUnit.Millisecond:
273
+ return 1000;
274
+ case TimeSpanUnit.Second:
275
+ return 60;
276
+ case TimeSpanUnit.Minute:
277
+ return 60;
278
+ case TimeSpanUnit.Hour:
279
+ return 24;
280
+ case TimeSpanUnit.Day:
281
+ return 365;
282
+ case TimeSpanUnit.Year:
283
+ return 9999;
284
+ default:
285
+ return 0;
286
+ }
287
+ }
288
+
289
+ private commitState() {
290
+ if (this.state.currentUnit) {
291
+ var num = Number(this.state.currentUnitText);
292
+ if (!isNaN(num)) {
293
+ const newOfUnitMs = num * this.oneUnitInMs(this.state.currentUnit);
294
+ const oldOfUnitMs =
295
+ this.getValue(this.props.timeSpan, this.state.currentUnit) *
296
+ this.oneUnitInMs(this.state.currentUnit);
297
+ const maxOfUnitMs =
298
+ this.maxOfUnit(this.state.currentUnit) *
299
+ this.oneUnitInMs(this.state.currentUnit);
300
+ const moreThanMax = maxOfUnitMs < newOfUnitMs;
301
+ const diff = newOfUnitMs - oldOfUnitMs;
302
+ if (moreThanMax) {
303
+ this.handleLimits(moment.duration(newOfUnitMs, 'millisecond'));
304
+ } else {
305
+ this.handleLimits(
306
+ moment.duration(
307
+ (this.props.timeSpan?.asMilliseconds() || 0) + diff,
308
+ 'millisecond'
309
+ )
310
+ );
311
+ }
312
+ }
313
+ this.setState({ currentUnit: undefined, currentUnitText: undefined });
314
+ }
315
+ }
316
+
317
+ private onBlur = () => {
318
+ this.commitState();
319
+ this.handleBlur();
320
+ };
321
+
322
+ private removeUnitClick = (e: React.MouseEvent<HTMLButtonElement>) => {
323
+ e.preventDefault();
324
+ const unit: TimeSpanUnit = Number(e.currentTarget.dataset.unit);
325
+ const diff = -1 * this.oneUnitInMs(unit);
326
+ const newDate = moment.duration(
327
+ (this.props.timeSpan?.asMilliseconds() || 0) + diff,
328
+ 'millisecond'
329
+ );
330
+ this.handleLimits(newDate);
331
+ };
332
+
333
+ private onUnitChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
334
+ // this.handleHoursChange(e.target.value);
335
+ const unit: TimeSpanUnit = Number(e.currentTarget.dataset.unit);
336
+ this.setState({ currentUnitText: e.target.value, currentUnit: unit });
337
+ };
338
+
339
+ private onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
340
+ if (e.key === 'Enter') {
341
+ this.commitState();
342
+ }
343
+ };
344
+
345
+ private addUnitClick = (e: React.MouseEvent<HTMLButtonElement>) => {
346
+ e.preventDefault();
347
+ const unit: TimeSpanUnit = Number(e.currentTarget.dataset.unit);
348
+ const diff = this.oneUnitInMs(unit);
349
+ const newDate = moment.duration(
350
+ (this.props.timeSpan?.asMilliseconds() || 0) + diff,
351
+ 'milliseconds'
352
+ );
353
+ this.handleLimits(newDate);
354
+ };
355
+
356
+ private handleLimits(time: Duration) {
357
+ if (this.props.min) {
358
+ if (time.asMilliseconds() - this.props.min.asMilliseconds() <= 0) {
359
+ this.props.timeSpanChange(this.props.min.clone());
360
+ return;
361
+ }
362
+ }
363
+ if (this.props.max) {
364
+ if (this.props.max.asMilliseconds() - time.asMilliseconds() <= 0) {
365
+ this.props.timeSpanChange(this.props.max.clone());
366
+ return;
367
+ }
368
+ }
369
+ this.props.timeSpanChange(time);
370
+ }
371
+ }
372
+
373
+ export const TimeSpan = withThemeContext<
374
+ TimeSpanProps,
375
+ InstanceType<typeof TimeSpanRaw>
376
+ >(withFormContext<TimeSpanProps>(TimeSpanRaw), 'timeSpan');
377
+
378
+ export default TimeSpan;
@@ -0,0 +1,2 @@
1
+ export * from './TimeSpan';
2
+ export { default } from './TimeSpan';
@@ -0,0 +1,9 @@
1
+ const guid = () => {
2
+ const s4 = () =>
3
+ Math.floor((1 + Math.random()) * 0x10000)
4
+ .toString(16)
5
+ .substring(1);
6
+ return `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4() + s4() + s4()}`;
7
+ };
8
+
9
+ export default guid;