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,702 @@
1
+ // Libs
2
+ import * as React from 'react';
3
+ import { InputGroup } from '../inputGroup/InputGroup';
4
+ import { Text, TextProps, TextRaw } from '../text/Text';
5
+ import * as PlusIcon from 'material-design-icons/content/svg/production/ic_add_circle_outline_24px.svg';
6
+ import * as LeftArrowIcon from 'material-design-icons/navigation/svg/production/ic_arrow_back_24px.svg';
7
+ import {
8
+ BaseInputProps,
9
+ BaseInputState,
10
+ BaseInput,
11
+ ValidationError,
12
+ defaultBaseTranslations,
13
+ } from '../base/input/BaseInput';
14
+ import { Button, ButtonComponentProps } from '../button/Button';
15
+ import TagsSuggestions, {
16
+ RenderSuggestionTagProps,
17
+ } from './subComponents/TagsSuggestions';
18
+ import { withFormContext } from '../form/withFormContext';
19
+ import classNames from 'classnames';
20
+ import { withThemeContext } from '../themeProvider/withThemeContext';
21
+ import { PopperProps } from '@mui/material/Popper/Popper';
22
+ import LinearProgress from '@mui/material/LinearProgress';
23
+ import Portal from '@mui/material/Portal';
24
+
25
+ // Misc
26
+ export type Tag = {
27
+ id: number | string;
28
+ name: string;
29
+ };
30
+
31
+ export const defaultTagsTranslations = {
32
+ ...defaultBaseTranslations,
33
+ addNew: 'Add new',
34
+ };
35
+
36
+ export type TagsTranslations = Partial<typeof defaultTagsTranslations>;
37
+
38
+ export type TagsProps<T extends Tag = Tag> = {
39
+ className?: string;
40
+ tagsSuggestionsClassName?: string;
41
+ disabled?: boolean;
42
+ tags: T[];
43
+ existingTags?: T[];
44
+ fetchExistingTags?: (text: string) => Promise<T[]>;
45
+ onTagsChanged: (newTags: T[]) => void;
46
+ onNewTagAdded?: (newTagName: string) => Promise<T>;
47
+ onTagClick?: (tag: T) => void;
48
+ showChips?: boolean;
49
+ allowNew?: boolean;
50
+ addNewOnBlur?: boolean;
51
+ textProps?: TextProps;
52
+ readOnly?: boolean;
53
+ readonlyEmptyPlaceholder?: string;
54
+ maxTags?: number;
55
+ valueNotAddedError?: string | JSX.Element;
56
+ maxTagsSurpassedError?: string | JSX.Element;
57
+ showSuggestions?: boolean;
58
+ suggestionsLoadingComponent?: string | JSX.Element;
59
+ suggestionsEmptyComponent?: string | JSX.Element | null;
60
+ waitingForMoreInputComponent?: string | JSX.Element;
61
+ loadingDelayMs?: number;
62
+ filterExistingTags?: (text: string, existingTags: T[]) => T[];
63
+ allowSameTagMultipleTimes?: boolean;
64
+ maxSuggestions?: number;
65
+ popperProps?: Partial<PopperProps>;
66
+ minLettersToFetch?: number;
67
+ mobileVersionEnabled?: boolean;
68
+ isLoading?: boolean;
69
+ closeSuggestionsAfterCreate?: boolean;
70
+ SuggestionTag?: React.ComponentType<RenderSuggestionTagProps<T>>;
71
+ } & BaseInputProps<HTMLInputElement, TagsTranslations>;
72
+
73
+ export interface TagsState<T extends Tag = Tag> extends BaseInputState {
74
+ textIsFocused: boolean;
75
+ textErrors: ValidationError[];
76
+ textIsValid: boolean;
77
+ suggestionsVisible: boolean;
78
+ fetchedExistingTags: T[];
79
+ fetchingExistingTags: boolean;
80
+ preselectedSuggestion?: number;
81
+ }
82
+
83
+ type InjectedProps = {};
84
+
85
+ const TagButtonComponent: React.FC<ButtonComponentProps> = (p) => (
86
+ <a className={p.className} id={p.id} onClick={p.onClick}>
87
+ {p.children}
88
+ </a>
89
+ );
90
+
91
+ export class TagsRaw<T extends Tag = Tag> extends BaseInput<
92
+ TagsProps<T> & InjectedProps,
93
+ TagsState<T>,
94
+ HTMLInputElement,
95
+ TagsTranslations
96
+ > {
97
+ public static defaultProps: TagsProps = {
98
+ ...BaseInput.defaultProps,
99
+ disabled: false,
100
+ className: '',
101
+ tags: [],
102
+ existingTags: [],
103
+ maxTags: 1000,
104
+ onTagsChanged: () => undefined,
105
+ onNewTagAdded: (newTagName) =>
106
+ Promise.resolve({ name: newTagName, id: new Date().getTime() }),
107
+ valueNotAddedError: <span>You forgot to add tag</span>,
108
+ maxTagsSurpassedError: <span>Maximum number of tags surpassed</span>,
109
+ waitingForMoreInputComponent: <span>Waiting for more input...</span>,
110
+ showSuggestions: true,
111
+ suggestionsLoadingComponent: (
112
+ <LinearProgress className="tags-input__suggestions__defaultLoading" />
113
+ ),
114
+ suggestionsEmptyComponent: 'No existing tags...',
115
+ loadingDelayMs: 0,
116
+ filterExistingTags: (text, tags) =>
117
+ tags.filter((tag) => tag.name && tag.name.toLowerCase().startsWith(text)),
118
+ maxSuggestions: 5,
119
+ addNewOnBlur: false,
120
+ translations: defaultTagsTranslations,
121
+ minLettersToFetch: 0,
122
+ mobileVersionEnabled: true,
123
+ closeSuggestionsAfterCreate: false,
124
+ };
125
+
126
+ private textRef: React.RefObject<TextRaw>;
127
+ private suggestionsRef: React.RefObject<HTMLDivElement>;
128
+ private isMobile: boolean = false;
129
+
130
+ constructor(props: TagsProps<T> & InjectedProps) {
131
+ super(props);
132
+ this.state = {
133
+ ...this.state,
134
+ textErrors: [],
135
+ textIsFocused: false,
136
+ suggestionsVisible: false,
137
+ fetchingExistingTags: false,
138
+ textIsValid: false,
139
+ fetchedExistingTags: [],
140
+ };
141
+ this.textRef = React.createRef();
142
+ this.suggestionsRef = React.createRef();
143
+ this.handleClickOutside = this.handleClickOutside.bind(this);
144
+ this.handleLeaveMobileClick = this.handleLeaveMobileClick.bind(this);
145
+ if (props.mobileVersionEnabled) {
146
+ this.isMobile = require('react-device-detect')?.isMobile;
147
+ }
148
+ }
149
+
150
+ public focus() {
151
+ if (this.textRef.current) {
152
+ this.textRef.current.focus();
153
+ }
154
+ }
155
+
156
+ public componentDidUpdate(oldProps: TagsProps & InjectedProps) {
157
+ if (
158
+ oldProps.tags !== this.props.tags ||
159
+ oldProps.validators !== this.props.validators ||
160
+ oldProps.customValidators !== this.props.customValidators ||
161
+ oldProps.required !== this.props.required
162
+ ) {
163
+ this.handleErrors(this.props.tags);
164
+ }
165
+ }
166
+
167
+ public handleLeaveMobileClick() {
168
+ this.setState({
169
+ textIsFocused: false,
170
+ suggestionsVisible: false,
171
+ preselectedSuggestion: undefined,
172
+ });
173
+ }
174
+
175
+ public handleClickOutside(e: MouseEvent) {
176
+ if (
177
+ !this.containerRef.current ||
178
+ this.containerRef.current
179
+ .querySelector('.tags-input__tag__wrapper')
180
+ ?.contains(e.target as HTMLDivElement) ||
181
+ this.containerRef.current
182
+ .querySelector('.tags-input__text-input')
183
+ ?.contains(e.target as HTMLDivElement) ||
184
+ !this.suggestionsRef.current ||
185
+ this.suggestionsRef.current.contains(e.target as HTMLDivElement)
186
+ ) {
187
+ return;
188
+ }
189
+ if (this.state.suggestionsVisible) {
190
+ this.props.onSuggestionsClosed?.();
191
+ }
192
+ this.setState({
193
+ suggestionsVisible: false,
194
+ preselectedSuggestion: undefined,
195
+ });
196
+ if (this.props.addNewOnBlur && this.state.value) {
197
+ const suggestions = this.getSuggestions();
198
+ const existing = suggestions.find((s) => s.name === this.state.value);
199
+ if (existing) {
200
+ this.onSuggestionSelected(existing, suggestions.length === 1);
201
+ } else if (this.props.allowNew) {
202
+ this.addNewTag();
203
+ }
204
+ } /* else if (this.state.value) {
205
+ this.setState({ value: '' });
206
+ }*/
207
+ }
208
+
209
+ public componentDidMount() {
210
+ document.addEventListener('mousedown', this.handleClickOutside);
211
+ document.addEventListener('touchstart', this.handleClickOutside);
212
+ this.handleErrors(this.props.tags);
213
+ }
214
+
215
+ public componentWillUnmount() {
216
+ document.removeEventListener('mousedown', this.handleClickOutside);
217
+ document.removeEventListener('touchstart', this.handleClickOutside);
218
+ super.componentWillUnmount();
219
+ }
220
+
221
+ public render() {
222
+ const translations = this.getTranslations(defaultTagsTranslations);
223
+ const textProps = this.props.textProps ? this.props.textProps : {};
224
+ const suggestions = this.getSuggestions();
225
+ const showMobileVersion =
226
+ this.props.mobileVersionEnabled &&
227
+ this.isMobile &&
228
+ (this.state.textIsFocused || this.state.suggestionsVisible);
229
+ const LeaveMobileButton = showMobileVersion ? (
230
+ <Button
231
+ className="tags-input__leaveMobileTagsButton line-height--0"
232
+ onClick={this.handleLeaveMobileClick}
233
+ noShadow={true}
234
+ unobtrusive={true}
235
+ >
236
+ <LeftArrowIcon />
237
+ </Button>
238
+ ) : undefined;
239
+ const showInput = Boolean(
240
+ (!this.props.maxTags ||
241
+ this.props.maxTags > (this.props.tags && this.props.tags.length)) &&
242
+ !this.props.readOnly
243
+ );
244
+ return (
245
+ <Portal container={document.body} disablePortal={!showMobileVersion}>
246
+ <InputGroup title={this.props.title} tooltip={this.props.tooltip}>
247
+ <div
248
+ {...(this.props.id && {
249
+ id: this.props.id,
250
+ })}
251
+ className={classNames(
252
+ 'input__base tags-input',
253
+ this.getValidationClass(),
254
+ this.props.className,
255
+ {
256
+ 'tags-input--readOnly': this.props.readOnly,
257
+ 'tags-input--hasPlaceholder':
258
+ this.props.textProps && this.props.textProps.placeholder,
259
+ 'tags-input--mobile': showMobileVersion,
260
+ }
261
+ )}
262
+ ref={this.containerRef}
263
+ >
264
+ {showMobileVersion && (
265
+ <div className="tags-input__mobileBackdrop" />
266
+ )}
267
+ <div className="tags-input__tags__wrapper">
268
+ {!showInput && showMobileVersion && LeaveMobileButton}
269
+ {this.props.tags && this.props.tags.length > 0 ? (
270
+ <div className="tags-input__tag__wrapper">
271
+ {this.props.tags.map((item, index) =>
272
+ this.renderTag(item, index)
273
+ )}
274
+ </div>
275
+ ) : (
276
+ this.props.readOnly && (
277
+ <div className="tags-input__tag__wrapper">
278
+ <div className="tags-input__tag">
279
+ {this.props.readonlyEmptyPlaceholder}
280
+ </div>
281
+ </div>
282
+ )
283
+ )}
284
+ </div>
285
+ {showInput && (
286
+ <div
287
+ className={
288
+ 'tags-input__tags__wrapper ' +
289
+ (this.props.readOnly ? 'filled ' : '')
290
+ }
291
+ >
292
+ <Text
293
+ showClearButton={true}
294
+ {...textProps}
295
+ {...(this.props.id && {
296
+ id: this.props.id + '-text-input',
297
+ })}
298
+ ref={this.textRef}
299
+ required={
300
+ this.props.tags.length > 0 ? false : this.props.required
301
+ }
302
+ className={
303
+ 'tags-input__text-input ' +
304
+ (textProps.className ? textProps.className : '')
305
+ }
306
+ onKeyDown={this.onKeyDown(suggestions)}
307
+ onErrorsChanged={this.onTextErrorsChanged}
308
+ onChange={this.onTextChanged}
309
+ onFocus={this.onFocus}
310
+ onBlur={this.onBlur}
311
+ value={this.state.value}
312
+ readOnly={this.props.readOnly}
313
+ showValidation={false}
314
+ ignoreContext={true}
315
+ validators={this.props.validators}
316
+ customValidators={this.props.customValidators}
317
+ before={LeaveMobileButton}
318
+ />
319
+ {this.state.suggestionsVisible &&
320
+ this.props.showSuggestions && (
321
+ <TagsSuggestions<T>
322
+ {...(this.props.id && {
323
+ id: this.props.id + '-text-input',
324
+ })}
325
+ className={classNames(
326
+ this.props.tagsSuggestionsClassName
327
+ )}
328
+ innerRef={this.suggestionsRef}
329
+ anchorEl={this.containerRef.current}
330
+ allowNew={this.props.allowNew}
331
+ preselectedSuggestion={this.state.preselectedSuggestion}
332
+ loading={
333
+ this.state.fetchingExistingTags || this.props.isLoading
334
+ }
335
+ LoadingComponent={this.props.suggestionsLoadingComponent}
336
+ isVisible={this.state.suggestionsVisible}
337
+ EmptyComponent={this.props.suggestionsEmptyComponent}
338
+ WaitingForMoreInputComponent={
339
+ this.props.waitingForMoreInputComponent
340
+ }
341
+ isWaitingForMoreInput={
342
+ this.state.value.length < this.props.minLettersToFetch
343
+ }
344
+ tags={suggestions}
345
+ onSelected={this.onSuggestionSelected}
346
+ value={this.state.value}
347
+ AddNewTagComponent={
348
+ this.props.allowNew &&
349
+ this.state.value !== '' &&
350
+ (!this.props.existingTags ||
351
+ !this.props.existingTags.find(
352
+ (e) => e.name === this.state.value
353
+ )) &&
354
+ (!this.state.fetchedExistingTags ||
355
+ !this.state.fetchedExistingTags.find(
356
+ (e) => e.name === this.state.value
357
+ )) &&
358
+ this.state.textIsValid && (
359
+ <Button
360
+ {...(this.props.id && {
361
+ id: this.props.id + '-add-new-button',
362
+ })}
363
+ className="tags-input__suggestion tags-input__add-new"
364
+ dropdown={true}
365
+ onClick={this.addNewTag}
366
+ >
367
+ {translations.addNew} "{this.state.value}"
368
+ </Button>
369
+ )
370
+ }
371
+ SuggestionTag={this.props.SuggestionTag}
372
+ popperProps={this.props.popperProps}
373
+ />
374
+ )}
375
+ </div>
376
+ )}
377
+ {this.renderDefaultValidation()}
378
+ {this.props.label && (
379
+ <label
380
+ className={
381
+ this.state.value !== '' ||
382
+ this.state.textIsFocused ||
383
+ this.props.readOnly ||
384
+ this.props.tags.length >= this.props.maxTags ||
385
+ showMobileVersion
386
+ ? 'label--focused'
387
+ : ''
388
+ }
389
+ >
390
+ {this.renderLabel()}
391
+ </label>
392
+ )}
393
+ </div>
394
+ </InputGroup>
395
+ </Portal>
396
+ );
397
+ }
398
+
399
+ private onTextErrorsChanged = (textErrors: ValidationError[]) =>
400
+ this.setState(
401
+ () => ({ textErrors }),
402
+ () => this.handleErrors()
403
+ );
404
+
405
+ private onFocus = () => {
406
+ this.props.onFocus?.();
407
+ if (!this.state.suggestionsVisible) {
408
+ this.props.onSuggestionsOpened?.();
409
+ }
410
+ this.fetchExistingTags(this.state.value);
411
+ this.setState(
412
+ () => ({ textIsFocused: true, suggestionsVisible: true, touched: true }),
413
+ () => this.handleErrors()
414
+ );
415
+ const showMobileVersion =
416
+ this.props.mobileVersionEnabled &&
417
+ this.isMobile &&
418
+ (this.state.textIsFocused || this.state.suggestionsVisible);
419
+ if (
420
+ !showMobileVersion &&
421
+ this.props.mobileVersionEnabled &&
422
+ this.isMobile
423
+ ) {
424
+ setTimeout(() => this.textRef.current?.focus(), 100);
425
+ }
426
+ };
427
+
428
+ private onKeyDown = (suggestions: T[]) => async (e: React.KeyboardEvent) => {
429
+ if (e.key === 'Tab') {
430
+ this.setState({
431
+ suggestionsVisible: false,
432
+ preselectedSuggestion: undefined,
433
+ });
434
+ }
435
+ if (
436
+ e.key === 'Enter' &&
437
+ (this.state.value !== '' ||
438
+ this.state.preselectedSuggestion !== undefined) &&
439
+ this.state.textErrors.length === 0
440
+ ) {
441
+ e.preventDefault();
442
+ e.stopPropagation();
443
+ const existingTag =
444
+ this.props.existingTags &&
445
+ this.props.existingTags.find((et) => et.name === this.state.value);
446
+ if (this.state.preselectedSuggestion !== undefined) {
447
+ this.props.onTagsChanged(
448
+ this.props.tags.concat(suggestions[this.state.preselectedSuggestion])
449
+ );
450
+ this.setState({ value: '', preselectedSuggestion: undefined }, () => {
451
+ this.fetchExistingTags();
452
+ this.handleErrors();
453
+ });
454
+ } else if (existingTag) {
455
+ this.props.onTagsChanged(this.props.tags.concat(existingTag));
456
+ this.setState({ value: '' }, () => {
457
+ this.fetchExistingTags();
458
+ this.handleErrors();
459
+ });
460
+ } else if (this.props.allowNew) {
461
+ await this.addNewTag();
462
+ this.handleErrors();
463
+ }
464
+ }
465
+ if (suggestions.length > 0 && this.state.suggestionsVisible) {
466
+ if (e.key === 'ArrowUp') {
467
+ const preselectedSuggestion =
468
+ this.state.preselectedSuggestion === undefined
469
+ ? suggestions.length - 1
470
+ : this.state.preselectedSuggestion === 0
471
+ ? suggestions.length - 1
472
+ : this.state.preselectedSuggestion - 1;
473
+ this.setState({ preselectedSuggestion });
474
+ } else if (e.key === 'ArrowDown') {
475
+ const preselectedSuggestion =
476
+ this.state.preselectedSuggestion === undefined
477
+ ? 0
478
+ : this.state.preselectedSuggestion === suggestions.length - 1
479
+ ? 0
480
+ : this.state.preselectedSuggestion + 1;
481
+ this.setState({ preselectedSuggestion });
482
+ } else {
483
+ this.setState({ preselectedSuggestion: undefined });
484
+ }
485
+ }
486
+ };
487
+
488
+ private addNewTag = async () => {
489
+ const newTag = await this.props.onNewTagAdded(this.state.value);
490
+ this.setState({
491
+ suggestionsVisible: this.props.closeSuggestionsAfterCreate
492
+ ? false
493
+ : this.state.suggestionsVisible,
494
+ });
495
+ if (newTag) {
496
+ this.props.onTagsChanged(
497
+ this.props.tags ? this.props.tags.concat(newTag) : [newTag]
498
+ );
499
+ }
500
+ this.setState({ value: '', textErrors: [] }, () => {
501
+ this.fetchExistingTags();
502
+ this.handleErrors();
503
+ });
504
+ };
505
+
506
+ private onSuggestionSelected = (tag: T, lastSelected: boolean) => {
507
+ const newTags = this.props.tags.concat(tag);
508
+ this.props.onTagsChanged(newTags);
509
+ const isMax = newTags.length === this.props.maxTags;
510
+ const finalValue =
511
+ !this.props.allowNew && !isMax && !lastSelected ? this.state.value : '';
512
+ this.setState(
513
+ {
514
+ value: finalValue,
515
+ suggestionsVisible:
516
+ isMax || this.props.closeSuggestionsAfterCreate
517
+ ? false
518
+ : this.state.suggestionsVisible,
519
+ preselectedSuggestion: undefined,
520
+ textErrors: [],
521
+ },
522
+ () => {
523
+ if (
524
+ !this.props.maxTags ||
525
+ this.props.tags.length + 1 < this.props.maxTags
526
+ ) {
527
+ this.fetchExistingTags(finalValue);
528
+ }
529
+ this.handleErrors();
530
+ }
531
+ );
532
+ };
533
+
534
+ private onBlur = () => {
535
+ this.props.onBlur?.();
536
+ this.setState(
537
+ {
538
+ textIsFocused: false,
539
+ preselectedSuggestion: undefined,
540
+ },
541
+ () => this.handleErrors()
542
+ );
543
+ };
544
+
545
+ private onTextChanged = (
546
+ e: React.ChangeEvent<HTMLInputElement>,
547
+ isValid: boolean
548
+ ) => {
549
+ const value = e.target.value;
550
+ this.setState(
551
+ () => ({
552
+ value,
553
+ isValid: isValid,
554
+ textIsValid: isValid,
555
+ suggestionsVisible: true,
556
+ }),
557
+ () => this.handleErrors()
558
+ );
559
+ this.fetchExistingTags(e.target.value);
560
+ };
561
+
562
+ private handleErrors = (tags: T[] = this.props.tags) => {
563
+ let errors = this.getErrors(tags);
564
+ if (errors.length > 0) {
565
+ this.setInvalid(errors);
566
+ } else {
567
+ this.setValid();
568
+ }
569
+ };
570
+
571
+ private getErrors(tags: T[]) {
572
+ let errors = [];
573
+ if (tags.length < this.props.maxTags) {
574
+ errors = errors.concat(this.state.textErrors);
575
+ }
576
+ if (this.state.value !== '' && tags.length === 0 && this.props.required) {
577
+ errors = errors.concat(
578
+ this.getTranslations(this.props.translations).required
579
+ );
580
+ }
581
+ if (this.state.value && this.props.allowNew && !this.state.textIsFocused) {
582
+ errors = errors.concat(this.props.valueNotAddedError);
583
+ }
584
+ if (this.props.maxTags < (this.props.tags && this.props.tags.length)) {
585
+ errors = errors.concat(this.props.maxTagsSurpassedError);
586
+ }
587
+ return errors.filter((i) => i);
588
+ }
589
+
590
+ private fetchExistingTags(startsWith: string = '') {
591
+ if (
592
+ this.props.fetchExistingTags &&
593
+ startsWith.length >= this.props.minLettersToFetch
594
+ ) {
595
+ const timer = setTimeout(
596
+ () => this.setState(() => ({ fetchingExistingTags: true })),
597
+ this.props.loadingDelayMs
598
+ );
599
+ this.props.fetchExistingTags(startsWith).then((fetchedExistingTags) => {
600
+ clearTimeout(timer);
601
+ this.setState(() => ({
602
+ fetchedExistingTags,
603
+ fetchingExistingTags: false,
604
+ }));
605
+ });
606
+ }
607
+ }
608
+
609
+ private getSuggestions() {
610
+ const existingTags: T[] = []
611
+ .concat(this.props.existingTags ? this.props.existingTags : [])
612
+ .concat(
613
+ this.state.fetchedExistingTags ? this.state.fetchedExistingTags : []
614
+ );
615
+ const filteredTags = this.props.filterExistingTags(
616
+ this.state.value ? this.state.value.toLowerCase() : '',
617
+ existingTags
618
+ );
619
+ let suggestions = filteredTags
620
+ .filter(
621
+ (tag) =>
622
+ this.props.allowSameTagMultipleTimes ||
623
+ !this.props.tags.some((t) => t.id === tag.id)
624
+ )
625
+ .slice(0, this.props.maxSuggestions);
626
+ return suggestions;
627
+ }
628
+
629
+ private renderTag(tag: T, index: number) {
630
+ const body = (
631
+ <>
632
+ {tag.name}
633
+ {!this.props.readOnly && (
634
+ <Button
635
+ {...(this.props.id && {
636
+ id: this.props.id + '-tag-' + index.toString(),
637
+ })}
638
+ circular={true}
639
+ blank={true}
640
+ onClick={this.tagRemoveClick(tag)}
641
+ className="ml-1 transform-rotate--45 line-height--0 p-0"
642
+ Component={TagButtonComponent}
643
+ preventsDefault={false}
644
+ >
645
+ <PlusIcon />
646
+ </Button>
647
+ )}
648
+ </>
649
+ );
650
+ const className = classNames('tags-input__tag', {
651
+ 'tags-input__tag-chip': this.props.showChips,
652
+ });
653
+ if (this.props.onTagClick) {
654
+ return (
655
+ <Button
656
+ onClick={this.tagClick(tag)}
657
+ small={true}
658
+ className={className}
659
+ key={index}
660
+ >
661
+ {body}
662
+ </Button>
663
+ );
664
+ }
665
+ return (
666
+ <div onClick={this.tagClick(tag)} className={className} key={index}>
667
+ {body}
668
+ </div>
669
+ );
670
+ }
671
+
672
+ private tagClick = (tag: T) => () => {
673
+ this.props.onTagClick && this.props.onTagClick(tag);
674
+ };
675
+
676
+ private tagRemoveClick = (tag: T) => (e: React.MouseEvent<HTMLElement>) => {
677
+ e.stopPropagation();
678
+ const newTags = this.props.tags.filter((sv) => sv.id !== tag.id);
679
+ /*if (newTags.length === 0) {
680
+ setTimeout(() => this.focus(), 50);
681
+ }
682
+ this.setState({
683
+ suggestionsVisible: false,
684
+ });*/
685
+ this.props.onTagsChanged && this.props.onTagsChanged(newTags);
686
+ this.handleErrors(newTags);
687
+ // this.fetchExistingTags();
688
+ };
689
+ }
690
+
691
+ interface TagsFinal {
692
+ <T extends Tag = Tag>(item: TagsProps<T>): React.ReactElement;
693
+ defaultProps?: Partial<TagsProps>;
694
+ }
695
+
696
+ export const Tags = withThemeContext<TagsProps, InstanceType<typeof TagsRaw>>(
697
+ // tslint:disable-next-line: no-any
698
+ withFormContext<TagsProps>(TagsRaw),
699
+ 'tags'
700
+ ) as unknown as TagsFinal;
701
+
702
+ export default Tags;
@@ -0,0 +1,2 @@
1
+ export * from './Tags';
2
+ export { default } from './Tags';