@dr.pogodin/react-utils 1.47.0-alpha.1 → 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 (306) hide show
  1. package/babel.config.js +1 -1
  2. package/babel.module.config.js +11 -0
  3. package/bin/build.js +8 -4
  4. package/bin/setup.js +2 -3
  5. package/build/development/client/getInj.js +57 -44
  6. package/build/development/client/getInj.js.map +1 -1
  7. package/build/development/client/index.js +15 -21
  8. package/build/development/client/index.js.map +1 -1
  9. package/build/development/client/init.js +2 -6
  10. package/build/development/client/init.js.map +1 -1
  11. package/build/development/index.js +3 -183
  12. package/build/development/index.js.map +1 -1
  13. package/build/development/server/Cache.js +1 -8
  14. package/build/development/server/Cache.js.map +1 -1
  15. package/build/development/server/index.js +22 -50
  16. package/build/development/server/index.js.map +1 -1
  17. package/build/development/server/renderer.js +83 -92
  18. package/build/development/server/renderer.js.map +1 -1
  19. package/build/development/server/server.js +58 -62
  20. package/build/development/server/server.js.map +1 -1
  21. package/build/development/server/utils/errors.js +8 -31
  22. package/build/development/server/utils/errors.js.map +1 -1
  23. package/build/development/server/utils/index.js +2 -9
  24. package/build/development/server/utils/index.js.map +1 -1
  25. package/build/development/shared/components/Button/index.js +9 -16
  26. package/build/development/shared/components/Button/index.js.map +1 -1
  27. package/build/development/shared/components/Checkbox/index.js +6 -13
  28. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  29. package/build/development/shared/components/GenericLink/index.js +4 -10
  30. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  31. package/build/development/shared/components/Input/index.js +11 -18
  32. package/build/development/shared/components/Input/index.js.map +1 -1
  33. package/build/development/shared/components/Link.js +6 -13
  34. package/build/development/shared/components/Link.js.map +1 -1
  35. package/build/development/shared/components/Modal/index.js +16 -22
  36. package/build/development/shared/components/Modal/index.js.map +1 -1
  37. package/build/development/shared/components/NavLink.js +6 -13
  38. package/build/development/shared/components/NavLink.js.map +1 -1
  39. package/build/development/shared/components/PageLayout/index.js +7 -14
  40. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  41. package/build/development/shared/components/TextArea/index.js +15 -22
  42. package/build/development/shared/components/TextArea/index.js.map +1 -1
  43. package/build/development/shared/components/Throbber/index.js +7 -14
  44. package/build/development/shared/components/Throbber/index.js.map +1 -1
  45. package/build/development/shared/components/WithTooltip/Tooltip.js +12 -18
  46. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  47. package/build/development/shared/components/WithTooltip/index.js +16 -23
  48. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  49. package/build/development/shared/components/YouTubeVideo/index.js +10 -17
  50. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  51. package/build/development/shared/components/index.js +16 -130
  52. package/build/development/shared/components/index.js.map +1 -1
  53. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +18 -19
  54. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  55. package/build/development/shared/components/selectors/CustomDropdown/index.js +24 -28
  56. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  57. package/build/development/shared/components/selectors/NativeDropdown/index.js +19 -19
  58. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  59. package/build/development/shared/components/selectors/Switch/index.js +12 -17
  60. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  61. package/build/development/shared/components/selectors/common.js +1 -7
  62. package/build/development/shared/components/selectors/common.js.map +1 -1
  63. package/build/development/shared/components/selectors/index.js +3 -27
  64. package/build/development/shared/components/selectors/index.js.map +1 -1
  65. package/build/development/shared/utils/config.js +40 -21
  66. package/build/development/shared/utils/config.js.map +1 -1
  67. package/build/development/shared/utils/globalState.js +3 -8
  68. package/build/development/shared/utils/globalState.js.map +1 -1
  69. package/build/development/shared/utils/index.js +12 -89
  70. package/build/development/shared/utils/index.js.map +1 -1
  71. package/build/development/shared/utils/isomorphy/buildInfo.js +2 -9
  72. package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
  73. package/build/development/shared/utils/isomorphy/environment-check.js +2 -8
  74. package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
  75. package/build/development/shared/utils/isomorphy/index.js +7 -32
  76. package/build/development/shared/utils/isomorphy/index.js.map +1 -1
  77. package/build/development/shared/utils/jest/E2eSsrEnv.js +24 -31
  78. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  79. package/build/development/shared/utils/jest/global.js +1 -7
  80. package/build/development/shared/utils/jest/global.js.map +1 -1
  81. package/build/development/shared/utils/jest/index.js +20 -44
  82. package/build/development/shared/utils/jest/index.js.map +1 -1
  83. package/build/development/shared/utils/splitComponent.js +54 -46
  84. package/build/development/shared/utils/splitComponent.js.map +1 -1
  85. package/build/development/shared/utils/time.js +22 -31
  86. package/build/development/shared/utils/time.js.map +1 -1
  87. package/build/development/shared/utils/webpack.js +17 -16
  88. package/build/development/shared/utils/webpack.js.map +1 -1
  89. package/build/production/client/getInj.js +13 -11
  90. package/build/production/client/getInj.js.map +1 -1
  91. package/build/production/client/index.js +3 -3
  92. package/build/production/client/index.js.map +1 -1
  93. package/build/production/client/init.js +2 -2
  94. package/build/production/client/init.js.map +1 -1
  95. package/build/production/index.js +2 -6
  96. package/build/production/index.js.map +1 -1
  97. package/build/production/server/Cache.js +3 -3
  98. package/build/production/server/Cache.js.map +1 -1
  99. package/build/production/server/index.js +8 -8
  100. package/build/production/server/index.js.map +1 -1
  101. package/build/production/server/renderer.js +24 -25
  102. package/build/production/server/renderer.js.map +1 -1
  103. package/build/production/server/server.js +9 -11
  104. package/build/production/server/server.js.map +1 -1
  105. package/build/production/server/utils/errors.js +9 -9
  106. package/build/production/server/utils/errors.js.map +1 -1
  107. package/build/production/server/utils/index.js +2 -1
  108. package/build/production/server/utils/index.js.map +1 -1
  109. package/build/production/shared/components/Button/index.js +4 -4
  110. package/build/production/shared/components/Button/index.js.map +1 -1
  111. package/build/production/shared/components/Checkbox/index.js +1 -1
  112. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  113. package/build/production/shared/components/GenericLink/index.js +4 -4
  114. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  115. package/build/production/shared/components/Input/index.js +5 -5
  116. package/build/production/shared/components/Input/index.js.map +1 -1
  117. package/build/production/shared/components/Link.js +3 -3
  118. package/build/production/shared/components/Link.js.map +1 -1
  119. package/build/production/shared/components/Modal/index.js +7 -7
  120. package/build/production/shared/components/Modal/index.js.map +1 -1
  121. package/build/production/shared/components/NavLink.js +2 -2
  122. package/build/production/shared/components/NavLink.js.map +1 -1
  123. package/build/production/shared/components/PageLayout/index.js +2 -2
  124. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  125. package/build/production/shared/components/TextArea/index.js +5 -5
  126. package/build/production/shared/components/TextArea/index.js.map +1 -1
  127. package/build/production/shared/components/Throbber/index.js +2 -2
  128. package/build/production/shared/components/Throbber/index.js.map +1 -1
  129. package/build/production/shared/components/WithTooltip/Tooltip.js +4 -4
  130. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  131. package/build/production/shared/components/WithTooltip/index.js +4 -4
  132. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  133. package/build/production/shared/components/YouTubeVideo/index.js +4 -4
  134. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  135. package/build/production/shared/components/index.js +3 -1
  136. package/build/production/shared/components/index.js.map +1 -1
  137. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
  138. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  139. package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
  140. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  141. package/build/production/shared/components/selectors/NativeDropdown/index.js +4 -4
  142. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  143. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  144. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  145. package/build/production/shared/components/selectors/common.js +2 -2
  146. package/build/production/shared/components/selectors/common.js.map +1 -1
  147. package/build/production/shared/components/selectors/index.js +1 -1
  148. package/build/production/shared/components/selectors/index.js.map +1 -1
  149. package/build/production/shared/utils/config.js +8 -6
  150. package/build/production/shared/utils/config.js.map +1 -1
  151. package/build/production/shared/utils/globalState.js +2 -2
  152. package/build/production/shared/utils/globalState.js.map +1 -1
  153. package/build/production/shared/utils/index.js +1 -1
  154. package/build/production/shared/utils/index.js.map +1 -1
  155. package/build/production/shared/utils/isomorphy/buildInfo.js +3 -3
  156. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  157. package/build/production/shared/utils/isomorphy/environment-check.js +3 -3
  158. package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
  159. package/build/production/shared/utils/isomorphy/index.js +4 -4
  160. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  161. package/build/production/shared/utils/jest/E2eSsrEnv.js +14 -14
  162. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  163. package/build/production/shared/utils/jest/global.js +1 -1
  164. package/build/production/shared/utils/jest/global.js.map +1 -1
  165. package/build/production/shared/utils/jest/index.js +11 -11
  166. package/build/production/shared/utils/jest/index.js.map +1 -1
  167. package/build/production/shared/utils/splitComponent.js +11 -22
  168. package/build/production/shared/utils/splitComponent.js.map +1 -1
  169. package/build/production/shared/utils/time.js +3 -3
  170. package/build/production/shared/utils/time.js.map +1 -1
  171. package/build/production/shared/utils/webpack.js +6 -6
  172. package/build/production/shared/utils/webpack.js.map +1 -1
  173. package/build/types-code/client/getInj.d.ts +1 -2
  174. package/build/types-code/client/index.d.ts +1 -1
  175. package/build/types-code/index.d.ts +1 -7
  176. package/build/types-code/server/index.d.ts +6 -11
  177. package/build/types-code/server/utils/index.d.ts +1 -1
  178. package/build/types-code/shared/utils/config.d.ts +4 -2
  179. package/build/types-code/shared/utils/index.d.ts +2 -2
  180. package/build/types-code/shared/utils/splitComponent.d.ts +6 -4
  181. package/build/web/client/getInj.js +55 -44
  182. package/build/web/client/getInj.js.map +1 -1
  183. package/build/web/client/index.js +15 -21
  184. package/build/web/client/index.js.map +1 -1
  185. package/build/web/client/init.js +2 -4
  186. package/build/web/client/init.js.map +1 -1
  187. package/build/web/index.js +1 -15
  188. package/build/web/index.js.map +1 -1
  189. package/build/web/server/index.js +12 -21
  190. package/build/web/server/index.js.map +1 -1
  191. package/build/web/server/renderer.js +34 -40
  192. package/build/web/server/renderer.js.map +1 -1
  193. package/build/web/server/server.js +14 -11
  194. package/build/web/server/server.js.map +1 -1
  195. package/build/web/server/utils/index.js +1 -1
  196. package/build/web/server/utils/index.js.map +1 -1
  197. package/build/web/shared/components/Button/index.js +1 -1
  198. package/build/web/shared/components/Button/index.js.map +1 -1
  199. package/build/web/shared/components/Checkbox/index.js +1 -1
  200. package/build/web/shared/components/Checkbox/index.js.map +1 -1
  201. package/build/web/shared/components/Input/index.js +1 -1
  202. package/build/web/shared/components/Input/index.js.map +1 -1
  203. package/build/web/shared/components/Modal/index.js +3 -3
  204. package/build/web/shared/components/Modal/index.js.map +1 -1
  205. package/build/web/shared/components/PageLayout/index.js +1 -1
  206. package/build/web/shared/components/PageLayout/index.js.map +1 -1
  207. package/build/web/shared/components/TextArea/index.js +1 -1
  208. package/build/web/shared/components/TextArea/index.js.map +1 -1
  209. package/build/web/shared/components/Throbber/index.js +1 -1
  210. package/build/web/shared/components/Throbber/index.js.map +1 -1
  211. package/build/web/shared/components/WithTooltip/index.js +1 -1
  212. package/build/web/shared/components/WithTooltip/index.js.map +1 -1
  213. package/build/web/shared/components/YouTubeVideo/index.js +1 -1
  214. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
  215. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +3 -0
  216. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  217. package/build/web/shared/components/selectors/CustomDropdown/index.js +3 -1
  218. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  219. package/build/web/shared/components/selectors/NativeDropdown/index.js +4 -1
  220. package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  221. package/build/web/shared/components/selectors/Switch/index.js +2 -1
  222. package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
  223. package/build/web/shared/utils/config.js +38 -14
  224. package/build/web/shared/utils/config.js.map +1 -1
  225. package/build/web/shared/utils/index.js +2 -2
  226. package/build/web/shared/utils/index.js.map +1 -1
  227. package/build/web/shared/utils/jest/E2eSsrEnv.js +3 -2
  228. package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  229. package/build/web/shared/utils/splitComponent.js +27 -20
  230. package/build/web/shared/utils/splitComponent.js.map +1 -1
  231. package/build/web/shared/utils/webpack.js +13 -7
  232. package/build/web/shared/utils/webpack.js.map +1 -1
  233. package/config/babel/node-ssr.js +12 -6
  234. package/config/babel/webpack.js +6 -1
  235. package/config/jest/default.js +8 -2
  236. package/config/jest/setup.js +8 -1
  237. package/config/webpack/app-base.js +23 -15
  238. package/config/webpack/app-development.js +2 -3
  239. package/config/webpack/lib-base.js +1 -2
  240. package/package.json +35 -25
  241. package/types.d.ts +1 -6
  242. package/node-entry.js +0 -15
  243. package/src/client/getInj.ts +0 -51
  244. package/src/client/index.tsx +0 -43
  245. package/src/client/init.ts +0 -52
  246. package/src/index.ts +0 -79
  247. package/src/server/Cache.ts +0 -61
  248. package/src/server/index.ts +0 -249
  249. package/src/server/renderer.tsx +0 -653
  250. package/src/server/server.ts +0 -332
  251. package/src/server/utils/errors.ts +0 -122
  252. package/src/server/utils/index.ts +0 -3
  253. package/src/shared/components/Button/index.tsx +0 -130
  254. package/src/shared/components/Button/style.scss +0 -54
  255. package/src/shared/components/Checkbox/index.tsx +0 -53
  256. package/src/shared/components/Checkbox/theme.scss +0 -63
  257. package/src/shared/components/GenericLink/index.tsx +0 -141
  258. package/src/shared/components/GenericLink/style.scss +0 -3
  259. package/src/shared/components/Input/index.tsx +0 -96
  260. package/src/shared/components/Input/theme.scss +0 -52
  261. package/src/shared/components/Link.tsx +0 -25
  262. package/src/shared/components/Modal/base-theme.scss +0 -38
  263. package/src/shared/components/Modal/index.tsx +0 -177
  264. package/src/shared/components/Modal/styles.scss +0 -3
  265. package/src/shared/components/NavLink.tsx +0 -18
  266. package/src/shared/components/PageLayout/base-theme.scss +0 -30
  267. package/src/shared/components/PageLayout/index.tsx +0 -51
  268. package/src/shared/components/TextArea/index.tsx +0 -139
  269. package/src/shared/components/TextArea/style.scss +0 -68
  270. package/src/shared/components/Throbber/index.tsx +0 -28
  271. package/src/shared/components/Throbber/theme.scss +0 -26
  272. package/src/shared/components/WithTooltip/Tooltip.tsx +0 -274
  273. package/src/shared/components/WithTooltip/default-theme.scss +0 -36
  274. package/src/shared/components/WithTooltip/index.tsx +0 -186
  275. package/src/shared/components/YouTubeVideo/base.scss +0 -15
  276. package/src/shared/components/YouTubeVideo/index.tsx +0 -73
  277. package/src/shared/components/YouTubeVideo/throbber.scss +0 -11
  278. package/src/shared/components/index.ts +0 -20
  279. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +0 -124
  280. package/src/shared/components/selectors/CustomDropdown/Options/style.scss +0 -6
  281. package/src/shared/components/selectors/CustomDropdown/index.tsx +0 -146
  282. package/src/shared/components/selectors/CustomDropdown/theme.scss +0 -118
  283. package/src/shared/components/selectors/NativeDropdown/index.tsx +0 -90
  284. package/src/shared/components/selectors/NativeDropdown/theme.scss +0 -81
  285. package/src/shared/components/selectors/Switch/index.tsx +0 -74
  286. package/src/shared/components/selectors/Switch/theme.scss +0 -39
  287. package/src/shared/components/selectors/common.ts +0 -57
  288. package/src/shared/components/selectors/index.ts +0 -8
  289. package/src/shared/utils/config.ts +0 -28
  290. package/src/shared/utils/globalState.ts +0 -44
  291. package/src/shared/utils/index.ts +0 -45
  292. package/src/shared/utils/isomorphy/buildInfo.ts +0 -50
  293. package/src/shared/utils/isomorphy/environment-check.ts +0 -18
  294. package/src/shared/utils/isomorphy/index.ts +0 -36
  295. package/src/shared/utils/jest/E2eSsrEnv.ts +0 -305
  296. package/src/shared/utils/jest/global.ts +0 -17
  297. package/src/shared/utils/jest/index.ts +0 -215
  298. package/src/shared/utils/splitComponent.tsx +0 -275
  299. package/src/shared/utils/time.ts +0 -101
  300. package/src/shared/utils/webpack.ts +0 -74
  301. package/src/styles/_global/reset.css +0 -52
  302. package/src/styles/_mixins/fonts.scss +0 -40
  303. package/src/styles/_mixins/media.scss +0 -150
  304. package/src/styles/_mixins/typography.scss +0 -83
  305. package/src/styles/global.scss +0 -11
  306. package/src/styles/mixins.scss +0 -6
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["_nodePath","require","_nodeUrl","_cloneDeep","_interopRequireDefault","_mapValues","_pick","_compression","_cookieParser","_csurf","_express","_serveFavicon","_helmet","_morgan","_requestIp","_uuid","_renderer","_errors","defaultCspSettings","directives","mapValues","helmet","contentSecurityPolicy","getDefaultDirectives","array","filter","item","push","getDefaultCspSettings","cloneDeep","factory","webpackConfig","options","rendererOps","pick","renderer","rendererFactory","publicPath","output","server","express","beforeExpressJsSetup","logger","httpsRedirect","use","req","res","next","schema","headers","url","host","originalUrl","redirect","compression","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","noCsp","req2","nonce","uuid","cspNonce","cspSettings","cspSettingsHook","favicon","send","json","limit","urlencoded","extended","cookieParser","cookieSignatureSecret","requestIp","mw","csrf","cookie","loggerMiddleware","token","clientIp","FORMAT","stream","write","info","bind","get","static","path","setHeaders","set","devMode","global","location","href","pathToFileURL","process","cwd","sep","webpack","webpackDevMiddleware","webpackHotMiddleware","compiler","serverSideRender","onExpressJsSetup","newError","ERRORS","NOT_FOUND","CODES","dontAttachDefaultErrorHandler","beforeExpressJsError","error","headersSent","status","INTERNAL_SERVER_ERROR","serverSide","log","toString","message","getErrorForCode","env","NODE_ENV"],"sources":["../../../src/server/server.ts"],"sourcesContent":["/**\n * Creation of standard ExpressJS server for ReactJS apps.\n */\n\nimport { sep } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport cloneDeep from 'lodash/cloneDeep';\nimport mapValues from 'lodash/mapValues';\nimport pick from 'lodash/pick';\n\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport csrf from '@dr.pogodin/csurf';\n\nimport express, {\n type Express,\n type NextFunction,\n type RequestHandler,\n type Request,\n type Response,\n} from 'express';\n\nimport favicon from 'serve-favicon';\nimport helmet, { type HelmetOptions } from 'helmet';\nimport loggerMiddleware from 'morgan';\nimport requestIp from 'request-ip';\nimport { v4 as uuid } from 'uuid';\n\nimport type { Compiler, Configuration } from 'webpack';\n\nimport rendererFactory, {\n type LoggerI,\n type OptionsT as RendererOptionsT,\n} from './renderer';\n\nimport {\n CODES,\n ERRORS,\n getErrorForCode,\n newError,\n} from './utils/errors';\n\nexport type CspOptionsT = Exclude<HelmetOptions['contentSecurityPolicy'], boolean | undefined>;\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ninterface RequestT extends Request {\n cspNonce: string;\n nonce: string;\n}\n\n/**\n * Default Content Security Policy settings.\n * @ignore\n */\nconst defaultCspSettings = {\n directives: mapValues(\n helmet.contentSecurityPolicy.getDefaultDirectives(),\n\n // 'https:' options (automatic re-write of insecure URLs to secure ones)\n // is removed to facilitate local development with HTTP server. In cloud\n // deployments we assume Apache or Nginx server in front of out app takes\n // care about such re-writes.\n (array) => (array as string[]).filter((item: string) => item !== 'https:'),\n ),\n};\ndefaultCspSettings.directives['frame-src'] = [\n \"'self'\",\n\n // YouTube domain is whitelisted to allow <YouTubeVideo> component to work\n // out of box.\n 'https://*.youtube.com',\n];\n\n{\n const directives = defaultCspSettings.directives['script-src'];\n if (directives) directives.push(\"'unsafe-eval'\");\n else defaultCspSettings.directives['script-src'] = [\"'unsafe-eval'\"];\n}\n\n// No need for automatic re-writes via Content Security Policy settings:\n// the forefront Apache or Nginx server is supposed to take care of this\n// in production cloud deployments.\ndelete defaultCspSettings.directives['upgrade-insecure-requests'];\n\n/**\n * @category Utilities\n * @func server/getDefaultCspSettings\n * @global\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { getDefaultCspSettings } from '@dr.pogodin/react-utils';\n * ```\n * @return {{\n * directives: object\n * }} A deep copy of default CSP settings object used by `react-utils`,\n * with the exception of `nonce-xxx` clause in `script-src` directive,\n * which is added dynamically for each request.\n */\nexport function getDefaultCspSettings(): {\n directives: Record<string, string[]>;\n} {\n return cloneDeep(defaultCspSettings);\n}\n\nexport type ServerT = Express & {\n logger: LoggerI;\n};\n\nexport type OptionsT = RendererOptionsT & {\n beforeExpressJsError?:\n (server: ServerT) => boolean | Promise<boolean>;\n\n beforeExpressJsSetup?: (server: ServerT) => Promise<void> | void;\n cookieSignatureSecret?: string;\n cspSettingsHook?: (\n defaultOptions: CspOptionsT,\n req: Request,\n ) => CspOptionsT;\n devMode?: boolean;\n httpsRedirect?: boolean;\n onExpressJsSetup?: (server: ServerT) => Promise<void> | void;\n};\n\nexport default async function factory(\n webpackConfig: Configuration,\n options: OptionsT,\n): Promise<ServerT> {\n const rendererOps: RendererOptionsT = pick(options, [\n 'Application',\n 'beforeRender',\n 'favicon',\n 'logger',\n 'maxSsrRounds',\n 'noCsp',\n 'ssrTimeout',\n 'staticCacheController',\n 'staticCacheSize',\n ]);\n const renderer = rendererFactory(webpackConfig, rendererOps);\n const { publicPath } = webpackConfig.output!;\n\n const server = express() as ServerT;\n\n if (options.beforeExpressJsSetup) {\n await options.beforeExpressJsSetup(server);\n }\n\n if (options.logger) server.logger = options.logger;\n\n if (options.httpsRedirect) {\n server.use((req, res, next) => {\n const schema = req.headers['x-forwarded-proto'];\n if (schema === 'http') {\n let url = `https://${req.headers.host}`;\n if (req.originalUrl !== '/') url += req.originalUrl;\n res.redirect(url);\n return;\n }\n next();\n });\n }\n\n server.use(compression());\n server.use(\n helmet({\n contentSecurityPolicy: false,\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n }),\n );\n\n if (!options.noCsp) {\n server.use(\n (req: Request, res: Response, next: NextFunction) => {\n const req2 = req as RequestT;\n\n req2.nonce = uuid();\n\n // TODO: This is deprecated, but it is kept for now for backward\n // compatibility. Should be removed sometime later.\n req2.cspNonce = req2.nonce;\n\n // The deep clone is necessary here to ensure that default value can't be\n // mutated during request processing.\n let cspSettings: CspOptionsT = cloneDeep(defaultCspSettings);\n (cspSettings.directives?.['script-src'] as string[]).push(`'nonce-${req2.nonce}'`);\n if (options.cspSettingsHook) {\n cspSettings = options.cspSettingsHook(cspSettings, req);\n }\n helmet.contentSecurityPolicy(cspSettings)(req, res, next);\n },\n );\n }\n\n if (options.favicon) {\n server.use(favicon(options.favicon));\n }\n\n server.use('/robots.txt', (req, res) => {\n res.send('User-agent: *\\nDisallow:');\n });\n\n server.use(express.json({ limit: '300kb' }));\n server.use(express.urlencoded({ extended: false }));\n server.use(cookieParser(options.cookieSignatureSecret));\n server.use(requestIp.mw());\n\n server.use(csrf({ cookie: true }));\n\n loggerMiddleware.token(\n 'ip',\n (req: Request & { clientIp: string }) => req.clientIp,\n );\n const FORMAT = ':ip > :status :method :url :response-time ms :res[content-length] :referrer :user-agent';\n server.use(loggerMiddleware(FORMAT, {\n stream: {\n // TODO: This implies the logger is always set. Is it on a higher level?\n // then mark it as always present.\n write: options.logger!.info.bind(options.logger),\n },\n }));\n\n // Note: no matter the \"public path\", we want the service worker, if any,\n // to be served from the root, to have all web app pages in its scope.\n // Thus, this setup to serve it. Probably, need some more configuration\n // for special cases, but this will do for now.\n server.get('/__service-worker.js', express.static(\n webpackConfig.output?.path ?? '',\n {\n setHeaders: (res) => res.set('Cache-Control', 'no-cache'),\n },\n ));\n\n /* Setup of Hot Module Reloading for development environment.\n * These dependencies are not used, nor installed for production use,\n * hence we should violate some import-related lint rules. */\n /* eslint-disable import/no-extraneous-dependencies */\n if (options.devMode) {\n // This is a workaround for SASS bug:\n // https://github.com/dart-lang/sdk/issues/27979\n // which manifests itself sometimes when webpack dev middleware is used\n // (in dev mode), and app modules are imported in some unfortunate ways.\n // TODO: Double-check, what is going on here.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!global.location) {\n global.location = {\n href: `${pathToFileURL(process.cwd()).href}${sep}`,\n } as Location;\n }\n\n /* eslint-disable @typescript-eslint/no-require-imports */\n const webpack = require('webpack') as (ops: Configuration) => Compiler;\n\n // TODO: Figure out the exact type for options, don't wanna waste time on it\n // right now.\n const webpackDevMiddleware = require('webpack-dev-middleware') as\n (c: Compiler, ops: unknown) => RequestHandler;\n\n const webpackHotMiddleware = require('webpack-hot-middleware') as\n (c: Compiler) => RequestHandler;\n\n const compiler = webpack(webpackConfig);\n server.use(webpackDevMiddleware(compiler, {\n publicPath,\n serverSideRender: true,\n }));\n server.use(webpackHotMiddleware(compiler));\n }\n /* eslint-enable import/no-extraneous-dependencies */\n\n server.use(publicPath as string, express.static(webpackConfig.output!.path!));\n\n if (options.onExpressJsSetup) {\n await options.onExpressJsSetup(server);\n }\n server.use(renderer);\n\n /* Detects 404 errors, and forwards them to the error handler. */\n server.use((req, res, next) => {\n next(newError(ERRORS.NOT_FOUND, CODES.NOT_FOUND));\n });\n\n let dontAttachDefaultErrorHandler;\n if (options.beforeExpressJsError) {\n dontAttachDefaultErrorHandler = await options.beforeExpressJsError(server);\n }\n\n /* Error handler. */\n if (!dontAttachDefaultErrorHandler) {\n // TODO: Do we need this error handler at all? It actually seems to do\n // what the default ExpressJS error handler does anyway, see:\n // https://expressjs.com/en/guide/error-handling.html\n //\n // TODO: It is better to move the default error handler definition\n // to a stand-alone function at top-level, but the use of options.logger\n // prevents to do it without some extra refactoring. Should be done sometime\n // though.\n server.use((\n error: Error & {\n status?: number;\n },\n req: Request,\n res: Response,\n next: NextFunction,\n ) => {\n // TODO: This is needed to correctly handled any errors thrown after\n // sending initial response to the client.\n if (res.headersSent) {\n next(error);\n return;\n }\n\n const status = error.status ?? CODES.INTERNAL_SERVER_ERROR;\n const serverSide = status >= (CODES.INTERNAL_SERVER_ERROR as number);\n\n // Log server-side errors always, client-side at debug level only.\n options.logger!.log(serverSide ? 'error' : 'debug', error.toString());\n\n let message = error.message || getErrorForCode(status);\n if (serverSide && process.env.NODE_ENV === 'production') {\n message = ERRORS.INTERNAL_SERVER_ERROR;\n }\n\n res.status(status).send(message);\n });\n }\n\n return server;\n}\n"],"mappings":"qOAIA,IAAAA,SAAA,CAAAC,OAAA,cACA,IAAAC,QAAA,CAAAD,OAAA,aAEA,IAAAE,UAAA,CAAAC,sBAAA,CAAAH,OAAA,sBACA,IAAAI,UAAA,CAAAD,sBAAA,CAAAH,OAAA,sBACA,IAAAK,KAAA,CAAAF,sBAAA,CAAAH,OAAA,iBAEA,IAAAM,YAAA,CAAAH,sBAAA,CAAAH,OAAA,iBACA,IAAAO,aAAA,CAAAJ,sBAAA,CAAAH,OAAA,mBACA,IAAAQ,MAAA,CAAAL,sBAAA,CAAAH,OAAA,uBAEA,IAAAS,QAAA,CAAAN,sBAAA,CAAAH,OAAA,aAQA,IAAAU,aAAA,CAAAP,sBAAA,CAAAH,OAAA,mBACA,IAAAW,OAAA,CAAAR,sBAAA,CAAAH,OAAA,YACA,IAAAY,OAAA,CAAAT,sBAAA,CAAAH,OAAA,YACA,IAAAa,UAAA,CAAAV,sBAAA,CAAAH,OAAA,gBACA,IAAAc,KAAA,CAAAd,OAAA,SAIA,IAAAe,SAAA,CAAAZ,sBAAA,CAAAH,OAAA,gBAKA,IAAAgB,OAAA,CAAAhB,OAAA,mBApCA;AACA;AACA,GA2CA;AAMA;AACA;AACA;AACA,GACA,KAAM,CAAAiB,kBAAkB,CAAG,CACzBC,UAAU,CAAE,GAAAC,kBAAS,EACnBC,eAAM,CAACC,qBAAqB,CAACC,oBAAoB,CAAC,CAAC,CAEnD;AACA;AACA;AACA;AACCC,KAAK,EAAMA,KAAK,CAAcC,MAAM,CAAEC,IAAY,EAAKA,IAAI,GAAK,QAAQ,CAC3E,CACF,CAAC,CACDR,kBAAkB,CAAC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CAAC,CAACC,GAAG,CAAEC,GAAG,CAAEC,IAAI,GAAK,CAC7BA,IAAI,CAAC,GAAAyD,gBAAQ,EAACC,cAAM,CAACC,SAAS,CAAEC,aAAK,CAACD,SAAS,CAAC,CAClD,CAAC,CAAC,CAEF,GAAI,CAAAE,6BAA6B,CACjC,GAAI5E,OAAO,CAAC6E,oBAAoB,CAAE,CAChCD,6BAA6B,CAAG,KAAM,CAAA5E,OAAO,CAAC6E,oBAAoB,CAACtE,MAAM,CAC3E,CAEA,oBACA,GAAI,CAACqE,6BAA6B,CAAE,CAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACArE,MAAM,CAACK,GAAG,CAAC,CACTkE,KAEC,CACDjE,GAAY,CACZC,GAAa,CACbC,IAAkB,GACf,CACH;AACA;AACA,GAAID,GAAG,CAACiE,WAAW,CAAE,CACnBhE,IAAI,CAAC+D,KAAK,CAAC,CACX,MACF,CAEA,KAAM,CAAAE,MAAM,CAAGF,KAAK,CAACE,MAAM,EAAIL,aAAK,CAACM,qBAAqB,CAC1D,KAAM,CAAAC,UAAU,CAAGF,MAAM,EAAKL,aAAK,CAACM,qBAAgC,CAEpE;AACAjF,OAAO,CAACU,MAAM,CAAEyE,GAAG,CAACD,UAAU,CAAG,OAAO,CAAG,OAAO,CAAEJ,KAAK,CAACM,QAAQ,CAAC,CAAC,CAAC,CAErE,GAAI,CAAAC,OAAO,CAAGP,KAAK,CAACO,OAAO,EAAI,GAAAC,uBAAe,EAACN,MAAM,CAAC,CACtD,GAAIE,UAAU,EAAInB,OAAO,CAACwB,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAE,CACvDH,OAAO,CAAGZ,cAAM,CAACQ,qBACnB,CAEAnE,GAAG,CAACkE,MAAM,CAACA,MAAM,CAAC,CAAC9C,IAAI,CAACmD,OAAO,CACjC,CAAC,CACH,CAEA,MAAO,CAAA9E,MACT","ignoreList":[]}
1
+ {"version":3,"file":"server.js","names":["sep","pathToFileURL","cloneDeep","mapValues","pick","compression","cookieParser","csrf","express","favicon","helmet","loggerMiddleware","requestIp","v4","uuid","rendererFactory","CODES","ERRORS","getErrorForCode","newError","defaultCspSettings","directives","contentSecurityPolicy","getDefaultDirectives","array","filter","item","push","getDefaultCspSettings","factory","webpackConfig","options","rendererOps","renderer","publicPath","output","server","beforeExpressJsSetup","logger","httpsRedirect","use","req","res","next","schema","headers","url","host","originalUrl","redirect","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","noCsp","req2","nonce","cspNonce","cspSettings","cspSettingsHook","send","json","limit","urlencoded","extended","cookieSignatureSecret","mw","cookie","token","clientIp","FORMAT","stream","write","info","bind","get","static","path","setHeaders","set","devMode","global","location","href","process","cwd","default","webpack","webpackDevMiddleware","webpackHotMiddleware","compiler","Error","serverSideRender","onExpressJsSetup","NOT_FOUND","dontAttachDefaultErrorHandler","beforeExpressJsError","error","headersSent","status","INTERNAL_SERVER_ERROR","serverSide","log","toString","message","env","NODE_ENV"],"sources":["../../../src/server/server.ts"],"sourcesContent":["/**\n * Creation of standard ExpressJS server for ReactJS apps.\n */\n\nimport { sep } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { cloneDeep, mapValues, pick } from 'lodash-es';\n\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport csrf from '@dr.pogodin/csurf';\n\nimport express, {\n type Express,\n type NextFunction,\n type Request,\n type Response,\n} from 'express';\n\nimport favicon from 'serve-favicon';\nimport helmet, { type HelmetOptions } from 'helmet';\nimport loggerMiddleware from 'morgan';\nimport requestIp from 'request-ip';\nimport { v4 as uuid } from 'uuid';\n\nimport type { Configuration } from 'webpack';\n\nimport rendererFactory, {\n type LoggerI,\n type OptionsT as RendererOptionsT,\n} from './renderer';\n\nimport {\n CODES,\n ERRORS,\n getErrorForCode,\n newError,\n} from './utils/errors';\n\nexport type CspOptionsT = Exclude<HelmetOptions['contentSecurityPolicy'], boolean | undefined>;\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ninterface RequestT extends Request {\n cspNonce: string;\n nonce: string;\n}\n\n/**\n * Default Content Security Policy settings.\n * @ignore\n */\nconst defaultCspSettings = {\n directives: mapValues(\n helmet.contentSecurityPolicy.getDefaultDirectives(),\n\n // 'https:' options (automatic re-write of insecure URLs to secure ones)\n // is removed to facilitate local development with HTTP server. In cloud\n // deployments we assume Apache or Nginx server in front of out app takes\n // care about such re-writes.\n (array) => (array as string[]).filter((item: string) => item !== 'https:'),\n ),\n};\ndefaultCspSettings.directives['frame-src'] = [\n \"'self'\",\n\n // YouTube domain is whitelisted to allow <YouTubeVideo> component to work\n // out of box.\n 'https://*.youtube.com',\n];\n\n{\n const directives = defaultCspSettings.directives['script-src'];\n if (directives) directives.push(\"'unsafe-eval'\");\n else defaultCspSettings.directives['script-src'] = [\"'unsafe-eval'\"];\n}\n\n// No need for automatic re-writes via Content Security Policy settings:\n// the forefront Apache or Nginx server is supposed to take care of this\n// in production cloud deployments.\ndelete defaultCspSettings.directives['upgrade-insecure-requests'];\n\n/**\n * @category Utilities\n * @func server/getDefaultCspSettings\n * @global\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { getDefaultCspSettings } from '@dr.pogodin/react-utils';\n * ```\n * @return {{\n * directives: object\n * }} A deep copy of default CSP settings object used by `react-utils`,\n * with the exception of `nonce-xxx` clause in `script-src` directive,\n * which is added dynamically for each request.\n */\nexport function getDefaultCspSettings(): {\n directives: Record<string, string[]>;\n} {\n return cloneDeep(defaultCspSettings);\n}\n\nexport type ServerT = Express & {\n logger: LoggerI;\n};\n\nexport type OptionsT = RendererOptionsT & {\n beforeExpressJsError?:\n (server: ServerT) => boolean | Promise<boolean>;\n\n beforeExpressJsSetup?: (server: ServerT) => Promise<void> | void;\n cookieSignatureSecret?: string;\n cspSettingsHook?: (\n defaultOptions: CspOptionsT,\n req: Request,\n ) => CspOptionsT;\n devMode?: boolean;\n httpsRedirect?: boolean;\n onExpressJsSetup?: (server: ServerT) => Promise<void> | void;\n};\n\nexport default async function factory(\n webpackConfig: Configuration,\n options: OptionsT,\n): Promise<ServerT> {\n const rendererOps: RendererOptionsT = pick(options, [\n 'Application',\n 'beforeRender',\n 'favicon',\n 'logger',\n 'maxSsrRounds',\n 'noCsp',\n 'ssrTimeout',\n 'staticCacheController',\n 'staticCacheSize',\n ]);\n const renderer = rendererFactory(webpackConfig, rendererOps);\n const { publicPath } = webpackConfig.output!;\n\n const server = express() as ServerT;\n\n if (options.beforeExpressJsSetup) {\n await options.beforeExpressJsSetup(server);\n }\n\n if (options.logger) server.logger = options.logger;\n\n if (options.httpsRedirect) {\n server.use((req, res, next) => {\n const schema = req.headers['x-forwarded-proto'];\n if (schema === 'http') {\n let url = `https://${req.headers.host}`;\n if (req.originalUrl !== '/') url += req.originalUrl;\n res.redirect(url);\n return;\n }\n next();\n });\n }\n\n server.use(compression());\n server.use(\n helmet({\n contentSecurityPolicy: false,\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n }),\n );\n\n if (!options.noCsp) {\n server.use(\n (req: Request, res: Response, next: NextFunction) => {\n const req2 = req as RequestT;\n\n req2.nonce = uuid();\n\n // TODO: This is deprecated, but it is kept for now for backward\n // compatibility. Should be removed sometime later.\n req2.cspNonce = req2.nonce;\n\n // The deep clone is necessary here to ensure that default value can't be\n // mutated during request processing.\n let cspSettings: CspOptionsT = cloneDeep(defaultCspSettings);\n (cspSettings.directives?.['script-src'] as string[]).push(`'nonce-${req2.nonce}'`);\n if (options.cspSettingsHook) {\n cspSettings = options.cspSettingsHook(cspSettings, req);\n }\n helmet.contentSecurityPolicy(cspSettings)(req, res, next);\n },\n );\n }\n\n if (options.favicon) {\n server.use(favicon(options.favicon));\n }\n\n server.use('/robots.txt', (req, res) => {\n res.send('User-agent: *\\nDisallow:');\n });\n\n server.use(express.json({ limit: '300kb' }));\n server.use(express.urlencoded({ extended: false }));\n server.use(cookieParser(options.cookieSignatureSecret));\n server.use(requestIp.mw());\n\n server.use(csrf({ cookie: true }));\n\n loggerMiddleware.token(\n 'ip',\n (req: Request & { clientIp: string }) => req.clientIp,\n );\n const FORMAT = ':ip > :status :method :url :response-time ms :res[content-length] :referrer :user-agent';\n server.use(loggerMiddleware(FORMAT, {\n stream: {\n // TODO: This implies the logger is always set. Is it on a higher level?\n // then mark it as always present.\n write: options.logger!.info.bind(options.logger),\n },\n }));\n\n // Note: no matter the \"public path\", we want the service worker, if any,\n // to be served from the root, to have all web app pages in its scope.\n // Thus, this setup to serve it. Probably, need some more configuration\n // for special cases, but this will do for now.\n server.get('/__service-worker.js', express.static(\n webpackConfig.output?.path ?? '',\n {\n setHeaders: (res) => res.set('Cache-Control', 'no-cache'),\n },\n ));\n\n /* Setup of Hot Module Reloading for development environment.\n * These dependencies are not used, nor installed for production use,\n * hence we should violate some import-related lint rules. */\n /* eslint-disable import/no-extraneous-dependencies */\n if (options.devMode) {\n // This is a workaround for SASS bug:\n // https://github.com/dart-lang/sdk/issues/27979\n // which manifests itself sometimes when webpack dev middleware is used\n // (in dev mode), and app modules are imported in some unfortunate ways.\n // TODO: Double-check, what is going on here.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!global.location) {\n global.location = {\n href: `${pathToFileURL(process.cwd()).href}${sep}`,\n } as Location;\n }\n\n const { default: webpack } = await import(/* webpackChunkName: \"server-side-code\" */ 'webpack');\n\n const { default: webpackDevMiddleware } = await import(\n /* webpackChunkName: \"server-side-code\" */ 'webpack-dev-middleware'\n );\n\n const { default: webpackHotMiddleware } = await import(\n /* webpackChunkName: \"server-side-code\" */ 'webpack-hot-middleware'\n );\n\n const compiler = webpack(webpackConfig);\n if (!compiler) throw Error('Internal error');\n\n server.use(webpackDevMiddleware(compiler, {\n publicPath,\n serverSideRender: true,\n }));\n server.use(webpackHotMiddleware(compiler));\n }\n /* eslint-enable import/no-extraneous-dependencies */\n\n server.use(publicPath as string, express.static(webpackConfig.output!.path!));\n\n if (options.onExpressJsSetup) {\n await options.onExpressJsSetup(server);\n }\n server.use(renderer);\n\n /* Detects 404 errors, and forwards them to the error handler. */\n server.use((req, res, next) => {\n next(newError(ERRORS.NOT_FOUND, CODES.NOT_FOUND));\n });\n\n let dontAttachDefaultErrorHandler;\n if (options.beforeExpressJsError) {\n dontAttachDefaultErrorHandler = await options.beforeExpressJsError(server);\n }\n\n /* Error handler. */\n if (!dontAttachDefaultErrorHandler) {\n // TODO: Do we need this error handler at all? It actually seems to do\n // what the default ExpressJS error handler does anyway, see:\n // https://expressjs.com/en/guide/error-handling.html\n //\n // TODO: It is better to move the default error handler definition\n // to a stand-alone function at top-level, but the use of options.logger\n // prevents to do it without some extra refactoring. Should be done sometime\n // though.\n server.use((\n error: Error & {\n status?: number;\n },\n req: Request,\n res: Response,\n next: NextFunction,\n ) => {\n // TODO: This is needed to correctly handled any errors thrown after\n // sending initial response to the client.\n if (res.headersSent) {\n next(error);\n return;\n }\n\n const status = error.status ?? CODES.INTERNAL_SERVER_ERROR;\n const serverSide = status >= (CODES.INTERNAL_SERVER_ERROR as number);\n\n // Log server-side errors always, client-side at debug level only.\n options.logger!.log(serverSide ? 'error' : 'debug', error.toString());\n\n let message = error.message || getErrorForCode(status);\n if (serverSide && process.env.NODE_ENV === 'production') {\n message = ERRORS.INTERNAL_SERVER_ERROR;\n }\n\n res.status(status).send(message);\n });\n }\n\n return server;\n}\n"],"mappings":"oRAAA;AACA;AACA,GAEA,OAASA,GAAG,KAAQ,WAAW,CAC/B,OAASC,aAAa,KAAQ,UAAU,CAExC,OAASC,SAAS,CAAEC,SAAS,CAAEC,IAAI,KAAQ,WAAW,CAEtD,MAAO,CAAAC,WAAW,KAAM,aAAa,CACrC,MAAO,CAAAC,YAAY,KAAM,eAAe,CACxC,MAAO,CAAAC,IAAI,KAAM,mBAAmB,CAEpC,MAAO,CAAAC,OAAO,KAKP,SAAS,CAEhB,MAAO,CAAAC,OAAO,KAAM,eAAe,CACnC,MAAO,CAAAC,MAAM,KAA8B,QAAQ,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CAAAC,UAAU,CAAGF,MAAM,EAAKlF,KAAK,CAACmF,qBAAgC,CAEpE;AACApE,OAAO,CAACO,MAAM,CAAE+D,GAAG,CAACD,UAAU,CAAG,OAAO,CAAG,OAAO,CAAEJ,KAAK,CAACM,QAAQ,CAAC,CAAC,CAAC,CAErE,GAAI,CAAAC,OAAO,CAAGP,KAAK,CAACO,OAAO,EAAIrF,eAAe,CAACgF,MAAM,CAAC,CACtD,GAAIE,UAAU,EAAIjB,OAAO,CAACqB,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAE,CACvDF,OAAO,CAAGtF,MAAM,CAACkF,qBACnB,CAEAzD,GAAG,CAACwD,MAAM,CAACA,MAAM,CAAC,CAACvC,IAAI,CAAC4C,OAAO,CACjC,CAAC,CACH,CAEA,MAAO,CAAAnE,MACT","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"CODES",{enumerable:true,get:function(){return _httpStatusCodes.StatusCodes}});Object.defineProperty(exports,"ERRORS",{enumerable:true,get:function(){return _httpStatusCodes.ReasonPhrases}});exports.assert=assert;exports.fail=fail;Object.defineProperty(exports,"getErrorForCode",{enumerable:true,get:function(){return _httpStatusCodes.getReasonPhrase}});exports.newError=newError;var _httpStatusCodes=require("http-status-codes");/**
1
+ /**
2
2
  * @category Utilities
3
3
  * @module server/errors
4
4
  * @desc
@@ -7,7 +7,7 @@
7
7
  * const { errors } = server;
8
8
  * ```
9
9
  * Server-side helpers for error handling.
10
- *//**
10
+ */import{StatusCodes as CODES,ReasonPhrases as ERRORS,getReasonPhrase as getErrorForCode}from"http-status-codes";/**
11
11
  * @static
12
12
  * @const CODES
13
13
  * @desc An alias for
@@ -17,7 +17,7 @@
17
17
  * import { server } from '@dr.pogodin/react-utils';
18
18
  * const { CODES } = server.errors;
19
19
  * console.log(CODES.BAD_REQUEST); // Prints: 400
20
- *//**
20
+ */export{CODES};/**
21
21
  * @static
22
22
  * @const ERRORS
23
23
  * @desc An alias for
@@ -27,7 +27,7 @@
27
27
  * import { server } from '@dr.pogodin/react-utils';
28
28
  * const { ERRORS } = server.errors;
29
29
  * console.log(ERRORS.BAD_REQUEST); // Prints: Bad Request
30
- *//**
30
+ */export{ERRORS};/**
31
31
  * @static
32
32
  * @func getErrorForCode
33
33
  * @desc An alias for
@@ -38,8 +38,8 @@
38
38
  * @example
39
39
  * import { server } from '@dr.pogodin/react-utils';
40
40
  * console.log(server.errors.getErrorForCode(400)); // Prints: Bad Request
41
- */// TODO: It could accept the status code as a constructor argument.
42
- class ErrorWithStatus extends Error{status=_httpStatusCodes.StatusCodes.INTERNAL_SERVER_ERROR}/**
41
+ */export{getErrorForCode};// TODO: It could accept the status code as a constructor argument.
42
+ class ErrorWithStatus extends Error{status=CODES.INTERNAL_SERVER_ERROR}/**
43
43
  * ```js
44
44
  * import { server } from '@dr.pogodin/react-utils';
45
45
  * const { newError } = server.errors;
@@ -50,9 +50,9 @@ class ErrorWithStatus extends Error{status=_httpStatusCodes.StatusCodes.INTERNAL
50
50
  * @param {number} [statusCode=500] HTTP status code. Defaults to 500 (Internal
51
51
  * Server Error).
52
52
  * @return {Error}
53
- */function newError(message,statusCode=_httpStatusCodes.StatusCodes.INTERNAL_SERVER_ERROR){const error=new ErrorWithStatus(message);error.status=statusCode;return error}/**
53
+ */export function newError(message,statusCode=CODES.INTERNAL_SERVER_ERROR){const error=new ErrorWithStatus(message);error.status=statusCode;return error}/**
54
54
  * Throws an error with given message and HTTP status code.
55
- */function fail(message,statusCode=_httpStatusCodes.StatusCodes.INTERNAL_SERVER_ERROR){throw newError(message,statusCode)}/**
55
+ */export function fail(message,statusCode=CODES.INTERNAL_SERVER_ERROR){throw newError(message,statusCode)}/**
56
56
  * Validates the `value` against the given "standard" validation `schema`.
57
57
  * Resolves to the correctly typed `value`, if it has passed the validation;
58
58
  * otherwise throws an error.
@@ -61,5 +61,5 @@ class ErrorWithStatus extends Error{status=_httpStatusCodes.StatusCodes.INTERNAL
61
61
  * @param [message] Optional error message, to prepend the validation error
62
62
  * message.
63
63
  * @param [statusCode=400] HTTP status code. Defaults to 400 (Bad Request).
64
- */async function assert(value,schema,message="",statusCode=_httpStatusCodes.StatusCodes.BAD_REQUEST){let result=schema["~standard"].validate(value);if(result instanceof Promise)result=await result;if(result.issues){let error=JSON.stringify(result.issues,null,2);if(message)error=`${message}\n\n${error}`;throw fail(error,statusCode)}return result.value}
64
+ */export async function assert(value,schema,message="",statusCode=CODES.BAD_REQUEST){let result=schema["~standard"].validate(value);if(result instanceof Promise)result=await result;if(result.issues){let error=JSON.stringify(result.issues,null,2);if(message)error=`${message}\n\n${error}`;throw fail(error,statusCode)}return result.value}
65
65
  //# sourceMappingURL=errors.js.map
@@ -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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,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":"_0S7CYa","ad":"YFXz0-","hoc":"BElFuo","button":"hXiBOw","active":"biX-UA","disabled":"_-6CH9q"};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","Link","role","tabIndex","exports","_default","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,aAEwC,IAAAE,WAAA,CAAAF,OAAA,sBAdxC;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,CACLC,EACF,CAAC,GAAK,CACJ,GAAI,CAAAC,SAAS,CAAGF,KAAK,CAACG,MAAM,C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,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,CAAAE,OAAA,CAOe,GAAAC,oBAAM,EAACjC,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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O,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":"_08mmmo","ad":"Hc06MV","hoc":"toOtOd","checkbox":"v4DmWM","indeterminate":"ckSC8W","container":"g7wee9","label":"XQ57WS","disabled":"baVvQA"};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,8BAEwC,IAAAC,WAAA,CAAAD,OAAA,4BAAAE,YAAA,2JAiBxC,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,GAAAC,gBAAA,SAAKC,SAAS,CAAEN,kBAAmB,CAAAO,QAAA,EAC/BX,KAAK,GAAKY,SAAS,CACjB,IAAI,cAAG,GAAAC,eAAA,SAAKH,SAAS,CAAEP,KAAK,CAACH,KAAM,CAAAW,QAAA,CAAEX,KAAK,CAAM,CAAC,cACrD,GAAAa,eAAA,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,KAAAC,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEc,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// 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",styleName:"link",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":["_jsxRuntime","require","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","_jsx","href","e","preventDefault","rel","styleName","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":"6FASsB,IAAAA,WAAA,CAAAC,OAAA,sBAqBtB;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,CAAAC,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,eAAA,OACEZ,SAAS,CAAEA,SACX;AACA;AACA;AACA;AAAA,CACAa,IAAI,CAAEJ,EAAa,CACnBL,OAAO,CAAEH,QAAQ,CAAIa,CAAC,EAAK,CACzBA,CAAC,CAACC,cAAc,CAAC,CACnB,CAAC,CAAGX,OAAQ,CACZC,WAAW,CAAEJ,QAAQ,CAAIa,CAAC,EAAK,CAC7BA,CAAC,CAACC,cAAc,CAAC,CACnB,CAAC,CAAGV,WAAY,CAChBW,GAAG,CAAC,qBAAqB,CACzBC,SAAS,CAAC,MAAM,CAChBC,MAAM,CAAEZ,UAAU,CAAG,QAAQ,CAAG,EAAG,CAAAP,QAAA,CAElCA,QAAQ,CACR,CAEP,CAEA,KAAM,CAAAoB,CAAC,CAAGX,cAAc,CAExB,mBACE,GAAAI,eAAA,EAACO,CAAC,EACAnB,SAAS,CAAEA,SAAU,CACrBoB,QAAQ,CAAC,MACT;AAAA,CACAhB,OAAO,CAAGU,CAAsC,EAAK,CACnD;AACA,GAAIV,OAAO,CAAEA,OAAO,CAACU,CAAC,CAAC,CAEvB;AACA,GAAI,CAACX,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,KAAAwB,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEc3B,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,WAAW,CAAGA,CAAC,CACnBC,QAAQ,CACRC,SAAS,CACTC,QAAQ,CACRC,QA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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":"-Jj9Dp","ad":"IOZUc8","hoc":"nSzLXc","container":"wW08uK","children":"hCuQWP","input":"oYQ-Uo","label":"OTmX5n","error":"_7jrZ-X","errorMessage":"qjYbwz"};/**
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,8BAEwC,IAAAG,WAAA,CAAAH,OAAA,4BAAAI,YAAA,wKAcxC;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,CAACQ,KAAK,EAAIT,KAAK,CAACU,KAAK,CAAEH,kBAAkB,EAAI,IAAIP,KAAK,CAACU,KAAK,EAAE,CAEvE,GAAId,KAAK,CAAEW,kBAAkB,EAAI,IAAIP,KAAK,CAACJ,KAAK,EAAE,CAElD,mBAC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M,CAAC,CAAG,IAAI,EAChE,CAET,CAAC,KAAA8B,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEc,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,CACJ;AACA;AACA,KAAM,CAACC,OAAO,CAAEC,UAAU,CAAC,CAAGhB,QAAQ,CAAC,KAAK,CAAC,CAE7C,KAAM,CAAAiB,QAAQ,CAAGlB,MAAM,CAAmB,IAAI,CAAC,CAE/C,GAAI,CAAAmB,kBAAkB,CAAGL,KAAK,CAACM,SAAS,CAExC;AACA;AACA,GAAIJ,OAAQ,uBAAwBG,kBA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AI,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","GenericLink","routerLinkType","RrLink","_default","exports","default"],"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,GAAAC,eAAA,EAACC,oBACC;AACA;AAAA,KACIF,KAAK,CACTG,cAAc,CAAEC,iBAAO,CACxB,CACF,KAAAC,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEYR,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":"sCYXfW","ad":"e0BH-f","hoc":"vqUuSP","overlay":"uAH4as","container":"zqpc6q"};const S={"scrollingDisabledByModal":"yfvOIZ"};/**
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,IAAAG,YAAA,CAAAD,sBAAA,CAAAF,OAAA,8BAG8B,IAAAI,WAAA,CAAAJ,OAAA,4BAAAK,SAAA,iGAAAC,CAAA,uCAiB9B;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,CACR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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,GAAAwB,eAAA,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,CAAAqC,OAAA,CAAAxD,SAAA,CAAAA,SAAA,KAAAyD,QAAA,CAAAD,OAAA,CAAAE,OAAA,CAEc,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);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pB,CACF,CAAE,CACFG,GAAG,CAAGC,IAAI,EAAK,CACb,GAAIA,IAAI,EAAIA,IAAI,GAAKhC,UAAU,CAACa,OAAO,CAAE,CACvCb,UAAU,CAACa,OAAO,CAAGmB,IAAI,CACzBA,IAAI,CAACf,KAAK,CAAC,CACb,CACF,CAAE,CACFgB,IAAI,CAAC,QAAQ,CACbtC,KAAK,CAAED,YAAa,CACpByB,QAAQ,CAAE,CAAE,CACb,CAAC,cAYFlC,IAAA,QAAK;AACH,aAAW,MAAM,CACjBmC,SAAS,CAAEtB,KAAK,CAACoC,SAAU,CAC3B,cAAaZ,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAG7B,MAAO,CACxE8B,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,CAAEhC,YAAa,CAClBkC,IAAI,CAAC,QAAQ,CACbtC,KAAK,CAAEA,KAAK,EAAIJ,cAAe,CAAAD,QAAA,CAE9BA,QAAQ,CACN,CAAC,cACNL,IAAA,QACE0B,OAAO,CAAEA,CAAA,GAAM,CACbX,UAAU,CAACa,OAAO,EAAEI,KAAK,CAAC,CAC5B,CACA;AACA;AAAA,CACAE,QAAQ,CAAE,CAAE,CACb,CAAC,CACDT,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