@dr.pogodin/react-utils 1.25.5 → 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 (294) hide show
  1. package/babel.config.js +3 -1
  2. package/bin/build.js +25 -5
  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 +168 -42
  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 -24
  14. package/build/development/server/index.js.map +1 -1
  15. package/build/development/server/renderer.js +56 -44
  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 +8 -7
  24. package/build/development/shared/components/Button/index.js.map +1 -1
  25. package/build/development/shared/components/Checkbox/index.js +25 -28
  26. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  27. package/build/development/shared/components/Dropdown/index.js +25 -19
  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 +8 -9
  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 +17 -18
  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 +17 -20
  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 -23
  46. package/build/development/shared/components/Throbber/index.js.map +1 -1
  47. package/build/development/shared/components/WithTooltip/Tooltip.js +20 -24
  48. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  49. package/build/development/shared/components/WithTooltip/index.js +11 -11
  50. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  51. package/build/development/shared/components/YouTubeVideo/index.js +16 -15
  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 +1 -2
  56. package/build/development/shared/utils/config.js.map +1 -1
  57. package/build/development/shared/utils/globalState.js +15 -0
  58. package/build/development/shared/utils/globalState.js.map +1 -0
  59. package/build/development/shared/utils/index.js +13 -11
  60. package/build/development/shared/utils/index.js.map +1 -1
  61. package/build/development/shared/utils/isomorphy/buildInfo.js +7 -3
  62. package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
  63. package/build/development/shared/utils/isomorphy/environment-check.js +2 -4
  64. package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
  65. package/build/development/shared/utils/isomorphy/index.js.map +1 -1
  66. package/build/development/shared/utils/jest/E2eSsrEnv.js +35 -28
  67. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  68. package/build/development/shared/utils/jest/global.js +17 -0
  69. package/build/development/shared/utils/jest/global.js.map +1 -0
  70. package/build/development/shared/utils/jest/index.js +18 -11
  71. package/build/development/shared/utils/jest/index.js.map +1 -1
  72. package/build/development/shared/utils/splitComponent.js +25 -34
  73. package/build/development/shared/utils/splitComponent.js.map +1 -1
  74. package/build/development/shared/utils/time.js +16 -13
  75. package/build/development/shared/utils/time.js.map +1 -1
  76. package/build/development/shared/utils/webpack.js +3 -3
  77. package/build/development/shared/utils/webpack.js.map +1 -1
  78. package/build/development/web.bundle.js +92 -82
  79. package/build/production/client/getInj.js +1 -1
  80. package/build/production/client/getInj.js.map +1 -1
  81. package/build/production/client/index.js +4 -4
  82. package/build/production/client/index.js.map +1 -1
  83. package/build/production/client/init.js +3 -1
  84. package/build/production/client/init.js.map +1 -1
  85. package/build/production/index.js +1 -1
  86. package/build/production/index.js.map +1 -1
  87. package/build/production/server/Cache.js +7 -8
  88. package/build/production/server/Cache.js.map +1 -1
  89. package/build/production/server/index.js +5 -4
  90. package/build/production/server/index.js.map +1 -1
  91. package/build/production/server/renderer.js +32 -30
  92. package/build/production/server/renderer.js.map +1 -1
  93. package/build/production/server/server.js +7 -5
  94. package/build/production/server/server.js.map +1 -1
  95. package/build/production/server/utils/errors.js +9 -10
  96. package/build/production/server/utils/errors.js.map +1 -1
  97. package/build/production/server/utils/index.js +1 -1
  98. package/build/production/server/utils/index.js.map +1 -1
  99. package/build/production/shared/components/Button/index.js +4 -4
  100. package/build/production/shared/components/Button/index.js.map +1 -1
  101. package/build/production/shared/components/Checkbox/index.js +12 -12
  102. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  103. package/build/production/shared/components/Dropdown/index.js +11 -11
  104. package/build/production/shared/components/Dropdown/index.js.map +1 -1
  105. package/build/production/shared/components/GenericLink/index.js +25 -20
  106. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  107. package/build/production/shared/components/Input/index.js +7 -7
  108. package/build/production/shared/components/Input/index.js.map +1 -1
  109. package/build/production/shared/components/Link.js +2 -2
  110. package/build/production/shared/components/Link.js.map +1 -1
  111. package/build/production/shared/components/MetaTags.js +10 -10
  112. package/build/production/shared/components/MetaTags.js.map +1 -1
  113. package/build/production/shared/components/Modal/index.js +2 -2
  114. package/build/production/shared/components/Modal/index.js.map +1 -1
  115. package/build/production/shared/components/NavLink.js +1 -1
  116. package/build/production/shared/components/NavLink.js.map +1 -1
  117. package/build/production/shared/components/PageLayout/index.js +2 -2
  118. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  119. package/build/production/shared/components/ScalableRect/index.js +7 -3
  120. package/build/production/shared/components/ScalableRect/index.js.map +1 -1
  121. package/build/production/shared/components/Throbber/index.js +2 -2
  122. package/build/production/shared/components/Throbber/index.js.map +1 -1
  123. package/build/production/shared/components/WithTooltip/Tooltip.js +13 -13
  124. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  125. package/build/production/shared/components/WithTooltip/index.js +3 -3
  126. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  127. package/build/production/shared/components/YouTubeVideo/index.js +7 -7
  128. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  129. package/build/production/shared/components/index.js +1 -1
  130. package/build/production/shared/components/index.js.map +1 -1
  131. package/build/production/shared/utils/config.js +1 -1
  132. package/build/production/shared/utils/config.js.map +1 -1
  133. package/build/production/shared/utils/globalState.js +3 -0
  134. package/build/production/shared/utils/globalState.js.map +1 -0
  135. package/build/production/shared/utils/index.js +3 -3
  136. package/build/production/shared/utils/index.js.map +1 -1
  137. package/build/production/shared/utils/isomorphy/buildInfo.js +7 -4
  138. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  139. package/build/production/shared/utils/isomorphy/environment-check.js +2 -2
  140. package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
  141. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  142. package/build/production/shared/utils/jest/E2eSsrEnv.js +9 -9
  143. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  144. package/build/production/shared/utils/jest/global.js +2 -0
  145. package/build/production/shared/utils/jest/global.js.map +1 -0
  146. package/build/production/shared/utils/jest/index.js +6 -6
  147. package/build/production/shared/utils/jest/index.js.map +1 -1
  148. package/build/production/shared/utils/splitComponent.js +16 -16
  149. package/build/production/shared/utils/splitComponent.js.map +1 -1
  150. package/build/production/shared/utils/time.js +12 -8
  151. package/build/production/shared/utils/time.js.map +1 -1
  152. package/build/production/shared/utils/webpack.js +3 -3
  153. package/build/production/shared/utils/webpack.js.map +1 -1
  154. package/build/production/web.bundle.js +1 -1
  155. package/build/production/web.bundle.js.map +1 -1
  156. package/build/types-code/client/getInj.d.ts +3 -0
  157. package/build/types-code/client/index.d.ts +11 -0
  158. package/build/types-code/client/init.d.ts +9 -0
  159. package/build/types-code/index.d.ts +10 -0
  160. package/build/types-code/server/Cache.d.ts +37 -0
  161. package/build/types-code/server/index.d.ts +145 -0
  162. package/build/types-code/server/renderer.d.ts +106 -0
  163. package/build/types-code/server/server.d.ts +41 -0
  164. package/build/types-code/server/utils/errors.d.ts +104 -0
  165. package/build/types-code/server/utils/index.d.ts +1 -0
  166. package/build/types-code/shared/components/Button/index.d.ts +27 -0
  167. package/build/types-code/shared/components/Checkbox/index.d.ts +21 -0
  168. package/build/types-code/shared/components/Dropdown/index.d.ts +23 -0
  169. package/build/types-code/shared/components/GenericLink/index.d.ts +61 -0
  170. package/build/types-code/shared/components/Input/index.d.ts +11 -0
  171. package/build/types-code/shared/components/Link.d.ts +12 -0
  172. package/build/types-code/shared/components/MetaTags.d.ts +68 -0
  173. package/build/types-code/shared/components/Modal/index.d.ts +26 -0
  174. package/build/types-code/shared/components/NavLink.d.ts +5 -0
  175. package/build/types-code/shared/components/PageLayout/index.d.ts +16 -0
  176. package/build/types-code/shared/components/ScalableRect/index.d.ts +19 -0
  177. package/build/types-code/shared/components/Throbber/index.d.ts +9 -0
  178. package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +23 -0
  179. package/build/types-code/shared/components/WithTooltip/index.d.ts +17 -0
  180. package/build/types-code/shared/components/YouTubeVideo/index.d.ts +13 -0
  181. package/build/types-code/shared/components/index.d.ts +16 -0
  182. package/build/types-code/shared/utils/config.d.ts +2 -0
  183. package/build/types-code/shared/utils/globalState.d.ts +20 -0
  184. package/build/types-code/shared/utils/index.d.ts +52 -0
  185. package/build/types-code/shared/utils/isomorphy/buildInfo.d.ts +23 -0
  186. package/build/types-code/shared/utils/isomorphy/environment-check.d.ts +11 -0
  187. package/build/types-code/shared/utils/isomorphy/index.d.ts +20 -0
  188. package/build/types-code/shared/utils/jest/E2eSsrEnv.d.ts +31 -0
  189. package/build/types-code/shared/utils/jest/global.d.ts +12 -0
  190. package/build/types-code/shared/utils/jest/index.d.ts +85 -0
  191. package/build/types-code/shared/utils/splitComponent.d.ts +41 -0
  192. package/build/types-code/shared/utils/time.d.ts +62 -0
  193. package/build/types-code/shared/utils/webpack.d.ts +18 -0
  194. package/build/types-scss/__tests__/js/config/publicPath support/__assets__/style.scss.d.ts +1 -0
  195. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
  196. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
  197. package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
  198. package/build/types-scss/__tests__/js/shared/components/NavLink/styles.scss.d.ts +1 -0
  199. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
  200. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
  201. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
  202. package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
  203. package/build/types-scss/__tests__/ts/config/publicPath support/__assets__/style.scss.d.ts +1 -0
  204. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
  205. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
  206. package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
  207. package/build/types-scss/__tests__/ts/shared/components/NavLink/styles.scss.d.ts +1 -0
  208. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
  209. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
  210. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
  211. package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
  212. package/build/types-scss/src/shared/components/Button/style.scss.d.ts +6 -0
  213. package/build/types-scss/src/shared/components/Checkbox/theme.scss.d.ts +6 -0
  214. package/build/types-scss/src/shared/components/Dropdown/theme.scss.d.ts +9 -0
  215. package/build/types-scss/src/shared/components/GenericLink/style.scss.d.ts +1 -0
  216. package/build/types-scss/src/shared/components/Input/theme.scss.d.ts +6 -0
  217. package/build/types-scss/src/shared/components/Modal/base-theme.scss.d.ts +5 -0
  218. package/build/types-scss/src/shared/components/PageLayout/base-theme.scss.d.ts +6 -0
  219. package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +2 -0
  220. package/build/types-scss/src/shared/components/Throbber/theme.scss.d.ts +6 -0
  221. package/build/types-scss/src/shared/components/WithTooltip/default-theme.scss.d.ts +7 -0
  222. package/build/types-scss/src/shared/components/YouTubeVideo/base.scss.d.ts +5 -0
  223. package/build/types-scss/src/shared/components/YouTubeVideo/throbber.scss.d.ts +4 -0
  224. package/config/eslint/jest.json +3 -2
  225. package/config/eslint/typescript.js +34 -0
  226. package/config/jest/default.js +3 -3
  227. package/package.json +75 -33
  228. package/src/client/getInj.ts +43 -0
  229. package/src/client/index.tsx +40 -0
  230. package/src/client/init.ts +47 -0
  231. package/src/index.ts +58 -0
  232. package/src/server/Cache.ts +68 -0
  233. package/src/server/index.ts +230 -0
  234. package/src/server/renderer.tsx +604 -0
  235. package/src/server/server.ts +309 -0
  236. package/src/server/utils/errors.ts +135 -0
  237. package/src/server/utils/index.ts +3 -0
  238. package/src/shared/components/Button/index.tsx +146 -0
  239. package/src/shared/components/Button/style.scss +53 -0
  240. package/src/shared/components/Checkbox/index.tsx +71 -0
  241. package/src/shared/components/Checkbox/theme.scss +43 -0
  242. package/src/shared/components/Dropdown/index.tsx +144 -0
  243. package/src/shared/components/Dropdown/theme.scss +63 -0
  244. package/src/shared/components/GenericLink/index.tsx +157 -0
  245. package/src/shared/components/GenericLink/style.scss +3 -0
  246. package/src/shared/components/Input/index.tsx +59 -0
  247. package/src/shared/components/Input/theme.scss +27 -0
  248. package/src/shared/components/Link.tsx +21 -0
  249. package/src/shared/components/MetaTags.tsx +170 -0
  250. package/src/shared/components/Modal/base-theme.scss +38 -0
  251. package/src/shared/components/Modal/index.tsx +144 -0
  252. package/src/shared/components/Modal/styles.scss +5 -0
  253. package/src/shared/components/NavLink.tsx +13 -0
  254. package/src/shared/components/PageLayout/base-theme.scss +30 -0
  255. package/src/shared/components/PageLayout/index.tsx +76 -0
  256. package/src/shared/components/ScalableRect/index.tsx +84 -0
  257. package/src/shared/components/ScalableRect/style.scss +10 -0
  258. package/src/shared/components/Throbber/index.tsx +43 -0
  259. package/src/shared/components/Throbber/theme.scss +26 -0
  260. package/src/shared/components/WithTooltip/Tooltip.tsx +353 -0
  261. package/src/shared/components/WithTooltip/default-theme.scss +36 -0
  262. package/src/shared/components/WithTooltip/index.tsx +204 -0
  263. package/src/shared/components/YouTubeVideo/base.scss +13 -0
  264. package/src/shared/components/YouTubeVideo/index.tsx +96 -0
  265. package/src/shared/components/YouTubeVideo/throbber.scss +11 -0
  266. package/src/shared/components/index.ts +17 -0
  267. package/src/shared/utils/config.ts +21 -0
  268. package/src/shared/utils/globalState.ts +29 -0
  269. package/src/shared/utils/index.ts +105 -0
  270. package/src/shared/utils/isomorphy/buildInfo.ts +54 -0
  271. package/src/shared/utils/isomorphy/environment-check.ts +18 -0
  272. package/src/shared/utils/isomorphy/index.ts +38 -0
  273. package/src/shared/utils/jest/E2eSsrEnv.ts +250 -0
  274. package/src/shared/utils/jest/global.ts +19 -0
  275. package/src/shared/utils/jest/index.tsx +157 -0
  276. package/src/shared/utils/splitComponent.tsx +255 -0
  277. package/src/shared/utils/time.ts +118 -0
  278. package/src/shared/utils/webpack.ts +45 -0
  279. package/src/styles/_global/reset.css +52 -0
  280. package/src/styles/global.scss +11 -0
  281. package/tsconfig.configs.json +18 -0
  282. package/tsconfig.json +27 -0
  283. package/tsconfig.types.json +53 -0
  284. package/typed-scss-modules.config.ts +9 -0
  285. package/types.d.ts +37 -0
  286. package/{webpack.config.js → webpack.config.ts} +7 -3
  287. package/config/babel/node-ssr.js +0 -85
  288. package/config/babel/webpack.js +0 -122
  289. package/config/webpack/app-base.js +0 -330
  290. package/config/webpack/app-development.js +0 -80
  291. package/config/webpack/app-production.js +0 -60
  292. package/config/webpack/lib-base.js +0 -155
  293. package/config/webpack/lib-development.js +0 -45
  294. package/config/webpack/lib-production.js +0 -44
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _utils = require("../../utils");
9
+ var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  const baseTheme = {
12
12
  "context": "-dr-pogodin-react-utils___src-shared-components-PageLayout-base-theme___context___m4mL-M",
@@ -31,27 +31,25 @@ const baseTheme = {
31
31
  * @param {...any} [props....]
32
32
  * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
33
33
  */
34
- function PageLayout({
34
+ const PageLayout = ({
35
35
  children,
36
36
  leftSidePanelContent,
37
37
  rightSidePanelContent,
38
38
  theme
39
- }) {
40
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
41
- className: theme.container,
42
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
43
- className: [theme.sidePanel, theme.leftSidePanel].join(' '),
44
- children: leftSidePanelContent
45
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
46
- className: theme.mainPanel,
47
- children: children
48
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
49
- className: [theme.sidePanel, theme.rightSidePanel].join(' '),
50
- children: rightSidePanelContent
51
- })]
52
- });
53
- }
54
- const ThemedPageLayout = (0, _utils.themed)('PageLayout', ['container', 'leftSidePanel', 'mainPanel', 'rightSidePanel', 'sidePanel'], baseTheme)(PageLayout);
39
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
40
+ className: theme.container,
41
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
42
+ className: [theme.sidePanel, theme.leftSidePanel].join(' '),
43
+ children: leftSidePanelContent
44
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
45
+ className: theme.mainPanel,
46
+ children: children
47
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
48
+ className: [theme.sidePanel, theme.rightSidePanel].join(' '),
49
+ children: rightSidePanelContent
50
+ })]
51
+ });
52
+ const ThemedPageLayout = (0, _reactThemes.default)(PageLayout, 'PageLayout', ['container', 'leftSidePanel', 'mainPanel', 'rightSidePanel', 'sidePanel'], baseTheme);
55
53
  PageLayout.propTypes = {
56
54
  children: _propTypes.default.node,
57
55
  leftSidePanelContent: _propTypes.default.node,
@@ -63,6 +61,5 @@ PageLayout.defaultProps = {
63
61
  leftSidePanelContent: null,
64
62
  rightSidePanelContent: null
65
63
  };
66
- var _default = ThemedPageLayout;
67
- exports.default = _default;
64
+ var _default = exports.default = ThemedPageLayout;
68
65
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_utils","_jsxRuntime","baseTheme","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","jsxs","className","container","jsx","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel","ThemedPageLayout","themed","propTypes","PT","node","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/PageLayout/index.jsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport baseTheme from './base-theme.scss';\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nfunction PageLayout({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) {\n return (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n );\n}\n\nconst ThemedPageLayout = themed('PageLayout', [\n 'container',\n 'leftSidePanel',\n 'mainPanel',\n 'rightSidePanel',\n 'sidePanel',\n], baseTheme)(PageLayout);\n\nPageLayout.propTypes = {\n children: PT.node,\n leftSidePanelContent: PT.node,\n rightSidePanelContent: PT.node,\n theme: ThemedPageLayout.themeType.isRequired,\n};\n\nPageLayout.defaultProps = {\n children: null,\n leftSidePanelContent: null,\n rightSidePanelContent: null,\n};\n\nexport default ThemedPageLayout;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC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d,KAAK,EAAEU,gBAAgB,CAACK,SAAS,CAACC;AACpC,CAAC;AAEDpB,UAAU,CAACqB,YAAY,GAAG;EACxBpB,QAAQ,EAAE,IAAI;EACdC,oBAAoB,EAAE,IAAI;EAC1BC,qBAAqB,EAAE;AACzB,CAAC;AAAC,IAAAmB,QAAA,GAEaR,gBAAgB;AAAAS,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","baseTheme","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","jsxs","className","container","jsx","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel","ThemedPageLayout","themed","propTypes","PT","node","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport type { ReactNode } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme: Theme & {\n container?: string;\n mainPanel?: string;\n sidePanel?: string;\n leftSidePanel?: string;\n rightSidePanel?: string;\n };\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: React.FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n);\n\nconst ThemedPageLayout = themed(PageLayout, 'PageLayout', [\n 'container',\n 'leftSidePanel',\n 'mainPanel',\n 'rightSidePanel',\n 'sidePanel',\n], baseTheme);\n\nPageLayout.propTypes = {\n children: PT.node,\n leftSidePanelContent: PT.node,\n rightSidePanelContent: PT.node,\n theme: ThemedPageLayout.themeType.isRequired,\n};\n\nPageLayout.defaultProps = {\n children: null,\n leftSidePanelContent: null,\n rightSidePanelContent: null,\n};\n\nexport default ThemedPageLayout;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAiB9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAA2C,GAAGA,CAAC;EACnDC,QAAQ;EACRC,oBAAoB;EACpBC,qBAAqB;EACrBC;AACF,CAAC,kBACC,IAAAN,WAAA,CAAAO,IAAA;EAAKC,SAAS,EAAEF,KAAK,CAACG,SAAU;EAAAN,QAAA,gBAC9B,IAAAH,WAAA,CAAAU,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACM,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC9DC;EAAoB,CAClB,CAAC,eACN,IAAAJ,WAAA,CAAAU,GAAA;IAAKF,SAAS,EAAEF,KAAK,CAACQ,SAAU;IAAAX,QAAA,EAC7BA;EAAQ,CACN,CAAC,eACN,IAAAH,WAAA,CAAAU,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACS,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC/DE;EAAqB,CACnB,CAAC;AAAA,CACH,CACN;AAED,MAAMW,gBAAgB,GAAG,IAAAC,oBAAM,EAACf,UAAU,EAAE,YAAY,EAAE,CACxD,WAAW,EACX,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,WAAW,CACZ,EAAED,SAAS,CAAC;AAEbC,UAAU,CAACgB,SAAS,GAAG;EACrBf,QAAQ,EAAEgB,kBAAE,CAACC,IAAI;EACjBhB,oBAAoB,EAAEe,kBAAE,CAACC,IAAI;EAC7Bf,qBAAqB,EAAEc,kBAAE,CAACC,IAAI;EAC9Bd,KAAK,EAAEU,gBAAgB,CAACK,SAAS,CAACC;AACpC,CAAC;AAEDpB,UAAU,CAACqB,YAAY,GAAG;EACxBpB,QAAQ,EAAE,IAAI;EACdC,oBAAoB,EAAE,IAAI;EAC1BC,qBAAqB,EAAE;AACzB,CAAC;AAAC,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,gBAAgB"}
@@ -4,8 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = ScalableRect;
7
+ exports.default = void 0;
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ require("react");
9
10
  var _jsxRuntime = require("react/jsx-runtime");
10
11
  /**
11
12
  * The `<ScalableRect>` component implements container keeping given aspect
@@ -17,13 +18,13 @@ var _jsxRuntime = require("react/jsx-runtime");
17
18
  * @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,
18
19
  * in `W:H` form.
19
20
  */
20
- function ScalableRect({
21
+ const ScalableRect = ({
21
22
  children,
22
23
  className,
23
24
  ratio
24
- }) {
25
+ }) => {
25
26
  const aux = ratio.split(':');
26
- const paddingBottom = `${100 * aux[1] / aux[0]}%`;
27
+ const paddingBottom = `${100 * parseFloat(aux[1]) / parseFloat(aux[0])}%`;
27
28
 
28
29
  /* NOTE: In case the following code looks strange to you, mind that we want to
29
30
  * allow the user to set custom styles on this component. If user passes in a
@@ -46,15 +47,34 @@ function ScalableRect({
46
47
  className: className,
47
48
  children: rect
48
49
  }) : rect;
49
- }
50
+ };
50
51
  ScalableRect.defaultProps = {
51
52
  children: null,
52
- className: null,
53
+ className: undefined,
53
54
  ratio: '1:1'
54
55
  };
55
56
  ScalableRect.propTypes = {
56
57
  children: _propTypes.default.node,
57
58
  className: _propTypes.default.string,
58
- ratio: _propTypes.default.string
59
+ ratio: (props, name) => {
60
+ const ratio = props[name];
61
+
62
+ // "ratio" prop is not required (defaults "1:1").
63
+ if (ratio === undefined) return null;
64
+
65
+ // If given, "ratio" must be a string.
66
+ if (typeof ratio !== 'string') {
67
+ return Error('"ratio" prop must be a string');
68
+ }
69
+
70
+ // If given, "ratio" must have "H:W" format.
71
+ if (!ratio.match(/\d\.\d+/)) {
72
+ return Error('"ratio" prop must have "H:W" format');
73
+ }
74
+
75
+ // Everything looks right.
76
+ return null;
77
+ }
59
78
  };
79
+ var _default = exports.default = ScalableRect;
60
80
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_jsxRuntime","ScalableRect","children","className","ratio","aux","split","paddingBottom","rect","jsx","style","defaultProps","propTypes","PT","node","string"],"sources":["../../../../../src/shared/components/ScalableRect/index.jsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport './style.scss';\n\n/**\n * The `<ScalableRect>` component implements container keeping given aspect\n * ratio, while its width is altered.\n *\n * **Children:** Component children are rendered as the component's content.\n * @param {object} props\n * @param {string} [props.className] CSS class for component container.\n * @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,\n * in `W:H` form.\n */\nexport default function ScalableRect({ children, className, ratio }) {\n const aux = ratio.split(':');\n const paddingBottom = `${(100 * aux[1]) / aux[0]}%`;\n\n /* NOTE: In case the following code looks strange to you, mind that we want to\n * allow the user to set custom styles on this component. If user passes in a\n * \"className\" prop (possibly \"styleName\", but that one is converted to\n * \"className\" by Babel just before being passed into this component), it\n * should not interfere with the sizing behavior, thus we need an extra <div>\n * level in this component; however, if user does not need a custom styling,\n * we can save one level of HTML code, so we do it. */\n const rect = (\n <div\n style={{ paddingBottom }}\n styleName=\"container\"\n >\n <div styleName=\"wrapper\">\n {children}\n </div>\n </div>\n );\n return className ? (\n <div className={className}>\n {rect}\n </div>\n ) : rect;\n}\n\nScalableRect.defaultProps = {\n children: null,\n className: null,\n ratio: '1:1',\n};\n\nScalableRect.propTypes = {\n children: PT.node,\n className: PT.string,\n ratio: PT.string,\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4B,IAAAC,WAAA,GAAAD,OAAA;AAI5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,YAAYA,CAAC;EAAEC,QAAQ;EAAEC,SAAS;EAAEC;AAAM,CAAC,EAAE;EACnE,MAAMC,GAAG,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;EAC5B,MAAMC,aAAa,GAAI,GAAG,GAAG,GAAGF,GAAG,CAAC,CAAC,CAAC,GAAIA,GAAG,CAAC,CAAC,CAAE,GAAE;;EAEnD;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMG,IAAI,gBACR,IAAAR,WAAA,CAAAS,GAAA;IACEC,KAAK,EAAE;MAAEH;IAAc,CAAE;IACzBJ,SAAS,EAAC,yFAAW;IAAAD,QAAA,eAErB,IAAAF,WAAA,CAAAS,GAAA;MAAKN,SAAS,EAAC,uFAAS;MAAAD,QAAA,EACrBA;IAAQ,CACN;EAAC,CACH,CACN;EACD,OAAOC,SAAS,gBACd,IAAAH,WAAA,CAAAS,GAAA;IAAKN,SAAS,EAAEA,SAAU;IAAAD,QAAA,EACvBM;EAAI,CACF,CAAC,GACJA,IAAI;AACV;AAEAP,YAAY,CAACU,YAAY,GAAG;EAC1BT,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE;AACT,CAAC;AAEDH,YAAY,CAACW,SAAS,GAAG;EACvBV,QAAQ,EAAEW,kBAAE,CAACC,IAAI;EACjBX,SAAS,EAAEU,kBAAE,CAACE,MAAM;EACpBX,KAAK,EAAES,kBAAE,CAACE;AACZ,CAAC"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_jsxRuntime","ScalableRect","children","className","ratio","aux","split","paddingBottom","parseFloat","rect","jsx","style","defaultProps","undefined","propTypes","PT","node","string","props","name","Error","match","_default","exports","default"],"sources":["../../../../../src/shared/components/ScalableRect/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport { type ReactNode } from 'react';\n\nimport './style.scss';\n\ntype PropsT = {\n children?: ReactNode;\n className?: string;\n ratio?: `${number}:${number}`,\n};\n\n/**\n * The `<ScalableRect>` component implements container keeping given aspect\n * ratio, while its width is altered.\n *\n * **Children:** Component children are rendered as the component's content.\n * @param {object} props\n * @param {string} [props.className] CSS class for component container.\n * @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,\n * in `W:H` form.\n */\nconst ScalableRect: React.FunctionComponent<PropsT> = ({\n children,\n className,\n ratio,\n}) => {\n const aux = ratio!.split(':');\n const paddingBottom = `${(100 * parseFloat(aux[1])) / parseFloat(aux[0])}%`;\n\n /* NOTE: In case the following code looks strange to you, mind that we want to\n * allow the user to set custom styles on this component. If user passes in a\n * \"className\" prop (possibly \"styleName\", but that one is converted to\n * \"className\" by Babel just before being passed into this component), it\n * should not interfere with the sizing behavior, thus we need an extra <div>\n * level in this component; however, if user does not need a custom styling,\n * we can save one level of HTML code, so we do it. */\n const rect = (\n <div\n style={{ paddingBottom }}\n styleName=\"container\"\n >\n <div styleName=\"wrapper\">\n {children}\n </div>\n </div>\n );\n return className ? (\n <div className={className}>\n {rect}\n </div>\n ) : rect;\n};\n\nScalableRect.defaultProps = {\n children: null,\n className: undefined,\n ratio: '1:1',\n};\n\nScalableRect.propTypes = {\n children: PT.node,\n className: PT.string,\n ratio: (props, name) => {\n const ratio = props[name];\n\n // \"ratio\" prop is not required (defaults \"1:1\").\n if (ratio === undefined) return null;\n\n // If given, \"ratio\" must be a string.\n if (typeof ratio !== 'string') {\n return Error('\"ratio\" prop must be a string');\n }\n\n // If given, \"ratio\" must have \"H:W\" format.\n if (!ratio.match(/\\d\\.\\d+/)) {\n return Error('\"ratio\" prop must have \"H:W\" format');\n }\n\n // Everything looks right.\n return null;\n },\n};\n\nexport default ScalableRect;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAAuC,IAAAC,WAAA,GAAAD,OAAA;AAUvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,YAA6C,GAAGA,CAAC;EACrDC,QAAQ;EACRC,SAAS;EACTC;AACF,CAAC,KAAK;EACJ,MAAMC,GAAG,GAAGD,KAAK,CAAEE,KAAK,CAAC,GAAG,CAAC;EAC7B,MAAMC,aAAa,GAAI,GAAG,GAAG,GAAGC,UAAU,CAACH,GAAG,CAAC,CAAC,CAAC,CAAC,GAAIG,UAAU,CAACH,GAAG,CAAC,CAAC,CAAC,CAAE,GAAE;;EAE3E;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMI,IAAI,gBACR,IAAAT,WAAA,CAAAU,GAAA;IACEC,KAAK,EAAE;MAAEJ;IAAc,CAAE;IACzBJ,SAAS,EAAC,yFAAW;IAAAD,QAAA,eAErB,IAAAF,WAAA,CAAAU,GAAA;MAAKP,SAAS,EAAC,uFAAS;MAAAD,QAAA,EACrBA;IAAQ,CACN;EAAC,CACH,CACN;EACD,OAAOC,SAAS,gBACd,IAAAH,WAAA,CAAAU,GAAA;IAAKP,SAAS,EAAEA,SAAU;IAAAD,QAAA,EACvBO;EAAI,CACF,CAAC,GACJA,IAAI;AACV,CAAC;AAEDR,YAAY,CAACW,YAAY,GAAG;EAC1BV,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAEU,SAAS;EACpBT,KAAK,EAAE;AACT,CAAC;AAEDH,YAAY,CAACa,SAAS,GAAG;EACvBZ,QAAQ,EAAEa,kBAAE,CAACC,IAAI;EACjBb,SAAS,EAAEY,kBAAE,CAACE,MAAM;EACpBb,KAAK,EAAEA,CAACc,KAAK,EAAEC,IAAI,KAAK;IACtB,MAAMf,KAAK,GAAGc,KAAK,CAACC,IAAI,CAAC;;IAEzB;IACA,IAAIf,KAAK,KAAKS,SAAS,EAAE,OAAO,IAAI;;IAEpC;IACA,IAAI,OAAOT,KAAK,KAAK,QAAQ,EAAE;MAC7B,OAAOgB,KAAK,CAAC,+BAA+B,CAAC;IAC/C;;IAEA;IACA,IAAI,CAAChB,KAAK,CAACiB,KAAK,CAAC,SAAS,CAAC,EAAE;MAC3B,OAAOD,KAAK,CAAC,qCAAqC,CAAC;IACrD;;IAEA;IACA,OAAO,IAAI;EACb;AACF,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEavB,YAAY"}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
10
9
  var _jsxRuntime = require("react/jsx-runtime");
11
10
  const defaultTheme = {
@@ -25,29 +24,21 @@ const defaultTheme = {
25
24
  * @param {...any} [props....]
26
25
  * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
27
26
  */
28
- function Throbber({
27
+ const Throbber = ({
29
28
  theme
30
- }) {
31
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
32
- className: (theme.container ? theme.container + " " : "") + "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___container___7zdld4",
33
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
34
- className: (theme.circle ? theme.circle + " " : "") + "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___circle___dBrB4g"
35
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
36
- className: (theme.circle ? theme.circle + " " : "") + "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___circle___dBrB4g"
37
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
38
- className: (theme.circle ? theme.circle + " " : "") + "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___circle___dBrB4g"
39
- })]
40
- });
41
- }
42
- Throbber.defaultProps = {
43
- theme: {}
44
- };
29
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
30
+ className: (theme.container ? theme.container + " " : "") + "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___container___7zdld4",
31
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
32
+ className: (theme.circle ? theme.circle + " " : "") + "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___circle___dBrB4g"
33
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
34
+ className: (theme.circle ? theme.circle + " " : "") + "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___circle___dBrB4g"
35
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
36
+ className: (theme.circle ? theme.circle + " " : "") + "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___circle___dBrB4g"
37
+ })]
38
+ });
39
+ const ThemedThrobber = (0, _reactThemes.default)(Throbber, 'Throbber', ['circle', 'container'], defaultTheme);
45
40
  Throbber.propTypes = {
46
- theme: _propTypes.default.shape({
47
- container: _propTypes.default.string,
48
- circle: _propTypes.default.string
49
- })
41
+ theme: ThemedThrobber.themeType.isRequired
50
42
  };
51
- var _default = (0, _reactThemes.default)('Throbber', ['circle', 'container'], defaultTheme)(Throbber);
52
- exports.default = _default;
43
+ var _default = exports.default = ThemedThrobber;
53
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","defaultTheme","Throbber","theme","jsxs","className","container","children","jsx","circle","defaultProps","propTypes","PT","shape","string","_default","themed","exports","default"],"sources":["../../../../../src/shared/components/Throbber/index.jsx"],"sourcesContent":["import PT from 'prop-types';\nimport themed from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Throbber is an \"action in progress\" indicator, which renders\n * three bouncing circles as a simple pending activity indicator,\n * and can be further themed to a certain degree.\n * @param {object} [props] Component properties.\n * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nfunction Throbber({\n theme,\n}) {\n return (\n <span className={theme.container} styleName=\"container\">\n <span className={theme.circle} styleName=\"circle\" />\n <span className={theme.circle} styleName=\"circle\" />\n <span className={theme.circle} styleName=\"circle\" />\n </span>\n );\n}\n\nThrobber.defaultProps = {\n theme: {},\n};\n\nThrobber.propTypes = {\n theme: PT.shape({\n container: PT.string,\n circle: PT.string,\n }),\n};\n\nexport default themed('Throbber', [\n 'circle',\n 'container',\n], defaultTheme)(Throbber);\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8C,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAAC;EAChBC;AACF,CAAC,EAAE;EACD,oBACE,IAAAH,WAAA,CAAAI,IAAA;IAAMC,SAAS,GAAEF,KAAK,CAACG,SAAS,GAAfH,KAAK,CAACG,SAAS,oGAAC;IAAAC,QAAA,gBAC/B,IAAAP,WAAA,CAAAQ,GAAA;MAAMH,SAAS,GAAEF,KAAK,CAACM,MAAM,GAAZN,KAAK,CAACM,MAAM;IAAC,CAAqB,CAAC,eACpD,IAAAT,WAAA,CAAAQ,GAAA;MAAMH,SAAS,GAAEF,KAAK,CAACM,MAAM,GAAZN,KAAK,CAACM,MAAM;IAAC,CAAqB,CAAC,eACpD,IAAAT,WAAA,CAAAQ,GAAA;MAAMH,SAAS,GAAEF,KAAK,CAACM,MAAM,GAAZN,KAAK,CAACM,MAAM;IAAC,CAAqB,CAAC;EAAA,CAChD,CAAC;AAEX;AAEAP,QAAQ,CAACQ,YAAY,GAAG;EACtBP,KAAK,EAAE,CAAC;AACV,CAAC;AAEDD,QAAQ,CAACS,SAAS,GAAG;EACnBR,KAAK,EAAES,kBAAE,CAACC,KAAK,CAAC;IACdP,SAAS,EAAEM,kBAAE,CAACE,MAAM;IACpBL,MAAM,EAAEG,kBAAE,CAACE;EACb,CAAC;AACH,CAAC;AAAC,IAAAC,QAAA,GAEa,IAAAC,oBAAM,EAAC,UAAU,EAAE,CAChC,QAAQ,EACR,WAAW,CACZ,EAAEf,YAAY,CAAC,CAACC,QAAQ,CAAC;AAAAe,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
1
+ {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireDefault","require","_jsxRuntime","defaultTheme","Throbber","theme","jsxs","className","container","children","jsx","circle","ThemedThrobber","themed","propTypes","themeType","isRequired","_default","exports","default"],"sources":["../../../../../src/shared/components/Throbber/index.tsx"],"sourcesContent":["import themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropsT = {\n theme: Theme & {\n container?: string;\n circle?: string;\n };\n};\n\n/**\n * Throbber is an \"action in progress\" indicator, which renders\n * three bouncing circles as a simple pending activity indicator,\n * and can be further themed to a certain degree.\n * @param {object} [props] Component properties.\n * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Throbber: React.FunctionComponent<PropsT> = ({ theme }) => (\n <span className={theme.container} styleName=\"container\">\n <span className={theme.circle} styleName=\"circle\" />\n <span className={theme.circle} styleName=\"circle\" />\n <span className={theme.circle} styleName=\"circle\" />\n </span>\n);\n\nconst ThemedThrobber = themed(\n Throbber,\n 'Throbber',\n [\n 'circle',\n 'container',\n ],\n defaultTheme,\n);\n\nThrobber.propTypes = {\n theme: ThemedThrobber.themeType.isRequired,\n};\n\nexport default ThemedThrobber;\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,IAAAC,WAAA,GAAAD,OAAA;AAAA,MAAAE,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAW9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAyC,GAAGA,CAAC;EAAEC;AAAM,CAAC,kBAC1D,IAAAH,WAAA,CAAAI,IAAA;EAAMC,SAAS,GAAEF,KAAK,CAACG,SAAS,GAAfH,KAAK,CAACG,SAAS,oGAAC;EAAAC,QAAA,gBAC/B,IAAAP,WAAA,CAAAQ,GAAA;IAAMH,SAAS,GAAEF,KAAK,CAACM,MAAM,GAAZN,KAAK,CAACM,MAAM;EAAC,CAAqB,CAAC,eACpD,IAAAT,WAAA,CAAAQ,GAAA;IAAMH,SAAS,GAAEF,KAAK,CAACM,MAAM,GAAZN,KAAK,CAACM,MAAM;EAAC,CAAqB,CAAC,eACpD,IAAAT,WAAA,CAAAQ,GAAA;IAAMH,SAAS,GAAEF,KAAK,CAACM,MAAM,GAAZN,KAAK,CAACM,MAAM;EAAC,CAAqB,CAAC;AAAA,CAChD,CACP;AAED,MAAMC,cAAc,GAAG,IAAAC,oBAAM,EAC3BT,QAAQ,EACR,UAAU,EACV,CACE,QAAQ,EACR,WAAW,CACZ,EACDD,YACF,CAAC;AAEDC,QAAQ,CAACU,SAAS,GAAG;EACnBT,KAAK,EAAEO,cAAc,CAACG,SAAS,CAACC;AAClC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaP,cAAc"}
@@ -14,19 +14,17 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  * performance during animation.
15
15
  */
16
16
  /* global document, window */
17
-
18
17
  /* Valid placements of the rendered tooltip. They will be overriden when
19
18
  * necessary to fit the tooltip within the viewport. */
20
- const PLACEMENTS = {
21
- ABOVE_CURSOR: 'ABOVE_CURSOR',
22
- ABOVE_ELEMENT: 'ABOVE_ELEMENT',
23
- BELOW_CURSOR: 'BELOW_CURSOR',
24
- BELOW_ELEMENT: 'BELOW_ELEMENT'
25
- };
26
- exports.PLACEMENTS = PLACEMENTS;
19
+ let PLACEMENTS = exports.PLACEMENTS = /*#__PURE__*/function (PLACEMENTS) {
20
+ PLACEMENTS["ABOVE_CURSOR"] = "ABOVE_CURSOR";
21
+ PLACEMENTS["ABOVE_ELEMENT"] = "ABOVE_ELEMENT";
22
+ PLACEMENTS["BELOW_CURSOR"] = "BELOW_CURSOR";
23
+ PLACEMENTS["BELOW_ELEMENT"] = "BELOW_ELEMENT";
24
+ return PLACEMENTS;
25
+ }({});
27
26
  const ARROW_STYLE_DOWN = ['border-bottom-color:transparent', 'border-left-color:transparent', 'border-right-color:transparent'].join(';');
28
27
  const ARROW_STYLE_UP = ['border-top-color:transparent', 'border-left-color:transparent', 'border-right-color:transparent'].join(';');
29
-
30
28
  /**
31
29
  * Creates tooltip components.
32
30
  * @ignore
@@ -51,14 +49,13 @@ function createTooltipComponents(theme) {
51
49
  content
52
50
  };
53
51
  }
54
-
55
52
  /**
56
53
  * Generates bounding client rectangles for tooltip components.
57
54
  * @ignore
58
- * @param {object} tooltip DOM references to the tooltip components.
59
- * @param {object} tooltip.arrow
60
- * @param {object} tooltip.container
61
- * @return {{ arrow: object, container}} Object holding tooltip rectangles in
55
+ * @param tooltip DOM references to the tooltip components.
56
+ * @param tooltip.arrow
57
+ * @param tooltip.container
58
+ * @return Object holding tooltip rectangles in
62
59
  * two fields.
63
60
  */
64
61
  function calcTooltipRects(tooltip) {
@@ -182,13 +179,13 @@ function xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {
182
179
  * Sets positions of tooltip components to point the tooltip to the specified
183
180
  * page point.
184
181
  * @ignore
185
- * @param {number} pageX
186
- * @param {number} pageY
187
- * @param {PLACEMENTS} placement
188
- * @param {object} element DOM reference to the element wrapped by the tooltip.
189
- * @param {object} tooltip
190
- * @param {object} tooltip.arrow DOM reference to the tooltip arrow.
191
- * @param {object} tooltip.container DOM reference to the tooltip container.
182
+ * @param pageX
183
+ * @param pageY
184
+ * @param placement
185
+ * @param element DOM reference to the element wrapped by the tooltip.
186
+ * @param tooltip
187
+ * @param tooltip.arrow DOM reference to the tooltip arrow.
188
+ * @param tooltip.container DOM reference to the tooltip container.
192
189
  */
193
190
  function setComponentPositions(pageX, pageY, placement, element, tooltip) {
194
191
  const tooltipRects = calcTooltipRects(tooltip);
@@ -277,11 +274,10 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)(({
277
274
  });
278
275
  Tooltip.propTypes = {
279
276
  children: _propTypes.default.node,
280
- theme: _propTypes.default.shape().isRequired
277
+ theme: _propTypes.default.shape({}).isRequired
281
278
  };
282
279
  Tooltip.defaultProps = {
283
280
  children: null
284
281
  };
285
- var _default = Tooltip;
286
- exports.default = _default;
282
+ var _default = exports.default = Tooltip;
287
283
  //# sourceMappingURL=Tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":["_react","require","_reactDom","_propTypes","_interopRequireDefault","PLACEMENTS","ABOVE_CURSOR","ABOVE_ELEMENT","BELOW_CURSOR","BELOW_ELEMENT","exports","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","createTooltipComponents","theme","arrow","document","createElement","setAttribute","content","container","appendChild","body","calcTooltipRects","tooltip","getBoundingClientRect","calcViewportRect","scrollX","scrollY","window","documentElement","clientHeight","clientWidth","left","right","top","bottom","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","arrowStyle","Tooltip","forwardRef","children","ref","current","heap","useRef","lastElement","undefined","lastPageX","lastPageY","lastPlacement","components","setComponents","useState","pointTo","useImperativeHandle","useEffect","removeChild","createPortal","propTypes","PT","node","shape","isRequired","defaultProps","_default","default"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.jsx"],"sourcesContent":["/**\n * The actual tooltip component. It is rendered outside the regular document\n * hierarchy, and with sub-components managed without React to achieve the best\n * performance during animation.\n */\n/* global document, window */\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport PT from 'prop-types';\n\n/* Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport. */\nexport const PLACEMENTS = {\n ABOVE_CURSOR: 'ABOVE_CURSOR',\n ABOVE_ELEMENT: 'ABOVE_ELEMENT',\n BELOW_CURSOR: 'BELOW_CURSOR',\n BELOW_ELEMENT: 'BELOW_ELEMENT',\n};\n\nconst ARROW_STYLE_DOWN = [\n 'border-bottom-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\nconst ARROW_STYLE_UP = [\n 'border-top-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\n/**\n * Creates tooltip components.\n * @ignore\n * @param {object} theme Themes to use for tooltip container, arrow,\n * and content.\n * @return {object} Object with DOM references to the container components:\n * container, arrow, content.\n */\nfunction createTooltipComponents(theme) {\n const arrow = document.createElement('div');\n if (theme.arrow) arrow.setAttribute('class', theme.arrow);\n\n const content = document.createElement('div');\n if (theme.content) content.setAttribute('class', theme.content);\n\n const container = document.createElement('div');\n if (theme.container) container.setAttribute('class', theme.container);\n\n container.appendChild(arrow);\n container.appendChild(content);\n document.body.appendChild(container);\n\n return { container, arrow, content };\n}\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param {object} tooltip DOM references to the tooltip components.\n * @param {object} tooltip.arrow\n * @param {object} tooltip.container\n * @return {{ arrow: object, container}} Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip) {\n return {\n arrow: tooltip.arrow.getBoundingClientRect(),\n container: tooltip.container.getBoundingClientRect(),\n };\n}\n\n/**\n * Calculates the document viewport size.\n * @ignore\n * @return {{x, y, width, height}}\n */\nfunction calcViewportRect() {\n const { scrollX, scrollY } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n left: scrollX,\n right: scrollX + clientWidth,\n top: scrollY,\n bottom: scrollY + clientHeight,\n };\n}\n\n/**\n * Calculates tooltip and arrow positions for the placement just above\n * the cursor.\n * @ignore\n * @param {number} x Cursor page-x position.\n * @param {number} y Cursor page-y position.\n * @param {object} tooltipRects Bounding client rectangles of tooltip parts.\n * @param {object} tooltipRects.arrow\n * @param {object} tooltipRects.container\n * @return {object} Contains the following fields:\n * - {number} arrowX\n * - {number} arrowY\n * - {number} containerX\n * - {number} containerY\n * - {string} baseArrowStyle\n */\nfunction calcPositionAboveXY(x, y, tooltipRects) {\n const { arrow, container } = tooltipRects;\n return {\n arrowX: 0.5 * (container.width - arrow.width),\n arrowY: container.height,\n containerX: x - container.width / 2,\n containerY: y - container.height - arrow.height / 1.5,\n\n // TODO: Instead of already setting the base style here, we should\n // introduce a set of constants for arrow directions, which will help\n // to do checks dependant on the arrow direction.\n baseArrowStyle: ARROW_STYLE_DOWN,\n };\n}\n\n/*\nconst HIT = {\n NONE: false,\n LEFT: 'LEFT',\n RIGHT: 'RIGHT',\n TOP: 'TOP',\n BOTTOM: 'BOTTOM',\n};\n*/\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n/*\nfunction checkViewportFit(pos, tooltipRects, viewportRect) {\n const { containerX, containerY } = pos;\n if (containerX < viewportRect.left + 6) return HIT.LEFT;\n if (containerX > viewportRect.right - 6) return HIT.RIGHT;\n return HIT.NONE;\n}\n*/\n\n/**\n * Shifts tooltip horizontally to fit into the viewport, while keeping\n * the arrow pointed to the XY point.\n * @param {number} x\n * @param {number} y\n * @param {object} pos\n * @param {number} pageXOffset\n * @param {number} pageXWidth\n */\n/*\nfunction xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {\n if (pos.containerX < pageXOffset + 6) {\n pos.containerX = pageXOffset + 6;\n pos.arrowX = Math.max(6, pageX - containerX - arrowRect.width / 2);\n } else {\n const maxX = pageXOffset + docRect.width - containerRect.width - 6;\n if (containerX > maxX) {\n containerX = maxX;\n arrowX = Math.min(\n containerRect.width - 6,\n pageX - containerX - arrowRect.width / 2,\n );\n }\n }\n}\n*/\n\n/**\n * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param {number} pageX\n * @param {number} pageY\n * @param {PLACEMENTS} placement\n * @param {object} element DOM reference to the element wrapped by the tooltip.\n * @param {object} tooltip\n * @param {object} tooltip.arrow DOM reference to the tooltip arrow.\n * @param {object} tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX,\n pageY,\n placement,\n element,\n tooltip,\n) {\n const tooltipRects = calcTooltipRects(tooltip);\n const viewportRect = calcViewportRect();\n\n /* Default container coords: tooltip at the top. */\n const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);\n\n if (pos.containerX < viewportRect.left + 6) {\n pos.containerX = viewportRect.left + 6;\n pos.arrowX = Math.max(\n 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n } else {\n const maxX = viewportRect.right - 6 - tooltipRects.container.width;\n if (pos.containerX > maxX) {\n pos.containerX = maxX;\n pos.arrowX = Math.min(\n tooltipRects.container.width - 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n }\n }\n\n /* If tooltip has not enough space on top - make it bottom tooltip. */\n if (pos.containerY < viewportRect.top + 6) {\n pos.containerY += tooltipRects.container.height\n + 2 * tooltipRects.arrow.height;\n pos.arrowY -= tooltipRects.container.height\n + tooltipRects.arrow.height;\n pos.baseArrowStyle = ARROW_STYLE_UP;\n }\n\n const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;\n tooltip.container.setAttribute('style', containerStyle);\n\n const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;\n tooltip.arrow.setAttribute('style', arrowStyle);\n}\n\n/* The Tooltip component itself. */\nconst Tooltip = forwardRef(({ children, theme }, ref) => {\n // NOTE: The way it has to be implemented, for clean mounting and unmounting\n // at the client side, the <Tooltip> is fully mounted into DOM in the next\n // rendering cycles, and only then it can be correctly measured and positioned.\n // Thus, when we create the <Tooltip> we have to record its target positioning\n // details, and then apply them when it is created.\n\n const { current: heap } = useRef({\n lastElement: undefined,\n lastPageX: 0,\n lastPageY: 0,\n lastPlacement: undefined,\n });\n\n const [components, setComponents] = useState(null);\n\n const pointTo = (pageX, pageY, placement, element) => {\n heap.lastElement = element;\n heap.lastPageX = pageX;\n heap.lastPageY = pageY;\n heap.lastPlacement = placement;\n\n if (components) {\n setComponentPositions(pageX, pageY, placement, element, components);\n }\n };\n useImperativeHandle(ref, () => ({ pointTo }));\n\n /* Inits and destroys tooltip components. */\n useEffect(() => {\n const x = createTooltipComponents(theme);\n setComponents(x);\n return () => {\n document.body.removeChild(x.container);\n setComponents(null);\n };\n }, [theme]);\n\n useEffect(() => {\n if (components) {\n setComponentPositions(\n heap.lastPageX,\n heap.lastPageY,\n heap.lastPlacement,\n heap.lastElement,\n components,\n );\n }\n }, [\n components,\n // BEWARE: Careful about these dependencies - they are updated when mouse\n // is moved over the tool-tipped element, thus potentially may cause\n // unnecessary firing of this effect on each mouse event. It does not\n // happen now just because the mouse movements themselves are not causing\n // the component re-rendering, thus dependencies of this effect are not\n // really re-evaluated.\n heap.lastPageX,\n heap.lastPageY,\n heap.lastPlacement,\n heap.lastElement,\n ]);\n\n return components ? createPortal(children, components.content) : null;\n});\n\nTooltip.propTypes = {\n children: PT.node,\n theme: PT.shape().isRequired,\n};\n\nTooltip.defaultProps = {\n children: null,\n};\n\nexport default Tooltip;\n"],"mappings":";;;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAjBA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACO,MAAMI,UAAU,GAAG;EACxBC,YAAY,EAAE,cAAc;EAC5BC,aAAa,EAAE,eAAe;EAC9BC,YAAY,EAAE,cAAc;EAC5BC,aAAa,EAAE;AACjB,CAAC;AAACC,OAAA,CAAAL,UAAA,GAAAA,UAAA;AAEF,MAAMM,gBAAgB,GAAG,CACvB,iCAAiC,EACjC,+BAA+B,EAC/B,gCAAgC,CACjC,CAACC,IAAI,CAAC,GAAG,CAAC;AAEX,MAAMC,cAAc,GAAG,CACrB,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,CACjC,CAACD,IAAI,CAAC,GAAG,CAAC;;AAEX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,uBAAuBA,CAACC,KAAK,EAAE;EACtC,MAAMC,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC3C,IAAIH,KAAK,CAACC,KAAK,EAAEA,KAAK,CAACG,YAAY,CAAC,OAAO,EAAEJ,KAAK,CAACC,KAAK,CAAC;EAEzD,MAAMI,OAAO,GAAGH,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC7C,IAAIH,KAAK,CAACK,OAAO,EAAEA,OAAO,CAACD,YAAY,CAAC,OAAO,EAAEJ,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C;IACH;EACF,CAAC,EAAE,CACDA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACAP,IAAI,CAACI,SAAS,EACdJ,IAAI,CAACK,SAAS,EACdL,IAAI,CAACM,aAAa,EAClBN,IAAI,CAACE,WAAW,CACjB,CAAC;EAEF,OAAOK,UAAU,gBAAG,IAAAO,sBAAY,EAACjB,QAAQ,EAAEU,UAAU,CAACtD,OAAO,CAAC,GAAG,IAAI;AACvE,CAAC,CAAC;AAEF0C,OAAO,CAACoB,SAAS,GAAG;EAClBlB,QAAQ,EAAEmB,kBAAE,CAACC,IAAI;EACjBrE,KAAK,EAAEoE,kBAAE,CAACE,KAAK,CAAC,CAAC,CAACC;AACpB,CAAC;AAEDxB,OAAO,CAACyB,YAAY,GAAG;EACrBvB,QAAQ,EAAE;AACZ,CAAC;AAAC,IAAAwB,QAAA,GAEa1B,OAAO;AAAApD,OAAA,CAAA+E,OAAA,GAAAD,QAAA"}
1
+ {"version":3,"file":"Tooltip.js","names":["_react","require","_reactDom","_propTypes","_interopRequireDefault","PLACEMENTS","exports","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","createTooltipComponents","theme","arrow","document","createElement","setAttribute","content","container","appendChild","body","calcTooltipRects","tooltip","getBoundingClientRect","calcViewportRect","scrollX","scrollY","window","documentElement","clientHeight","clientWidth","left","right","top","bottom","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","arrowStyle","Tooltip","forwardRef","children","ref","current","heap","useRef","lastElement","undefined","lastPageX","lastPageY","lastPlacement","components","setComponents","useState","pointTo","useImperativeHandle","useEffect","removeChild","createPortal","propTypes","PT","node","shape","isRequired","defaultProps","_default","default"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.tsx"],"sourcesContent":["/**\n * The actual tooltip component. It is rendered outside the regular document\n * hierarchy, and with sub-components managed without React to achieve the best\n * performance during animation.\n */\n/* global document, window */\n\nimport {\n type ReactNode,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport PT from 'prop-types';\n\n/* Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport. */\nexport enum PLACEMENTS {\n ABOVE_CURSOR = 'ABOVE_CURSOR',\n ABOVE_ELEMENT = 'ABOVE_ELEMENT',\n BELOW_CURSOR = 'BELOW_CURSOR',\n BELOW_ELEMENT = 'BELOW_ELEMENT',\n}\n\nconst ARROW_STYLE_DOWN = [\n 'border-bottom-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\nconst ARROW_STYLE_UP = [\n 'border-top-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\ntype ComponentsT = {\n container: HTMLDivElement;\n arrow: HTMLDivElement;\n content: HTMLDivElement;\n};\n\ntype HeapT = {\n lastElement?: HTMLElement;\n lastPageX: number;\n lastPageY: number;\n lastPlacement?: PLACEMENTS | undefined;\n};\n\nexport interface TooltipThemeT {\n appearance?: string;\n arrow?: string;\n content?: string;\n container?: string;\n}\n\n/**\n * Creates tooltip components.\n * @ignore\n * @param {object} theme Themes to use for tooltip container, arrow,\n * and content.\n * @return {object} Object with DOM references to the container components:\n * container, arrow, content.\n */\nfunction createTooltipComponents(theme: TooltipThemeT): ComponentsT {\n const arrow = document.createElement('div');\n if (theme.arrow) arrow.setAttribute('class', theme.arrow);\n\n const content = document.createElement('div');\n if (theme.content) content.setAttribute('class', theme.content);\n\n const container = document.createElement('div');\n if (theme.container) container.setAttribute('class', theme.container);\n\n container.appendChild(arrow);\n container.appendChild(content);\n document.body.appendChild(container);\n\n return { container, arrow, content };\n}\n\ntype TooltipRectsT = {\n arrow: DOMRect;\n container: DOMRect;\n};\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param tooltip DOM references to the tooltip components.\n * @param tooltip.arrow\n * @param tooltip.container\n * @return Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip: ComponentsT): TooltipRectsT {\n return {\n arrow: tooltip.arrow.getBoundingClientRect(),\n container: tooltip.container.getBoundingClientRect(),\n };\n}\n\n/**\n * Calculates the document viewport size.\n * @ignore\n * @return {{x, y, width, height}}\n */\nfunction calcViewportRect() {\n const { scrollX, scrollY } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n left: scrollX,\n right: scrollX + clientWidth,\n top: scrollY,\n bottom: scrollY + clientHeight,\n };\n}\n\n/**\n * Calculates tooltip and arrow positions for the placement just above\n * the cursor.\n * @ignore\n * @param {number} x Cursor page-x position.\n * @param {number} y Cursor page-y position.\n * @param {object} tooltipRects Bounding client rectangles of tooltip parts.\n * @param {object} tooltipRects.arrow\n * @param {object} tooltipRects.container\n * @return {object} Contains the following fields:\n * - {number} arrowX\n * - {number} arrowY\n * - {number} containerX\n * - {number} containerY\n * - {string} baseArrowStyle\n */\nfunction calcPositionAboveXY(\n x: number,\n y: number,\n tooltipRects: TooltipRectsT,\n) {\n const { arrow, container } = tooltipRects;\n return {\n arrowX: 0.5 * (container.width - arrow.width),\n arrowY: container.height,\n containerX: x - container.width / 2,\n containerY: y - container.height - arrow.height / 1.5,\n\n // TODO: Instead of already setting the base style here, we should\n // introduce a set of constants for arrow directions, which will help\n // to do checks dependant on the arrow direction.\n baseArrowStyle: ARROW_STYLE_DOWN,\n };\n}\n\n/*\nconst HIT = {\n NONE: false,\n LEFT: 'LEFT',\n RIGHT: 'RIGHT',\n TOP: 'TOP',\n BOTTOM: 'BOTTOM',\n};\n*/\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n/*\nfunction checkViewportFit(pos, tooltipRects, viewportRect) {\n const { containerX, containerY } = pos;\n if (containerX < viewportRect.left + 6) return HIT.LEFT;\n if (containerX > viewportRect.right - 6) return HIT.RIGHT;\n return HIT.NONE;\n}\n*/\n\n/**\n * Shifts tooltip horizontally to fit into the viewport, while keeping\n * the arrow pointed to the XY point.\n * @param {number} x\n * @param {number} y\n * @param {object} pos\n * @param {number} pageXOffset\n * @param {number} pageXWidth\n */\n/*\nfunction xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {\n if (pos.containerX < pageXOffset + 6) {\n pos.containerX = pageXOffset + 6;\n pos.arrowX = Math.max(6, pageX - containerX - arrowRect.width / 2);\n } else {\n const maxX = pageXOffset + docRect.width - containerRect.width - 6;\n if (containerX > maxX) {\n containerX = maxX;\n arrowX = Math.min(\n containerRect.width - 6,\n pageX - containerX - arrowRect.width / 2,\n );\n }\n }\n}\n*/\n\n/**\n * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param pageX\n * @param pageY\n * @param placement\n * @param element DOM reference to the element wrapped by the tooltip.\n * @param tooltip\n * @param tooltip.arrow DOM reference to the tooltip arrow.\n * @param tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX: number,\n pageY: number,\n placement: PLACEMENTS | undefined,\n element: HTMLElement | undefined,\n tooltip: ComponentsT,\n) {\n const tooltipRects = calcTooltipRects(tooltip);\n const viewportRect = calcViewportRect();\n\n /* Default container coords: tooltip at the top. */\n const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);\n\n if (pos.containerX < viewportRect.left + 6) {\n pos.containerX = viewportRect.left + 6;\n pos.arrowX = Math.max(\n 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n } else {\n const maxX = viewportRect.right - 6 - tooltipRects.container.width;\n if (pos.containerX > maxX) {\n pos.containerX = maxX;\n pos.arrowX = Math.min(\n tooltipRects.container.width - 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n }\n }\n\n /* If tooltip has not enough space on top - make it bottom tooltip. */\n if (pos.containerY < viewportRect.top + 6) {\n pos.containerY += tooltipRects.container.height\n + 2 * tooltipRects.arrow.height;\n pos.arrowY -= tooltipRects.container.height\n + tooltipRects.arrow.height;\n pos.baseArrowStyle = ARROW_STYLE_UP;\n }\n\n const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;\n tooltip.container.setAttribute('style', containerStyle);\n\n const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;\n tooltip.arrow.setAttribute('style', arrowStyle);\n}\n\n/* The Tooltip component itself. */\nconst Tooltip = forwardRef<unknown, {\n children?: ReactNode;\n theme: any;\n}>(({ children, theme }, ref) => {\n // NOTE: The way it has to be implemented, for clean mounting and unmounting\n // at the client side, the <Tooltip> is fully mounted into DOM in the next\n // rendering cycles, and only then it can be correctly measured and positioned.\n // Thus, when we create the <Tooltip> we have to record its target positioning\n // details, and then apply them when it is created.\n\n const { current: heap } = useRef<HeapT>({\n lastElement: undefined,\n lastPageX: 0,\n lastPageY: 0,\n lastPlacement: undefined,\n });\n\n const [components, setComponents] = useState<ComponentsT | null>(null);\n\n const pointTo = (\n pageX: number,\n pageY: number,\n placement: PLACEMENTS,\n element: HTMLElement,\n ) => {\n heap.lastElement = element;\n heap.lastPageX = pageX;\n heap.lastPageY = pageY;\n heap.lastPlacement = placement;\n\n if (components) {\n setComponentPositions(pageX, pageY, placement, element, components);\n }\n };\n useImperativeHandle(ref, () => ({ pointTo }));\n\n /* Inits and destroys tooltip components. */\n useEffect(() => {\n const x = createTooltipComponents(theme);\n setComponents(x);\n return () => {\n document.body.removeChild(x.container);\n setComponents(null);\n };\n }, [theme]);\n\n useEffect(() => {\n if (components) {\n setComponentPositions(\n heap.lastPageX,\n heap.lastPageY,\n heap.lastPlacement,\n heap.lastElement,\n components,\n );\n }\n }, [\n components,\n // BEWARE: Careful about these dependencies - they are updated when mouse\n // is moved over the tool-tipped element, thus potentially may cause\n // unnecessary firing of this effect on each mouse event. It does not\n // happen now just because the mouse movements themselves are not causing\n // the component re-rendering, thus dependencies of this effect are not\n // really re-evaluated.\n heap.lastPageX,\n heap.lastPageY,\n heap.lastPlacement,\n heap.lastElement,\n ]);\n\n return components ? createPortal(children, components.content) : null;\n});\n\nTooltip.propTypes = {\n children: PT.node,\n theme: PT.shape({}).isRequired,\n};\n\nTooltip.defaultProps = {\n children: null,\n};\n\nexport default Tooltip;\n"],"mappings":";;;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAlBA;AACA;AACA;AACA;AACA;AACA;AAeA;AACA;AADA,IAEYI,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAOtB,MAAME,gBAAgB,GAAG,CACvB,iCAAiC,EACjC,+BAA+B,EAC/B,gCAAgC,CACjC,CAACC,IAAI,CAAC,GAAG,CAAC;AAEX,MAAMC,cAAc,GAAG,CACrB,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,CACjC,CAACD,IAAI,CAAC,GAAG,CAAC;AAsBX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,uBAAuBA,CAACC,KAAoB,EAAe;EAClE,MAAMC,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC3C,IAAIH,KAAK,CAACC,KAAK,EAAEA,KAAK,CAACG,YAAY,CAAC,OAAO,EAAEJ,KAAK,CAACC,KAAK,CAAC;EAEzD,MAAMI,OAAO,GAAGH,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC7C,IAAIH,KAAK,CAACK,OAAO,EAAEA,OAAO,CAACD,YAAY,CAAC,OAAO,EAAEJ,KAAK,CAACK,OAAO,CAAC;EAE/D,MAAMC,SAAS,GAAGJ,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC/C,IAAIH,KAAK,CAACM,SAAS,EAAEA,SAAS,CAACF,YAAY,CAAC,OAAO,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AI,CAACE,WAAW,CACjB,CAAC;EAEF,OAAOK,UAAU,gBAAG,IAAAO,sBAAY,EAACjB,QAAQ,EAAEU,UAAU,CAACtD,OAAO,CAAC,GAAG,IAAI;AACvE,CAAC,CAAC;AAEF0C,OAAO,CAACoB,SAAS,GAAG;EAClBlB,QAAQ,EAAEmB,kBAAE,CAACC,IAAI;EACjBrE,KAAK,EAAEoE,kBAAE,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC,CAACC;AACtB,CAAC;AAEDxB,OAAO,CAACyB,YAAY,GAAG;EACrBvB,QAAQ,EAAE;AACZ,CAAC;AAAC,IAAAwB,QAAA,GAAA9E,OAAA,CAAA+E,OAAA,GAEa3B,OAAO"}
@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _react = require("react");
10
- var _utils = require("../../utils");
10
+ var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
11
11
  var _Tooltip = _interopRequireWildcard(require("./Tooltip"));
12
12
  var _jsxRuntime = require("react/jsx-runtime");
13
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  /* global window */
16
16
  const defaultTheme = {
17
17
  "ad": "-dr-pogodin-react-utils___src-shared-components-WithTooltip-default-theme___ad___4xT7zE",
@@ -37,12 +37,12 @@ const defaultTheme = {
37
37
  * _e.g._ a tooltip text. This will be the tooltip content.
38
38
  * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.
39
39
  */
40
- function Wrapper({
40
+ const Wrapper = ({
41
41
  children,
42
42
  placement,
43
43
  tip,
44
44
  theme
45
- }) {
45
+ }) => {
46
46
  const {
47
47
  current: heap
48
48
  } = (0, _react.useRef)({
@@ -52,7 +52,7 @@ function Wrapper({
52
52
  timerId: undefined
53
53
  });
54
54
  const tooltipRef = (0, _react.useRef)();
55
- const wrapperRef = (0, _react.useRef)();
55
+ const wrapperRef = (0, _react.useRef)(null);
56
56
  const [showTooltip, setShowTooltip] = (0, _react.useState)(false);
57
57
  const updatePortalPosition = (cursorX, cursorY) => {
58
58
  if (!showTooltip) {
@@ -121,9 +121,10 @@ function Wrapper({
121
121
  children: tip
122
122
  }) : null, children]
123
123
  });
124
- }
125
- const ThemedWrapper = (0, _utils.themed)('WithTooltip', ['appearance', 'arrow', 'container', 'content', 'wrapper'], defaultTheme)(Wrapper);
126
- ThemedWrapper.PLACEMENTS = _Tooltip.PLACEMENTS;
124
+ };
125
+ const ThemedWrapper = (0, _reactThemes.default)(Wrapper, 'WithTooltip', ['appearance', 'arrow', 'container', 'content', 'wrapper'], defaultTheme);
126
+ const e = ThemedWrapper;
127
+ e.PLACEMENTS = _Tooltip.PLACEMENTS;
127
128
  Wrapper.propTypes = {
128
129
  children: _propTypes.default.node,
129
130
  placement: _propTypes.default.oneOf(Object.values(_Tooltip.PLACEMENTS)),
@@ -135,6 +136,5 @@ Wrapper.defaultProps = {
135
136
  placement: _Tooltip.PLACEMENTS.ABOVE_CURSOR,
136
137
  tip: null
137
138
  };
138
- var _default = ThemedWrapper;
139
- exports.default = _default;
139
+ var _default = exports.default = e;
140
140
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_utils","_Tooltip","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","defaultTheme","Wrapper","children","placement","tip","theme","current","heap","useRef","lastCursorX","lastCursorY","triggeredByTouch","timerId","undefined","tooltipRef","wrapperRef","showTooltip","setShowTooltip","useState","updatePortalPosition","cursorX","cursorY","setTimeout","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","useEffect","listener","addEventListener","removeEventListener","jsxs","className","wrapper","onMouseLeave","onMouseMove","e","clientX","clientY","onClick","clearTimeout","onTouchStart","ref","role","jsx","ThemedWrapper","themed","PLACEMENTS","propTypes","PT","node","oneOf","values","themeType","isRequired","defaultProps","ABOVE_CURSOR","_default","exports"],"sources":["../../../../../src/shared/components/WithTooltip/index.jsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { themed } from 'utils';\n\nimport Tooltip, { PLACEMENTS } from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param {object} props Component properties.\n * @param {React.node} props.tip &ndash; Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nfunction Wrapper({\n children,\n placement,\n tip,\n theme,\n}) {\n const { current: heap } = useRef({\n lastCursorX: 0,\n lastCursorY: 0,\n triggeredByTouch: false,\n timerId: undefined,\n });\n const tooltipRef = useRef();\n const wrapperRef = useRef();\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX, cursorY) => {\n if (!showTooltip) {\n heap.lastCursorX = cursorX;\n heap.lastCursorY = cursorY;\n\n // If tooltip was triggered by a touch, we delay its opening by a bit,\n // to ensure it was not a touch-click - in the case of touch click we\n // want to do the click, rather than show the tooltip, and the delay\n // gives click handler a chance to abort the tooltip openning.\n if (heap.triggeredByTouch) {\n if (!heap.timerId) {\n heap.timerId = setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n }\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n } else {\n const wrapperRect = wrapperRef.current.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.scrollX,\n cursorY + window.scrollY,\n placement,\n wrapperRef.current,\n );\n }\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n heap.lastCursorX + window.scrollX,\n heap.lastCursorY + window.scrollY,\n placement,\n wrapperRef.current,\n );\n }\n\n const listener = () => setShowTooltip(false);\n window.addEventListener('scroll', listener);\n return () => window.removeEventListener('scroll', listener);\n }\n return undefined;\n }, [\n heap.lastCursorX,\n heap.lastCursorY,\n placement,\n showTooltip,\n tip,\n ]);\n\n return (\n <div\n className={theme.wrapper}\n onMouseLeave={() => setShowTooltip(false)}\n onMouseMove={(e) => updatePortalPosition(e.clientX, e.clientY)}\n onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n }}\n onTouchStart={() => {\n heap.triggeredByTouch = true;\n }}\n ref={wrapperRef}\n role=\"presentation\"\n >\n {\n showTooltip && tip !== null ? (\n <Tooltip ref={tooltipRef} theme={theme}>{tip}</Tooltip>\n ) : null\n }\n {children}\n </div>\n );\n}\n\nconst ThemedWrapper = themed(\n 'WithTooltip',\n [\n 'appearance',\n 'arrow',\n 'container',\n 'content',\n 'wrapper',\n ],\n defaultTheme,\n)(Wrapper);\n\nThemedWrapper.PLACEMENTS = PLACEMENTS;\n\nWrapper.propTypes = {\n children: PT.node,\n placement: PT.oneOf(Object.values(PLACEMENTS)),\n theme: ThemedWrapper.themeType.isRequired,\n tip: PT.node,\n};\n\nWrapper.defaultProps = {\n children: null,\n placement: PLACEMENTS.ABOVE_CURSOR,\n tip: null,\n};\n\nexport default ThemedWrapper;\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAA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CAACS,YAAY;EAClC1D,GAAG,EAAE;AACP,CAAC;AAAC,IAAA2D,QAAA,GAEaZ,aAAa;AAAAa,OAAA,CAAA/E,OAAA,GAAA8E,QAAA"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactThemes","_Tooltip","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","defaultTheme","Wrapper","children","placement","tip","theme","current","heap","useRef","lastCursorX","lastCursorY","triggeredByTouch","timerId","undefined","tooltipRef","wrapperRef","showTooltip","setShowTooltip","useState","updatePortalPosition","cursorX","cursorY","setTimeout","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","useEffect","listener","addEventListener","removeEventListener","jsxs","className","wrapper","onMouseLeave","onMouseMove","clientX","clientY","onClick","clearTimeout","onTouchStart","ref","role","jsx","ThemedWrapper","themed","PLACEMENTS","propTypes","PT","node","oneOf","values","themeType","isRequired","defaultProps","ABOVE_CURSOR","_default","exports"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport {\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport Tooltip, { PLACEMENTS, type TooltipThemeT } from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\ntype PropsT = {\n children?: ReactNode;\n placement?: PLACEMENTS;\n tip?: ReactNode;\n theme: Theme & TooltipThemeT & {\n wrapper?: string;\n };\n};\n\ntype TooltipRefT = {\n pointTo: (\n x: number,\n y: number,\n placement: PLACEMENTS,\n wrapperRef: HTMLDivElement,\n ) => void;\n};\n\ntype HeapT = {\n lastCursorX: number;\n lastCursorY: number;\n triggeredByTouch: boolean;\n timerId?: NodeJS.Timeout;\n};\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param {object} props Component properties.\n * @param {React.node} props.tip &ndash; Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nconst Wrapper: React.FunctionComponent<PropsT> = ({\n children,\n placement,\n tip,\n theme,\n}) => {\n const { current: heap } = useRef<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n triggeredByTouch: false,\n timerId: undefined,\n });\n const tooltipRef = useRef<TooltipRefT>();\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (!showTooltip) {\n heap.lastCursorX = cursorX;\n heap.lastCursorY = cursorY;\n\n // If tooltip was triggered by a touch, we delay its opening by a bit,\n // to ensure it was not a touch-click - in the case of touch click we\n // want to do the click, rather than show the tooltip, and the delay\n // gives click handler a chance to abort the tooltip openning.\n if (heap.triggeredByTouch) {\n if (!heap.timerId) {\n heap.timerId = setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n }\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n } else {\n const wrapperRect = wrapperRef.current!.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.scrollX,\n cursorY + window.scrollY,\n placement!,\n wrapperRef.current!,\n );\n }\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n heap.lastCursorX + window.scrollX,\n heap.lastCursorY + window.scrollY,\n placement!,\n wrapperRef.current!,\n );\n }\n\n const listener = () => setShowTooltip(false);\n window.addEventListener('scroll', listener);\n return () => window.removeEventListener('scroll', listener);\n }\n return undefined;\n }, [\n heap.lastCursorX,\n heap.lastCursorY,\n placement,\n showTooltip,\n tip,\n ]);\n\n return (\n <div\n className={theme.wrapper}\n onMouseLeave={() => setShowTooltip(false)}\n onMouseMove={(e) => updatePortalPosition(e.clientX, e.clientY)}\n onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n }}\n onTouchStart={() => {\n heap.triggeredByTouch = true;\n }}\n ref={wrapperRef}\n role=\"presentation\"\n >\n {\n showTooltip && tip !== null ? (\n <Tooltip ref={tooltipRef} theme={theme}>{tip}</Tooltip>\n ) : null\n }\n {children}\n </div>\n );\n};\n\nconst ThemedWrapper = themed(\n Wrapper,\n 'WithTooltip',\n [\n 'appearance',\n 'arrow',\n 'container',\n 'content',\n 'wrapper',\n ],\n defaultTheme,\n);\n\ntype ExportT = typeof ThemedWrapper & {\n PLACEMENTS: typeof PLACEMENTS;\n};\n\nconst e: ExportT = ThemedWrapper as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nWrapper.propTypes = {\n children: PT.node,\n placement: PT.oneOf(Object.values(PLACEMENTS)),\n theme: ThemedWrapper.themeType.isRequired,\n tip: PT.node,\n};\n\nWrapper.defaultProps = {\n children: null,\n placement: PLACEMENTS.ABOVE_CURSOR,\n tip: null,\n};\n\nexport default e;\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAA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AEkD,kBAAE,CAACC;AACV,CAAC;AAEDtD,OAAO,CAAC2D,YAAY,GAAG;EACrB1D,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAEiD,mBAAU,CAACS,YAAY;EAClCzD,GAAG,EAAE;AACP,CAAC;AAAC,IAAA0D,QAAA,GAAAC,OAAA,CAAA9E,OAAA,GAEaL,CAAC"}
@@ -26,31 +26,33 @@ const throbberTheme = {
26
26
  };
27
27
  /**
28
28
  * A component for embeding a YouTube video.
29
- * @param {object} [props] Component properties.
30
- * @param {boolean} [props.autoplay] If `true` the video will start to play
29
+ * @param [props] Component properties.
30
+ * @param [props.autoplay] If `true` the video will start to play
31
31
  * automatically once loaded.
32
- * @param {string} [props.src] URL of the video to play. Can be in any of
32
+ * @param [props.src] URL of the video to play. Can be in any of
33
33
  * the following formats, and keeps any additional query parameters understood
34
34
  * by the YouTube IFrame player:
35
35
  * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`
36
36
  * - `https://youtu.be/NdF6Rmt6Ado`
37
37
  * - `https://www.youtube.com/embed/NdF6Rmt6Ado`
38
- * @param {YouTubeVideoTheme} [props.theme] _Ad hoc_ theme.
39
- * @param {string} [props.title] The `title` attribute to add to the player
38
+ * @param [props.theme] _Ad hoc_ theme.
39
+ * @param [props.title] The `title` attribute to add to the player
40
40
  * IFrame.
41
41
  */
42
- function YouTubeVideo({
42
+ const YouTubeVideo = ({
43
43
  autoplay,
44
44
  src,
45
45
  theme,
46
46
  title
47
- }) {
48
- let [url, query] = src.split('?');
49
- query = query ? _qs.default.parse(query) : {};
50
- const videoId = query.v || url.match(/\/([a-zA-Z0-9-_]*)$/)[1];
47
+ }) => {
48
+ const srcParts = src.split('?');
49
+ let url = srcParts[0];
50
+ const queryString = srcParts[1];
51
+ const query = queryString ? _qs.default.parse(queryString) : {};
52
+ const videoId = query.v || url.match(/\/([a-zA-Z0-9-_]*)$/)?.[1];
51
53
  url = `https://www.youtube.com/embed/${videoId}`;
52
54
  delete query.v;
53
- query.autoplay = autoplay ? 1 : 0;
55
+ query.autoplay = autoplay ? '1' : '0';
54
56
  url += `?${_qs.default.stringify(query)}`;
55
57
 
56
58
  // TODO: https://developers.google.com/youtube/player_parameters
@@ -69,8 +71,8 @@ function YouTubeVideo({
69
71
  title: title
70
72
  })]
71
73
  });
72
- }
73
- const ThemedYouTubeVideo = (0, _reactThemes.default)('YouTubeVideo', ['container', 'video'], baseTheme)(YouTubeVideo);
74
+ };
75
+ const ThemedYouTubeVideo = (0, _reactThemes.default)(YouTubeVideo, 'YouTubeVideo', ['container', 'video'], baseTheme);
74
76
  YouTubeVideo.propTypes = {
75
77
  autoplay: _propTypes.default.bool,
76
78
  src: _propTypes.default.string.isRequired,
@@ -81,6 +83,5 @@ YouTubeVideo.defaultProps = {
81
83
  autoplay: false,
82
84
  title: ''
83
85
  };
84
- var _default = ThemedYouTubeVideo;
85
- exports.default = _default;
86
+ var _default = exports.default = ThemedYouTubeVideo;
86
87
  //# sourceMappingURL=index.js.map