@dr.pogodin/react-utils 1.46.2 → 1.47.0-alpha.11

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 (332) hide show
  1. package/babel.config.js +1 -0
  2. package/babel.libweb.config.js +16 -0
  3. package/babel.module.config.js +11 -0
  4. package/bin/build.js +21 -11
  5. package/bin/setup.js +11 -9
  6. package/build/development/client/getInj.js +57 -44
  7. package/build/development/client/getInj.js.map +1 -1
  8. package/build/development/client/index.js +15 -21
  9. package/build/development/client/index.js.map +1 -1
  10. package/build/development/client/init.js +2 -6
  11. package/build/development/client/init.js.map +1 -1
  12. package/build/development/index.js +3 -177
  13. package/build/development/index.js.map +1 -1
  14. package/build/development/server/Cache.js +1 -8
  15. package/build/development/server/Cache.js.map +1 -1
  16. package/build/development/server/index.js +22 -45
  17. package/build/development/server/index.js.map +1 -1
  18. package/build/development/server/renderer.js +84 -86
  19. package/build/development/server/renderer.js.map +1 -1
  20. package/build/development/server/server.js +58 -60
  21. package/build/development/server/server.js.map +1 -1
  22. package/build/development/server/utils/errors.js +8 -31
  23. package/build/development/server/utils/errors.js.map +1 -1
  24. package/build/development/server/utils/index.js +2 -9
  25. package/build/development/server/utils/index.js.map +1 -1
  26. package/build/development/shared/components/Button/index.js +15 -22
  27. package/build/development/shared/components/Button/index.js.map +1 -1
  28. package/build/development/shared/components/Checkbox/index.js +14 -21
  29. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  30. package/build/development/shared/components/GenericLink/index.js +9 -11
  31. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  32. package/build/development/shared/components/Input/index.js +21 -27
  33. package/build/development/shared/components/Input/index.js.map +1 -1
  34. package/build/development/shared/components/Link.js +6 -13
  35. package/build/development/shared/components/Link.js.map +1 -1
  36. package/build/development/shared/components/Modal/index.js +24 -28
  37. package/build/development/shared/components/Modal/index.js.map +1 -1
  38. package/build/development/shared/components/NavLink.js +6 -13
  39. package/build/development/shared/components/NavLink.js.map +1 -1
  40. package/build/development/shared/components/PageLayout/index.js +13 -20
  41. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  42. package/build/development/shared/components/TextArea/index.js +28 -31
  43. package/build/development/shared/components/TextArea/index.js.map +1 -1
  44. package/build/development/shared/components/Throbber/index.js +13 -20
  45. package/build/development/shared/components/Throbber/index.js.map +1 -1
  46. package/build/development/shared/components/WithTooltip/Tooltip.js +13 -18
  47. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  48. package/build/development/shared/components/WithTooltip/index.js +23 -30
  49. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  50. package/build/development/shared/components/YouTubeVideo/index.js +19 -26
  51. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  52. package/build/development/shared/components/index.js +16 -130
  53. package/build/development/shared/components/index.js.map +1 -1
  54. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +19 -20
  55. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  56. package/build/development/shared/components/selectors/CustomDropdown/index.js +35 -39
  57. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  58. package/build/development/shared/components/selectors/NativeDropdown/index.js +31 -31
  59. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  60. package/build/development/shared/components/selectors/Switch/index.js +19 -24
  61. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  62. package/build/development/shared/components/selectors/common.js +1 -7
  63. package/build/development/shared/components/selectors/common.js.map +1 -1
  64. package/build/development/shared/components/selectors/index.js +3 -27
  65. package/build/development/shared/components/selectors/index.js.map +1 -1
  66. package/build/development/shared/utils/config.js +40 -21
  67. package/build/development/shared/utils/config.js.map +1 -1
  68. package/build/development/shared/utils/globalState.js +3 -8
  69. package/build/development/shared/utils/globalState.js.map +1 -1
  70. package/build/development/shared/utils/index.js +12 -89
  71. package/build/development/shared/utils/index.js.map +1 -1
  72. package/build/development/shared/utils/isomorphy/buildInfo.js +2 -9
  73. package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
  74. package/build/development/shared/utils/isomorphy/environment-check.js +2 -8
  75. package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
  76. package/build/development/shared/utils/isomorphy/index.js +7 -32
  77. package/build/development/shared/utils/isomorphy/index.js.map +1 -1
  78. package/build/development/shared/utils/jest/E2eSsrEnv.js +34 -37
  79. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  80. package/build/development/shared/utils/jest/global.js +1 -7
  81. package/build/development/shared/utils/jest/global.js.map +1 -1
  82. package/build/development/shared/utils/jest/index.js +20 -44
  83. package/build/development/shared/utils/jest/index.js.map +1 -1
  84. package/build/development/shared/utils/splitComponent.js +54 -45
  85. package/build/development/shared/utils/splitComponent.js.map +1 -1
  86. package/build/development/shared/utils/time.js +22 -31
  87. package/build/development/shared/utils/time.js.map +1 -1
  88. package/build/development/shared/utils/webpack.js +17 -16
  89. package/build/development/shared/utils/webpack.js.map +1 -1
  90. package/build/production/client/getInj.js +13 -11
  91. package/build/production/client/getInj.js.map +1 -1
  92. package/build/production/client/index.js +3 -3
  93. package/build/production/client/index.js.map +1 -1
  94. package/build/production/client/init.js +2 -2
  95. package/build/production/client/init.js.map +1 -1
  96. package/build/production/index.js +2 -3
  97. package/build/production/index.js.map +1 -1
  98. package/build/production/server/Cache.js +3 -3
  99. package/build/production/server/Cache.js.map +1 -1
  100. package/build/production/server/index.js +8 -8
  101. package/build/production/server/index.js.map +1 -1
  102. package/build/production/server/renderer.js +24 -25
  103. package/build/production/server/renderer.js.map +1 -1
  104. package/build/production/server/server.js +9 -11
  105. package/build/production/server/server.js.map +1 -1
  106. package/build/production/server/utils/errors.js +9 -9
  107. package/build/production/server/utils/errors.js.map +1 -1
  108. package/build/production/server/utils/index.js +2 -1
  109. package/build/production/server/utils/index.js.map +1 -1
  110. package/build/production/shared/components/Button/index.js +4 -4
  111. package/build/production/shared/components/Button/index.js.map +1 -1
  112. package/build/production/shared/components/Checkbox/index.js +1 -1
  113. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  114. package/build/production/shared/components/GenericLink/index.js +4 -4
  115. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  116. package/build/production/shared/components/Input/index.js +5 -5
  117. package/build/production/shared/components/Input/index.js.map +1 -1
  118. package/build/production/shared/components/Link.js +3 -3
  119. package/build/production/shared/components/Link.js.map +1 -1
  120. package/build/production/shared/components/Modal/index.js +7 -7
  121. package/build/production/shared/components/Modal/index.js.map +1 -1
  122. package/build/production/shared/components/NavLink.js +2 -2
  123. package/build/production/shared/components/NavLink.js.map +1 -1
  124. package/build/production/shared/components/PageLayout/index.js +2 -2
  125. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  126. package/build/production/shared/components/TextArea/index.js +5 -5
  127. package/build/production/shared/components/TextArea/index.js.map +1 -1
  128. package/build/production/shared/components/Throbber/index.js +2 -2
  129. package/build/production/shared/components/Throbber/index.js.map +1 -1
  130. package/build/production/shared/components/WithTooltip/Tooltip.js +4 -4
  131. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  132. package/build/production/shared/components/WithTooltip/index.js +4 -4
  133. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  134. package/build/production/shared/components/YouTubeVideo/index.js +4 -4
  135. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  136. package/build/production/shared/components/index.js +3 -1
  137. package/build/production/shared/components/index.js.map +1 -1
  138. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
  139. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  140. package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
  141. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  142. package/build/production/shared/components/selectors/NativeDropdown/index.js +4 -4
  143. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  144. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  145. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  146. package/build/production/shared/components/selectors/common.js +2 -2
  147. package/build/production/shared/components/selectors/common.js.map +1 -1
  148. package/build/production/shared/components/selectors/index.js +1 -1
  149. package/build/production/shared/components/selectors/index.js.map +1 -1
  150. package/build/production/shared/utils/config.js +8 -6
  151. package/build/production/shared/utils/config.js.map +1 -1
  152. package/build/production/shared/utils/globalState.js +2 -2
  153. package/build/production/shared/utils/globalState.js.map +1 -1
  154. package/build/production/shared/utils/index.js +1 -1
  155. package/build/production/shared/utils/index.js.map +1 -1
  156. package/build/production/shared/utils/isomorphy/buildInfo.js +3 -3
  157. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  158. package/build/production/shared/utils/isomorphy/environment-check.js +3 -3
  159. package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
  160. package/build/production/shared/utils/isomorphy/index.js +4 -4
  161. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  162. package/build/production/shared/utils/jest/E2eSsrEnv.js +16 -15
  163. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  164. package/build/production/shared/utils/jest/global.js +1 -1
  165. package/build/production/shared/utils/jest/global.js.map +1 -1
  166. package/build/production/shared/utils/jest/index.js +11 -11
  167. package/build/production/shared/utils/jest/index.js.map +1 -1
  168. package/build/production/shared/utils/splitComponent.js +11 -22
  169. package/build/production/shared/utils/splitComponent.js.map +1 -1
  170. package/build/production/shared/utils/time.js +3 -3
  171. package/build/production/shared/utils/time.js.map +1 -1
  172. package/build/production/shared/utils/webpack.js +6 -6
  173. package/build/production/shared/utils/webpack.js.map +1 -1
  174. package/build/types-code/client/getInj.d.ts +1 -2
  175. package/build/types-code/client/index.d.ts +1 -1
  176. package/build/types-code/index.d.ts +1 -7
  177. package/build/types-code/server/index.d.ts +6 -11
  178. package/build/types-code/server/utils/index.d.ts +1 -1
  179. package/build/types-code/shared/utils/config.d.ts +4 -2
  180. package/build/types-code/shared/utils/index.d.ts +2 -2
  181. package/build/types-code/shared/utils/splitComponent.d.ts +6 -4
  182. package/build/web/client/getInj.js +65 -0
  183. package/build/web/client/getInj.js.map +1 -0
  184. package/{src/client/index.tsx → build/web/client/index.js} +13 -24
  185. package/build/web/client/index.js.map +1 -0
  186. package/{src/client/init.ts → build/web/client/init.js} +9 -14
  187. package/build/web/client/init.js.map +1 -0
  188. package/build/web/index.js +11 -0
  189. package/build/web/index.js.map +1 -0
  190. package/{src/server/Cache.ts → build/web/server/Cache.js} +15 -22
  191. package/build/web/server/Cache.js.map +1 -0
  192. package/{src/server/index.ts → build/web/server/index.js} +32 -81
  193. package/build/web/server/index.js.map +1 -0
  194. package/{src/server/renderer.tsx → build/web/server/renderer.js} +188 -333
  195. package/build/web/server/renderer.js.map +1 -0
  196. package/{src/server/server.ts → build/web/server/server.js} +82 -182
  197. package/build/web/server/server.js.map +1 -0
  198. package/{src/server/utils/errors.ts → build/web/server/utils/errors.js} +6 -25
  199. package/build/web/server/utils/errors.js.map +1 -0
  200. package/build/web/server/utils/index.js +4 -0
  201. package/build/web/server/utils/index.js.map +1 -0
  202. package/build/web/shared/components/Button/index.js +90 -0
  203. package/build/web/shared/components/Button/index.js.map +1 -0
  204. package/build/web/shared/components/Checkbox/index.js +35 -0
  205. package/build/web/shared/components/Checkbox/index.js.map +1 -0
  206. package/{src/shared/components/GenericLink/index.tsx → build/web/shared/components/GenericLink/index.js} +44 -78
  207. package/build/web/shared/components/GenericLink/index.js.map +1 -0
  208. package/build/web/shared/components/Input/index.js +71 -0
  209. package/build/web/shared/components/Input/index.js.map +1 -0
  210. package/build/web/shared/components/Link.js +20 -0
  211. package/build/web/shared/components/Link.js.map +1 -0
  212. package/{src → build/web}/shared/components/Modal/base-theme.scss +1 -1
  213. package/build/web/shared/components/Modal/index.js +128 -0
  214. package/build/web/shared/components/Modal/index.js.map +1 -0
  215. package/build/web/shared/components/NavLink.js +13 -0
  216. package/build/web/shared/components/NavLink.js.map +1 -0
  217. package/{src → build/web}/shared/components/PageLayout/base-theme.scss +1 -1
  218. package/{src/shared/components/PageLayout/index.tsx → build/web/shared/components/PageLayout/index.js} +20 -33
  219. package/build/web/shared/components/PageLayout/index.js.map +1 -0
  220. package/build/web/shared/components/TextArea/index.js +106 -0
  221. package/build/web/shared/components/TextArea/index.js.map +1 -0
  222. package/build/web/shared/components/Throbber/index.js +26 -0
  223. package/build/web/shared/components/Throbber/index.js.map +1 -0
  224. package/{src/shared/components/WithTooltip/Tooltip.tsx → build/web/shared/components/WithTooltip/Tooltip.js} +61 -109
  225. package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -0
  226. package/build/web/shared/components/WithTooltip/index.js +117 -0
  227. package/build/web/shared/components/WithTooltip/index.js.map +1 -0
  228. package/{src/shared/components/YouTubeVideo/index.tsx → build/web/shared/components/YouTubeVideo/index.js} +23 -40
  229. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -0
  230. package/build/web/shared/components/index.js +18 -0
  231. package/build/web/shared/components/index.js.map +1 -0
  232. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +82 -0
  233. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
  234. package/{src/shared/components/selectors/CustomDropdown/index.tsx → build/web/shared/components/selectors/CustomDropdown/index.js} +56 -80
  235. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -0
  236. package/{src/shared/components/selectors/NativeDropdown/index.tsx → build/web/shared/components/selectors/NativeDropdown/index.js} +39 -44
  237. package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -0
  238. package/build/web/shared/components/selectors/Switch/index.js +50 -0
  239. package/build/web/shared/components/selectors/Switch/index.js.map +1 -0
  240. package/build/web/shared/components/selectors/common.js +12 -0
  241. package/build/web/shared/components/selectors/common.js.map +1 -0
  242. package/build/web/shared/components/selectors/index.js +4 -0
  243. package/build/web/shared/components/selectors/index.js.map +1 -0
  244. package/build/web/shared/utils/config.js +45 -0
  245. package/build/web/shared/utils/config.js.map +1 -0
  246. package/build/web/shared/utils/globalState.js +15 -0
  247. package/build/web/shared/utils/globalState.js.map +1 -0
  248. package/build/web/shared/utils/index.js +13 -0
  249. package/build/web/shared/utils/index.js.map +1 -0
  250. package/{src/shared/utils/isomorphy/buildInfo.ts → build/web/shared/utils/isomorphy/buildInfo.js} +4 -10
  251. package/build/web/shared/utils/isomorphy/buildInfo.js.map +1 -0
  252. package/build/web/shared/utils/isomorphy/environment-check.js +17 -0
  253. package/build/web/shared/utils/isomorphy/environment-check.js.map +1 -0
  254. package/{src/shared/utils/isomorphy/index.ts → build/web/shared/utils/isomorphy/index.js} +6 -6
  255. package/build/web/shared/utils/isomorphy/index.js.map +1 -0
  256. package/{src/shared/utils/jest/E2eSsrEnv.ts → build/web/shared/utils/jest/E2eSsrEnv.js} +73 -140
  257. package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -0
  258. package/build/web/shared/utils/jest/global.js +4 -0
  259. package/build/web/shared/utils/jest/global.js.map +1 -0
  260. package/{src/shared/utils/jest/index.ts → build/web/shared/utils/jest/index.js} +33 -83
  261. package/build/web/shared/utils/jest/index.js.map +1 -0
  262. package/{src/shared/utils/splitComponent.tsx → build/web/shared/utils/splitComponent.js} +77 -124
  263. package/build/web/shared/utils/splitComponent.js.map +1 -0
  264. package/{src/shared/utils/time.ts → build/web/shared/utils/time.js} +21 -37
  265. package/build/web/shared/utils/time.js.map +1 -0
  266. package/build/web/shared/utils/webpack.js +67 -0
  267. package/build/web/shared/utils/webpack.js.map +1 -0
  268. package/config/babel/node-ssr.js +12 -3
  269. package/config/babel/webpack.js +6 -1
  270. package/config/jest/default.js +8 -2
  271. package/config/jest/setup.js +8 -1
  272. package/config/webpack/app-base.js +25 -14
  273. package/config/webpack/app-development.js +2 -2
  274. package/config/webpack/lib-base.js +1 -2
  275. package/package.json +41 -42
  276. package/types.d.ts +1 -6
  277. package/build/development/__chunk_groups__.json +0 -6
  278. package/build/development/style.css +0 -909
  279. package/build/development/web.bundle.js +0 -752
  280. package/build/production/__chunk_groups__.json +0 -6
  281. package/build/production/style.css +0 -2
  282. package/build/production/style.css.map +0 -1
  283. package/build/production/web.bundle.js +0 -3
  284. package/build/production/web.bundle.js.LICENSE.txt +0 -9
  285. package/build/production/web.bundle.js.map +0 -1
  286. package/dev-styles.js +0 -1
  287. package/node-entry.js +0 -15
  288. package/null.js +0 -1
  289. package/prod-styles.js +0 -1
  290. package/src/client/getInj.ts +0 -51
  291. package/src/index.ts +0 -73
  292. package/src/server/utils/index.ts +0 -3
  293. package/src/shared/components/Button/index.tsx +0 -130
  294. package/src/shared/components/Checkbox/index.tsx +0 -53
  295. package/src/shared/components/Input/index.tsx +0 -96
  296. package/src/shared/components/Link.tsx +0 -25
  297. package/src/shared/components/Modal/index.tsx +0 -177
  298. package/src/shared/components/NavLink.tsx +0 -18
  299. package/src/shared/components/TextArea/index.tsx +0 -139
  300. package/src/shared/components/Throbber/index.tsx +0 -28
  301. package/src/shared/components/WithTooltip/index.tsx +0 -186
  302. package/src/shared/components/index.ts +0 -20
  303. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +0 -124
  304. package/src/shared/components/selectors/Switch/index.tsx +0 -74
  305. package/src/shared/components/selectors/common.ts +0 -57
  306. package/src/shared/components/selectors/index.ts +0 -8
  307. package/src/shared/utils/config.ts +0 -28
  308. package/src/shared/utils/globalState.ts +0 -44
  309. package/src/shared/utils/index.ts +0 -45
  310. package/src/shared/utils/isomorphy/environment-check.ts +0 -18
  311. package/src/shared/utils/jest/global.ts +0 -17
  312. package/src/shared/utils/webpack.ts +0 -74
  313. /package/{src → build/web}/shared/components/Button/style.scss +0 -0
  314. /package/{src → build/web}/shared/components/Checkbox/theme.scss +0 -0
  315. /package/{src → build/web}/shared/components/GenericLink/style.scss +0 -0
  316. /package/{src → build/web}/shared/components/Input/theme.scss +0 -0
  317. /package/{src → build/web}/shared/components/Modal/styles.scss +0 -0
  318. /package/{src → build/web}/shared/components/TextArea/style.scss +0 -0
  319. /package/{src → build/web}/shared/components/Throbber/theme.scss +0 -0
  320. /package/{src → build/web}/shared/components/WithTooltip/default-theme.scss +0 -0
  321. /package/{src → build/web}/shared/components/YouTubeVideo/base.scss +0 -0
  322. /package/{src → build/web}/shared/components/YouTubeVideo/throbber.scss +0 -0
  323. /package/{src → build/web}/shared/components/selectors/CustomDropdown/Options/style.scss +0 -0
  324. /package/{src → build/web}/shared/components/selectors/CustomDropdown/theme.scss +0 -0
  325. /package/{src → build/web}/shared/components/selectors/NativeDropdown/theme.scss +0 -0
  326. /package/{src → build/web}/shared/components/selectors/Switch/theme.scss +0 -0
  327. /package/{src → build/web}/styles/_global/reset.css +0 -0
  328. /package/{src → build/web}/styles/_mixins/fonts.scss +0 -0
  329. /package/{src → build/web}/styles/_mixins/media.scss +0 -0
  330. /package/{src → build/web}/styles/_mixins/typography.scss +0 -0
  331. /package/{src → build/web}/styles/global.scss +0 -0
  332. /package/{src → build/web}/styles/mixins.scss +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["_httpStatusCodes","require","ErrorWithStatus","Error","status","CODES","INTERNAL_SERVER_ERROR","newError","message","statusCode","error","fail","assert","value","schema","BAD_REQUEST","result","validate","Promise","issues","JSON","stringify"],"sources":["../../../../src/server/utils/errors.ts"],"sourcesContent":["/**\n * @category Utilities\n * @module server/errors\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { errors } = server;\n * ```\n * Server-side helpers for error handling.\n */\n\nimport {\n StatusCodes as CODES,\n ReasonPhrases as ERRORS,\n getReasonPhrase as getErrorForCode,\n} from 'http-status-codes';\n\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\n/**\n * @static\n * @const CODES\n * @desc An alias for\n * [StatusCodes object from **http-status-codes** library](https://www.npmjs.com/package/http-status-codes).\n * It is a map between HTTP status code names and corresponding numeric codes.\n * @example\n * import { server } from '@dr.pogodin/react-utils';\n * const { CODES } = server.errors;\n * console.log(CODES.BAD_REQUEST); // Prints: 400\n */\nexport { CODES };\n\n/**\n * @static\n * @const ERRORS\n * @desc An alias for\n * [ReasonPhrases object from **http-status-codes** library](https://www.npmjs.com/package/http-status-codes).\n * It is a map between HTTP status code names and their pretty-printed forms.\n * @example\n * import { server } from '@dr.pogodin/react-utils';\n * const { ERRORS } = server.errors;\n * console.log(ERRORS.BAD_REQUEST); // Prints: Bad Request\n */\nexport { ERRORS };\n\n/**\n * @static\n * @func getErrorForCode\n * @desc An alias for\n * [getReasonPhrase() function from **http-status-codes** library](https://www.npmjs.com/package/http-status-codes).\n * Given an HTTP code it returns the corresponding error text.\n * @param {number} code HTTP code.\n * @return {string} HTTP error text.\n * @example\n * import { server } from '@dr.pogodin/react-utils';\n * console.log(server.errors.getErrorForCode(400)); // Prints: Bad Request\n */\nexport { getErrorForCode };\n\n// TODO: It could accept the status code as a constructor argument.\nclass ErrorWithStatus extends Error {\n status: number = CODES.INTERNAL_SERVER_ERROR;\n}\n\n/**\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { newError } = server.errors;\n * ```\n * Creates a new `Error` object with given message, and HTTP status code\n * attached as `status` field.\n * @param {string} message Error message.\n * @param {number} [statusCode=500] HTTP status code. Defaults to 500 (Internal\n * Server Error).\n * @return {Error}\n */\nexport function newError(\n message: string,\n statusCode = CODES.INTERNAL_SERVER_ERROR,\n): ErrorWithStatus {\n const error = new ErrorWithStatus(message);\n error.status = statusCode;\n return error;\n}\n\n/**\n * Throws an error with given message and HTTP status code.\n */\nexport function fail(\n message: string,\n statusCode: CODES = CODES.INTERNAL_SERVER_ERROR,\n): Error {\n throw newError(message, statusCode);\n}\n\n/**\n * Validates the `value` against the given \"standard\" validation `schema`.\n * Resolves to the correctly typed `value`, if it has passed the validation;\n * otherwise throws an error.\n * @param value The value to validate.\n * @param schema The \"standard\" validation schema to use.\n * @param [message] Optional error message, to prepend the validation error\n * message.\n * @param [statusCode=400] HTTP status code. Defaults to 400 (Bad Request).\n */\nexport async function assert<T extends StandardSchemaV1>(\n value: unknown,\n schema: T,\n message = '',\n statusCode = CODES.BAD_REQUEST,\n): Promise<StandardSchemaV1.InferOutput<T>> {\n let result = schema['~standard'].validate(value);\n if (result instanceof Promise) result = await result;\n\n if (result.issues) {\n let error = JSON.stringify(result.issues, null, 2);\n if (message) error = `${message}\\n\\n${error}`;\n throw fail(error, statusCode);\n }\n\n return result.value;\n}\n"],"mappings":"geAWA,IAAAA,gBAAA,CAAAC,OAAA,sBAXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAGA;AACA,KAAM,CAAAC,eAAe,QAAS,CAAAC,KAAM,CAClCC,MAAM,CAAWC,4BAAK,CAACC,qBACzB,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,QAAS,CAAAC,QAAQA,CACtBC,OAAe,CACfC,UAAU,CAAGJ,4BAAK,CAACC,qBAAqB,CACvB,CACjB,KAAM,CAAAI,KAAK,CAAG,GAAI,CAAAR,eAAe,CAACM,OAAO,CAAC,CAC1CE,KAAK,CAACN,MAAM,CAAGK,UAAU,CACzB,MAAO,CAAAC,KACT,CAEA;AACA;AACA,GACO,QAAS,CAAAC,IAAIA,CAClBH,OAAe,CACfC,UAAiB,CAAGJ,4BAAK,CAACC,qBAAqB,CACxC,CACP,KAAM,CAAAC,QAAQ,CAACC,OAAO,CAAEC,UAAU,CACpC,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,cAAe,CAAAG,MAAMA,CAC1BC,KAAc,CACdC,MAAS,CACTN,OAAO,CAAG,EAAE,CACZC,UAAU,CAAGJ,4BAAK,CAACU,WAAW,CACY,CAC1C,GAAI,CAAAC,MAAM,CAAGF,MAAM,CAAC,WAAW,CAAC,CAACG,QAAQ,CAACJ,KAAK,CAAC,CAChD,GAAIG,MAAM,WAAY,CAAAE,OAAO,CAAEF,MAAM,CAAG,KAAM,CAAAA,MAAM,CAEpD,GAAIA,MAAM,CAACG,MAAM,CAAE,CACjB,GAAI,CAAAT,KAAK,CAAGU,IAAI,CAACC,SAAS,CAACL,MAAM,CAACG,MAAM,CAAE,IAAI,CAAE,CAAC,CAAC,CAClD,GAAIX,OAAO,CAAEE,KAAK,CAAG,GAAGF,OAAO,OAAOE,KAAK,EAAE,CAC7C,KAAM,CAAAC,IAAI,CAACD,KAAK,CAAED,UAAU,CAC9B,CAEA,MAAO,CAAAO,MAAM,CAACH,KAChB","ignoreList":[]}
1
+ {"version":3,"file":"errors.js","names":["StatusCodes","CODES","ReasonPhrases","ERRORS","getReasonPhrase","getErrorForCode","ErrorWithStatus","Error","status","INTERNAL_SERVER_ERROR","newError","message","statusCode","error","fail","assert","value","schema","BAD_REQUEST","result","validate","Promise","issues","JSON","stringify"],"sources":["../../../../src/server/utils/errors.ts"],"sourcesContent":["/**\n * @category Utilities\n * @module server/errors\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { errors } = server;\n * ```\n * Server-side helpers for error handling.\n */\n\nimport {\n StatusCodes as CODES,\n ReasonPhrases as ERRORS,\n getReasonPhrase as getErrorForCode,\n} from 'http-status-codes';\n\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\n/**\n * @static\n * @const CODES\n * @desc An alias for\n * [StatusCodes object from **http-status-codes** library](https://www.npmjs.com/package/http-status-codes).\n * It is a map between HTTP status code names and corresponding numeric codes.\n * @example\n * import { server } from '@dr.pogodin/react-utils';\n * const { CODES } = server.errors;\n * console.log(CODES.BAD_REQUEST); // Prints: 400\n */\nexport { CODES };\n\n/**\n * @static\n * @const ERRORS\n * @desc An alias for\n * [ReasonPhrases object from **http-status-codes** library](https://www.npmjs.com/package/http-status-codes).\n * It is a map between HTTP status code names and their pretty-printed forms.\n * @example\n * import { server } from '@dr.pogodin/react-utils';\n * const { ERRORS } = server.errors;\n * console.log(ERRORS.BAD_REQUEST); // Prints: Bad Request\n */\nexport { ERRORS };\n\n/**\n * @static\n * @func getErrorForCode\n * @desc An alias for\n * [getReasonPhrase() function from **http-status-codes** library](https://www.npmjs.com/package/http-status-codes).\n * Given an HTTP code it returns the corresponding error text.\n * @param {number} code HTTP code.\n * @return {string} HTTP error text.\n * @example\n * import { server } from '@dr.pogodin/react-utils';\n * console.log(server.errors.getErrorForCode(400)); // Prints: Bad Request\n */\nexport { getErrorForCode };\n\n// TODO: It could accept the status code as a constructor argument.\nclass ErrorWithStatus extends Error {\n status: number = CODES.INTERNAL_SERVER_ERROR;\n}\n\n/**\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { newError } = server.errors;\n * ```\n * Creates a new `Error` object with given message, and HTTP status code\n * attached as `status` field.\n * @param {string} message Error message.\n * @param {number} [statusCode=500] HTTP status code. Defaults to 500 (Internal\n * Server Error).\n * @return {Error}\n */\nexport function newError(\n message: string,\n statusCode = CODES.INTERNAL_SERVER_ERROR,\n): ErrorWithStatus {\n const error = new ErrorWithStatus(message);\n error.status = statusCode;\n return error;\n}\n\n/**\n * Throws an error with given message and HTTP status code.\n */\nexport function fail(\n message: string,\n statusCode: CODES = CODES.INTERNAL_SERVER_ERROR,\n): Error {\n throw newError(message, statusCode);\n}\n\n/**\n * Validates the `value` against the given \"standard\" validation `schema`.\n * Resolves to the correctly typed `value`, if it has passed the validation;\n * otherwise throws an error.\n * @param value The value to validate.\n * @param schema The \"standard\" validation schema to use.\n * @param [message] Optional error message, to prepend the validation error\n * message.\n * @param [statusCode=400] HTTP status code. Defaults to 400 (Bad Request).\n */\nexport async function assert<T extends StandardSchemaV1>(\n value: unknown,\n schema: T,\n message = '',\n statusCode = CODES.BAD_REQUEST,\n): Promise<StandardSchemaV1.InferOutput<T>> {\n let result = schema['~standard'].validate(value);\n if (result instanceof Promise) result = await result;\n\n if (result.issues) {\n let error = JSON.stringify(result.issues, null, 2);\n if (message) error = `${message}\\n\\n${error}`;\n throw fail(error, statusCode);\n }\n\n return result.value;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,OACEA,WAAW,GAAI,CAAAC,KAAK,CACpBC,aAAa,GAAI,CAAAC,MAAM,CACvBC,eAAe,GAAI,CAAAC,eAAe,KAC7B,mBAAmB,CAI1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,OAASJ,KAAK,EAEd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,OAASE,MAAM,EAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,OAASE,eAAe,EAExB;AACA,KAAM,CAAAC,eAAe,QAAS,CAAAC,KAAM,CAClCC,MAAM,CAAWP,KAAK,CAACQ,qBACzB,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,CAAAC,QAAQA,CACtBC,OAAe,CACfC,UAAU,CAAGX,KAAK,CAACQ,qBAAqB,CACvB,CACjB,KAAM,CAAAI,KAAK,CAAG,GAAI,CAAAP,eAAe,CAACK,OAAO,CAAC,CAC1CE,KAAK,CAACL,MAAM,CAAGI,UAAU,CACzB,MAAO,CAAAC,KACT,CAEA;AACA;AACA,GACA,MAAO,SAAS,CAAAC,IAAIA,CAClBH,OAAe,CACfC,UAAiB,CAAGX,KAAK,CAACQ,qBAAqB,CACxC,CACP,KAAM,CAAAC,QAAQ,CAACC,OAAO,CAAEC,UAAU,CACpC,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,eAAe,CAAAG,MAAMA,CAC1BC,KAAc,CACdC,MAAS,CACTN,OAAO,CAAG,EAAE,CACZC,UAAU,CAAGX,KAAK,CAACiB,WAAW,CACY,CAC1C,GAAI,CAAAC,MAAM,CAAGF,MAAM,CAAC,WAAW,CAAC,CAACG,QAAQ,CAACJ,KAAK,CAAC,CAChD,GAAIG,MAAM,WAAY,CAAAE,OAAO,CAAEF,MAAM,CAAG,KAAM,CAAAA,MAAM,CAEpD,GAAIA,MAAM,CAACG,MAAM,CAAE,CACjB,GAAI,CAAAT,KAAK,CAAGU,IAAI,CAACC,SAAS,CAACL,MAAM,CAACG,MAAM,CAAE,IAAI,CAAE,CAAC,CAAC,CAClD,GAAIX,OAAO,CAAEE,KAAK,CAAG,GAAGF,OAAO,OAAOE,KAAK,EAAE,CAC7C,KAAM,CAAAC,IAAI,CAACD,KAAK,CAAED,UAAU,CAC9B,CAEA,MAAO,CAAAO,MAAM,CAACH,KAChB","ignoreList":[]}
@@ -1,2 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.errors=void 0;var _errors=_interopRequireWildcard(require("./errors"));exports.errors=_errors;function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?o(f,t,i):f[t]=e[t]);return f})(e,t)}
1
+ // Aggregates utility modules together.
2
+ export*from"./errors.js";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/server/utils/index.ts"],"sourcesContent":["// Aggregates utility modules together.\n\nexport * as errors from './errors';\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/server/utils/index.ts"],"sourcesContent":["// Aggregates utility modules together.\n\nexport * from './errors';\n"],"mappings":"AAAA;AAAA","ignoreList":[]}
@@ -1,14 +1,14 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.BaseButton=void 0;var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _Link=_interopRequireDefault(require("../Link"));var _jsxRuntime=require("react/jsx-runtime");// The <Button> component implements a standard button / button-like link.
2
- const defaultTheme={"context":"KM0v4f","ad":"_3jm1-Q","hoc":"_0plpDL","button":"E1FNQT","active":"MAe9O6","disabled":"Br9IWV"};const BaseButton=({active,children,disabled,enforceA,onClick,onKeyDown:onKeyDownProp,onKeyUp,onMouseDown,onMouseUp,onPointerDown,onPointerUp,openNewTab,replace,testId,theme,to})=>{let className=theme.button;if(active&&theme.active)className+=` ${theme.active}`;if(disabled){if(theme.disabled)className+=` ${theme.disabled}`;return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,children:children})}let onKeyDown=onKeyDownProp;if(!onKeyDown&&onClick){onKeyDown=e=>{if(e.key==="Enter")onClick(e)}}if(to){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_Link.default,{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,enforceA:enforceA,onClick:onClick// TODO: For now, the `onKeyDown` handler is not passed to the <Link>,
1
+ // The <Button> component implements a standard button / button-like link.
2
+ import themed from"@dr.pogodin/react-themes";import Link from"../Link.js";const defaultTheme={"context":"_0S7CYa","ad":"YFXz0-","hoc":"BElFuo","button":"hXiBOw","active":"biX-UA","disabled":"_-6CH9q"};import{jsx as _jsx}from"react/jsx-runtime";export const BaseButton=({active,children,disabled,enforceA,onClick,onKeyDown:onKeyDownProp,onKeyUp,onMouseDown,onMouseUp,onPointerDown,onPointerUp,openNewTab,replace,testId,theme,to})=>{let className=theme.button;if(active&&theme.active)className+=` ${theme.active}`;if(disabled){if(theme.disabled)className+=` ${theme.disabled}`;return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,children:children})}let onKeyDown=onKeyDownProp;if(!onKeyDown&&onClick){onKeyDown=e=>{if(e.key==="Enter")onClick(e)}}if(to){return/*#__PURE__*/_jsx(Link,{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,enforceA:enforceA,onClick:onClick// TODO: For now, the `onKeyDown` handler is not passed to the <Link>,
3
3
  // as <Link> component does not call it anyway, presumably due to
4
4
  // the inner implementation details. We should look into supporting it:
5
5
  // https://github.com/birdofpreyru/react-utils/issues/444
6
6
  // onKeyDown={onKeyDown}
7
- ,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,openNewTab:openNewTab,replace:replace,to:to,children:children})}return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:onClick,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,role:"button",tabIndex:0,children:children})};/**
7
+ ,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,openNewTab:openNewTab,replace:replace,to:to,children:children})}return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:onClick,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,role:"button",tabIndex:0,children:children})};/**
8
8
  * Button component theme: a map of CSS
9
9
  * class names to append to button elements:
10
10
  * @prop {string} [active] to the root element of active button.
11
11
  * @prop {string} [button] to the root element of any button.
12
12
  * @prop {string} [disabled] to the root element of disabled button.
13
- */exports.BaseButton=BaseButton;var _default=exports.default=(0,_reactThemes.default)(BaseButton,"Button",defaultTheme);
13
+ */export default/* #__PURE__ */themed(BaseButton,"Button",defaultTheme);
14
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireDefault","require","_Link","_jsxRuntime","defaultTheme","BaseButton","active","children","disabled","enforceA","onClick","onKeyDown","onKeyDownProp","onKeyUp","onMouseDown","onMouseUp","onPointerDown","onPointerUp","openNewTab","replace","testId","theme","to","className","button","jsx","process","env","NODE_ENV","undefined","e","key","default","role","tabIndex","exports","_default","themed"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport type {\n FunctionComponent,\n KeyboardEventHandler,\n MouseEventHandler,\n PointerEventHandler,\n ReactNode,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport Link from 'components/Link';\n\nimport defaultTheme from './style.scss';\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n onClick?: MouseEventHandler & KeyboardEventHandler;\n onKeyDown?: KeyboardEventHandler;\n onKeyUp?: KeyboardEventHandler;\n onMouseDown?: MouseEventHandler;\n onMouseUp?: MouseEventHandler;\n onPointerDown?: PointerEventHandler;\n onPointerUp?: PointerEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n testId?: string;\n theme: Theme<'active' | 'button' | 'disabled'>;\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\nexport const BaseButton: FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n onClick,\n onKeyDown: onKeyDownProp,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onPointerDown,\n onPointerUp,\n openNewTab,\n replace,\n testId,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n >\n {children}\n </div>\n );\n }\n\n let onKeyDown = onKeyDownProp;\n if (!onKeyDown && onClick) {\n onKeyDown = (e) => {\n if (e.key === 'Enter') onClick(e);\n };\n }\n\n if (to) {\n return (\n <Link\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n enforceA={enforceA}\n onClick={onClick}\n\n // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,\n // as <Link> component does not call it anyway, presumably due to\n // the inner implementation details. We should look into supporting it:\n // https://github.com/birdofpreyru/react-utils/issues/444\n // onKeyDown={onKeyDown}\n\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={onClick}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\n/**\n * Button component theme: a map of CSS\n * class names to append to button elements:\n * @prop {string} [active] to the root element of active button.\n * @prop {string} [button] to the root element of any button.\n * @prop {string} [disabled] to the root element of disabled button.\n */\nexport default themed(BaseButton, 'Button', defaultTheme);\n"],"mappings":"mMAUA,IAAAA,YAAA,CAAAC,sBAAA,CAAAC,OAAA,8BAEA,IAAAC,KAAA,CAAAF,sBAAA,CAAAC,OAAA,aAAmC,IAAAE,WAAA,CAAAF,OAAA,sBAZnC;AAAA,MAAAG,YAAA,6GAoCO,KAAM,CAAAC,UAAqC,CAAGA,CAAC,CACpDC,MAAM,CACNC,QAAQ,CACRC,QAAQ,CACRC,QAAQ,CACRC,OAAO,CACPC,SAAS,CAAEC,aAAa,CACxBC,OAAO,CACPC,WAAW,CACXC,SAAS,CACTC,aAAa,CACbC,WAAW,CACXC,UAAU,CACVC,OAAO,CACPC,MAAM,CACNC,KAAK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,GAAA,SACEF,SAAS,CAAEA,SAAU,CACrB,cAAaG,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGT,MAAO,CACxEV,OAAO,CAAEA,OAAQ,CACjBC,SAAS,CAAEA,SAAU,CACrBE,OAAO,CAAEA,OAAQ,CACjBC,WAAW,CAAEA,WAAY,CACzBC,SAAS,CAAEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBgB,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAA3B,QAAA,CAEXA,QAAQ,CACN,CAET,CAAC,CAED;AACA;AACA;AACA;AACA;AACA;AACA,GANA4B,OAAA,CAAA9B,UAAA,CAAAA,UAAA,KAAA+B,QAAA,CAAAD,OAAA,CAAAH,OAAA,CAOe,GAAAK,oBAAM,EAAChC,UAAU,CAAE,QAAQ,CAAED,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["themed","Link","defaultTheme","jsx","_jsx","BaseButton","active","children","disabled","enforceA","onClick","onKeyDown","onKeyDownProp","onKeyUp","onMouseDown","onMouseUp","onPointerDown","onPointerUp","openNewTab","replace","testId","theme","to","className","button","process","env","NODE_ENV","undefined","e","key","role","tabIndex"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport type {\n FunctionComponent,\n KeyboardEventHandler,\n MouseEventHandler,\n PointerEventHandler,\n ReactNode,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport Link from 'components/Link';\n\nimport defaultTheme from './style.scss';\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n onClick?: MouseEventHandler & KeyboardEventHandler;\n onKeyDown?: KeyboardEventHandler;\n onKeyUp?: KeyboardEventHandler;\n onMouseDown?: MouseEventHandler;\n onMouseUp?: MouseEventHandler;\n onPointerDown?: PointerEventHandler;\n onPointerUp?: PointerEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n testId?: string;\n theme: Theme<'active' | 'button' | 'disabled'>;\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\nexport const BaseButton: FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n onClick,\n onKeyDown: onKeyDownProp,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onPointerDown,\n onPointerUp,\n openNewTab,\n replace,\n testId,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n >\n {children}\n </div>\n );\n }\n\n let onKeyDown = onKeyDownProp;\n if (!onKeyDown && onClick) {\n onKeyDown = (e) => {\n if (e.key === 'Enter') onClick(e);\n };\n }\n\n if (to) {\n return (\n <Link\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n enforceA={enforceA}\n onClick={onClick}\n\n // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,\n // as <Link> component does not call it anyway, presumably due to\n // the inner implementation details. We should look into supporting it:\n // https://github.com/birdofpreyru/react-utils/issues/444\n // onKeyDown={onKeyDown}\n\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={onClick}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\n/**\n * Button component theme: a map of CSS\n * class names to append to button elements:\n * @prop {string} [active] to the root element of active button.\n * @prop {string} [button] to the root element of any button.\n * @prop {string} [disabled] to the root element of disabled button.\n */\nexport default /* #__PURE__ */ themed(BaseButton, 'Button', defaultTheme);\n"],"mappings":"AAAA;AAUA,MAAO,CAAAA,MAAM,KAAsB,0BAA0B,OAEtD,CAAAC,IAAI,wBAAAC,YAAA,6GAE6B,OAAAC,GAAA,IAAAC,IAAA,yBAsBxC,MAAO,MAAM,CAAAC,UAAqC,CAAGA,CAAC,CACpDC,MAAM,CACNC,QAAQ,CACRC,QAAQ,CACRC,QAAQ,CACRC,OAAO,CACPC,SAAS,CAAEC,aAAa,CACxBC,OAAO,CACPC,WAAW,CACXC,SAAS,CACTC,aAAa,CACbC,WAAW,CACXC,UAAU,CACVC,OAAO,CACPC,MAAM,CACNC,KAAK,CACLC,EACF,CAAC,GAAK,CACJ,GAAI,CAAAC,SAAS,CAAGF,KAAK,CAACG,MAAM,CAC5B,GAAIlB,MAAM,EAAIe,KAAK,CAACf,MAAM,CAAEiB,SAAS,EAAI,IAAIF,KAAK,CAACf,MAAM,EAAE,CAC3D,GAAIE,QAAQ,CAAE,CACZ,GAAIa,KAAK,CAACb,QAAQ,CAAEe,SAAS,EAAI,IAAIF,KAAK,CAACb,QAAQ,EAAE,CACrD,mBACEJ,IAAA,QACEmB,SAAS,CAAEA,SAAU,CACrB,cAAaE,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGR,MAAO,CAAAb,QAAA,CAEvEA,QAAQ,CACN,CAET,CAEA,GAAI,CAAAI,SAAS,CAAGC,aAAa,CAC7B,GAAI,CAACD,SAAS,EAAID,OAAO,CAAE,CACzBC,SAAS,CAAIkB,CAAC,EAAK,CACjB,GAAIA,CAAC,CAACC,GAAG,GAAK,OAAO,CAAEpB,OAAO,CAACmB,CAAC,CAClC,CACF,CAEA,GAAIP,EAAE,CAAE,CACN,mBACElB,IAAA,CAACH,IAAI,EACHsB,SAAS,CAAEA,SAAU,CACrB,cAAaE,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGR,MAAO,CACxEX,QAAQ,CAAEA,QAAS,CACnBC,OAAO,CAAEA,OAET;AACA;AACA;AACA;AACA;AAAA,CAEAG,OAAO,CAAEA,OAAQ,CACjBC,WAAW,CAAEA,WAAY,CACzBC,SAAS,CAAEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBC,UAAU,CAAEA,UAAW,CACvBC,OAAO,CAAEA,OAAQ,CACjBG,EAAE,CAAEA,EAAG,CAAAf,QAAA,CAENA,QAAQ,CACL,CAEV,CAEA,mBACEH,IAAA,QACEmB,SAAS,CAAEA,SAAU,CACrB,cAAaE,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGR,MAAO,CACxEV,OAAO,CAAEA,OAAQ,CACjBC,SAAS,CAAEA,SAAU,CACrBE,OAAO,CAAEA,OAAQ,CACjBC,WAAW,CAAEA,WAAY,CACzBC,SAAS,CAAEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBc,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAAzB,QAAA,CAEXA,QAAQ,CACN,CAET,CAAC,CAED;AACA;AACA;AACA;AACA;AACA;AACA,GACA,cAAe,eAAgBP,MAAM,CAACK,UAAU,CAAE,QAAQ,CAAEH,YAAY,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _jsxRuntime=require("react/jsx-runtime");const defaultTheme={"context":"dNQcC6","ad":"earXxa","hoc":"qAPfQ6","checkbox":"A-f8qJ","indeterminate":"N9bCb8","container":"Kr0g3M","label":"_3dML-O","disabled":"EzQra1"};const Checkbox=({checked,disabled,label,onChange,testId,theme})=>{let containerClassName=theme.container;if(disabled)containerClassName+=` ${theme.disabled}`;let checkboxClassName=theme.checkbox;if(checked==="indeterminate")checkboxClassName+=` ${theme.indeterminate}`;return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsx)("input",{checked:checked===undefined?undefined:checked===true,className:checkboxClassName,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onChange:onChange,onClick:e=>{e.stopPropagation()},type:"checkbox"})]})};var _default=exports.default=(0,_reactThemes.default)(Checkbox,"Checkbox",defaultTheme);
1
+ import themed from"@dr.pogodin/react-themes";const defaultTheme={"context":"_08mmmo","ad":"Hc06MV","hoc":"toOtOd","checkbox":"v4DmWM","indeterminate":"ckSC8W","container":"g7wee9","label":"XQ57WS","disabled":"baVvQA"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Checkbox=({checked,disabled,label,onChange,testId,theme})=>{let containerClassName=theme.container;if(disabled)containerClassName+=` ${theme.disabled}`;let checkboxClassName=theme.checkbox;if(checked==="indeterminate")checkboxClassName+=` ${theme.indeterminate}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:theme.label,children:label}),/*#__PURE__*/_jsx("input",{checked:checked===undefined?undefined:checked===true,className:checkboxClassName,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onChange:onChange,onClick:e=>{e.stopPropagation()},type:"checkbox"})]})};export default/* #__PURE__ */themed(Checkbox,"Checkbox",defaultTheme);
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireDefault","require","_jsxRuntime","defaultTheme","Checkbox","checked","disabled","label","onChange","testId","theme","containerClassName","container","checkboxClassName","checkbox","indeterminate","jsxs","className","children","undefined","jsx","process","env","NODE_ENV","onClick","e","stopPropagation","type","_default","exports","default","themed"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT<ValueT> = {\n checked?: ValueT;\n disabled?: boolean;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n testId?: string;\n theme: Theme<\n | 'checkbox'\n | 'container'\n | 'disabled'\n | 'indeterminate'\n | 'label'\n >;\n};\n\nconst Checkbox = <ValueT extends boolean | 'indeterminate' = boolean>({\n checked,\n disabled,\n label,\n onChange,\n testId,\n theme,\n}: PropT<ValueT>) => {\n let containerClassName = theme.container;\n if (disabled) containerClassName += ` ${theme.disabled}`;\n\n let checkboxClassName = theme.checkbox;\n if (checked === 'indeterminate') checkboxClassName += ` ${theme.indeterminate}`;\n\n return (\n <div className={containerClassName}>\n { label === undefined\n ? null : <div className={theme.label}>{label}</div> }\n <input\n checked={checked === undefined ? undefined : checked === true}\n className={checkboxClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onChange={onChange}\n onClick={(e) => {\n e.stopPropagation();\n }}\n type=\"checkbox\"\n />\n </div>\n );\n};\n\nexport default themed(Checkbox, 'Checkbox', defaultTheme);\n"],"mappings":"gLAAA,IAAAA,YAAA,CAAAC,sBAAA,CAAAC,OAAA,8BAA8D,IAAAC,WAAA,CAAAD,OAAA,4BAAAE,YAAA,2JAmB9D,KAAM,CAAAC,QAAQ,CAAGA,CAAqD,CACpEC,OAAO,CACPC,QAAQ,CACRC,KAAK,CACLC,QAAQ,CACRC,MAAM,CACNC,KACa,CAAC,GAAK,CACnB,GAAI,CAAAC,kBAAkB,CAAGD,KAAK,CAACE,SAAS,CACxC,GAAIN,QAAQ,CAAEK,kBAAkB,EAAI,IAAID,KAAK,CAACJ,QAAQ,EAAE,CAExD,GAAI,CAAAO,iBAAiB,CAAGH,KAAK,CAACI,QAAQ,CACtC,GAAIT,OAAO,GAAK,eAAe,CAAEQ,iBAAiB,EAAI,IAAIH,KAAK,CAACK,aAAa,EAAE,CAE/E,mBACE,GAAAb,WAAA,CAAAc,IAAA,SAAKC,SAAS,CAAEN,kBAAmB,CAAAO,QAAA,EAC/BX,KAAK,GAAKY,SAAS,CACjB,IAAI,cAAG,GAAAjB,WAAA,CAAAkB,GAAA,SAAKH,SAAS,CAAEP,KAAK,CAACH,KAAM,CAAAW,QAAA,CAAEX,KAAK,CAAM,CAAC,cACrD,GAAAL,WAAA,CAAAkB,GAAA,WACEf,OAAO,CAAEA,OAAO,GAAKc,SAAS,CAAGA,SAAS,CAAGd,OAAO,GAAK,IAAK,CAC9DY,SAAS,CAAEJ,iBAAkB,CAC7B,cAAaQ,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGJ,SAAS,CAAGV,MAAO,CACxEH,QAAQ,CAAEA,QAAS,CACnBE,QAAQ,CAAEA,QAAS,CACnBgB,OAAO,CAAGC,CAAC,EAAK,CACdA,CAAC,CAACC,eAAe,CAAC,CACpB,CAAE,CACFC,IAAI,CAAC,UAAU,CAChB,CAAC,EACC,CAET,CAAC,CAAC,IAAAC,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEa,GAAAC,oBAAM,EAAC3B,QAAQ,CAAE,UAAU,CAAED,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["themed","defaultTheme","jsx","_jsx","jsxs","_jsxs","Checkbox","checked","disabled","label","onChange","testId","theme","containerClassName","container","checkboxClassName","checkbox","indeterminate","className","children","undefined","process","env","NODE_ENV","onClick","e","stopPropagation","type"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT<ValueT> = {\n checked?: ValueT;\n disabled?: boolean;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n testId?: string;\n theme: Theme<\n | 'checkbox'\n | 'container'\n | 'disabled'\n | 'indeterminate'\n | 'label'\n >;\n};\n\nconst Checkbox = <ValueT extends boolean | 'indeterminate' = boolean>({\n checked,\n disabled,\n label,\n onChange,\n testId,\n theme,\n}: PropT<ValueT>) => {\n let containerClassName = theme.container;\n if (disabled) containerClassName += ` ${theme.disabled}`;\n\n let checkboxClassName = theme.checkbox;\n if (checked === 'indeterminate') checkboxClassName += ` ${theme.indeterminate}`;\n\n return (\n <div className={containerClassName}>\n { label === undefined\n ? null : <div className={theme.label}>{label}</div> }\n <input\n checked={checked === undefined ? undefined : checked === true}\n className={checkboxClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onChange={onChange}\n onClick={(e) => {\n e.stopPropagation();\n }}\n type=\"checkbox\"\n />\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(Checkbox, 'Checkbox', defaultTheme);\n"],"mappings":"AAAA,MAAO,CAAAA,MAAM,KAAsB,0BAA0B,OAAAC,YAAA,2JAErB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAiBxC,KAAM,CAAAC,QAAQ,CAAGA,CAAqD,CACpEC,OAAO,CACPC,QAAQ,CACRC,KAAK,CACLC,QAAQ,CACRC,MAAM,CACNC,KACa,CAAC,GAAK,CACnB,GAAI,CAAAC,kBAAkB,CAAGD,KAAK,CAACE,SAAS,CACxC,GAAIN,QAAQ,CAAEK,kBAAkB,EAAI,IAAID,KAAK,CAACJ,QAAQ,EAAE,CAExD,GAAI,CAAAO,iBAAiB,CAAGH,KAAK,CAACI,QAAQ,CACtC,GAAIT,OAAO,GAAK,eAAe,CAAEQ,iBAAiB,EAAI,IAAIH,KAAK,CAACK,aAAa,EAAE,CAE/E,mBACEZ,KAAA,QAAKa,SAAS,CAAEL,kBAAmB,CAAAM,QAAA,EAC/BV,KAAK,GAAKW,SAAS,CACjB,IAAI,cAAGjB,IAAA,QAAKe,SAAS,CAAEN,KAAK,CAACH,KAAM,CAAAU,QAAA,CAAEV,KAAK,CAAM,CAAC,cACrDN,IAAA,UACEI,OAAO,CAAEA,OAAO,GAAKa,SAAS,CAAGA,SAAS,CAAGb,OAAO,GAAK,IAAK,CAC9DW,SAAS,CAAEH,iBAAkB,CAC7B,cAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGH,SAAS,CAAGT,MAAO,CACxEH,QAAQ,CAAEA,QAAS,CACnBE,QAAQ,CAAEA,QAAS,CACnBc,OAAO,CAAGC,CAAC,EAAK,CACdA,CAAC,CAACC,eAAe,CAAC,CACpB,CAAE,CACFC,IAAI,CAAC,UAAU,CAChB,CAAC,EACC,CAET,CAAC,CAED,cAAe,eAAgB3B,MAAM,CAACM,QAAQ,CAAE,UAAU,CAAEL,YAAY,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _jsxRuntime=require("react/jsx-runtime");/**
1
+ import{jsx as _jsx}from"react/jsx-runtime";/**
2
2
  * The `<Link>` component, and almost identical `<NavLink>` component, are
3
3
  * auxiliary wrappers around
4
4
  * [React Router](https://github.com/ReactTraining/react-router)'s
@@ -41,14 +41,14 @@
41
41
  * - It is opted explicitely by `enforceA` prop;
42
42
  * - It should be opened in a new tab;
43
43
  * - It is an absolte URL (starts with http:// or https://);
44
- * - It is anchor link (starts with #). */if(disabled||enforceA||openNewTab||to.match(/^(#|(https?|mailto):)/)){return/*#__PURE__*/(0,_jsxRuntime.jsx)("a",{className:(className?className+" ":"")+"zH52sA"// TODO: This requires a fix: disabled is not really an attribute of <a>
44
+ * - It is anchor link (starts with #). */if(disabled||enforceA||openNewTab||to.match(/^(#|(https?|mailto):)/)){return/*#__PURE__*/_jsx("a",{className:className// TODO: This requires a fix: disabled is not really an attribute of <a>
45
45
  // tag, thus for disabled option we rather should render a plain text
46
46
  // styled as a link.
47
47
  // disabled={disabled}
48
- ,href:to,onClick:disabled?e=>{e.preventDefault()}:onClick,onMouseDown:disabled?e=>{e.preventDefault()}:onMouseDown,rel:"noopener noreferrer",target:openNewTab?"_blank":"",children:children})}const L=routerLinkType;return/*#__PURE__*/(0,_jsxRuntime.jsx)(L,{className:className,discover:"none"// disabled
48
+ ,href:to,onClick:disabled?e=>{e.preventDefault()}:onClick,onMouseDown:disabled?e=>{e.preventDefault()}:onMouseDown,rel:"noopener noreferrer",styleName:"link",target:openNewTab?"_blank":"",children:children})}const L=routerLinkType;return/*#__PURE__*/_jsx(L,{className:className,discover:"none"// disabled
49
49
  ,onClick:e=>{// Executes the user-provided event handler, if any.
50
50
  if(onClick)onClick(e);// By default, clicking the link scrolls the page to beginning.
51
51
  if(!keepScrollPosition)window.scroll(0,0)},onMouseDown:onMouseDown,replace:replace,to:to// TODO: Refactor it later.
52
52
  // eslint-disable-next-line react/jsx-props-no-spreading
53
- ,...rest,children:children})};var _default=exports.default=GenericLink;
53
+ ,...rest,children:children})};export default GenericLink;
54
54
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","_jsxRuntime","jsx","href","e","preventDefault","rel","target","L","discover","window","scroll","_default","exports","default"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type {\n Link,\n LinkProps,\n NavLink,\n NavLinkProps,\n} from 'react-router';\n\nimport './style.scss';\n\ntype LinkT = typeof Link;\ntype NavLinkT = typeof NavLink;\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkT | NavLinkT;\n to: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink = ({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}: (LinkProps | NavLinkProps) & PropsT): ReactNode => {\n /* Renders Link as <a> element if:\n * - It is opted explicitely by `enforceA` prop;\n * - It should be opened in a new tab;\n * - It is an absolte URL (starts with http:// or https://);\n * - It is anchor link (starts with #). */\n if (disabled || enforceA || openNewTab\n || (to as string).match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => {\n e.preventDefault();\n } : onClick}\n onMouseDown={disabled ? (e) => {\n e.preventDefault();\n } : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType;\n\n return (\n <L\n className={className}\n discover=\"none\"\n // disabled\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n onMouseDown={onMouseDown}\n replace={replace}\n to={to}\n // TODO: Refactor it later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n >\n {children}\n </L>\n );\n};\n\nexport default GenericLink;\n"],"mappings":"0IA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAA,WAAW,CAAGA,CAAC,CACnBC,QAAQ,CACRC,SAAS,CACTC,QAAQ,CACRC,QAAQ,CACRC,kBAAkB,CAClBC,OAAO,CACPC,WAAW,CACXC,UAAU,CACVC,OAAO,CACPC,cAAc,CACdC,EAAE,CACF,GAAGC,IACgC,CAAC,GAAgB,CACpD;AACF;AACA;AACA;AACA,4CACE,GAAIT,QAAQ,EAAIC,QAAQ,EAAII,UAAU,EAChCG,EAAE,CAAYE,KAAK,CAAC,uBAAuB,CAAC,CAAE,CAClD,mBACE,GAAAC,WAAA,CAAAC,GAAA,OACEb,SAAS,EAAEA,SAAS,CAATA,SAAS,iBACpB;AACA;AACA;AACA;AAAA,CACAc,IAAI,CAAEL,EAAa,CACnBL,OAAO,CAAEH,QAAQ,CAAIc,CAAC,EAAK,CACzBA,CAAC,CAACC,cAAc,CAAC,CACnB,CAAC,CAAGZ,OAAQ,CACZC,WAAW,CAAEJ,QAAQ,CAAIc,CAAC,EAAK,CAC7BA,CAAC,CAACC,cAAc,CAAC,CACnB,CAAC,CAAGX,WAAY,CAChBY,GAAG,CAAC,qBAAqB,CAEzBC,MAAM,CAAEZ,UAAU,CAAG,QAAQ,CAAG,EAAG,CAAAP,QAAA,CAElCA,QAAQ,CACR,CAEP,CAEA,KAAM,CAAAoB,CAAC,CAAGX,cAAc,CAExB,mBACE,GAAAI,WAAA,CAAAC,GAAA,EAACM,CAAC,EACAnB,SAAS,CAAEA,SAAU,CACrBoB,QAAQ,CAAC,MACT;AAAA,CACAhB,OAAO,CAAGW,CAAsC,EAAK,CACnD;AACA,GAAIX,OAAO,CAAEA,OAAO,CAACW,CAAC,CAAC,CAEvB;AACA,GAAI,CAACZ,kBAAkB,CAAEkB,MAAM,CAACC,MAAM,CAAC,CAAC,CAAE,CAAC,CAC7C,CAAE,CACFjB,WAAW,CAAEA,WAAY,CACzBE,OAAO,CAAEA,OAAQ,CACjBE,EAAE,CAAEA,EACJ;AACA;AAAA,IACIC,IAAI,CAAAX,QAAA,CAEPA,QAAQ,CACR,CAEP,CAAC,CAAC,IAAAwB,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEa3B,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["jsx","_jsx","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","href","e","preventDefault","rel","styleName","target","L","discover","window","scroll"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type {\n Link,\n LinkProps,\n NavLink,\n NavLinkProps,\n} from 'react-router';\n\nimport './style.scss';\n\ntype LinkT = typeof Link;\ntype NavLinkT = typeof NavLink;\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkT | NavLinkT;\n to: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink = ({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}: (LinkProps | NavLinkProps) & PropsT): ReactNode => {\n /* Renders Link as <a> element if:\n * - It is opted explicitely by `enforceA` prop;\n * - It should be opened in a new tab;\n * - It is an absolte URL (starts with http:// or https://);\n * - It is anchor link (starts with #). */\n if (disabled || enforceA || openNewTab\n || (to as string).match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => {\n e.preventDefault();\n } : onClick}\n onMouseDown={disabled ? (e) => {\n e.preventDefault();\n } : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType;\n\n return (\n <L\n className={className}\n discover=\"none\"\n // disabled\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n onMouseDown={onMouseDown}\n replace={replace}\n to={to}\n // TODO: Refactor it later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n >\n {children}\n </L>\n );\n};\n\nexport default GenericLink;\n"],"mappings":"AASsB,OAAAA,GAAA,IAAAC,IAAA,yBAqBtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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A,OAAQ,CACjBE,EAAE,CAAEA,EACJ;AACA;AAAA,IACIC,IAAI,CAAAX,QAAA,CAEPA,QAAQ,CACR,CAEP,CAAC,CAED,cAAe,CAAAD,WAAW","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=require("react");var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _jsxRuntime=require("react/jsx-runtime");const defaultTheme={"context":"X5WszA","ad":"_8s7GCr","hoc":"TVlBYc","container":"Cxx397","children":"m4FpDO","input":"M07d4s","label":"gfbdq-","error":"p2idHY","errorMessage":"Q9uslG"};/**
1
+ import{useRef,useState}from"react";import themed from"@dr.pogodin/react-themes";const defaultTheme={"context":"-Jj9Dp","ad":"IOZUc8","hoc":"nSzLXc","container":"wW08uK","children":"hCuQWP","input":"oYQ-Uo","label":"OTmX5n","error":"_7jrZ-X","errorMessage":"qjYbwz"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * Themeable input field, based on the standard HTML `<input>` element.
3
3
  * @param [props.label] Input label.
4
4
  * @param [props.theme] _Ad hoc_ theme.
@@ -7,12 +7,12 @@
7
7
  * `<input>` element.
8
8
  */const Input=({children,error,label,ref,testId,theme,...rest})=>{// NOTE: As of now, it is only updated when "theme.focused" is defined,
9
9
  // as otherwise its value is not used.
10
- const[focused,setFocused]=(0,_react.useState)(false);const localRef=(0,_react.useRef)(null);let containerClassName=theme.container;// NOTE: As of now, "focused" can be true only when "theme.focused"
10
+ const[focused,setFocused]=useState(false);const localRef=useRef(null);let containerClassName=theme.container;// NOTE: As of now, "focused" can be true only when "theme.focused"
11
11
  // is provided.
12
- if(focused/* && theme.focused */)containerClassName+=` ${theme.focused}`;if(!rest.value&&theme.empty)containerClassName+=` ${theme.empty}`;if(error)containerClassName+=` ${theme.error}`;return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:containerClassName,onFocus:()=>{// TODO: It does not really work if a callback-style `ref` is passed in,
12
+ if(focused/* && theme.focused */)containerClassName+=` ${theme.focused}`;if(!rest.value&&theme.empty)containerClassName+=` ${theme.empty}`;if(error)containerClassName+=` ${theme.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:()=>{// TODO: It does not really work if a callback-style `ref` is passed in,
13
13
  // we need a more complex logic to cover that case, but for now this serves
14
14
  // the case we need it for.
15
- if(typeof ref==="object")ref?.current?.focus();else localRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsx)("input",{className:theme.input,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,ref:ref??localRef// TODO: Avoid the spreading later.
15
+ if(typeof ref==="object")ref?.current?.focus();else localRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:theme.label,children:label}),/*#__PURE__*/_jsx("input",{className:theme.input,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,ref:ref??localRef// TODO: Avoid the spreading later.
16
16
  // eslint-disable-next-line react/jsx-props-no-spreading
17
- ,...rest,onBlur:theme.focused?e=>{setFocused(false);rest.onBlur?.(e)}:rest.onBlur,onFocus:theme.focused?e=>{setFocused(true);rest.onFocus?.(e)}:rest.onFocus}),error&&error!==true?/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.errorMessage,children:error}):null,children?/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.children,children:children}):null]})};var _default=exports.default=(0,_reactThemes.default)(Input,"Input",defaultTheme);
17
+ ,...rest,onBlur:theme.focused?e=>{setFocused(false);rest.onBlur?.(e)}:rest.onBlur,onFocus:theme.focused?e=>{setFocused(true);rest.onFocus?.(e)}:rest.onFocus}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:theme.errorMessage,children:error}):null,children?/*#__PURE__*/_jsx("div",{className:theme.children,children:children}):null]})};export default/* #__PURE__ */themed(Input,"Input",defaultTheme);
18
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","require","_reactThemes","_interopRequireDefault","_jsxRuntime","defaultTheme","Input","children","error","label","ref","testId","theme","rest","focused","setFocused","useState","localRef","useRef","containerClassName","container","value","empty","jsxs","className","onFocus","current","focus","undefined","jsx","input","process","env","NODE_ENV","onBlur","e","errorMessage","_default","exports","default","themed"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type Ref,\n useRef,\n useState,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'\n | 'focused' | 'input' | 'label';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n children?: ReactNode;\n error?: ReactNode;\n label?: React.ReactNode;\n ref?: Ref<HTMLInputElement>;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props.label] Input label.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n * @param [props...] Any other properties are passed to the underlying\n * `<input>` element.\n */\nconst Input: FunctionComponent<PropsT> = ({\n children,\n error,\n label,\n ref,\n testId,\n theme,\n ...rest\n}) => {\n // NOTE: As of now, it is only updated when \"theme.focused\" is defined,\n // as otherwise its value is not used.\n const [focused, setFocused] = useState(false);\n\n const localRef = useRef<HTMLInputElement>(null);\n\n let containerClassName = theme.container;\n\n // NOTE: As of now, \"focused\" can be true only when \"theme.focused\"\n // is provided.\n if (focused /* && theme.focused */) containerClassName += ` ${theme.focused}`;\n\n if (!rest.value && theme.empty) containerClassName += ` ${theme.empty}`;\n\n if (error) containerClassName += ` ${theme.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n // TODO: It does not really work if a callback-style `ref` is passed in,\n // we need a more complex logic to cover that case, but for now this serves\n // the case we need it for.\n if (typeof ref === 'object') ref?.current?.focus();\n else localRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={theme.label}>{label}</div>}\n <input\n className={theme.input}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n ref={ref ?? localRef}\n\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n\n onBlur={theme.focused ? (e) => {\n setFocused(false);\n rest.onBlur?.(e);\n } : rest.onBlur}\n onFocus={theme.focused ? (e) => {\n setFocused(true);\n rest.onFocus?.(e);\n } : rest.onFocus}\n />\n {error && error !== true\n ? <div className={theme.errorMessage}>{error}</div>\n : null}\n {children ? <div className={theme.children}>{children}</div> : null}\n </div>\n );\n};\n\nexport default themed(Input, 'Input', defaultTheme);\n"],"mappings":"gLAAA,IAAAA,MAAA,CAAAC,OAAA,UAQA,IAAAC,YAAA,CAAAC,sBAAA,CAAAF,OAAA,8BAA8D,IAAAG,WAAA,CAAAH,OAAA,4BAAAI,YAAA,wKAgB9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,KAAgC,CAAGA,CAAC,CACxCC,QAAQ,CACRC,KAAK,CACLC,KAAK,CACLC,GAAG,CACHC,MAAM,CACNC,KAAK,CACL,GAAGC,IACL,CAAC,GAAK,CACJ;AACA;AACA,KAAM,CAACC,OAAO,CAAEC,UAAU,CAAC,CAAG,GAAAC,eAAQ,EAAC,KAAK,CAAC,CAE7C,KAAM,CAAAC,QAAQ,CAAG,GAAAC,aAAM,EAAmB,IAAI,CAAC,CAE/C,GAAI,CAAAC,kBAAkB,CAAGP,KAAK,CAACQ,SAAS,CAExC;AACA;AACA,GAAIN,OAAQ,uBAAwBK,kBAAkB,EAAI,IAAIP,KAAK,CAACE,OAAO,EAAE,CAE7E,GAAI,CAACD,IAAI,CAAC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B,GAAAJ,WAAA,CAAAyB,GAAA,SAAKL,SAAS,CAAEZ,KAAK,CAACwB,YAAa,CAAA7B,QAAA,CAAEC,KAAK,CAAM,CAAC,CACjD,IAAI,CACPD,QAAQ,cAAG,GAAAH,WAAA,CAAAyB,GAAA,SAAKL,SAAS,CAAEZ,KAAK,CAACL,QAAS,CAAAA,QAAA,CAAEA,QAAQ,CAAM,CAAC,CAAG,IAAI,EAChE,CAET,CAAC,CAAC,IAAA8B,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEa,GAAAC,oBAAM,EAAClC,KAAK,CAAE,OAAO,CAAED,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useRef","useState","themed","defaultTheme","jsx","_jsx","jsxs","_jsxs","Input","children","error","label","ref","testId","theme","rest","focused","setFocused","localRef","containerClassName","container","value","empty","className","onFocus","current","focus","undefined","input","process","env","NODE_ENV","onBlur","e","errorMessage"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type Ref,\n useRef,\n useState,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'\n | 'focused' | 'input' | 'label';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n children?: ReactNode;\n error?: ReactNode;\n label?: React.ReactNode;\n ref?: Ref<HTMLInputElement>;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props.label] Input label.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n * @param [props...] Any other properties are passed to the underlying\n * `<input>` element.\n */\nconst Input: FunctionComponent<PropsT> = ({\n children,\n error,\n label,\n ref,\n testId,\n theme,\n ...rest\n}) => {\n // NOTE: As of now, it is only updated when \"theme.focused\" is defined,\n // as otherwise its value is not used.\n const [focused, setFocused] = useState(false);\n\n const localRef = useRef<HTMLInputElement>(null);\n\n let containerClassName = theme.container;\n\n // NOTE: As of now, \"focused\" can be true only when \"theme.focused\"\n // is provided.\n if (focused /* && theme.focused */) containerClassName += ` ${theme.focused}`;\n\n if (!rest.value && theme.empty) containerClassName += ` ${theme.empty}`;\n\n if (error) containerClassName += ` ${theme.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n // TODO: It does not really work if a callback-style `ref` is passed in,\n // we need a more complex logic to cover that case, but for now this serves\n // the case we need it for.\n if (typeof ref === 'object') ref?.current?.focus();\n else localRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={theme.label}>{label}</div>}\n <input\n className={theme.input}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n ref={ref ?? localRef}\n\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n\n onBlur={theme.focused ? (e) => {\n setFocused(false);\n rest.onBlur?.(e);\n } : rest.onBlur}\n onFocus={theme.focused ? (e) => {\n setFocused(true);\n rest.onFocus?.(e);\n } : rest.onFocus}\n />\n {error && error !== true\n ? <div className={theme.errorMessage}>{error}</div>\n : null}\n {children ? <div className={theme.children}>{children}</div> : null}\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(Input, 'Input', defaultTheme);\n"],"mappings":"AAAA,OAIEA,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,MAAO,CAAAC,MAAM,KAAsB,0BAA0B,OAAAC,YAAA,wKAErB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAcxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,KAAgC,CAAGA,CAAC,CACxCC,QAAQ,CACRC,KAAK,CACLC,KAAK,CACLC,GAAG,CACHC,MAAM,CACNC,KAAK,CACL,GAAGC,IACL,CAAC,GAAK,C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AC,CAAGlB,IAAI,CAACiB,MAAO,CAChBR,OAAO,CAAEV,KAAK,CAACE,OAAO,CAAIiB,CAAC,EAAK,CAC9BhB,UAAU,CAAC,IAAI,CAAC,CAChBF,IAAI,CAACS,OAAO,GAAGS,CAAC,CAClB,CAAC,CAAGlB,IAAI,CAACS,OAAQ,CAClB,CAAC,CACDd,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBL,IAAA,QAAKkB,SAAS,CAAET,KAAK,CAACoB,YAAa,CAAAzB,QAAA,CAAEC,KAAK,CAAM,CAAC,CACjD,IAAI,CACPD,QAAQ,cAAGJ,IAAA,QAAKkB,SAAS,CAAET,KAAK,CAACL,QAAS,CAAAA,QAAA,CAAEA,QAAQ,CAAM,CAAC,CAAG,IAAI,EAChE,CAET,CAAC,CAED,cAAe,eAAgBP,MAAM,CAACM,KAAK,CAAE,OAAO,CAAEL,YAAY,CAAC","ignoreList":[]}
@@ -1,10 +1,10 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactRouter=require("react-router");var _GenericLink=_interopRequireDefault(require("./GenericLink"));var _jsxRuntime=require("react/jsx-runtime");/**
1
+ /**
2
2
  * The Link wraps around React Router's Link component, to automatically replace
3
3
  * it by the regular <a> element when:
4
4
  * - The target reference points to another domain;
5
5
  * - User opts to open the reference in a new tab;
6
6
  * - User explicitely opts to use <a>.
7
- */const Link=props=>/*#__PURE__*/(0,_jsxRuntime.jsx)(_GenericLink.default// TODO: Avoid the spreading later.
7
+ */import{Link as RrLink}from"react-router";import GenericLink from"./GenericLink/index.js";import{jsx as _jsx}from"react/jsx-runtime";const Link=props=>/*#__PURE__*/_jsx(GenericLink// TODO: Avoid the spreading later.
8
8
  // eslint-disable-next-line react/jsx-props-no-spreading
9
- ,{...props,routerLinkType:_reactRouter.Link});var _default=exports.default=Link;
9
+ ,{...props,routerLinkType:RrLink});export default Link;
10
10
  //# sourceMappingURL=Link.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","names":["_reactRouter","require","_GenericLink","_interopRequireDefault","_jsxRuntime","Link","props","jsx","default","routerLinkType","RrLink","_default","exports"],"sources":["../../../../src/shared/components/Link.tsx"],"sourcesContent":["/**\n * The Link wraps around React Router's Link component, to automatically replace\n * it by the regular <a> element when:\n * - The target reference points to another domain;\n * - User opts to open the reference in a new tab;\n * - User explicitely opts to use <a>.\n */\n\nimport { type LinkProps, Link as RrLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & LinkProps;\n\nconst Link: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrLink}\n />\n );\n\nexport default Link;\n"],"mappings":"gLAQA,IAAAA,YAAA,CAAAC,OAAA,iBAEA,IAAAC,YAAA,CAAAC,sBAAA,CAAAF,OAAA,mBAA8E,IAAAG,WAAA,CAAAH,OAAA,sBAV9E;AACA;AACA;AACA;AACA;AACA;AACA,GAQA,KAAM,CAAAI,IAAqC,CACtCC,KAAK,eACN,GAAAF,WAAA,CAAAG,GAAA,EAACL,YAAA,CAAAM,OACC;AACA;AAAA,KACIF,KAAK,CACTG,cAAc,CAAEC,iBAAO,CACxB,CACF,CAAC,IAAAC,QAAA,CAAAC,OAAA,CAAAJ,OAAA,CAEWH,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"Link.js","names":["Link","RrLink","GenericLink","jsx","_jsx","props","routerLinkType"],"sources":["../../../../src/shared/components/Link.tsx"],"sourcesContent":["/**\n * The Link wraps around React Router's Link component, to automatically replace\n * it by the regular <a> element when:\n * - The target reference points to another domain;\n * - User opts to open the reference in a new tab;\n * - User explicitely opts to use <a>.\n */\n\nimport { type LinkProps, Link as RrLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & LinkProps;\n\nconst Link: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrLink}\n />\n );\n\nexport default Link;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,OAAyBA,IAAI,GAAI,CAAAC,MAAM,KAAQ,cAAc,OAEtD,CAAAC,WAAW,8BAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,IAAqC,CACtCK,KAAK,eACND,IAAA,CAACF,WACC;AACA;AAAA,KACIG,KAAK,CACTC,cAAc,CAAEL,MAAO,CACxB,CACF,CAEH,cAAe,CAAAD,IAAI","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.BaseModal=void 0;var _react=require("react");var _reactDom=_interopRequireDefault(require("react-dom"));var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _jsxRuntime=require("react/jsx-runtime");const baseTheme={"context":"Szmbbz","ad":"Ah-Nsc","hoc":"Wki41G","overlay":"ye2BZo","container":"gyZ4rc"};const S={"scrollingDisabledByModal":"_5fRFtF"};/**
1
+ import{useEffect,useMemo,useRef}from"react";import{createPortal}from"react-dom";import themed from"@dr.pogodin/react-themes";const baseTheme={"context":"sCYXfW","ad":"e0BH-f","hoc":"vqUuSP","overlay":"uAH4as","container":"zqpc6q"};const S={"scrollingDisabledByModal":"yfvOIZ"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * The `<Modal>` component implements a simple themeable modal window, wrapped
3
3
  * into the default theme. `<BaseModal>` exposes the base non-themed component.
4
4
  * **Children:** Component children are rendered as the modal content.
@@ -8,12 +8,12 @@
8
8
  * clicks outside the modal, or presses Escape. It is expected to hide the
9
9
  * modal.
10
10
  * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
11
- */const BaseModal=({cancelOnScrolling,children,containerStyle,dontDisableScrolling,onCancel,overlayStyle,style,testId,testIdForOverlay,theme})=>{const containerRef=(0,_react.useRef)(null);const overlayRef=(0,_react.useRef)(null);// Sets up modal cancellation of scrolling, if opted-in.
12
- (0,_react.useEffect)(()=>{if(cancelOnScrolling&&onCancel){window.addEventListener("scroll",onCancel);window.addEventListener("wheel",onCancel)}return()=>{if(cancelOnScrolling&&onCancel){window.removeEventListener("scroll",onCancel);window.removeEventListener("wheel",onCancel)}}},[cancelOnScrolling,onCancel]);// Disables window scrolling, if it is not opted-out.
13
- (0,_react.useEffect)(()=>{if(!dontDisableScrolling){document.body.classList.add(S.scrollingDisabledByModal)}return()=>{if(!dontDisableScrolling){document.body.classList.remove(S.scrollingDisabledByModal)}}},[dontDisableScrolling]);const focusLast=(0,_react.useMemo)(()=>/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{onFocus:()=>{const elems=containerRef.current.querySelectorAll("*");for(let i=elems.length-1;i>=0;--i){elems[i].focus();if(document.activeElement===elems[i])return}overlayRef.current?.focus()}// TODO: Have a look at this later.
11
+ */const BaseModal=({cancelOnScrolling,children,containerStyle,dontDisableScrolling,onCancel,overlayStyle,style,testId,testIdForOverlay,theme})=>{const containerRef=useRef(null);const overlayRef=useRef(null);// Sets up modal cancellation of scrolling, if opted-in.
12
+ useEffect(()=>{if(cancelOnScrolling&&onCancel){window.addEventListener("scroll",onCancel);window.addEventListener("wheel",onCancel)}return()=>{if(cancelOnScrolling&&onCancel){window.removeEventListener("scroll",onCancel);window.removeEventListener("wheel",onCancel)}}},[cancelOnScrolling,onCancel]);// Disables window scrolling, if it is not opted-out.
13
+ useEffect(()=>{if(!dontDisableScrolling){document.body.classList.add(S.scrollingDisabledByModal)}return()=>{if(!dontDisableScrolling){document.body.classList.remove(S.scrollingDisabledByModal)}}},[dontDisableScrolling]);const focusLast=useMemo(()=>/*#__PURE__*/_jsx("div",{onFocus:()=>{const elems=containerRef.current.querySelectorAll("*");for(let i=elems.length-1;i>=0;--i){elems[i].focus();if(document.activeElement===elems[i])return}overlayRef.current?.focus()}// TODO: Have a look at this later.
14
14
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
15
- ,tabIndex:0}),[]);return/*#__PURE__*/_reactDom.default.createPortal(/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{children:[focusLast,/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{"aria-label":"Cancel",className:theme.overlay,"data-testid":process.env.NODE_ENV==="production"?undefined:testIdForOverlay,onClick:e=>{if(onCancel){onCancel();e.stopPropagation()}},onKeyDown:e=>{if(e.key==="Escape"&&onCancel){onCancel();e.stopPropagation()}},ref:node=>{if(node&&node!==overlayRef.current){overlayRef.current=node;node.focus()}},role:"button",style:overlayStyle,tabIndex:0}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{// eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
16
- "aria-modal":"true",className:theme.container,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:e=>{e.stopPropagation()},onWheel:event=>{event.stopPropagation()},ref:containerRef,role:"dialog",style:style??containerStyle,children:children}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{onFocus:()=>{overlayRef.current?.focus()}// TODO: Have a look at this later.
15
+ ,tabIndex:0}),[]);return/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("div",{children:[focusLast,/*#__PURE__*/_jsx("div",{"aria-label":"Cancel",className:theme.overlay,"data-testid":process.env.NODE_ENV==="production"?undefined:testIdForOverlay,onClick:e=>{if(onCancel){onCancel();e.stopPropagation()}},onKeyDown:e=>{if(e.key==="Escape"&&onCancel){onCancel();e.stopPropagation()}},ref:node=>{if(node&&node!==overlayRef.current){overlayRef.current=node;node.focus()}},role:"button",style:overlayStyle,tabIndex:0}),/*#__PURE__*/_jsx("div",{// eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
16
+ "aria-modal":"true",className:theme.container,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:e=>{e.stopPropagation()},onWheel:event=>{event.stopPropagation()},ref:containerRef,role:"dialog",style:style??containerStyle,children:children}),/*#__PURE__*/_jsx("div",{onFocus:()=>{overlayRef.current?.focus()}// TODO: Have a look at this later.
17
17
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
18
- ,tabIndex:0}),focusLast]}),document.body)};exports.BaseModal=BaseModal;var _default=exports.default=(0,_reactThemes.default)(BaseModal,"Modal",baseTheme);/* Non-themed version of the Modal. */
18
+ ,tabIndex:0}),focusLast]}),document.body)};export default/* #__PURE__ */themed(BaseModal,"Modal",baseTheme);/* Non-themed version of the Modal. */export{BaseModal};
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","require","_reactDom","_interopRequireDefault","_reactThemes","_jsxRuntime","baseTheme","S","BaseModal","cancelOnScrolling","children","containerStyle","dontDisableScrolling","onCancel","overlayStyle","style","testId","testIdForOverlay","theme","containerRef","useRef","overlayRef","useEffect","window","addEventListener","removeEventListener","document","body","classList","add","scrollingDisabledByModal","remove","focusLast","useMemo","jsx","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","ReactDom","createPortal","jsxs","className","overlay","process","env","NODE_ENV","undefined","onClick","e","stopPropagation","onKeyDown","key","ref","node","role","container","onWheel","event","exports","_default","default","themed"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport ReactDom from 'react-dom';\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport S from './styles.scss';\n\ntype PropsT = {\n cancelOnScrolling?: boolean;\n children?: ReactNode;\n dontDisableScrolling?: boolean;\n onCancel?: () => void;\n overlayStyle?: CSSProperties;\n style?: CSSProperties;\n testId?: string;\n testIdForOverlay?: string;\n theme: Theme<'container' | 'overlay'>;\n\n /** @deprecated */\n containerStyle?: CSSProperties;\n};\n\n/**\n * The `<Modal>` component implements a simple themeable modal window, wrapped\n * into the default theme. `<BaseModal>` exposes the base non-themed component.\n * **Children:** Component children are rendered as the modal content.\n * @param {object} props Component properties. Beside props documented below,\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.\n * @param {function} [props.onCancel] The callback to trigger when user\n * clicks outside the modal, or presses Escape. It is expected to hide the\n * modal.\n * @param {ModalTheme} [props.theme] _Ad hoc_ theme.\n */\nconst BaseModal: FunctionComponent<PropsT> = ({\n cancelOnScrolling,\n children,\n containerStyle,\n dontDisableScrolling,\n onCancel,\n overlayStyle,\n style,\n testId,\n testIdForOverlay,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n\n // Sets up modal cancellation of scrolling, if opted-in.\n useEffect(() => {\n if (cancelOnScrolling && onCancel) {\n window.addEventListener('scroll', onCancel);\n window.addEventListener('wheel', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', onCancel);\n window.removeEventListener('wheel', onCancel);\n }\n };\n }, [cancelOnScrolling, onCancel]);\n\n // Disables window scrolling, if it is not opted-out.\n useEffect(() => {\n if (!dontDisableScrolling) {\n document.body.classList.add(S.scrollingDisabledByModal);\n }\n return () => {\n if (!dontDisableScrolling) {\n document.body.classList.remove(S.scrollingDisabledByModal);\n }\n };\n }, [dontDisableScrolling]);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current!.querySelectorAll('*');\n for (let i = elems.length - 1; i >= 0; --i) {\n (elems[i] as HTMLElement).focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n ), []);\n\n return ReactDom.createPortal(\n (\n <div>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n data-testid={\n process.env.NODE_ENV === 'production'\n ? undefined : testIdForOverlay\n }\n onClick={(e) => {\n if (onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n style={overlayStyle}\n tabIndex={0}\n />\n {\n // NOTE: These rules are disabled because our intention is to keep\n // the element non-interactive (thus not on the keyboard focus chain),\n // and it has `onClick` handler merely to stop propagation of click\n // events to its parent container. This is needed because, for example\n // when the modal is wrapped into an interactive element we don't want\n // any clicks inside the modal to bubble-up to that parent element\n // (because visually and logically the modal dialog does not belong\n // to its parent container, where it technically belongs from\n // the HTML mark-up perpective).\n }\n <div // eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n aria-modal=\"true\"\n className={theme.container}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={(e) => {\n e.stopPropagation();\n }}\n onWheel={(event) => {\n event.stopPropagation();\n }}\n ref={containerRef}\n role=\"dialog\"\n style={style ?? containerStyle}\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n {focusLast}\n </div>\n ),\n document.body,\n );\n};\n\nexport default themed(BaseModal, 'Modal', baseTheme);\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":"kMAAA,IAAAA,MAAA,CAAAC,OAAA,UASA,IAAAC,SAAA,CAAAC,sBAAA,CAAAF,OAAA,eACA,IAAA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A,IAAI,EAAIA,IAAI,GAAKtC,UAAU,CAACgB,OAAO,CAAE,CACvChB,UAAU,CAACgB,OAAO,CAAGsB,IAAI,CACzBA,IAAI,CAAClB,KAAK,CAAC,CACb,CACF,CAAE,CACFmB,IAAI,CAAC,QAAQ,CACb7C,KAAK,CAAED,YAAa,CACpB6B,QAAQ,CAAE,CAAE,CACb,CAAC,cAYF,GAAAtC,WAAA,CAAA6B,GAAA,SAAK;AACH,aAAW,MAAM,CACjBa,SAAS,CAAE7B,KAAK,CAAC2C,SAAU,CAC3B,cAAaZ,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGpC,MAAO,CACxEqC,OAAO,CAAGC,CAAC,EAAK,CACdA,CAAC,CAACC,eAAe,CAAC,CACpB,CAAE,CACFO,OAAO,CAAGC,KAAK,EAAK,CAClBA,KAAK,CAACR,eAAe,CAAC,CACxB,CAAE,CACFG,GAAG,CAAEvC,YAAa,CAClByC,IAAI,CAAC,QAAQ,CACb7C,KAAK,CAAEA,KAAK,EAAIJ,cAAe,CAAAD,QAAA,CAE9BA,QAAQ,CACN,CAAC,cACN,GAAAL,WAAA,CAAA6B,GAAA,SACEC,OAAO,CAAEA,CAAA,GAAM,CACbd,UAAU,CAACgB,OAAO,EAAEI,KAAK,CAAC,CAC5B,CACA;AACA;AAAA,CACAE,QAAQ,CAAE,CAAE,CACb,CAAC,CACDX,SAAS,EACP,CAAC,CAERN,QAAQ,CAACC,IACX,CACF,CAAC,CAACqC,OAAA,CAAAxD,SAAA,CAAAA,SAAA,KAAAyD,QAAA,CAAAD,OAAA,CAAAE,OAAA,CAEa,GAAAC,oBAAM,EAAC3D,SAAS,CAAE,OAAO,CAAEF,SAAS,CAAC,CAEpD","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useMemo","useRef","createPortal","themed","baseTheme","S","jsx","_jsx","jsxs","_jsxs","BaseModal","cancelOnScrolling","children","containerStyle","dontDisableScrolling","onCancel","overlayStyle","style","testId","testIdForOverlay","theme","containerRef","overlayRef","window","addEventListener","removeEventListener","document","body","classList","add","scrollingDisabledByModal","remove","focusLast","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","className","overlay","process","env","NODE_ENV","undefined","onClick","e","stopPropagation","onKeyDown","key","ref","node","role","container","onWheel","event"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport S from './styles.scss';\n\ntype PropsT = {\n cancelOnScrolling?: boolean;\n children?: ReactNode;\n dontDisableScrolling?: boolean;\n onCancel?: () => void;\n overlayStyle?: CSSProperties;\n style?: CSSProperties;\n testId?: string;\n testIdForOverlay?: string;\n theme: Theme<'container' | 'overlay'>;\n\n /** @deprecated */\n containerStyle?: CSSProperties;\n};\n\n/**\n * The `<Modal>` component implements a simple themeable modal window, wrapped\n * into the default theme. `<BaseModal>` exposes the base non-themed component.\n * **Children:** Component children are rendered as the modal content.\n * @param {object} props Component properties. Beside props documented below,\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.\n * @param {function} [props.onCancel] The callback to trigger when user\n * clicks outside the modal, or presses Escape. It is expected to hide the\n * modal.\n * @param {ModalTheme} [props.theme] _Ad hoc_ theme.\n */\nconst BaseModal: FunctionComponent<PropsT> = ({\n cancelOnScrolling,\n children,\n containerStyle,\n dontDisableScrolling,\n onCancel,\n overlayStyle,\n style,\n testId,\n testIdForOverlay,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n\n // Sets up modal cancellation of scrolling, if opted-in.\n useEffect(() => {\n if (cancelOnScrolling && onCancel) {\n window.addEventListener('scroll', onCancel);\n window.addEventListener('wheel', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', onCancel);\n window.removeEventListener('wheel', onCancel);\n }\n };\n }, [cancelOnScrolling, onCancel]);\n\n // Disables window scrolling, if it is not opted-out.\n useEffect(() => {\n if (!dontDisableScrolling) {\n document.body.classList.add(S.scrollingDisabledByModal);\n }\n return () => {\n if (!dontDisableScrolling) {\n document.body.classList.remove(S.scrollingDisabledByModal);\n }\n };\n }, [dontDisableScrolling]);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current!.querySelectorAll('*');\n for (let i = elems.length - 1; i >= 0; --i) {\n (elems[i] as HTMLElement).focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n ), []);\n\n return createPortal(\n (\n <div>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n data-testid={\n process.env.NODE_ENV === 'production'\n ? undefined : testIdForOverlay\n }\n onClick={(e) => {\n if (onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n style={overlayStyle}\n tabIndex={0}\n />\n {\n // NOTE: These rules are disabled because our intention is to keep\n // the element non-interactive (thus not on the keyboard focus chain),\n // and it has `onClick` handler merely to stop propagation of click\n // events to its parent container. This is needed because, for example\n // when the modal is wrapped into an interactive element we don't want\n // any clicks inside the modal to bubble-up to that parent element\n // (because visually and logically the modal dialog does not belong\n // to its parent container, where it technically belongs from\n // the HTML mark-up perpective).\n }\n <div // eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n aria-modal=\"true\"\n className={theme.container}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={(e) => {\n e.stopPropagation();\n }}\n onWheel={(event) => {\n event.stopPropagation();\n }}\n ref={containerRef}\n role=\"dialog\"\n style={style ?? containerStyle}\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n {focusLast}\n </div>\n ),\n document.body,\n );\n};\n\nexport default /* #__PURE__ */ themed(BaseModal, 'Modal', baseTheme);\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":"AAAA,OAIEA,SAAS,CACTC,OAAO,CACPC,MAAM,KACD,OAAO,CAEd,OAASC,YAAY,KAAQ,WAAW,CACxC,MAAO,CAAAC,MAAM,KAAsB,0BAA0B,OAAAC,SAAA,iGAAAC,CAAA,uCAG/B,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAiB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,SAAoC,CAAGA,CAAC,CAC5CC,iBAAiB,CACjBC,QAAQ,CACRC,cAAc,CACdC,oBAAoB,CACpBC,QAAQ,CACRC,YAAY,CACZC,KAAK,CACLC,MAAM,CACNC,gBAAgB,CAChBC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,YAAY,CAAGpB,MAAM,CAAwB,IAAI,CAAC,CACxD,KAAM,CAAAqB,UAAU,CAAGrB,MAAM,CAAwB,IAAI,CAAC,CAEtD;AACAF,SAAS,CAAC,IAAM,CACd,GAAIY,iBAAiB,EAAII,QAAQ,CAAE,CACjCQ,MAAM,CAACC,gBAAgB,CAAC,QAAQ,CAAET,QAAQ,CAAC,CAC3CQ,MAAM,CAACC,gBAAgB,CAAC,OAAO,CAAET,QAAQ,CAC3C,CACA,MAAO,IAAM,CACX,GAAIJ,iBAAiB,EAAII,QAAQ,CAAE,CACjCQ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DT,SAAS,EACP,CAAC,CAERN,QAAQ,CAACC,IACX,CACF,CAAC,CAED,cAAe,eAAgBxB,MAAM,CAACO,SAAS,CAAE,OAAO,CAAEN,SAAS,CAAC,CAEpE,sCACA,OAASM,SAAS","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactRouter=require("react-router");var _GenericLink=_interopRequireDefault(require("./GenericLink"));var _jsxRuntime=require("react/jsx-runtime");const NavLink=props=>/*#__PURE__*/(0,_jsxRuntime.jsx)(_GenericLink.default// TODO: I guess, we better re-write it to avoid the props spreading,
1
+ import{NavLink as RrNavLink}from"react-router";import GenericLink from"./GenericLink/index.js";import{jsx as _jsx}from"react/jsx-runtime";const NavLink=props=>/*#__PURE__*/_jsx(GenericLink// TODO: I guess, we better re-write it to avoid the props spreading,
2
2
  // but no need to spend time on it right now.
3
3
  // eslint-disable-next-line react/jsx-props-no-spreading
4
- ,{...props,routerLinkType:_reactRouter.NavLink});var _default=exports.default=NavLink;
4
+ ,{...props,routerLinkType:RrNavLink});export default NavLink;
5
5
  //# sourceMappingURL=NavLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NavLink.js","names":["_reactRouter","require","_GenericLink","_interopRequireDefault","_jsxRuntime","NavLink","props","jsx","default","routerLinkType","RrNavLink","_default","exports"],"sources":["../../../../src/shared/components/NavLink.tsx"],"sourcesContent":["import { type NavLinkProps, NavLink as RrNavLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & NavLinkProps;\n\nconst NavLink: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: I guess, we better re-write it to avoid the props spreading,\n // but no need to spend time on it right now.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrNavLink}\n />\n );\n\nexport default NavLink;\n"],"mappings":"gLAAA,IAAAA,YAAA,CAAAC,OAAA,iBAEA,IAAAC,YAAA,CAAAC,sBAAA,CAAAF,OAAA,mBAA8E,IAAAG,WAAA,CAAAH,OAAA,sBAI9E,KAAM,CAAAI,OAAwC,CACzCC,KAAK,eACN,GAAAF,WAAA,CAAAG,GAAA,EAACL,YAAA,CAAAM,OACC;AACA;AACA;AAAA,KACIF,KAAK,CACTG,cAAc,CAAEC,oBAAU,CAC3B,CACF,CAAC,IAAAC,QAAA,CAAAC,OAAA,CAAAJ,OAAA,CAEWH,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"NavLink.js","names":["NavLink","RrNavLink","GenericLink","jsx","_jsx","props","routerLinkType"],"sources":["../../../../src/shared/components/NavLink.tsx"],"sourcesContent":["import { type NavLinkProps, NavLink as RrNavLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & NavLinkProps;\n\nconst NavLink: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: I guess, we better re-write it to avoid the props spreading,\n // but no need to spend time on it right now.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrNavLink}\n />\n );\n\nexport default NavLink;\n"],"mappings":"AAAA,OAA4BA,OAAO,GAAI,CAAAC,SAAS,KAAQ,cAAc,OAE/D,CAAAC,WAAW,8BAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,OAAwC,CACzCK,KAAK,eACND,IAAA,CAACF,WACC;AACA;AACA;AAAA,KACIG,KAAK,CACTC,cAAc,CAAEL,SAAU,CAC3B,CACF,CAEH,cAAe,CAAAD,OAAO","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _jsxRuntime=require("react/jsx-runtime");const baseTheme={"context":"m4mL-M","ad":"m3-mdC","hoc":"J15Z4H","container":"T3cuHB","mainPanel":"pPlQO2","sidePanel":"lqNh4h"};/**
1
+ import themed from"@dr.pogodin/react-themes";const baseTheme={"context":"zv9tdn","ad":"yr8hbI","hoc":"_01Mz0J","container":"blPmpk","mainPanel":"zPoY0u","sidePanel":"mRD159"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * Simple and themeable page layout. It keeps the main content centered in
3
3
  * a column of limited width, which fills entire viewport on small screens
4
4
  * (under `$screen-md = 1024px` size). At larger screens the column keeps
@@ -12,5 +12,5 @@
12
12
  * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.
13
13
  * @param {...any} [props....]
14
14
  * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
15
- */const PageLayout=({children,leftSidePanelContent,rightSidePanelContent,theme})=>/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.container,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:[theme.sidePanel,theme.leftSidePanel].join(" "),children:leftSidePanelContent}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.mainPanel,children:children}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:[theme.sidePanel,theme.rightSidePanel].join(" "),children:rightSidePanelContent})]});var _default=exports.default=(0,_reactThemes.default)(PageLayout,"PageLayout",baseTheme);
15
+ */const PageLayout=({children,leftSidePanelContent,rightSidePanelContent,theme})=>/*#__PURE__*/_jsxs("div",{className:theme.container,children:[/*#__PURE__*/_jsx("div",{className:[theme.sidePanel,theme.leftSidePanel].join(" "),children:leftSidePanelContent}),/*#__PURE__*/_jsx("div",{className:theme.mainPanel,children:children}),/*#__PURE__*/_jsx("div",{className:[theme.sidePanel,theme.rightSidePanel].join(" "),children:rightSidePanelContent})]});export default/* #__PURE__ */themed(PageLayout,"PageLayout",baseTheme);
16
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireDefault","require","_jsxRuntime","baseTheme","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","jsxs","className","container","jsx","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel","_default","exports","default","themed"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\ntype ThemeKeyT = 'container' | 'leftSidePanel' | 'mainPanel' | 'rightSidePanel'\n | 'sidePanel';\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme: Theme<ThemeKeyT>;\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: React.FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n);\n\nexport default themed(PageLayout, 'PageLayout', baseTheme);\n"],"mappings":"gLAEA,IAAAA,YAAA,CAAAC,sBAAA,CAAAC,OAAA,8BAA8D,IAAAC,WAAA,CAAAD,OAAA,4BAAAE,SAAA,kHAc9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,UAA2C,CAAGA,CAAC,CACnDC,QAAQ,CACRC,oBAAoB,CACpBC,qBAAqB,CACrBC,KACF,CAAC,gBACC,GAAAN,WAAA,CAAAO,IAAA,SAAKC,SAAS,CAAEF,KAAK,CAACG,SAAU,CAAAN,QAAA,eAC9B,GAAAH,WAAA,CAAAU,GAAA,SAAKF,SAAS,CAAE,CAACF,KAAK,CAACK,SAAS,CAAEL,KAAK,CAACM,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE,CAAAV,QAAA,CAC9DC,oBAAoB,CAClB,CAAC,cACN,GAAAJ,WAAA,CAAAU,GAAA,SAAKF,SAAS,CAAEF,KAAK,CAACQ,SAAU,CAAAX,QAAA,CAC7BA,QAAQ,CACN,CAAC,cACN,GAAAH,WAAA,CAAAU,GAAA,SAAKF,SAAS,CAAE,CAACF,KAAK,CAACK,SAAS,CAAEL,KAAK,CAACS,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE,CAAAV,QAAA,CAC/DE,qBAAqB,CACnB,CAAC,EACH,CACN,CAAC,IAAAW,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEa,GAAAC,oBAAM,EAACjB,UAAU,CAAE,YAAY,CAAED,SAAS,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["themed","baseTheme","jsx","_jsx","jsxs","_jsxs","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","className","container","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\ntype ThemeKeyT = 'container' | 'leftSidePanel' | 'mainPanel' | 'rightSidePanel'\n | 'sidePanel';\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme: Theme<ThemeKeyT>;\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: React.FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n);\n\nexport default /* #__PURE__ */ themed(PageLayout, 'PageLayout', baseTheme);\n"],"mappings":"AAEA,MAAO,CAAAA,MAAM,KAAsB,0BAA0B,OAAAC,SAAA,mHAEnB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAY1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,UAA2C,CAAGA,CAAC,CACnDC,QAAQ,CACRC,oBAAoB,CACpBC,qBAAqB,CACrBC,KACF,CAAC,gBACCL,KAAA,QAAKM,SAAS,CAAED,KAAK,CAACE,SAAU,CAAAL,QAAA,eAC9BJ,IAAA,QAAKQ,SAAS,CAAE,CAACD,KAAK,CAACG,SAAS,CAAEH,KAAK,CAACI,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE,CAAAR,QAAA,CAC9DC,oBAAoB,CAClB,CAAC,cACNL,IAAA,QAAKQ,SAAS,CAAED,KAAK,CAACM,SAAU,CAAAT,QAAA,CAC7BA,QAAQ,CACN,CAAC,cACNJ,IAAA,QAAKQ,SAAS,CAAE,CAACD,KAAK,CAACG,SAAS,CAAEH,KAAK,CAACO,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE,CAAAR,QAAA,CAC/DE,qBAAqB,CACnB,CAAC,EACH,CACN,CAED,cAAe,eAAgBT,MAAM,CAACM,UAAU,CAAE,YAAY,CAAEL,SAAS,CAAC","ignoreList":[]}
@@ -1,12 +1,12 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=require("react");var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _jsxRuntime=require("react/jsx-runtime");const defaultTheme={"context":"KVPc7g","ad":"z2GQ0Z","hoc":"_8R1Qdj","container":"dzMVIB","label":"Vw9EKL","textarea":"zd-OFg","error":"K2JcEY","errorMessage":"nWsJDB","hidden":"GiHBXI"};const TextArea=({disabled,error,label,onBlur,onChange,onKeyDown,placeholder,testId,theme,value})=>{const hiddenAreaRef=(0,_react.useRef)(null);const[height,setHeight]=(0,_react.useState)();const textAreaRef=(0,_react.useRef)(null);const[localValue,setLocalValue]=(0,_react.useState)(value??"");if(value!==undefined&&localValue!==value)setLocalValue(value);// This resizes text area's height when its width is changed for any reason.
2
- (0,_react.useEffect)(()=>{const el=hiddenAreaRef.current;if(!el)return undefined;const cb=()=>{setHeight(el.scrollHeight)};const observer=new ResizeObserver(cb);observer.observe(el);return()=>{observer.disconnect()}},[]);// Resizes the text area when its content is modified.
1
+ import{useEffect,useLayoutEffect,useRef,useState}from"react";import themed from"@dr.pogodin/react-themes";const defaultTheme={"context":"tECG8C","ad":"epeH4O","hoc":"_2kFnSt","container":"lV5ZyX","label":"_7qDPW1","textarea":"gkaNJJ","error":"ObwtG4","errorMessage":"ikIw0x","hidden":"-UyujK"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TextArea=({disabled,error,label,onBlur,onChange,onKeyDown,placeholder,testId,theme,value})=>{const hiddenAreaRef=useRef(null);const[height,setHeight]=useState();const textAreaRef=useRef(null);const[localValue,setLocalValue]=useState(value??"");if(value!==undefined&&localValue!==value)setLocalValue(value);// This resizes text area's height when its width is changed for any reason.
2
+ useEffect(()=>{const el=hiddenAreaRef.current;if(!el)return undefined;const cb=()=>{setHeight(el.scrollHeight)};const observer=new ResizeObserver(cb);observer.observe(el);return()=>{observer.disconnect()}},[]);// Resizes the text area when its content is modified.
3
3
  //
4
4
  // NOTE: useLayoutEffect() instead of useEffect() makes difference here,
5
5
  // as it helps to avoid visible "content/height" jumps (i.e. with just
6
6
  // useEffect() it becomes visible how the content is modified first,
7
7
  // and then input height is incremented, if necessary).
8
8
  // See: https://github.com/birdofpreyru/react-utils/issues/313
9
- (0,_react.useLayoutEffect)(()=>{const el=hiddenAreaRef.current;if(el)setHeight(el.scrollHeight)},[localValue]);let containerClassName=theme.container;if(error)containerClassName+=` ${theme.error}`;return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:containerClassName,onFocus:()=>{textAreaRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsx)("textarea",{className:`${theme.textarea} ${theme.hidden}`// This text area is hidden underneath the primary one below,
9
+ useLayoutEffect(()=>{const el=hiddenAreaRef.current;if(el)setHeight(el.scrollHeight)},[localValue]);let containerClassName=theme.container;if(error)containerClassName+=` ${theme.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:()=>{textAreaRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:theme.label,children:label}),/*#__PURE__*/_jsx("textarea",{className:`${theme.textarea} ${theme.hidden}`// This text area is hidden underneath the primary one below,
10
10
  // and it is used for text measurements, to implement auto-scaling
11
11
  // of the primary textarea's height.
12
12
  ,readOnly:true,ref:hiddenAreaRef// The "-1" value of "tabIndex" removes this hidden text area from
@@ -15,8 +15,8 @@
15
15
  // area is zero, thus collapsing <TextArea> height below the single line
16
16
  // input height. To avoid it we fallback to whitespace (" ") character
17
17
  // here.
18
- ,value:localValue||" "}),/*#__PURE__*/(0,_jsxRuntime.jsx)("textarea",{className:theme.textarea,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onBlur:onBlur// When value is "undefined" the text area is not-managed, and we should
18
+ ,value:localValue||" "}),/*#__PURE__*/_jsx("textarea",{className:theme.textarea,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onBlur:onBlur// When value is "undefined" the text area is not-managed, and we should
19
19
  // manage it internally for the measurement / resizing functionality
20
20
  // to work.
21
- ,onChange:value===undefined?e=>{setLocalValue(e.target.value)}:onChange,onKeyDown:onKeyDown,placeholder:placeholder,ref:textAreaRef,style:{height},value:localValue}),error&&error!==true?/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.errorMessage,children:error}):null]})};var _default=exports.default=(0,_reactThemes.default)(TextArea,"TextArea",defaultTheme);
21
+ ,onChange:value===undefined?e=>{setLocalValue(e.target.value)}:onChange,onKeyDown:onKeyDown,placeholder:placeholder,ref:textAreaRef,style:{height},value:localValue}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:theme.errorMessage,children:error}):null]})};export default/* #__PURE__ */themed(TextArea,"TextArea",defaultTheme);
22
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","require","_reactThemes","_interopRequireDefault","_jsxRuntime","defaultTheme","TextArea","disabled","error","label","onBlur","onChange","onKeyDown","placeholder","testId","theme","value","hiddenAreaRef","useRef","height","setHeight","useState","textAreaRef","localValue","setLocalValue","undefined","useEffect","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","useLayoutEffect","containerClassName","container","jsxs","className","onFocus","focus","children","jsx","textarea","hidden","readOnly","ref","tabIndex","process","env","NODE_ENV","e","target","style","errorMessage","_default","exports","default","themed"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import {\n type ChangeEventHandler,\n type FocusEventHandler,\n type FunctionComponent,\n type KeyboardEventHandler,\n type ReactNode,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeKeyT = 'container' | 'error' | 'errorMessage' | 'hidden' | 'label'\n | 'textarea';\n\ntype Props = {\n disabled?: boolean;\n error?: ReactNode;\n label?: string;\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n placeholder?: string;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n value?: string;\n};\n\nconst TextArea: FunctionComponent<Props> = ({\n disabled,\n error,\n label,\n onBlur,\n onChange,\n onKeyDown,\n placeholder,\n testId,\n theme,\n value,\n}) => {\n const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);\n const [height, setHeight] = useState<number | undefined>();\n\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [localValue, setLocalValue] = useState(value ?? '');\n if (value !== undefined && localValue !== value) setLocalValue(value);\n\n // This resizes text area's height when its width is changed for any reason.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (!el) return undefined;\n\n const cb = () => {\n setHeight(el.scrollHeight);\n };\n const observer = new ResizeObserver(cb);\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n // Resizes the text area when its content is modified.\n //\n // NOTE: useLayoutEffect() instead of useEffect() makes difference here,\n // as it helps to avoid visible \"content/height\" jumps (i.e. with just\n // useEffect() it becomes visible how the content is modified first,\n // and then input height is incremented, if necessary).\n // See: https://github.com/birdofpreyru/react-utils/issues/313\n useLayoutEffect(() => {\n const el = hiddenAreaRef.current;\n if (el) setHeight(el.scrollHeight);\n }, [localValue]);\n\n let containerClassName = theme.container;\n if (error) containerClassName += ` ${theme.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n textAreaRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={theme.label}>{label}</div>}\n <textarea\n className={`${theme.textarea} ${theme.hidden}`}\n\n // This text area is hidden underneath the primary one below,\n // and it is used for text measurements, to implement auto-scaling\n // of the primary textarea's height.\n readOnly\n ref={hiddenAreaRef}\n\n // The \"-1\" value of \"tabIndex\" removes this hidden text area from\n // the tab-focus-chain.\n tabIndex={-1}\n\n // NOTE: With empty string value (\"\") the scrolling height of this text\n // area is zero, thus collapsing <TextArea> height below the single line\n // input height. To avoid it we fallback to whitespace (\" \") character\n // here.\n value={localValue || ' '}\n />\n <textarea\n className={theme.textarea}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onBlur={onBlur}\n\n // When value is \"undefined\" the text area is not-managed, and we should\n // manage it internally for the measurement / resizing functionality\n // to work.\n onChange={\n value === undefined\n ? (e) => {\n setLocalValue(e.target.value);\n } : onChange\n }\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={textAreaRef}\n style={{ height }}\n value={localValue}\n />\n {error && error !== true\n ? <div className={theme.errorMessage}>{error}</div>\n : null}\n </div>\n );\n};\n\nexport default themed(TextArea, 'TextArea', defaultTheme);\n"],"mappings":"gLAAA,IAAAA,MAAA,CAAAC,OAAA,UAYA,IAAAC,YAAA,CAAAC,sBAAA,CAAAF,OAAA,8BAA8D,IAAAG,WAAA,CAAAH,OAAA,4BAAAI,YAAA,yKAoB9D,KAAM,CAAAC,QAAkC,CAAGA,CAAC,CAC1CC,QAAQ,CACRC,KAA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GAAAJ,WAAA,CAAAuC,GAAA,SAAKJ,SAAS,CAAExB,KAAK,CAACwC,YAAa,CAAAb,QAAA,CAAElC,KAAK,CAAM,CAAC,CACjD,IAAI,EACL,CAET,CAAC,CAAC,IAAAgD,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEa,GAAAC,oBAAM,EAACrD,QAAQ,CAAE,UAAU,CAAED,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useLayoutEffect","useRef","useState","themed","defaultTheme","jsx","_jsx","jsxs","_jsxs","TextArea","disabled","error","label","onBlur","onChange","onKeyDown","placeholder","testId","theme","value","hiddenAreaRef","height","setHeight","textAreaRef","localValue","setLocalValue","undefined","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","containerClassName","container","className","onFocus","focus","children","textarea","hidden","readOnly","ref","tabIndex","process","env","NODE_ENV","e","target","style","errorMessage"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import {\n type ChangeEventHandler,\n type FocusEventHandler,\n type FunctionComponent,\n type KeyboardEventHandler,\n type ReactNode,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeKeyT = 'container' | 'error' | 'errorMessage' | 'hidden' | 'label'\n | 'textarea';\n\ntype Props = {\n disabled?: boolean;\n error?: ReactNode;\n label?: string;\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n placeholder?: string;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n value?: string;\n};\n\nconst TextArea: FunctionComponent<Props> = ({\n disabled,\n error,\n label,\n onBlur,\n onChange,\n onKeyDown,\n placeholder,\n testId,\n theme,\n value,\n}) => {\n const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);\n const [height, setHeight] = useState<number | undefined>();\n\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [localValue, setLocalValue] = useState(value ?? '');\n if (value !== undefined && localValue !== value) setLocalValue(value);\n\n // This resizes text area's height when its width is changed for any reason.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (!el) return undefined;\n\n const cb = () => {\n setHeight(el.scrollHeight);\n };\n const observer = new ResizeObserver(cb);\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n // Resizes the text area when its content is modified.\n //\n // NOTE: useLayoutEffect() instead of useEffect() makes difference here,\n // as it helps to avoid visible \"content/height\" jumps (i.e. with just\n // useEffect() it becomes visible how the content is modified first,\n // and then input height is incremented, if necessary).\n // See: https://github.com/birdofpreyru/react-utils/issues/313\n useLayoutEffect(() => {\n const el = hiddenAreaRef.current;\n if (el) setHeight(el.scrollHeight);\n }, [localValue]);\n\n let containerClassName = theme.container;\n if (error) containerClassName += ` ${theme.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n textAreaRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={theme.label}>{label}</div>}\n <textarea\n className={`${theme.textarea} ${theme.hidden}`}\n\n // This text area is hidden underneath the primary one below,\n // and it is used for text measurements, to implement auto-scaling\n // of the primary textarea's height.\n readOnly\n ref={hiddenAreaRef}\n\n // The \"-1\" value of \"tabIndex\" removes this hidden text area from\n // the tab-focus-chain.\n tabIndex={-1}\n\n // NOTE: With empty string value (\"\") the scrolling height of this text\n // area is zero, thus collapsing <TextArea> height below the single line\n // input height. To avoid it we fallback to whitespace (\" \") character\n // here.\n value={localValue || ' '}\n />\n <textarea\n className={theme.textarea}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onBlur={onBlur}\n\n // When value is \"undefined\" the text area is not-managed, and we should\n // manage it internally for the measurement / resizing functionality\n // to work.\n onChange={\n value === undefined\n ? (e) => {\n setLocalValue(e.target.value);\n } : onChange\n }\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={textAreaRef}\n style={{ height }}\n value={localValue}\n />\n {error && error !== true\n ? <div className={theme.errorMessage}>{error}</div>\n : null}\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(TextArea, 'TextArea', defaultTheme);\n"],"mappings":"AAAA,OAMEA,SAAS,CACTC,eAAe,CACfC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,MAAO,CAAAC,MAAM,KAAsB,0BAA0B,OAAAC,YAAA,0KAErB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAkBxC,KAAM,CAAAC,QAAkC,CAAGA,CAAC,CAC1CC,QAAQ,CACRC,KAAK,CACLC,KAAK,CACLC,MAAM,CACNC,QAAQ,CACRC,SAAS,CACTC,WAAW,CACXC,MAAM,CACNC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,aAAa,CAAGnB,MAAM,CAAsB,IAAI,CAAC,CACvD,KAAM,CAACoB,MAAM,CAAEC,SAAS,CAAC,CAAGpB,QAAQ,CAAqB,CAAC,CAE1D,KAAM,CAAAqB,WAAW,CAAGtB,MAAM,CAAsB,IAAI,CAAC,CAErD,KAAM,CAACuB,UAAU,CAAEC,aAAa,CAAC,CAAGvB,QAAQ,CAACiB,KAAK,EAAI,EAAE,CAAC,CACzD,GAAIA,KAAK,GAAKO,SAAS,EAAIF,UAAU,GAAKL,KAAK,CAAEM,aAAa,CAACN,KAAK,CAAC,CAErE;AACApB,SAAS,CAAC,IAAM,CACd,KAAM,CAAA4B,EAAE,CAAGP,aAAa,CAACQ,OAAO,CAChC,GAAI,CAACD,EAAE,CAAE,MAAO,CAAAD,SAAS,CAEzB,KAAM,CAAAG,EAAE,CAAGA,CAAA,GAAM,CACfP,SAAS,CAACK,EAAE,CAACG,YAAY,CAC3B,CAAC,CACD,KAAM,CAAAC,QAAQ,CAAG,GAAI,CAAAC,cAAc,CAACH,EAAE,CAAC,CACvCE,QAAQ,CAACE,OAAO,CAACN,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,SAAS,CACduB,CAAC,EAAK,CACPxB,aAAa,CAACwB,CAAC,CAACC,MAAM,CAAC/B,KAAK,CAC9B,CAAC,CAAGL,QACP,CACDC,SAAS,CAAEA,SAAU,CACrBC,WAAW,CAAEA,WAAY,CACzB4B,GAAG,CAAErB,WAAY,CACjB4B,KAAK,CAAE,CAAE9B,MAAO,CAAE,CAClBF,KAAK,CAAEK,UAAW,CACnB,CAAC,CACDb,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBL,IAAA,QAAK+B,SAAS,CAAEnB,KAAK,CAACkC,YAAa,CAAAZ,QAAA,CAAE7B,KAAK,CAAM,CAAC,CACjD,IAAI,EACL,CAET,CAAC,CAED,cAAe,eAAgBR,MAAM,CAACM,QAAQ,CAAE,UAAU,CAAEL,YAAY,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _jsxRuntime=require("react/jsx-runtime");const defaultTheme={"context":"uIObt7","ad":"XIxe9o","hoc":"YOyORH","bouncing":"TJe-6j","container":"_7zdld4","circle":"dBrB4g"};/**
1
+ import themed from"@dr.pogodin/react-themes";const defaultTheme={"context":"eVCJf-","ad":"CU2B6H","hoc":"_1V5iVx","bouncing":"h6ZYmQ","container":"VDVI-X","circle":"Y2rzbL"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * Throbber is an "action in progress" indicator, which renders
3
3
  * three bouncing circles as a simple pending activity indicator,
4
4
  * and can be further themed to a certain degree.
@@ -6,5 +6,5 @@
6
6
  * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.
7
7
  * @param {...any} [props....]
8
8
  * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
9
- */const Throbber=({theme})=>/*#__PURE__*/(0,_jsxRuntime.jsxs)("span",{className:theme.container,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("span",{className:theme.circle}),/*#__PURE__*/(0,_jsxRuntime.jsx)("span",{className:theme.circle}),/*#__PURE__*/(0,_jsxRuntime.jsx)("span",{className:theme.circle})]});var _default=exports.default=(0,_reactThemes.default)(Throbber,"Throbber",defaultTheme);
9
+ */const Throbber=({theme})=>/*#__PURE__*/_jsxs("span",{className:theme.container,children:[/*#__PURE__*/_jsx("span",{className:theme.circle}),/*#__PURE__*/_jsx("span",{className:theme.circle}),/*#__PURE__*/_jsx("span",{className:theme.circle})]});export default/* #__PURE__ */themed(Throbber,"Throbber",defaultTheme);
10
10
  //# sourceMappingURL=index.js.map