@dr.pogodin/react-utils 1.25.6 → 1.26.0

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 (290) hide show
  1. package/babel.config.js +3 -1
  2. package/bin/build.js +18 -4
  3. package/build/development/client/getInj.js +9 -8
  4. package/build/development/client/getInj.js.map +1 -1
  5. package/build/development/client/index.js +6 -3
  6. package/build/development/client/index.js.map +1 -1
  7. package/build/development/client/init.js +4 -0
  8. package/build/development/client/init.js.map +1 -1
  9. package/build/development/index.js +166 -38
  10. package/build/development/index.js.map +1 -1
  11. package/build/development/server/Cache.js +13 -13
  12. package/build/development/server/Cache.js.map +1 -1
  13. package/build/development/server/index.js +16 -23
  14. package/build/development/server/index.js.map +1 -1
  15. package/build/development/server/renderer.js +56 -43
  16. package/build/development/server/renderer.js.map +1 -1
  17. package/build/development/server/server.js +9 -5
  18. package/build/development/server/server.js.map +1 -1
  19. package/build/development/server/utils/errors.js +12 -9
  20. package/build/development/server/utils/errors.js.map +1 -1
  21. package/build/development/server/utils/index.js +2 -2
  22. package/build/development/server/utils/index.js.map +1 -1
  23. package/build/development/shared/components/Button/index.js +7 -5
  24. package/build/development/shared/components/Button/index.js.map +1 -1
  25. package/build/development/shared/components/Checkbox/index.js +24 -26
  26. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  27. package/build/development/shared/components/Dropdown/index.js +24 -17
  28. package/build/development/shared/components/Dropdown/index.js.map +1 -1
  29. package/build/development/shared/components/GenericLink/index.js +44 -37
  30. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  31. package/build/development/shared/components/Input/index.js +7 -7
  32. package/build/development/shared/components/Input/index.js.map +1 -1
  33. package/build/development/shared/components/Link.js +10 -9
  34. package/build/development/shared/components/Link.js.map +1 -1
  35. package/build/development/shared/components/MetaTags.js +22 -18
  36. package/build/development/shared/components/MetaTags.js.map +1 -1
  37. package/build/development/shared/components/Modal/index.js +16 -16
  38. package/build/development/shared/components/Modal/index.js.map +1 -1
  39. package/build/development/shared/components/NavLink.js +10 -9
  40. package/build/development/shared/components/NavLink.js.map +1 -1
  41. package/build/development/shared/components/PageLayout/index.js +16 -18
  42. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  43. package/build/development/shared/components/ScalableRect/index.js +27 -7
  44. package/build/development/shared/components/ScalableRect/index.js.map +1 -1
  45. package/build/development/shared/components/Throbber/index.js +14 -22
  46. package/build/development/shared/components/Throbber/index.js.map +1 -1
  47. package/build/development/shared/components/WithTooltip/Tooltip.js +19 -21
  48. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  49. package/build/development/shared/components/WithTooltip/index.js +11 -10
  50. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  51. package/build/development/shared/components/YouTubeVideo/index.js +15 -13
  52. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  53. package/build/development/shared/components/index.js +2 -2
  54. package/build/development/shared/components/index.js.map +1 -1
  55. package/build/development/shared/utils/config.js.map +1 -1
  56. package/build/development/shared/utils/globalState.js +15 -0
  57. package/build/development/shared/utils/globalState.js.map +1 -0
  58. package/build/development/shared/utils/index.js +13 -10
  59. package/build/development/shared/utils/index.js.map +1 -1
  60. package/build/development/shared/utils/isomorphy/buildInfo.js +7 -3
  61. package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
  62. package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
  63. package/build/development/shared/utils/isomorphy/index.js.map +1 -1
  64. package/build/development/shared/utils/jest/E2eSsrEnv.js +35 -28
  65. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  66. package/build/development/shared/utils/jest/global.js +17 -0
  67. package/build/development/shared/utils/jest/global.js.map +1 -0
  68. package/build/development/shared/utils/jest/index.js +17 -9
  69. package/build/development/shared/utils/jest/index.js.map +1 -1
  70. package/build/development/shared/utils/splitComponent.js +25 -34
  71. package/build/development/shared/utils/splitComponent.js.map +1 -1
  72. package/build/development/shared/utils/time.js +16 -12
  73. package/build/development/shared/utils/time.js.map +1 -1
  74. package/build/development/shared/utils/webpack.js +3 -3
  75. package/build/development/shared/utils/webpack.js.map +1 -1
  76. package/build/development/web.bundle.js +92 -82
  77. package/build/production/client/getInj.js +1 -1
  78. package/build/production/client/getInj.js.map +1 -1
  79. package/build/production/client/index.js +4 -4
  80. package/build/production/client/index.js.map +1 -1
  81. package/build/production/client/init.js +3 -1
  82. package/build/production/client/init.js.map +1 -1
  83. package/build/production/index.js +1 -1
  84. package/build/production/index.js.map +1 -1
  85. package/build/production/server/Cache.js +7 -8
  86. package/build/production/server/Cache.js.map +1 -1
  87. package/build/production/server/index.js +5 -4
  88. package/build/production/server/index.js.map +1 -1
  89. package/build/production/server/renderer.js +32 -30
  90. package/build/production/server/renderer.js.map +1 -1
  91. package/build/production/server/server.js +7 -5
  92. package/build/production/server/server.js.map +1 -1
  93. package/build/production/server/utils/errors.js +9 -10
  94. package/build/production/server/utils/errors.js.map +1 -1
  95. package/build/production/server/utils/index.js +1 -1
  96. package/build/production/server/utils/index.js.map +1 -1
  97. package/build/production/shared/components/Button/index.js +3 -3
  98. package/build/production/shared/components/Button/index.js.map +1 -1
  99. package/build/production/shared/components/Checkbox/index.js +11 -11
  100. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  101. package/build/production/shared/components/Dropdown/index.js +11 -11
  102. package/build/production/shared/components/Dropdown/index.js.map +1 -1
  103. package/build/production/shared/components/GenericLink/index.js +25 -20
  104. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  105. package/build/production/shared/components/Input/index.js +7 -7
  106. package/build/production/shared/components/Input/index.js.map +1 -1
  107. package/build/production/shared/components/Link.js +2 -2
  108. package/build/production/shared/components/Link.js.map +1 -1
  109. package/build/production/shared/components/MetaTags.js +10 -10
  110. package/build/production/shared/components/MetaTags.js.map +1 -1
  111. package/build/production/shared/components/Modal/index.js +2 -2
  112. package/build/production/shared/components/Modal/index.js.map +1 -1
  113. package/build/production/shared/components/NavLink.js +1 -1
  114. package/build/production/shared/components/NavLink.js.map +1 -1
  115. package/build/production/shared/components/PageLayout/index.js +2 -2
  116. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  117. package/build/production/shared/components/ScalableRect/index.js +7 -3
  118. package/build/production/shared/components/ScalableRect/index.js.map +1 -1
  119. package/build/production/shared/components/Throbber/index.js +2 -2
  120. package/build/production/shared/components/Throbber/index.js.map +1 -1
  121. package/build/production/shared/components/WithTooltip/Tooltip.js +13 -13
  122. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  123. package/build/production/shared/components/WithTooltip/index.js +3 -3
  124. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  125. package/build/production/shared/components/YouTubeVideo/index.js +7 -7
  126. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  127. package/build/production/shared/components/index.js +1 -1
  128. package/build/production/shared/components/index.js.map +1 -1
  129. package/build/production/shared/utils/config.js.map +1 -1
  130. package/build/production/shared/utils/globalState.js +3 -0
  131. package/build/production/shared/utils/globalState.js.map +1 -0
  132. package/build/production/shared/utils/index.js +2 -2
  133. package/build/production/shared/utils/index.js.map +1 -1
  134. package/build/production/shared/utils/isomorphy/buildInfo.js +7 -4
  135. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  136. package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
  137. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  138. package/build/production/shared/utils/jest/E2eSsrEnv.js +9 -9
  139. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  140. package/build/production/shared/utils/jest/global.js +2 -0
  141. package/build/production/shared/utils/jest/global.js.map +1 -0
  142. package/build/production/shared/utils/jest/index.js +5 -5
  143. package/build/production/shared/utils/jest/index.js.map +1 -1
  144. package/build/production/shared/utils/splitComponent.js +16 -16
  145. package/build/production/shared/utils/splitComponent.js.map +1 -1
  146. package/build/production/shared/utils/time.js +12 -8
  147. package/build/production/shared/utils/time.js.map +1 -1
  148. package/build/production/shared/utils/webpack.js +3 -3
  149. package/build/production/shared/utils/webpack.js.map +1 -1
  150. package/build/production/web.bundle.js +1 -1
  151. package/build/production/web.bundle.js.map +1 -1
  152. package/build/types-code/client/getInj.d.ts +3 -0
  153. package/build/types-code/client/index.d.ts +11 -0
  154. package/build/types-code/client/init.d.ts +9 -0
  155. package/build/types-code/index.d.ts +10 -0
  156. package/build/types-code/server/Cache.d.ts +37 -0
  157. package/build/types-code/server/index.d.ts +145 -0
  158. package/build/types-code/server/renderer.d.ts +106 -0
  159. package/build/types-code/server/server.d.ts +41 -0
  160. package/build/types-code/server/utils/errors.d.ts +104 -0
  161. package/build/types-code/server/utils/index.d.ts +1 -0
  162. package/build/types-code/shared/components/Button/index.d.ts +27 -0
  163. package/build/types-code/shared/components/Checkbox/index.d.ts +21 -0
  164. package/build/types-code/shared/components/Dropdown/index.d.ts +23 -0
  165. package/build/types-code/shared/components/GenericLink/index.d.ts +61 -0
  166. package/build/types-code/shared/components/Input/index.d.ts +11 -0
  167. package/build/types-code/shared/components/Link.d.ts +12 -0
  168. package/build/types-code/shared/components/MetaTags.d.ts +68 -0
  169. package/build/types-code/shared/components/Modal/index.d.ts +26 -0
  170. package/build/types-code/shared/components/NavLink.d.ts +5 -0
  171. package/build/types-code/shared/components/PageLayout/index.d.ts +16 -0
  172. package/build/types-code/shared/components/ScalableRect/index.d.ts +19 -0
  173. package/build/types-code/shared/components/Throbber/index.d.ts +9 -0
  174. package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +23 -0
  175. package/build/types-code/shared/components/WithTooltip/index.d.ts +17 -0
  176. package/build/types-code/shared/components/YouTubeVideo/index.d.ts +13 -0
  177. package/build/types-code/shared/components/index.d.ts +16 -0
  178. package/build/types-code/shared/utils/config.d.ts +2 -0
  179. package/build/types-code/shared/utils/globalState.d.ts +20 -0
  180. package/build/types-code/shared/utils/index.d.ts +52 -0
  181. package/build/types-code/shared/utils/isomorphy/buildInfo.d.ts +23 -0
  182. package/build/types-code/shared/utils/isomorphy/environment-check.d.ts +11 -0
  183. package/build/types-code/shared/utils/isomorphy/index.d.ts +20 -0
  184. package/build/types-code/shared/utils/jest/E2eSsrEnv.d.ts +31 -0
  185. package/build/types-code/shared/utils/jest/global.d.ts +12 -0
  186. package/build/types-code/shared/utils/jest/index.d.ts +85 -0
  187. package/build/types-code/shared/utils/splitComponent.d.ts +41 -0
  188. package/build/types-code/shared/utils/time.d.ts +62 -0
  189. package/build/types-code/shared/utils/webpack.d.ts +18 -0
  190. package/build/types-scss/__tests__/js/config/publicPath support/__assets__/style.scss.d.ts +1 -0
  191. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
  192. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
  193. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
  194. package/build/types-scss/__tests__/js/shared/components/NavLink/styles.scss.d.ts +1 -0
  195. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
  196. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
  197. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
  198. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
  199. package/build/types-scss/__tests__/ts/config/publicPath support/__assets__/style.scss.d.ts +1 -0
  200. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
  201. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
  202. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
  203. package/build/types-scss/__tests__/ts/shared/components/NavLink/styles.scss.d.ts +1 -0
  204. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
  205. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
  206. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
  207. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
  208. package/build/types-scss/src/shared/components/Button/style.scss.d.ts +6 -0
  209. package/build/types-scss/src/shared/components/Checkbox/theme.scss.d.ts +6 -0
  210. package/build/types-scss/src/shared/components/Dropdown/theme.scss.d.ts +9 -0
  211. package/build/types-scss/src/shared/components/GenericLink/style.scss.d.ts +1 -0
  212. package/build/types-scss/src/shared/components/Input/theme.scss.d.ts +6 -0
  213. package/build/types-scss/src/shared/components/Modal/base-theme.scss.d.ts +5 -0
  214. package/build/types-scss/src/shared/components/PageLayout/base-theme.scss.d.ts +6 -0
  215. package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +2 -0
  216. package/build/types-scss/src/shared/components/Throbber/theme.scss.d.ts +6 -0
  217. package/build/types-scss/src/shared/components/WithTooltip/default-theme.scss.d.ts +7 -0
  218. package/build/types-scss/src/shared/components/YouTubeVideo/base.scss.d.ts +5 -0
  219. package/build/types-scss/src/shared/components/YouTubeVideo/throbber.scss.d.ts +4 -0
  220. package/config/eslint/jest.json +3 -2
  221. package/config/eslint/typescript.js +34 -0
  222. package/config/jest/default.js +3 -3
  223. package/package.json +74 -32
  224. package/src/client/getInj.ts +43 -0
  225. package/src/client/index.tsx +40 -0
  226. package/src/client/init.ts +47 -0
  227. package/src/index.ts +58 -0
  228. package/src/server/Cache.ts +68 -0
  229. package/src/server/index.ts +230 -0
  230. package/src/server/renderer.tsx +604 -0
  231. package/src/server/server.ts +309 -0
  232. package/src/server/utils/errors.ts +135 -0
  233. package/src/server/utils/index.ts +3 -0
  234. package/src/shared/components/Button/index.tsx +146 -0
  235. package/src/shared/components/Button/style.scss +53 -0
  236. package/src/shared/components/Checkbox/index.tsx +71 -0
  237. package/src/shared/components/Checkbox/theme.scss +43 -0
  238. package/src/shared/components/Dropdown/index.tsx +144 -0
  239. package/src/shared/components/Dropdown/theme.scss +63 -0
  240. package/src/shared/components/GenericLink/index.tsx +157 -0
  241. package/src/shared/components/GenericLink/style.scss +3 -0
  242. package/src/shared/components/Input/index.tsx +59 -0
  243. package/src/shared/components/Input/theme.scss +27 -0
  244. package/src/shared/components/Link.tsx +21 -0
  245. package/src/shared/components/MetaTags.tsx +170 -0
  246. package/src/shared/components/Modal/base-theme.scss +38 -0
  247. package/src/shared/components/Modal/index.tsx +144 -0
  248. package/src/shared/components/Modal/styles.scss +5 -0
  249. package/src/shared/components/NavLink.tsx +13 -0
  250. package/src/shared/components/PageLayout/base-theme.scss +30 -0
  251. package/src/shared/components/PageLayout/index.tsx +76 -0
  252. package/src/shared/components/ScalableRect/index.tsx +84 -0
  253. package/src/shared/components/ScalableRect/style.scss +10 -0
  254. package/src/shared/components/Throbber/index.tsx +43 -0
  255. package/src/shared/components/Throbber/theme.scss +26 -0
  256. package/src/shared/components/WithTooltip/Tooltip.tsx +353 -0
  257. package/src/shared/components/WithTooltip/default-theme.scss +36 -0
  258. package/src/shared/components/WithTooltip/index.tsx +204 -0
  259. package/src/shared/components/YouTubeVideo/base.scss +13 -0
  260. package/src/shared/components/YouTubeVideo/index.tsx +96 -0
  261. package/src/shared/components/YouTubeVideo/throbber.scss +11 -0
  262. package/src/shared/components/index.ts +17 -0
  263. package/src/shared/utils/config.ts +21 -0
  264. package/src/shared/utils/globalState.ts +29 -0
  265. package/src/shared/utils/index.ts +105 -0
  266. package/src/shared/utils/isomorphy/buildInfo.ts +54 -0
  267. package/src/shared/utils/isomorphy/environment-check.ts +18 -0
  268. package/src/shared/utils/isomorphy/index.ts +38 -0
  269. package/src/shared/utils/jest/E2eSsrEnv.ts +250 -0
  270. package/src/shared/utils/jest/global.ts +19 -0
  271. package/src/shared/utils/jest/index.tsx +157 -0
  272. package/src/shared/utils/splitComponent.tsx +255 -0
  273. package/src/shared/utils/time.ts +118 -0
  274. package/src/shared/utils/webpack.ts +45 -0
  275. package/src/styles/_global/reset.css +52 -0
  276. package/src/styles/global.scss +11 -0
  277. package/tsconfig.configs.json +18 -0
  278. package/tsconfig.json +27 -0
  279. package/tsconfig.types.json +53 -0
  280. package/typed-scss-modules.config.ts +9 -0
  281. package/types.d.ts +37 -0
  282. package/{webpack.config.js → webpack.config.ts} +7 -3
  283. package/config/babel/node-ssr.js +0 -85
  284. package/config/babel/webpack.js +0 -123
  285. package/config/webpack/app-base.js +0 -330
  286. package/config/webpack/app-development.js +0 -80
  287. package/config/webpack/app-production.js +0 -60
  288. package/config/webpack/lib-base.js +0 -155
  289. package/config/webpack/lib-development.js +0 -45
  290. package/config/webpack/lib-production.js +0 -44
@@ -0,0 +1,68 @@
1
+ import { type ReactNode } from 'react';
2
+ type PropsT = {
3
+ children?: ReactNode;
4
+ description: string;
5
+ image?: string;
6
+ siteName?: string;
7
+ socialDescription?: string;
8
+ socialTitle?: string;
9
+ title: string;
10
+ url?: string;
11
+ };
12
+ /**
13
+ * The `<MetaTags>` component is an auxiliary wrapper around `react-helmet`,
14
+ * which helps to inject meta tags (page title, a brief content description,
15
+ * and social media thumbnails) into generated pages.
16
+ *
17
+ * When `<MetaTags>` are nested within the app's component tree, meta tags
18
+ * content injected by components encountered down the tree overrides tags
19
+ * injected by previously encountered `<MetaTags>` components.
20
+ *
21
+ * **Children:** `<MetaTags>` children, if any, are rendered at the component's
22
+ * location. The context passes down all meta tag properties of parent
23
+ * `<MetaTag>` instances. These properties can fetched within children
24
+ * hierarchy in the following way, thus facilitating tags modification by
25
+ * children:
26
+ * ```jsx
27
+ * import { useContext } from 'react';
28
+ * import { MetaTags } from '@dr.pogodin/react-utils';
29
+ * export default function SampleComponent() {
30
+ * const { title, description, ...rest } = useContext(MetaTags.Context);
31
+ * // Do something with these props here, e.g. prefix the page title with
32
+ * // the component name:
33
+ * return (
34
+ * <MetaTags title={`Sample component - ${title}`} />
35
+ * );
36
+ * }
37
+ * ```
38
+ * @param [props]
39
+ * @param [props.description] Page description to use in
40
+ * the `description` meta tag, and as a default description of Open Graph Tags.
41
+ * @param [props.image] The absolute URL of thumbnail image to use
42
+ * in Open Graph Tags (`twitter:image`, and `og:image`). By default these tags
43
+ * are not injected.
44
+ *
45
+ * **BEWARE:** It must be a complete, absolute URL, including the correct
46
+ * website domain and HTTP schema.
47
+ *
48
+ * @param [props.siteName]: The site name to use in `twitter:site`,
49
+ * and `og:sitename` tags. By default these tags are not injected.
50
+ *
51
+ * @param [props.socialDescription] The site description to use in
52
+ * `twitter:description` and `og:description` meta tags. By default the value of
53
+ * `description` prop is used.
54
+ * @param [props.socialTitle] The page title to use in
55
+ * `twitter:title`, `og:title`, and `og:image:alt` tags. By default the value of
56
+ * `title` prop is used. Also the `og:image:alt` tag is only injected if `image`
57
+ * prop is present.
58
+ *
59
+ * @param props.title: The page name to use in the `<title>` tag.
60
+ * It is also used as the default value of `socialTitle` prop.
61
+ *
62
+ * @param [props.url] The page URL to use in `og:url` tag.
63
+ * By default the tag is not injected.
64
+ */
65
+ declare const MetaTags: React.FunctionComponent<PropsT> & {
66
+ Context: React.Context<PropsT>;
67
+ };
68
+ export default MetaTags;
@@ -0,0 +1,26 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type Theme } from '@dr.pogodin/react-themes';
3
+ import './styles.scss';
4
+ type PropsT = {
5
+ children?: ReactNode;
6
+ onCancel?: () => void;
7
+ theme: Theme & {
8
+ container?: string;
9
+ overlay?: string;
10
+ };
11
+ };
12
+ /**
13
+ * The `<Modal>` component implements a simple themeable modal window, wrapped
14
+ * into the default theme. `<BaseModal>` exposes the base non-themed component.
15
+ * **Children:** Component children are rendered as the modal content.
16
+ * @param {object} props Component properties. Beside props documented below,
17
+ * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.
18
+ * @param {function} [props.onCancel] The callback to trigger when user
19
+ * clicks outside the modal, or presses Escape. It is expected to hide the
20
+ * modal.
21
+ * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
22
+ */
23
+ declare const BaseModal: React.FunctionComponent<PropsT>;
24
+ declare const ThemedModal: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
25
+ export default ThemedModal;
26
+ export { BaseModal };
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { type PropsT as GenericLinkPropsT } from './GenericLink';
3
+ type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'>;
4
+ declare const NavLink: React.FunctionComponent<PropsT>;
5
+ export default NavLink;
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type Theme } from '@dr.pogodin/react-themes';
3
+ type PropsT = {
4
+ children?: ReactNode;
5
+ leftSidePanelContent?: ReactNode;
6
+ rightSidePanelContent?: ReactNode;
7
+ theme: Theme & {
8
+ container?: string;
9
+ mainPanel?: string;
10
+ sidePanel?: string;
11
+ leftSidePanel?: string;
12
+ rightSidePanel?: string;
13
+ };
14
+ };
15
+ declare const ThemedPageLayout: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
16
+ export default ThemedPageLayout;
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from 'react';
2
+ import './style.scss';
3
+ type PropsT = {
4
+ children?: ReactNode;
5
+ className?: string;
6
+ ratio?: `${number}:${number}`;
7
+ };
8
+ /**
9
+ * The `<ScalableRect>` component implements container keeping given aspect
10
+ * ratio, while its width is altered.
11
+ *
12
+ * **Children:** Component children are rendered as the component's content.
13
+ * @param {object} props
14
+ * @param {string} [props.className] CSS class for component container.
15
+ * @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,
16
+ * in `W:H` form.
17
+ */
18
+ declare const ScalableRect: React.FunctionComponent<PropsT>;
19
+ export default ScalableRect;
@@ -0,0 +1,9 @@
1
+ import { type Theme } from '@dr.pogodin/react-themes';
2
+ type PropsT = {
3
+ theme: Theme & {
4
+ container?: string;
5
+ circle?: string;
6
+ };
7
+ };
8
+ declare const ThemedThrobber: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
9
+ export default ThemedThrobber;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The actual tooltip component. It is rendered outside the regular document
3
+ * hierarchy, and with sub-components managed without React to achieve the best
4
+ * performance during animation.
5
+ */
6
+ import { type ReactNode } from 'react';
7
+ export declare enum PLACEMENTS {
8
+ ABOVE_CURSOR = "ABOVE_CURSOR",
9
+ ABOVE_ELEMENT = "ABOVE_ELEMENT",
10
+ BELOW_CURSOR = "BELOW_CURSOR",
11
+ BELOW_ELEMENT = "BELOW_ELEMENT"
12
+ }
13
+ export interface TooltipThemeT {
14
+ appearance?: string;
15
+ arrow?: string;
16
+ content?: string;
17
+ container?: string;
18
+ }
19
+ declare const Tooltip: React.ForwardRefExoticComponent<{
20
+ children?: ReactNode;
21
+ theme: any;
22
+ } & React.RefAttributes<unknown>>;
23
+ export default Tooltip;
@@ -0,0 +1,17 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type Theme } from '@dr.pogodin/react-themes';
3
+ import { PLACEMENTS, type TooltipThemeT } from './Tooltip';
4
+ type PropsT = {
5
+ children?: ReactNode;
6
+ placement?: PLACEMENTS;
7
+ tip?: ReactNode;
8
+ theme: Theme & TooltipThemeT & {
9
+ wrapper?: string;
10
+ };
11
+ };
12
+ declare const ThemedWrapper: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
13
+ type ExportT = typeof ThemedWrapper & {
14
+ PLACEMENTS: typeof PLACEMENTS;
15
+ };
16
+ declare const e: ExportT;
17
+ export default e;
@@ -0,0 +1,13 @@
1
+ import { type Theme } from '@dr.pogodin/react-themes';
2
+ type ComponentThemeT = Theme & {
3
+ container?: string;
4
+ video?: string;
5
+ };
6
+ type PropsT = {
7
+ autoplay?: boolean;
8
+ src: string;
9
+ theme: ComponentThemeT;
10
+ title?: string;
11
+ };
12
+ declare const ThemedYouTubeVideo: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
13
+ export default ThemedYouTubeVideo;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Just an aggregation of all exported components into a single module.
3
+ */
4
+ export { default as Button } from './Button';
5
+ export { default as Checkbox } from './Checkbox';
6
+ export { default as Dropdown } from './Dropdown';
7
+ export { default as Input } from './Input';
8
+ export { default as Link } from './Link';
9
+ export { default as PageLayout } from './PageLayout';
10
+ export { default as MetaTags } from './MetaTags';
11
+ export { default as Modal, BaseModal } from './Modal';
12
+ export { default as NavLink } from './NavLink';
13
+ export { default as ScalableRect } from './ScalableRect';
14
+ export { default as Throbber } from './Throbber';
15
+ export { default as WithTooltip } from './WithTooltip';
16
+ export { default as YouTubeVideo } from './YouTubeVideo';
@@ -0,0 +1,2 @@
1
+ declare const config: any;
2
+ export default config;
@@ -0,0 +1,20 @@
1
+ import type { Request } from 'express';
2
+ import { type SsrContext } from '@dr.pogodin/react-global-state';
3
+ export type ChunkGroupsT = {
4
+ [chunkName: string]: string[];
5
+ };
6
+ export type InjT = {
7
+ CHUNK_GROUPS?: ChunkGroupsT;
8
+ CONFIG?: {
9
+ [key: string]: any;
10
+ };
11
+ ISTATE?: unknown;
12
+ };
13
+ export interface SsrContextT<StateT> extends SsrContext<StateT> {
14
+ chunkGroups: ChunkGroupsT;
15
+ chunks: string[];
16
+ req: Request;
17
+ status: number;
18
+ }
19
+ declare const getSsrContext: (throwWithoutSsrContext?: boolean | undefined) => SsrContextT<unknown> | undefined;
20
+ export { getSsrContext, };
@@ -0,0 +1,52 @@
1
+ import themedImpl, { type Theme, COMPOSE, PRIORITY, ThemeProvider } from '@dr.pogodin/react-themes';
2
+ import config from './config';
3
+ import * as isomorphy from './isomorphy';
4
+ import time from './time';
5
+ import * as webpack from './webpack';
6
+ import type * as JuT from './jest';
7
+ export { Barrier, Emitter, Semaphore } from '@dr.pogodin/js-utils';
8
+ export { getSsrContext } from './globalState';
9
+ export { default as splitComponent } from './splitComponent';
10
+ type ThemedT = typeof themedImpl & {
11
+ COMPOSE: typeof COMPOSE;
12
+ PRIORITY: typeof PRIORITY;
13
+ };
14
+ declare const themed: ThemedT;
15
+ declare const JU: typeof JuT | null;
16
+ /**
17
+ * @category Utilities
18
+ * @global
19
+ * @func withRetries
20
+ * @desc
21
+ * ```js
22
+ * import { withRetries } from '@dr.pogodin/react-utils';
23
+ * ```
24
+ * Attempts to perform given asynchronous `action` up to `maxRetries` times,
25
+ * with the given `interval` between attempts. If any attempt is successful,
26
+ * the result is returned immediately, with no further attempts done;
27
+ * otherwise, if all attempts fail, the result Promise rejects after the last
28
+ * attempt.
29
+ * @param {function} action
30
+ * @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults
31
+ * to 5 attempts.
32
+ * @param {number} [interval=1000] Optional. Interval between retries [ms].
33
+ * Defaults to 1 second.
34
+ * @return {Promise} Resolves to the result of successful operation, or
35
+ * rejects with the error from the latst failed attempt.
36
+ * @example
37
+ * import { withRetries } from '@dr.pogodin/react-utils';
38
+ *
39
+ * let firstCall = true;
40
+ *
41
+ * function sampleAction() {
42
+ * if (!firstCall) return 'success';
43
+ * firstCall = false;
44
+ * throw Error('The first call to this method fails');
45
+ * }
46
+ *
47
+ * withRetries(sampleAction).then(console.log);
48
+ * // It will print 'success' after one second, once the second attempt
49
+ * // is performed.
50
+ */
51
+ export declare function withRetries(action: () => Promise<unknown>, maxRetries?: number, interval?: number): Promise<unknown>;
52
+ export { type Theme, config, isomorphy, JU, themed, ThemeProvider, time, webpack, };
@@ -0,0 +1,23 @@
1
+ export type BuildInfoT = {
2
+ key: string;
3
+ publicPath: string;
4
+ timestamp: string;
5
+ useServiceWorker: boolean;
6
+ };
7
+ declare global {
8
+ const BUILD_INFO: BuildInfoT | undefined;
9
+ }
10
+ /**
11
+ * In scenarious where "BUILD_INFO" is not injected by Webpack (server-side,
12
+ * tests, etc.) we expect the host codebase to explicitly set it before it is
13
+ * ever requested. As a precaution, this function throws if build info has been
14
+ * set already, unless `force` flag is explicitly set.
15
+ * @param info
16
+ * @param force
17
+ */
18
+ export declare function setBuildInfo(info?: BuildInfoT, force?: boolean): void;
19
+ /**
20
+ * Returns "Build Info" object; throws if it has not been initialized yet.
21
+ * @returns
22
+ */
23
+ export declare function getBuildInfo(): BuildInfoT;
@@ -0,0 +1,11 @@
1
+ declare global {
2
+ var REACT_UTILS_FORCE_CLIENT_SIDE: boolean | undefined;
3
+ }
4
+ /**
5
+ * `true` within client-side environment (browser), `false` at server-side.
6
+ */
7
+ export declare const IS_CLIENT_SIDE: boolean;
8
+ /**
9
+ * `true` within the server-side environment (node), `false` at client-side.
10
+ */
11
+ export declare const IS_SERVER_SIDE: boolean;
@@ -0,0 +1,20 @@
1
+ import { getBuildInfo } from './buildInfo';
2
+ import { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './environment-check';
3
+ /**
4
+ * Returns `true` if development version of the code is running;
5
+ * `false` otherwise.
6
+ * @return {boolean}
7
+ */
8
+ export declare function isDevBuild(): boolean;
9
+ /**
10
+ * Returns `true` if production build of the code is running;
11
+ * `false` otherwise.
12
+ * @return {boolean}
13
+ */
14
+ export declare function isProdBuild(): boolean;
15
+ /**
16
+ * Returns build timestamp of the front-end JS bundle.
17
+ * @return {string} ISO date/time string.
18
+ */
19
+ export declare function buildTimestamp(): string;
20
+ export { IS_CLIENT_SIDE, IS_SERVER_SIDE, getBuildInfo };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Jest environment for end-to-end SSR and client-side testing. It relies on
3
+ * the standard react-utils mechanics to execute SSR of given scene, and also
4
+ * Webpack build of the code for client-side execution, it further exposes
5
+ * Jsdom environment for the client-side testing of the outcomes.
6
+ */
7
+ import JsdomEnv from 'jest-environment-jsdom';
8
+ import webpack from 'webpack';
9
+ import type { EnvironmentContext, JestEnvironmentConfig } from '@jest/environment';
10
+ export default class E2eSsrEnv extends JsdomEnv {
11
+ pragmas: Record<string, string | string[]>;
12
+ ssrRequest: object;
13
+ rootDir: string;
14
+ testFolder: string;
15
+ withSsr: boolean;
16
+ webpackStats?: webpack.StatsCompilation;
17
+ /**
18
+ * Loads Webpack config, and exposes it to the environment via global
19
+ * webpackConfig object.
20
+ */
21
+ loadWebpackConfig(): void;
22
+ /**
23
+ * Executes Webpack build.
24
+ * @return {Promise}
25
+ */
26
+ runWebpack(): Promise<void>;
27
+ runSsr(): Promise<void>;
28
+ constructor(config: JestEnvironmentConfig, context: EnvironmentContext);
29
+ setup(): Promise<void>;
30
+ teardown(): Promise<void>;
31
+ }
@@ -0,0 +1,12 @@
1
+ import { type IFs } from 'memfs';
2
+ import webpack from 'webpack';
3
+ declare global {
4
+ interface Window {
5
+ ssrMarkup: string | undefined;
6
+ ssrStatus: number | undefined;
7
+ webpackConfig: webpack.Configuration | undefined;
8
+ webpackOutputFs: IFs;
9
+ webpackStats?: webpack.StatsCompilation;
10
+ }
11
+ }
12
+ export default function getGlobal(): Window;
@@ -0,0 +1,85 @@
1
+ /// <reference types="trusted-types" />
2
+ import { type ReactElement, type ReactNode } from 'react';
3
+ import TU, { act } from 'react-dom/test-utils';
4
+ import Renderer from 'react-test-renderer';
5
+ /**
6
+ * An alias for [act(..)](https://reactjs.org/docs/test-utils.html#act)
7
+ * from `react-dom/test-utils`.
8
+ * @param {function} action
9
+ */
10
+ export { act };
11
+ export { default as getGlobal } from './global';
12
+ declare global {
13
+ var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;
14
+ }
15
+ /**
16
+ * Tricks **react-utils** into thinking the test is running within client-side
17
+ * (browser) environment.
18
+ */
19
+ export declare function mockClientSide(): void;
20
+ /**
21
+ * Reverts the effect of {@link module:JU.mockClientSide mockClientSide(..)}.
22
+ */
23
+ export declare function unmockClientSide(): void;
24
+ /**
25
+ * Generates a mock UUID, or better said it determenistically transforms given
26
+ * `seed` number into a UUID-formatted string.
27
+ * @param {number} seed
28
+ * @return {string}
29
+ */
30
+ export declare function getMockUuid(seed?: number): string;
31
+ /**
32
+ * Advances mock timers, and mock date by the specified time.
33
+ * @param {number} time Time step [ms].
34
+ * @returns {Promise} Wait for this to "jump after" any async code which should
35
+ * be executed because of the mock time movement.
36
+ */
37
+ export declare function mockTimer(time: number): Promise<void>;
38
+ export type MountedSceneT = HTMLElement & {
39
+ destroy: () => void;
40
+ };
41
+ /**
42
+ * Mounts `scene` to the DOM, and returns the root scene element.
43
+ * @param scene
44
+ * @return Created container DOM element with destroy() function
45
+ * attached.
46
+ */
47
+ export declare function mount(scene: ReactNode): MountedSceneT;
48
+ /**
49
+ * Renders provided ReactJS component into JSON representation of the component
50
+ * tree, using [`react-test-renderer`](https://www.npmjs.com/package/react-test-renderer).
51
+ * @param {object} component ReactJS component to render.
52
+ * @return {object} JSON representation of the rendered tree.
53
+ * @example
54
+ * import { JU } from '@dr.pogodin/react-utils';
55
+ * console.log(JU.render(<div>Example</div>));
56
+ */
57
+ export declare function render(component: ReactElement): Renderer.ReactTestRendererJSON | Renderer.ReactTestRendererJSON[] | null;
58
+ /**
59
+ * Generates a shallow render of given ReactJS component, using
60
+ * [react-test-renderer/shallow](https://reactjs.org/docs/shallow-renderer.html)
61
+ * and returns the result.
62
+ * @param {object} component ReactJS component to render.
63
+ * @return {object} JSON representation of the shallow component's render tree.
64
+ */
65
+ export declare function shallowRender(component: ReactElement): ReactElement<any, string | React.JSXElementConstructor<any>>;
66
+ /**
67
+ * Makes a shallow snapshot test of the given ReactJS component, and also
68
+ * returns JSON representation of the rendered component tree. Under the hood
69
+ * it uses {@link module:JU.shallowRender shallowRender(..)} to generate
70
+ * the render, then executes `expect(RENDER_RESULT).toMatchSnapshot()`,
71
+ * and finally returns the `RENDER_RESULT` to the caller.
72
+ * @param {object} component ReactJS component to render.
73
+ * @return {object} JSON representation of shallow render.
74
+ */
75
+ export declare function shallowSnapshot(component: ReactElement): ReactElement<any, string | React.JSXElementConstructor<any>>;
76
+ /**
77
+ * Makes snapshot test of the given ReactJS component, and also returns JSON
78
+ * representation of the rendered component tree. Under the hood, it uses
79
+ * {@link module:JU.render render(..)} to render it, then executes
80
+ * `expect(RENDER_RESULT).toMatchSnapshot()`, and then returns `RENDER_RESULT`.
81
+ * @param {object} component ReactJS component to render.
82
+ * @return {object} JSON render of the component.
83
+ */
84
+ export declare function snapshot(component: ReactElement): Renderer.ReactTestRendererJSON | Renderer.ReactTestRendererJSON[] | null;
85
+ export declare const simulate: typeof TU.Simulate;
@@ -0,0 +1,41 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ import { type ChunkGroupsT } from './globalState';
3
+ /**
4
+ * Client-side only! Ensures all CSS stylesheets required for the specified
5
+ * code chunk are loaded into the document; loads the missing ones; and does
6
+ * simple reference counting to facilitate future clean-up.
7
+ * @param chunkName Chunk name.
8
+ * @param refCount
9
+ * @return Resolves once all pending stylesheets, necessary for
10
+ * the chunk, are either loaded, or failed to load.
11
+ */
12
+ export declare function bookStyleSheets(chunkName: string, chunkGroups: ChunkGroupsT, refCount: boolean): Promise<void>;
13
+ /**
14
+ * Client-side only! Frees from the document all CSS stylesheets that are
15
+ * required by the specified chunk, and have reference counter equal to one
16
+ * (for chunks with larger reference counter values, it just decrements
17
+ * the reference counter).
18
+ * @param {string} chunkName
19
+ */
20
+ export declare function freeStyleSheets(chunkName: string, chunkGroups: ChunkGroupsT): void;
21
+ type ComponentOrModule<PropsT> = ComponentType<PropsT> | {
22
+ default: ComponentType<PropsT>;
23
+ };
24
+ /**
25
+ * Given an async component retrieval function `getComponent()` it creates
26
+ * a special "code split" component, which uses <Suspense> to asynchronously
27
+ * load on demand the code required by `getComponent()`.
28
+ * @param options
29
+ * @param options.chunkName
30
+ * @param {function} options.getComponent
31
+ * @param {React.Element} [options.placeholder]
32
+ * @return {React.ElementType}
33
+ */
34
+ export default function splitComponent<ComponentPropsT extends {
35
+ children?: ReactNode;
36
+ }>({ chunkName, getComponent, placeholder, }: {
37
+ chunkName: string;
38
+ getComponent: () => Promise<ComponentOrModule<ComponentPropsT>>;
39
+ placeholder?: ReactNode;
40
+ }): React.FunctionComponent<ComponentPropsT>;
41
+ export {};
@@ -0,0 +1,62 @@
1
+ import dayjs from 'dayjs';
2
+ import { timer } from '@dr.pogodin/js-utils';
3
+ /**
4
+ * This react hook wraps Date.now() function in a SSR friendly way,
5
+ * ensuring that all calls to useCurrent() within the same render return
6
+ * exactly the same time (which is retrieved from Date.now() first, and
7
+ * then stored in the global state to be reused in all other calls), which
8
+ * is also passed and used in the first client side render, and then updated
9
+ * with a finite precision to avoid infinite re-rendering loops.
10
+ * @param [options] Optional settings.
11
+ * @param [options.globalStatePath="currentTime"] Global state path
12
+ * to keep the current time value.
13
+ * @param [options.precision= 5 * time.SEC_MS] Current time precision.
14
+ * The hook won't update the current time stored in the global state unless it
15
+ * is different from Date.now() result by this number (in milliseconds).
16
+ * Default to 5 seconds.
17
+ * @param [options.autorefresh=false] Set `true` to automatically
18
+ * refresh time stored in the global state with the given `precision` (and
19
+ * thus automatically re-rendering components dependent on this hook, or
20
+ * the global state with the period equal to the `precision`.
21
+ * @return Unix timestamp in milliseconds.
22
+ */
23
+ export declare function useCurrent({ autorefresh, globalStatePath, precision, }?: {
24
+ autorefresh?: boolean | undefined;
25
+ globalStatePath?: string | undefined;
26
+ precision?: number | undefined;
27
+ }): number;
28
+ /**
29
+ * Wraps the standard Date.getTimezoneOffset() method in a SSR-friendly way.
30
+ * This hook retrieves the offset value at the client side and uses a cookie
31
+ * to pass it to the server in subsequent requests from that user. At the server
32
+ * side the value from cookie is used in renders and passed back to the client
33
+ * via the global state. Prior to the value being known (in the very first
34
+ * request from the user, when the cookie is still missing), zero value is used
35
+ * as the default value.
36
+ *
37
+ * @param {object} [options] Optional settings.
38
+ * @param {string} [options.cookieName="timezoneOffset"] Optional. The name of
39
+ * cookie to use to store the timezone offset. Defaults "timezoneOffset". Set
40
+ * to a falsy value to forbid using cookies altogether (in that case the hook
41
+ * will always return zero value at the server-side, and in the first render
42
+ * at the client-side).
43
+ * @param {string} [options.timezoneOffset="timezoneOffset"] Optional.
44
+ * The global state path to store the offset. Defaults "timezoneOffset".
45
+ * @return {number} Timezone offset.
46
+ */
47
+ export declare function useTimezoneOffset({ cookieName, globalStatePath, }?: {
48
+ cookieName?: string | undefined;
49
+ globalStatePath?: string | undefined;
50
+ }): number;
51
+ declare const _default: typeof dayjs & {
52
+ DAY_MS: number;
53
+ HOUR_MS: number;
54
+ MIN_MS: number;
55
+ SEC_MS: number;
56
+ YEAR_MS: number;
57
+ now: () => number;
58
+ timer: typeof timer;
59
+ useCurrent: typeof useCurrent;
60
+ useTimezoneOffset: typeof useTimezoneOffset;
61
+ };
62
+ export default _default;
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Requires the specified module without including it into the bundle during
4
+ * Webpack build.
5
+ * @param modulePath
6
+ * @param [basePath]
7
+ * @return Required module.
8
+ */
9
+ export declare function requireWeak(modulePath: string, basePath?: string): NodeJS.Module | null;
10
+ /**
11
+ * Resolves specified module path with help of Babel's module resolver.
12
+ * Yes, the function itself just returns its argument to the caller, but Babel
13
+ * is configured to resolve the first argument of resolveWeak(..) function, thus
14
+ * the result will be the resolved path.
15
+ * @param {string} modulePath
16
+ * @return {string} Absolute or relative path to the module.
17
+ */
18
+ export declare function resolveWeak(modulePath: string): string;
@@ -0,0 +1 @@
1
+ export declare const container: string;
@@ -0,0 +1 @@
1
+ export declare const sampleClassName: string;
@@ -0,0 +1 @@
1
+ export declare const navLink: string;
@@ -0,0 +1 @@
1
+ export declare const container: string;