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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/babel.config.js +1 -0
  2. package/babel.libweb.config.js +16 -0
  3. package/babel.module.config.js +11 -0
  4. package/bin/build.js +21 -11
  5. package/bin/setup.js +11 -9
  6. package/build/development/client/getInj.js +57 -44
  7. package/build/development/client/getInj.js.map +1 -1
  8. package/build/development/client/index.js +15 -21
  9. package/build/development/client/index.js.map +1 -1
  10. package/build/development/client/init.js +2 -6
  11. package/build/development/client/init.js.map +1 -1
  12. package/build/development/index.js +3 -177
  13. package/build/development/index.js.map +1 -1
  14. package/build/development/server/Cache.js +1 -8
  15. package/build/development/server/Cache.js.map +1 -1
  16. package/build/development/server/index.js +22 -45
  17. package/build/development/server/index.js.map +1 -1
  18. package/build/development/server/renderer.js +84 -86
  19. package/build/development/server/renderer.js.map +1 -1
  20. package/build/development/server/server.js +58 -60
  21. package/build/development/server/server.js.map +1 -1
  22. package/build/development/server/utils/errors.js +8 -31
  23. package/build/development/server/utils/errors.js.map +1 -1
  24. package/build/development/server/utils/index.js +2 -9
  25. package/build/development/server/utils/index.js.map +1 -1
  26. package/build/development/shared/components/Button/index.js +15 -22
  27. package/build/development/shared/components/Button/index.js.map +1 -1
  28. package/build/development/shared/components/Checkbox/index.js +14 -21
  29. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  30. package/build/development/shared/components/GenericLink/index.js +9 -11
  31. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  32. package/build/development/shared/components/Input/index.js +21 -27
  33. package/build/development/shared/components/Input/index.js.map +1 -1
  34. package/build/development/shared/components/Link.js +6 -13
  35. package/build/development/shared/components/Link.js.map +1 -1
  36. package/build/development/shared/components/Modal/index.js +24 -28
  37. package/build/development/shared/components/Modal/index.js.map +1 -1
  38. package/build/development/shared/components/NavLink.js +6 -13
  39. package/build/development/shared/components/NavLink.js.map +1 -1
  40. package/build/development/shared/components/PageLayout/index.js +13 -20
  41. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  42. package/build/development/shared/components/TextArea/index.js +28 -31
  43. package/build/development/shared/components/TextArea/index.js.map +1 -1
  44. package/build/development/shared/components/Throbber/index.js +13 -20
  45. package/build/development/shared/components/Throbber/index.js.map +1 -1
  46. package/build/development/shared/components/WithTooltip/Tooltip.js +13 -18
  47. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  48. package/build/development/shared/components/WithTooltip/index.js +23 -30
  49. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  50. package/build/development/shared/components/YouTubeVideo/index.js +19 -26
  51. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  52. package/build/development/shared/components/index.js +16 -130
  53. package/build/development/shared/components/index.js.map +1 -1
  54. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +19 -20
  55. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  56. package/build/development/shared/components/selectors/CustomDropdown/index.js +35 -39
  57. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  58. package/build/development/shared/components/selectors/NativeDropdown/index.js +31 -31
  59. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  60. package/build/development/shared/components/selectors/Switch/index.js +19 -24
  61. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  62. package/build/development/shared/components/selectors/common.js +1 -7
  63. package/build/development/shared/components/selectors/common.js.map +1 -1
  64. package/build/development/shared/components/selectors/index.js +3 -27
  65. package/build/development/shared/components/selectors/index.js.map +1 -1
  66. package/build/development/shared/utils/config.js +40 -21
  67. package/build/development/shared/utils/config.js.map +1 -1
  68. package/build/development/shared/utils/globalState.js +3 -8
  69. package/build/development/shared/utils/globalState.js.map +1 -1
  70. package/build/development/shared/utils/index.js +12 -89
  71. package/build/development/shared/utils/index.js.map +1 -1
  72. package/build/development/shared/utils/isomorphy/buildInfo.js +2 -9
  73. package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
  74. package/build/development/shared/utils/isomorphy/environment-check.js +2 -8
  75. package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
  76. package/build/development/shared/utils/isomorphy/index.js +7 -32
  77. package/build/development/shared/utils/isomorphy/index.js.map +1 -1
  78. package/build/development/shared/utils/jest/E2eSsrEnv.js +34 -37
  79. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  80. package/build/development/shared/utils/jest/global.js +1 -7
  81. package/build/development/shared/utils/jest/global.js.map +1 -1
  82. package/build/development/shared/utils/jest/index.js +20 -44
  83. package/build/development/shared/utils/jest/index.js.map +1 -1
  84. package/build/development/shared/utils/splitComponent.js +54 -45
  85. package/build/development/shared/utils/splitComponent.js.map +1 -1
  86. package/build/development/shared/utils/time.js +22 -31
  87. package/build/development/shared/utils/time.js.map +1 -1
  88. package/build/development/shared/utils/webpack.js +17 -16
  89. package/build/development/shared/utils/webpack.js.map +1 -1
  90. package/build/production/client/getInj.js +13 -11
  91. package/build/production/client/getInj.js.map +1 -1
  92. package/build/production/client/index.js +3 -3
  93. package/build/production/client/index.js.map +1 -1
  94. package/build/production/client/init.js +2 -2
  95. package/build/production/client/init.js.map +1 -1
  96. package/build/production/index.js +2 -3
  97. package/build/production/index.js.map +1 -1
  98. package/build/production/server/Cache.js +3 -3
  99. package/build/production/server/Cache.js.map +1 -1
  100. package/build/production/server/index.js +8 -8
  101. package/build/production/server/index.js.map +1 -1
  102. package/build/production/server/renderer.js +24 -25
  103. package/build/production/server/renderer.js.map +1 -1
  104. package/build/production/server/server.js +9 -11
  105. package/build/production/server/server.js.map +1 -1
  106. package/build/production/server/utils/errors.js +9 -9
  107. package/build/production/server/utils/errors.js.map +1 -1
  108. package/build/production/server/utils/index.js +2 -1
  109. package/build/production/server/utils/index.js.map +1 -1
  110. package/build/production/shared/components/Button/index.js +4 -4
  111. package/build/production/shared/components/Button/index.js.map +1 -1
  112. package/build/production/shared/components/Checkbox/index.js +1 -1
  113. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  114. package/build/production/shared/components/GenericLink/index.js +4 -4
  115. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  116. package/build/production/shared/components/Input/index.js +5 -5
  117. package/build/production/shared/components/Input/index.js.map +1 -1
  118. package/build/production/shared/components/Link.js +3 -3
  119. package/build/production/shared/components/Link.js.map +1 -1
  120. package/build/production/shared/components/Modal/index.js +7 -7
  121. package/build/production/shared/components/Modal/index.js.map +1 -1
  122. package/build/production/shared/components/NavLink.js +2 -2
  123. package/build/production/shared/components/NavLink.js.map +1 -1
  124. package/build/production/shared/components/PageLayout/index.js +2 -2
  125. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  126. package/build/production/shared/components/TextArea/index.js +5 -5
  127. package/build/production/shared/components/TextArea/index.js.map +1 -1
  128. package/build/production/shared/components/Throbber/index.js +2 -2
  129. package/build/production/shared/components/Throbber/index.js.map +1 -1
  130. package/build/production/shared/components/WithTooltip/Tooltip.js +4 -4
  131. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  132. package/build/production/shared/components/WithTooltip/index.js +4 -4
  133. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  134. package/build/production/shared/components/YouTubeVideo/index.js +4 -4
  135. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  136. package/build/production/shared/components/index.js +3 -1
  137. package/build/production/shared/components/index.js.map +1 -1
  138. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
  139. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  140. package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
  141. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  142. package/build/production/shared/components/selectors/NativeDropdown/index.js +4 -4
  143. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  144. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  145. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  146. package/build/production/shared/components/selectors/common.js +2 -2
  147. package/build/production/shared/components/selectors/common.js.map +1 -1
  148. package/build/production/shared/components/selectors/index.js +1 -1
  149. package/build/production/shared/components/selectors/index.js.map +1 -1
  150. package/build/production/shared/utils/config.js +8 -6
  151. package/build/production/shared/utils/config.js.map +1 -1
  152. package/build/production/shared/utils/globalState.js +2 -2
  153. package/build/production/shared/utils/globalState.js.map +1 -1
  154. package/build/production/shared/utils/index.js +1 -1
  155. package/build/production/shared/utils/index.js.map +1 -1
  156. package/build/production/shared/utils/isomorphy/buildInfo.js +3 -3
  157. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  158. package/build/production/shared/utils/isomorphy/environment-check.js +3 -3
  159. package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
  160. package/build/production/shared/utils/isomorphy/index.js +4 -4
  161. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  162. package/build/production/shared/utils/jest/E2eSsrEnv.js +16 -15
  163. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  164. package/build/production/shared/utils/jest/global.js +1 -1
  165. package/build/production/shared/utils/jest/global.js.map +1 -1
  166. package/build/production/shared/utils/jest/index.js +11 -11
  167. package/build/production/shared/utils/jest/index.js.map +1 -1
  168. package/build/production/shared/utils/splitComponent.js +11 -22
  169. package/build/production/shared/utils/splitComponent.js.map +1 -1
  170. package/build/production/shared/utils/time.js +3 -3
  171. package/build/production/shared/utils/time.js.map +1 -1
  172. package/build/production/shared/utils/webpack.js +6 -6
  173. package/build/production/shared/utils/webpack.js.map +1 -1
  174. package/build/types-code/client/getInj.d.ts +1 -2
  175. package/build/types-code/client/index.d.ts +1 -1
  176. package/build/types-code/index.d.ts +1 -7
  177. package/build/types-code/server/index.d.ts +6 -11
  178. package/build/types-code/server/utils/index.d.ts +1 -1
  179. package/build/types-code/shared/utils/config.d.ts +4 -2
  180. package/build/types-code/shared/utils/index.d.ts +2 -2
  181. package/build/types-code/shared/utils/splitComponent.d.ts +6 -4
  182. package/build/web/client/getInj.js +65 -0
  183. package/build/web/client/getInj.js.map +1 -0
  184. package/{src/client/index.tsx → build/web/client/index.js} +13 -24
  185. package/build/web/client/index.js.map +1 -0
  186. package/{src/client/init.ts → build/web/client/init.js} +9 -14
  187. package/build/web/client/init.js.map +1 -0
  188. package/build/web/index.js +11 -0
  189. package/build/web/index.js.map +1 -0
  190. package/{src/server/Cache.ts → build/web/server/Cache.js} +15 -22
  191. package/build/web/server/Cache.js.map +1 -0
  192. package/{src/server/index.ts → build/web/server/index.js} +32 -81
  193. package/build/web/server/index.js.map +1 -0
  194. package/{src/server/renderer.tsx → build/web/server/renderer.js} +188 -333
  195. package/build/web/server/renderer.js.map +1 -0
  196. package/{src/server/server.ts → build/web/server/server.js} +82 -182
  197. package/build/web/server/server.js.map +1 -0
  198. package/{src/server/utils/errors.ts → build/web/server/utils/errors.js} +6 -25
  199. package/build/web/server/utils/errors.js.map +1 -0
  200. package/build/web/server/utils/index.js +4 -0
  201. package/build/web/server/utils/index.js.map +1 -0
  202. package/build/web/shared/components/Button/index.js +90 -0
  203. package/build/web/shared/components/Button/index.js.map +1 -0
  204. package/build/web/shared/components/Checkbox/index.js +35 -0
  205. package/build/web/shared/components/Checkbox/index.js.map +1 -0
  206. package/{src/shared/components/GenericLink/index.tsx → build/web/shared/components/GenericLink/index.js} +44 -78
  207. package/build/web/shared/components/GenericLink/index.js.map +1 -0
  208. package/build/web/shared/components/Input/index.js +71 -0
  209. package/build/web/shared/components/Input/index.js.map +1 -0
  210. package/build/web/shared/components/Link.js +20 -0
  211. package/build/web/shared/components/Link.js.map +1 -0
  212. package/{src → build/web}/shared/components/Modal/base-theme.scss +1 -1
  213. package/build/web/shared/components/Modal/index.js +128 -0
  214. package/build/web/shared/components/Modal/index.js.map +1 -0
  215. package/build/web/shared/components/NavLink.js +13 -0
  216. package/build/web/shared/components/NavLink.js.map +1 -0
  217. package/{src → build/web}/shared/components/PageLayout/base-theme.scss +1 -1
  218. package/{src/shared/components/PageLayout/index.tsx → build/web/shared/components/PageLayout/index.js} +20 -33
  219. package/build/web/shared/components/PageLayout/index.js.map +1 -0
  220. package/build/web/shared/components/TextArea/index.js +106 -0
  221. package/build/web/shared/components/TextArea/index.js.map +1 -0
  222. package/build/web/shared/components/Throbber/index.js +26 -0
  223. package/build/web/shared/components/Throbber/index.js.map +1 -0
  224. package/{src/shared/components/WithTooltip/Tooltip.tsx → build/web/shared/components/WithTooltip/Tooltip.js} +61 -109
  225. package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -0
  226. package/build/web/shared/components/WithTooltip/index.js +117 -0
  227. package/build/web/shared/components/WithTooltip/index.js.map +1 -0
  228. package/{src/shared/components/YouTubeVideo/index.tsx → build/web/shared/components/YouTubeVideo/index.js} +23 -40
  229. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -0
  230. package/build/web/shared/components/index.js +18 -0
  231. package/build/web/shared/components/index.js.map +1 -0
  232. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +82 -0
  233. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
  234. package/{src/shared/components/selectors/CustomDropdown/index.tsx → build/web/shared/components/selectors/CustomDropdown/index.js} +56 -80
  235. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -0
  236. package/{src/shared/components/selectors/NativeDropdown/index.tsx → build/web/shared/components/selectors/NativeDropdown/index.js} +39 -44
  237. package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -0
  238. package/build/web/shared/components/selectors/Switch/index.js +50 -0
  239. package/build/web/shared/components/selectors/Switch/index.js.map +1 -0
  240. package/build/web/shared/components/selectors/common.js +12 -0
  241. package/build/web/shared/components/selectors/common.js.map +1 -0
  242. package/build/web/shared/components/selectors/index.js +4 -0
  243. package/build/web/shared/components/selectors/index.js.map +1 -0
  244. package/build/web/shared/utils/config.js +45 -0
  245. package/build/web/shared/utils/config.js.map +1 -0
  246. package/build/web/shared/utils/globalState.js +15 -0
  247. package/build/web/shared/utils/globalState.js.map +1 -0
  248. package/build/web/shared/utils/index.js +13 -0
  249. package/build/web/shared/utils/index.js.map +1 -0
  250. package/{src/shared/utils/isomorphy/buildInfo.ts → build/web/shared/utils/isomorphy/buildInfo.js} +4 -10
  251. package/build/web/shared/utils/isomorphy/buildInfo.js.map +1 -0
  252. package/build/web/shared/utils/isomorphy/environment-check.js +17 -0
  253. package/build/web/shared/utils/isomorphy/environment-check.js.map +1 -0
  254. package/{src/shared/utils/isomorphy/index.ts → build/web/shared/utils/isomorphy/index.js} +6 -6
  255. package/build/web/shared/utils/isomorphy/index.js.map +1 -0
  256. package/{src/shared/utils/jest/E2eSsrEnv.ts → build/web/shared/utils/jest/E2eSsrEnv.js} +73 -140
  257. package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -0
  258. package/build/web/shared/utils/jest/global.js +4 -0
  259. package/build/web/shared/utils/jest/global.js.map +1 -0
  260. package/{src/shared/utils/jest/index.ts → build/web/shared/utils/jest/index.js} +33 -83
  261. package/build/web/shared/utils/jest/index.js.map +1 -0
  262. package/{src/shared/utils/splitComponent.tsx → build/web/shared/utils/splitComponent.js} +77 -124
  263. package/build/web/shared/utils/splitComponent.js.map +1 -0
  264. package/{src/shared/utils/time.ts → build/web/shared/utils/time.js} +21 -37
  265. package/build/web/shared/utils/time.js.map +1 -0
  266. package/build/web/shared/utils/webpack.js +67 -0
  267. package/build/web/shared/utils/webpack.js.map +1 -0
  268. package/config/babel/node-ssr.js +12 -3
  269. package/config/babel/webpack.js +6 -1
  270. package/config/jest/default.js +8 -2
  271. package/config/jest/setup.js +8 -1
  272. package/config/webpack/app-base.js +25 -14
  273. package/config/webpack/app-development.js +2 -2
  274. package/config/webpack/lib-base.js +1 -2
  275. package/package.json +41 -42
  276. package/types.d.ts +1 -6
  277. package/build/development/__chunk_groups__.json +0 -6
  278. package/build/development/style.css +0 -909
  279. package/build/development/web.bundle.js +0 -752
  280. package/build/production/__chunk_groups__.json +0 -6
  281. package/build/production/style.css +0 -2
  282. package/build/production/style.css.map +0 -1
  283. package/build/production/web.bundle.js +0 -3
  284. package/build/production/web.bundle.js.LICENSE.txt +0 -9
  285. package/build/production/web.bundle.js.map +0 -1
  286. package/dev-styles.js +0 -1
  287. package/node-entry.js +0 -15
  288. package/null.js +0 -1
  289. package/prod-styles.js +0 -1
  290. package/src/client/getInj.ts +0 -51
  291. package/src/index.ts +0 -73
  292. package/src/server/utils/index.ts +0 -3
  293. package/src/shared/components/Button/index.tsx +0 -130
  294. package/src/shared/components/Checkbox/index.tsx +0 -53
  295. package/src/shared/components/Input/index.tsx +0 -96
  296. package/src/shared/components/Link.tsx +0 -25
  297. package/src/shared/components/Modal/index.tsx +0 -177
  298. package/src/shared/components/NavLink.tsx +0 -18
  299. package/src/shared/components/TextArea/index.tsx +0 -139
  300. package/src/shared/components/Throbber/index.tsx +0 -28
  301. package/src/shared/components/WithTooltip/index.tsx +0 -186
  302. package/src/shared/components/index.ts +0 -20
  303. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +0 -124
  304. package/src/shared/components/selectors/Switch/index.tsx +0 -74
  305. package/src/shared/components/selectors/common.ts +0 -57
  306. package/src/shared/components/selectors/index.ts +0 -8
  307. package/src/shared/utils/config.ts +0 -28
  308. package/src/shared/utils/globalState.ts +0 -44
  309. package/src/shared/utils/index.ts +0 -45
  310. package/src/shared/utils/isomorphy/environment-check.ts +0 -18
  311. package/src/shared/utils/jest/global.ts +0 -17
  312. package/src/shared/utils/webpack.ts +0 -74
  313. /package/{src → build/web}/shared/components/Button/style.scss +0 -0
  314. /package/{src → build/web}/shared/components/Checkbox/theme.scss +0 -0
  315. /package/{src → build/web}/shared/components/GenericLink/style.scss +0 -0
  316. /package/{src → build/web}/shared/components/Input/theme.scss +0 -0
  317. /package/{src → build/web}/shared/components/Modal/styles.scss +0 -0
  318. /package/{src → build/web}/shared/components/TextArea/style.scss +0 -0
  319. /package/{src → build/web}/shared/components/Throbber/theme.scss +0 -0
  320. /package/{src → build/web}/shared/components/WithTooltip/default-theme.scss +0 -0
  321. /package/{src → build/web}/shared/components/YouTubeVideo/base.scss +0 -0
  322. /package/{src → build/web}/shared/components/YouTubeVideo/throbber.scss +0 -0
  323. /package/{src → build/web}/shared/components/selectors/CustomDropdown/Options/style.scss +0 -0
  324. /package/{src → build/web}/shared/components/selectors/CustomDropdown/theme.scss +0 -0
  325. /package/{src → build/web}/shared/components/selectors/NativeDropdown/theme.scss +0 -0
  326. /package/{src → build/web}/shared/components/selectors/Switch/theme.scss +0 -0
  327. /package/{src → build/web}/styles/_global/reset.css +0 -0
  328. /package/{src → build/web}/styles/_mixins/fonts.scss +0 -0
  329. /package/{src → build/web}/styles/_mixins/media.scss +0 -0
  330. /package/{src → build/web}/styles/_mixins/typography.scss +0 -0
  331. /package/{src → build/web}/styles/global.scss +0 -0
  332. /package/{src → build/web}/styles/mixins.scss +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireDefault","require","_jsxRuntime","defaultTheme","Throbber","theme","jsxs","className","container","children","jsx","circle","_default","exports","default","themed"],"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 ThemeKeyT = 'bouncing' | 'circle' | 'container';\n\ntype PropsT = {\n theme: Theme<ThemeKeyT>;\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}>\n <span className={theme.circle} />\n <span className={theme.circle} />\n <span className={theme.circle} />\n </span>\n);\n\nexport default themed(Throbber, 'Throbber', defaultTheme);\n"],"mappings":"gLAAA,IAAAA,YAAA,CAAAC,sBAAA,CAAAC,OAAA,8BAA8D,IAAAC,WAAA,CAAAD,OAAA,4BAAAE,YAAA,+GAU9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,QAAyC,CAAGA,CAAC,CAAEC,KAAM,CAAC,gBAC1D,GAAAH,WAAA,CAAAI,IAAA,UAAMC,SAAS,CAAEF,KAAK,CAACG,SAAU,CAAAC,QAAA,eAC/B,GAAAP,WAAA,CAAAQ,GAAA,UAAMH,SAAS,CAAEF,KAAK,CAACM,MAAO,CAAE,CAAC,cACjC,GAAAT,WAAA,CAAAQ,GAAA,UAAMH,SAAS,CAAEF,KAAK,CAACM,MAAO,CAAE,CAAC,cACjC,GAAAT,WAAA,CAAAQ,GAAA,UAAMH,SAAS,CAAEF,KAAK,CAACM,MAAO,CAAE,CAAC,EAC7B,CACP,CAAC,IAAAC,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEa,GAAAC,oBAAM,EAACX,QAAQ,CAAE,UAAU,CAAED,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["themed","defaultTheme","jsx","_jsx","jsxs","_jsxs","Throbber","theme","className","container","children","circle"],"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 ThemeKeyT = 'bouncing' | 'circle' | 'container';\n\ntype PropsT = {\n theme: Theme<ThemeKeyT>;\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}>\n <span className={theme.circle} />\n <span className={theme.circle} />\n <span className={theme.circle} />\n </span>\n);\n\nexport default /* #__PURE__ */ themed(Throbber, 'Throbber', defaultTheme);\n"],"mappings":"AAAA,MAAO,CAAAA,MAAM,KAAsB,0BAA0B,OAAAC,YAAA,+GAErB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAQxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,QAAyC,CAAGA,CAAC,CAAEC,KAAM,CAAC,gBAC1DF,KAAA,SAAMG,SAAS,CAAED,KAAK,CAACE,SAAU,CAAAC,QAAA,eAC/BP,IAAA,SAAMK,SAAS,CAAED,KAAK,CAACI,MAAO,CAAE,CAAC,cACjCR,IAAA,SAAMK,SAAS,CAAED,KAAK,CAACI,MAAO,CAAE,CAAC,cACjCR,IAAA,SAAMK,SAAS,CAAED,KAAK,CAACI,MAAO,CAAE,CAAC,EAC7B,CACP,CAED,cAAe,eAAgBX,MAAM,CAACM,QAAQ,CAAE,UAAU,CAAEL,YAAY,CAAC","ignoreList":[]}
@@ -1,11 +1,11 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.PLACEMENTS=void 0;var _react=require("react");var _reactDom=require("react-dom");var _jsxRuntime=require("react/jsx-runtime");/**
1
+ /**
2
2
  * The actual tooltip component. It is rendered outside the regular document
3
3
  * hierarchy, and with sub-components managed without React to achieve the best
4
4
  * performance during animation.
5
- *//**
5
+ */import{useImperativeHandle,useRef}from"react";import{createPortal}from"react-dom";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
6
6
  * Valid placements of the rendered tooltip. They will be overriden when
7
7
  * necessary to fit the tooltip within the viewport.
8
- */let PLACEMENTS=exports.PLACEMENTS=/*#__PURE__*/function(PLACEMENTS){PLACEMENTS["ABOVE_CURSOR"]="ABOVE_CURSOR";PLACEMENTS["ABOVE_ELEMENT"]="ABOVE_ELEMENT";PLACEMENTS["BELOW_CURSOR"]="BELOW_CURSOR";PLACEMENTS["BELOW_ELEMENT"]="BELOW_ELEMENT";return PLACEMENTS}({});const ARROW_STYLE_DOWN=["border-bottom-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");const ARROW_STYLE_UP=["border-top-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");/**
8
+ */export let PLACEMENTS=/*#__PURE__*/function(PLACEMENTS){PLACEMENTS["ABOVE_CURSOR"]="ABOVE_CURSOR";PLACEMENTS["ABOVE_ELEMENT"]="ABOVE_ELEMENT";PLACEMENTS["BELOW_CURSOR"]="BELOW_CURSOR";PLACEMENTS["BELOW_ELEMENT"]="BELOW_ELEMENT";return PLACEMENTS}({});const ARROW_STYLE_DOWN=["border-bottom-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");const ARROW_STYLE_UP=["border-top-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");/**
9
9
  * Generates bounding client rectangles for tooltip components.
10
10
  * @ignore
11
11
  * @param tooltip DOM references to the tooltip components.
@@ -93,5 +93,5 @@ baseArrowStyle:ARROW_STYLE_DOWN}}// const HIT = {
93
93
  // rendering cycles, and only then it can be correctly measured and positioned.
94
94
  // Thus, when we create the <Tooltip> we have to record its target positioning
95
95
  // details, and then apply them when it is created.
96
- const arrowRef=(0,_react.useRef)(null);const containerRef=(0,_react.useRef)(null);const contentRef=(0,_react.useRef)(null);const pointTo=(pageX,pageY,placement,element)=>{if(!arrowRef.current||!containerRef.current||!contentRef.current){throw Error("Internal error")}setComponentPositions(pageX,pageY,placement,element,{arrow:arrowRef.current,container:containerRef.current,content:contentRef.current})};(0,_react.useImperativeHandle)(ref,()=>({pointTo}));return/*#__PURE__*/(0,_reactDom.createPortal)(/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.container,ref:containerRef,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.arrow,ref:arrowRef}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.content,ref:contentRef,children:children})]}),document.body)};var _default=exports.default=Tooltip;
96
+ const arrowRef=useRef(null);const containerRef=useRef(null);const contentRef=useRef(null);const pointTo=(pageX,pageY,placement,element)=>{if(!arrowRef.current||!containerRef.current||!contentRef.current){throw Error("Internal error")}setComponentPositions(pageX,pageY,placement,element,{arrow:arrowRef.current,container:containerRef.current,content:contentRef.current})};useImperativeHandle(ref,()=>({pointTo}));return/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("div",{className:theme.container,ref:containerRef,children:[/*#__PURE__*/_jsx("div",{className:theme.arrow,ref:arrowRef}),/*#__PURE__*/_jsx("div",{className:theme.content,ref:contentRef,children:children})]}),document.body)};export default Tooltip;
97
97
  //# sourceMappingURL=Tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":["_react","require","_reactDom","_jsxRuntime","PLACEMENTS","exports","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","calcTooltipRects","tooltip","arrow","getBoundingClientRect","container","calcViewportRect","scrollX","scrollY","window","documentElement","clientHeight","clientWidth","document","bottom","left","right","top","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","setAttribute","arrowStyle","Tooltip","children","ref","theme","arrowRef","useRef","containerRef","contentRef","pointTo","current","Error","content","useImperativeHandle","createPortal","jsxs","className","jsx","body","_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\nimport {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\n/**\n * Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport.\n */\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\nexport type ThemeKeysT = 'appearance' | 'arrow' | 'content' | 'container';\n\ntype TooltipThemeT = Theme<ThemeKeysT>;\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 bottom: scrollY + clientHeight,\n left: scrollX,\n right: scrollX + clientWidth,\n top: scrollY,\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// const HIT = {\n// NONE: false,\n// LEFT: 'LEFT',\n// RIGHT: 'RIGHT',\n// TOP: 'TOP',\n// BOTTOM: 'BOTTOM',\n// };\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n// function 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 * 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// function 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 * 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: FunctionComponent<{\n children?: ReactNode;\n ref?: RefObject<unknown>;\n theme: TooltipThemeT;\n}> = ({ children, ref, theme }) => {\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 arrowRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n\n const pointTo = (\n pageX: number,\n pageY: number,\n placement: PLACEMENTS,\n element: HTMLElement,\n ) => {\n if (!arrowRef.current || !containerRef.current || !contentRef.current) {\n throw Error('Internal error');\n }\n\n setComponentPositions(pageX, pageY, placement, element, {\n arrow: arrowRef.current,\n container: containerRef.current,\n content: contentRef.current,\n });\n };\n useImperativeHandle(ref, () => ({ pointTo }));\n\n return createPortal(\n (\n <div className={theme.container} ref={containerRef}>\n <div className={theme.arrow} ref={arrowRef} />\n <div className={theme.content} ref={contentRef}>{children}</div>\n </div>\n ),\n document.body,\n );\n};\n\nexport default Tooltip;\n"],"mappings":"gHAMA,IAAAA,MAAA,CAAAC,OAAA,UAQA,IAAAC,SAAA,CAAAD,OAAA,cAAyC,IAAAE,WAAA,CAAAF,OAAA,sBAdzC;AACA;AACA;AACA;AACA,GAcA;AACA;AACA;AACA,GAHA,GAIY,CAAAG,UAAU,CAAAC,OAAA,CAAAD,UAAA,uBAAVA,UAAU,EAAVA,UAAU,gCAAVA,UAAU,kCAAVA,UAAU,gCAAVA,UAAU,wCAAV,CAAAA,UAAU,MAOtB,KAAM,CAAAE,gBAAgB,CAAG,CACvB,iCAAiC,CACjC,+BAA+B,CAC/B,gCAAgC,CACjC,CAACC,IAAI,CAAC,GAAG,CAAC,CAEX,KAAM,CAAAC,cAAc,CAAG,CACrB,8BAA8B,CAC9B,+BAA+B,CAC/B,gCAAgC,CACjC,CAACD,IAAI,CAAC,GAAG,CAAC,CAiBX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAE,gBAAgBA,CAACC,OAAoB,CAAiB,CAC7D,MAAO,CACLC,KAAK,CAAED,OAAO,CAACC,KAAK,CAACC,qBAAqB,CAAC,CAAC,CAC5CC,SAAS,CAAEH,OAAO,CAACG,SAAS,CAACD,qBAAqB,CAAC,CACrD,CACF,CAEA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAE,gBAAgBA,CAAA,CAAG,CAC1B,KAAM,CAAEC,OAAO,CAAEC,OAAQ,CAAC,CAAGC,MAAM,CACnC,KAAM,CAAEC,eAAe,CAAE,CAAEC,YAAY,CAAEC,WAAY,CAAE,CAAC,CAAGC,QAAQ,CACnE,MAAO,CACLC,MAAM,CAAEN,OAAO,CAAGG,YAAY,CAC9BI,IAAI,CAAER,OAAO,CACbS,KAAK,CAAET,OAAO,CAAGK,WAAW,CAC5BK,GAAG,CAAET,OACP,CACF,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAU,mBAAmBA,CAC1BC,CAAS,CACTC,CAAS,CACTC,YAA2B,CAC3B,CACA,KAAM,CAAElB,KAAK,CAAEE,SAAU,CAAC,CAAGgB,YAAY,CACzC,MAAO,CACLC,MAAM,CAAE,GAAG,EAAIjB,SAAS,CAACkB,KAAK,CAAGpB,KAAK,CAACoB,KAAK,CAAC,CAC7CC,MAAM,CAAEnB,SAAS,CAACoB,MAAM,CACxBC,UAAU,CAAEP,CAAC,CAAGd,SAAS,CAACkB,KAAK,CAAG,CAAC,CACnCI,UAAU,CAAEP,CAAC,CAAGf,SAAS,CAACoB,MAAM,CAAGtB,KAAK,CAACsB,MAAM,CAAG,GAAG,CAErD;AACA;AACA;AACAG,cAAc,CAAE9B,gBAClB,CACF,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAA+B,qBAAqBA,CAC5BC,KAAa,CACbC,KAAa,CACbC,SAAiC,CACjCC,OAAgC,CAChC/B,OAAoB,CACpB,CACA,KAAM,CAAAmB,YAAY,CAAGpB,gBAAgB,CAACC,OAAO,CAAC,CAC9C,KAAM,CAAAgC,YAAY,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KAAK,CAACzC,SAAU,CAACwC,GAAG,CAAEI,YAAa,CAAAL,QAAA,eACjD,GAAAjD,WAAA,CAAAgE,GAAA,SAAKD,SAAS,CAAEZ,KAAK,CAAC3C,KAAM,CAAC0C,GAAG,CAAEE,QAAS,CAAE,CAAC,cAC9C,GAAApD,WAAA,CAAAgE,GAAA,SAAKD,SAAS,CAAEZ,KAAK,CAACQ,OAAQ,CAACT,GAAG,CAAEK,UAAW,CAAAN,QAAA,CAAEA,QAAQ,CAAM,CAAC,EAC7D,CAAC,CAER/B,QAAQ,CAAC+C,IACX,CACF,CAAC,CAAC,IAAAC,QAAA,CAAAhE,OAAA,CAAAiE,OAAA,CAEanB,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"Tooltip.js","names":["useImperativeHandle","useRef","createPortal","jsx","_jsx","jsxs","_jsxs","PLACEMENTS","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","calcTooltipRects","tooltip","arrow","getBoundingClientRect","container","calcViewportRect","scrollX","scrollY","window","documentElement","clientHeight","clientWidth","document","bottom","left","right","top","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","setAttribute","arrowStyle","Tooltip","children","ref","theme","arrowRef","containerRef","contentRef","pointTo","current","Error","content","className","body"],"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\nimport {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\n/**\n * Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport.\n */\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\nexport type ThemeKeysT = 'appearance' | 'arrow' | 'content' | 'container';\n\ntype TooltipThemeT = Theme<ThemeKeysT>;\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 bottom: scrollY + clientHeight,\n left: scrollX,\n right: scrollX + clientWidth,\n top: scrollY,\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// const HIT = {\n// NONE: false,\n// LEFT: 'LEFT',\n// RIGHT: 'RIGHT',\n// TOP: 'TOP',\n// BOTTOM: 'BOTTOM',\n// };\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n// function 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 * 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// function 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 * 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: FunctionComponent<{\n children?: ReactNode;\n ref?: RefObject<unknown>;\n theme: TooltipThemeT;\n}> = ({ children, ref, theme }) => {\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 arrowRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n\n const pointTo = (\n pageX: number,\n pageY: number,\n placement: PLACEMENTS,\n element: HTMLElement,\n ) => {\n if (!arrowRef.current || !containerRef.current || !contentRef.current) {\n throw Error('Internal error');\n }\n\n setComponentPositions(pageX, pageY, placement, element, {\n arrow: arrowRef.current,\n container: containerRef.current,\n content: contentRef.current,\n });\n };\n useImperativeHandle(ref, () => ({ pointTo }));\n\n return createPortal(\n (\n <div className={theme.container} ref={containerRef}>\n <div className={theme.arrow} ref={arrowRef} />\n <div className={theme.content} ref={contentRef}>{children}</div>\n </div>\n ),\n document.body,\n );\n};\n\nexport default Tooltip;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,GAEA,OAIEA,mBAAmB,CACnBC,MAAM,KACD,OAAO,CAEd,OAASC,YAAY,KAAQ,WAAW,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAIzC;AACA;AACA;AACA,GACA,UAAY,CAAAC,UAAU,uBAAVA,UAAU,EAAVA,UAAU,gCAAVA,UAAU,kCAAVA,UAAU,gCAAVA,UAAU,wCAAV,CAAAA,UAAU,MAOtB,KAAM,CAAAC,gBAAgB,CAAG,CACvB,iCAAiC,CACjC,+BAA+B,CAC/B,gCAAgC,CACjC,CAACC,IAAI,CAAC,GAAG,CAAC,CAEX,KAAM,CAAAC,cAAc,CAAG,CACrB,8BAA8B,CAC9B,+BAA+B,CAC/B,gCAAgC,CACjC,CAACD,IAAI,CAAC,GAAG,CAAC,CAiBX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAE,gBAAgBA,CAACC,OAAoB,CAAiB,CAC7D,MAAO,CACLC,KAAK,CAAED,OAAO,CAACC,KAAK,CAACC,qBAAqB,CAAC,CAAC,CAC5CC,SAAS,CAAEH,OAAO,CAACG,SAAS,CAACD,qBAAqB,CAAC,CACrD,CACF,CAEA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAE,gBAAgBA,CAAA,CAAG,CAC1B,KAAM,CAAEC,OAAO,CAAEC,OAAQ,CAAC,CAAGC,MAAM,CACnC,KAAM,CAAEC,eAAe,CAAE,CAAEC,YAAY,CAAEC,WAAY,CAAE,CAAC,CAAGC,QAAQ,CACnE,MAAO,CACLC,MAAM,CAAEN,OAAO,CAAGG,YAAY,CAC9BI,IAAI,CAAER,OAAO,CACbS,KAAK,CAAET,OAAO,CAAGK,WAAW,CAC5BK,GAAG,CAAET,OACP,CACF,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAU,mBAAmBA,CAC1BC,CAAS,CACTC,CAAS,CACTC,YAA2B,CAC3B,CACA,KAAM,CAAElB,KAAK,CAAEE,SAAU,CAAC,CAAGgB,YAAY,CACzC,MAAO,CACLC,MAAM,CAAE,GAAG,EAAIjB,SAAS,CAACkB,KAAK,CAAGpB,KAAK,CAACoB,KAAK,CAAC,CAC7CC,MAAM,CAAEnB,SAAS,CAACoB,MAAM,CACxBC,UAAU,CAAEP,CAAC,CAAGd,SAAS,CAACkB,KAAK,CAAG,CAAC,CACnCI,UAAU,CAAEP,CAAC,CAAGf,SAAS,CAACoB,MAAM,CAAGtB,KAAK,CAACsB,MAAM,CAAG,GAAG,CAErD;AACA;AACA;AACAG,cAAc,CAAE9B,gBAClB,CACF,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAA+B,qBAAqBA,CAC5BC,KAAa,CACbC,KAAa,CACbC,SAAiC,CACjCC,OAAgC,CAChC/B,OAAoB,CACpB,CACA,KAAM,CAAAmB,YAAY,CAAGpB,gBAAgB,CAACC,OAAO,CAAC,CAC9C,KAAM,CAAAgC,YAAY,CAAG5B,gBAAgB,CA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jDlD,IAAA,QAAK4D,SAAS,CAAER,KAAK,CAAC3C,KAAM,CAAC0C,GAAG,CAAEE,QAAS,CAAE,CAAC,cAC9CrD,IAAA,QAAK4D,SAAS,CAAER,KAAK,CAACO,OAAQ,CAACR,GAAG,CAAEI,UAAW,CAAAL,QAAA,CAAEA,QAAQ,CAAM,CAAC,EAC7D,CAAC,CAER/B,QAAQ,CAAC0C,IACX,CACF,CAAC,CAED,cAAe,CAAAZ,OAAO","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=require("react");var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _Tooltip=_interopRequireWildcard(require("./Tooltip"));var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?o(f,t,i):f[t]=e[t]);return f})(e,t)}/* global window */const defaultTheme={"ad":"_4xT7zE","hoc":"zd-vnH","context":"GdZucr","appearance":"L4ubm-","arrow":"M9gywF","container":"f9gY8K","wrapper":"_4qDBRM"};/**
1
+ /* global window */import{useEffect,useRef,useState}from"react";import themed from"@dr.pogodin/react-themes";import Tooltip,{PLACEMENTS}from"./Tooltip.js";const defaultTheme={"ad":"n6OiU9","hoc":"zwsjGc","context":"JVJPcU","appearance":"_9U4YiR","arrow":"_9n65k-","container":"uA1tHZ","wrapper":"JFVmGf"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * Implements a simple to use and themeable tooltip component, _e.g._
3
3
  * ```js
4
4
  * <WithTooltip tip="This is example tooltip.">
@@ -11,15 +11,15 @@
11
11
  * @param tip &ndash; Anything React is able to render,
12
12
  * _e.g._ a tooltip text. This will be the tooltip content.
13
13
  * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.
14
- */const Wrapper=({children,placement=_Tooltip.PLACEMENTS.ABOVE_CURSOR,tip,theme})=>{const{current:heap}=(0,_react.useRef)({lastCursorX:0,lastCursorY:0,timerId:undefined,triggeredByTouch:false});const tooltipRef=(0,_react.useRef)(null);const wrapperRef=(0,_react.useRef)(null);const[showTooltip,setShowTooltip]=(0,_react.useState)(false);const updatePortalPosition=(cursorX,cursorY)=>{if(showTooltip){const wrapperRect=wrapperRef.current.getBoundingClientRect();if(cursorX<wrapperRect.left||cursorX>wrapperRect.right||cursorY<wrapperRect.top||cursorY>wrapperRect.bottom){setShowTooltip(false)}else if(tooltipRef.current){tooltipRef.current.pointTo(cursorX+window.scrollX,cursorY+window.scrollY,placement,wrapperRef.current)}}else{heap.lastCursorX=cursorX;heap.lastCursorY=cursorY;// If tooltip was triggered by a touch, we delay its opening by a bit,
14
+ */const Wrapper=({children,placement=PLACEMENTS.ABOVE_CURSOR,tip,theme})=>{const{current:heap}=useRef({lastCursorX:0,lastCursorY:0,timerId:undefined,triggeredByTouch:false});const tooltipRef=useRef(null);const wrapperRef=useRef(null);const[showTooltip,setShowTooltip]=useState(false);const updatePortalPosition=(cursorX,cursorY)=>{if(showTooltip){const wrapperRect=wrapperRef.current.getBoundingClientRect();if(cursorX<wrapperRect.left||cursorX>wrapperRect.right||cursorY<wrapperRect.top||cursorY>wrapperRect.bottom){setShowTooltip(false)}else if(tooltipRef.current){tooltipRef.current.pointTo(cursorX+window.scrollX,cursorY+window.scrollY,placement,wrapperRef.current)}}else{heap.lastCursorX=cursorX;heap.lastCursorY=cursorY;// If tooltip was triggered by a touch, we delay its opening by a bit,
15
15
  // to ensure it was not a touch-click - in the case of touch click we
16
16
  // want to do the click, rather than show the tooltip, and the delay
17
17
  // gives click handler a chance to abort the tooltip openning.
18
18
  if(heap.triggeredByTouch){heap.timerId??=setTimeout(()=>{heap.triggeredByTouch=false;heap.timerId=undefined;setShowTooltip(true)},300);// Otherwise we can just open the tooltip right away.
19
- }else setShowTooltip(true)}};(0,_react.useEffect)(()=>{if(showTooltip&&tip!==null){// This is necessary to ensure that even when a single mouse event
19
+ }else setShowTooltip(true)}};useEffect(()=>{if(showTooltip&&tip!==null){// This is necessary to ensure that even when a single mouse event
20
20
  // arrives to a tool-tipped component, the tooltip is correctly positioned
21
21
  // once opened (because similar call above does not have effect until
22
22
  // the tooltip is fully mounted, and that is delayed to future rendering
23
23
  // cycle due to the implementation).
24
- if(tooltipRef.current){tooltipRef.current.pointTo(heap.lastCursorX+window.scrollX,heap.lastCursorY+window.scrollY,placement,wrapperRef.current)}const listener=()=>{setShowTooltip(false)};window.addEventListener("scroll",listener);return()=>{window.removeEventListener("scroll",listener)}}return undefined},[heap.lastCursorX,heap.lastCursorY,placement,showTooltip,tip]);return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.wrapper,onClick:()=>{if(heap.timerId){clearTimeout(heap.timerId);heap.timerId=undefined;heap.triggeredByTouch=false}},onMouseLeave:()=>{setShowTooltip(false)},onMouseMove:e=>{updatePortalPosition(e.clientX,e.clientY)},onTouchStart:()=>{heap.triggeredByTouch=true},ref:wrapperRef,role:"presentation",children:[showTooltip&&tip!==null?/*#__PURE__*/(0,_jsxRuntime.jsx)(_Tooltip.default,{ref:tooltipRef,theme:theme,children:tip}):null,children]})};const ThemedWrapper=(0,_reactThemes.default)(Wrapper,"WithTooltip",defaultTheme);const e=ThemedWrapper;e.PLACEMENTS=_Tooltip.PLACEMENTS;var _default=exports.default=e;
24
+ if(tooltipRef.current){tooltipRef.current.pointTo(heap.lastCursorX+window.scrollX,heap.lastCursorY+window.scrollY,placement,wrapperRef.current)}const listener=()=>{setShowTooltip(false)};window.addEventListener("scroll",listener);return()=>{window.removeEventListener("scroll",listener)}}return undefined},[heap.lastCursorX,heap.lastCursorY,placement,showTooltip,tip]);return/*#__PURE__*/_jsxs("div",{className:theme.wrapper,onClick:()=>{if(heap.timerId){clearTimeout(heap.timerId);heap.timerId=undefined;heap.triggeredByTouch=false}},onMouseLeave:()=>{setShowTooltip(false)},onMouseMove:e=>{updatePortalPosition(e.clientX,e.clientY)},onTouchStart:()=>{heap.triggeredByTouch=true},ref:wrapperRef,role:"presentation",children:[showTooltip&&tip!==null?/*#__PURE__*/_jsx(Tooltip,{ref:tooltipRef,theme:theme,children:tip}):null,children]})};const ThemedWrapper=/* #__PURE__ */themed(Wrapper,"WithTooltip",defaultTheme);const e=ThemedWrapper;e.PLACEMENTS=PLACEMENTS;export default e;
25
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","require","_reactThemes","_interopRequireDefault","_Tooltip","_interopRequireWildcard","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","defaultTheme","Wrapper","children","placement","PLACEMENTS","ABOVE_CURSOR","tip","theme","current","heap","useRef","lastCursorX","lastCursorY","timerId","undefined","triggeredByTouch","tooltipRef","wrapperRef","showTooltip","setShowTooltip","useState","updatePortalPosition","cursorX","cursorY","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","setTimeout","useEffect","listener","addEventListener","removeEventListener","jsxs","className","wrapper","onClick","clearTimeout","onMouseLeave","onMouseMove","clientX","clientY","onTouchStart","ref","role","jsx","ThemedWrapper","themed","_default","exports"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport {\n type FunctionComponent,\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, {\n type ThemeKeysT as TooltipThemeKeysT,\n PLACEMENTS,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\ntype PropsT = {\n children?: ReactNode;\n placement?: PLACEMENTS;\n tip?: ReactNode;\n theme: Theme<'wrapper' | TooltipThemeKeysT>;\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 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: FunctionComponent<PropsT> = ({\n children,\n placement = PLACEMENTS.ABOVE_CURSOR,\n tip,\n theme,\n}) => {\n const { current: heap } = useRef<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n timerId: undefined,\n triggeredByTouch: false,\n });\n const tooltipRef = useRef<TooltipRefT>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (showTooltip) {\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 } else {\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 heap.timerId ??= setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\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 = () => {\n setShowTooltip(false);\n };\n window.addEventListener('scroll', listener);\n return () => {\n window.removeEventListener('scroll', listener);\n };\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 onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n }}\n onMouseMove={(e) => {\n updatePortalPosition(e.clientX, e.clientY);\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(Wrapper, 'WithTooltip', defaultTheme);\n\ntype ExportT = typeof ThemedWrapper & {\n PLACEMENTS: typeof PLACEMENTS;\n};\n\nconst e: ExportT = ThemedWrapper as ExportT;\n\ne.PLACEM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CAACM,gBAAgB,CAAG,KAC1B,CACF,CAAE,CACF6B,YAAY,CAAEA,CAAA,GAAM,CAClBzB,cAAc,CAAC,KAAK,CACtB,CAAE,CACF0B,WAAW,CAAGhE,CAAC,EAAK,CAClBwC,oBAAoB,CAACxC,CAAC,CAACiE,OAAO,CAAEjE,CAAC,CAACkE,OAAO,CAC3C,CAAE,CACFC,YAAY,CAAEA,CAAA,GAAM,CAClBvC,IAAI,CAACM,gBAAgB,CAAG,IAC1B,CAAE,CACFkC,GAAG,CAAEhC,UAAW,CAChBiC,IAAI,CAAC,cAAc,CAAAhD,QAAA,EAGjBgB,WAAW,EAAIZ,GAAG,GAAK,IAAI,cACvB,GAAA1B,WAAA,CAAAuE,GAAA,EAACzE,QAAA,CAAAa,OAAO,EAAC0D,GAAG,CAAEjC,UAAW,CAACT,KAAK,CAAEA,KAAM,CAAAL,QAAA,CAAEI,GAAG,CAAU,CAAC,CACvD,IAAI,CAETJ,QAAQ,EACN,CAET,CAAC,CAED,KAAM,CAAAkD,aAAa,CAAG,GAAAC,oBAAM,EAACpD,OAAO,CAAE,aAAa,CAAED,YAAY,CAAC,CAMlE,KAAM,CAAAnB,CAAU,CAAGuE,aAAwB,CAE3CvE,CAAC,CAACuB,UAAU,CAAGA,mBAAU,CAAC,IAAAkD,QAAA,CAAAC,OAAA,CAAAhE,OAAA,CAEXV,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useRef","useState","themed","Tooltip","PLACEMENTS","defaultTheme","jsx","_jsx","jsxs","_jsxs","Wrapper","children","placement","ABOVE_CURSOR","tip","theme","current","heap","lastCursorX","lastCursorY","timerId","undefined","triggeredByTouch","tooltipRef","wrapperRef","showTooltip","setShowTooltip","updatePortalPosition","cursorX","cursorY","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","setTimeout","listener","addEventListener","removeEventListener","className","wrapper","onClick","clearTimeout","onMouseLeave","onMouseMove","e","clientX","clientY","onTouchStart","ref","role","ThemedWrapper"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport {\n type FunctionComponent,\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, {\n type ThemeKeysT as TooltipThemeKeysT,\n PLACEMENTS,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\ntype PropsT = {\n children?: ReactNode;\n placement?: PLACEMENTS;\n tip?: ReactNode;\n theme: Theme<'wrapper' | TooltipThemeKeysT>;\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 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: FunctionComponent<PropsT> = ({\n children,\n placement = PLACEMENTS.ABOVE_CURSOR,\n tip,\n theme,\n}) => {\n const { current: heap } = useRef<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n timerId: undefined,\n triggeredByTouch: false,\n });\n const tooltipRef = useRef<TooltipRefT>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (showTooltip) {\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 } else {\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 heap.timerId ??= setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\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 = () => {\n setShowTooltip(false);\n };\n window.addEventListener('scroll', listener);\n return () => {\n window.removeEventListener('scroll', listener);\n };\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 onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n }}\n onMouseMove={(e) => {\n updatePortalPosition(e.clientX, e.clientY);\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 = /* #__PURE__ */ themed(Wrapper, 'WithTooltip', defaultTheme);\n\ntype ExportT = typeof ThemedWrapper & {\n PLACEMENTS: typeof PLACEMENTS;\n};\n\nconst e: ExportT = ThemedWrapper as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nexport default e;\n"],"mappings":"AAAA,mBAEA,OAGEA,SAAS,CACTC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,MAAO,CAAAC,MAAM,KAAsB,0BAA0B,OAEtD,CAAAC,OAAO,EAEZC,UAAU,0BAAAC,YAAA,oIAGoC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAyBhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,OAAkC,CAAGA,CAAC,CAC1CC,QAAQ,CACRC,SAAS,CAAGR,UAAU,CAACS,YAAY,CACnCC,GAAG,CACHC,KACF,CAAC,GAAK,CACJ,KAAM,CAAEC,OAAO,CAAEC,IAAK,CAAC,CAAGjB,MAAM,CAAQ,CACtCkB,WAAW,CAAE,CAAC,CACdC,WAAW,CAAE,CAAC,CACdC,OAAO,CAAEC,SAAS,CAClBC,gBAAgB,CAAE,KACpB,CAAC,CAAC,CACF,KAAM,CAAAC,UAAU,CAAGvB,MAAM,CAAc,IAAI,CAAC,CAC5C,KAAM,CAAAwB,UAAU,CAAGxB,MAAM,CAAiB,IAAI,CAAC,CAC/C,KAAM,CAACyB,WAAW,CAAEC,cAAc,CAAC,CAAGzB,QAAQ,CAAC,KAAK,CAAC,CAErD,KAAM,CAAA0B,oBAAoB,CAAGA,CAACC,OAAe,CAAEC,OAAe,GAAK,CACjE,GAAIJ,WAAW,CAAE,CACf,KAAM,CAAAK,WAAW,CAAGN,UAAU,CAACR,OAAO,CAAEe,qBAAqB,CAAC,CAAC,CAC/D,GACEH,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U,CAEzB,cAAe,CAAA8C,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _qs=_interopRequireDefault(require("qs"));var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _Throbber=_interopRequireDefault(require("../Throbber"));var _jsxRuntime=require("react/jsx-runtime");const baseTheme={"context":"veKyYi","ad":"r3ABzd","hoc":"YKcPnR","container":"sXHM81","video":"SlV2zw"};const throbberTheme={"context":"dzIcLh","ad":"_5a9XX1","hoc":"_7sH52O","container":"jTxmOX"};/**
1
+ import qs from"qs";import themed from"@dr.pogodin/react-themes";import Throbber from"../Throbber/index.js";const baseTheme={"context":"Pa7GiX","ad":"NikZ57","hoc":"FydyFQ","container":"pQTzJV","video":"iFTALT"};const throbberTheme={"context":"_0Piy3R","ad":"GD-lgk","hoc":"T5TGzT","container":"IgN6Uf"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * A component for embeding a YouTube video.
3
3
  * @param [props] Component properties.
4
4
  * @param [props.autoplay] If `true` the video will start to play
@@ -12,8 +12,8 @@
12
12
  * @param [props.theme] _Ad hoc_ theme.
13
13
  * @param [props.title] The `title` attribute to add to the player
14
14
  * IFrame.
15
- */const YouTubeVideo=({autoplay,src,theme,title})=>{const srcParts=src.split("?");let[url]=srcParts;const[,queryString]=srcParts;const query=queryString?_qs.default.parse(queryString):{};const videoId=query.v??url?.match(/\/([a-zA-Z0-9-_]*)$/)?.[1];url=`https://www.youtube.com/embed/${videoId}`;delete query.v;query.autoplay=autoplay?"1":"0";url+=`?${_qs.default.stringify(query)}`;// TODO: https://developers.google.com/youtube/player_parameters
15
+ */const YouTubeVideo=({autoplay,src,theme,title})=>{const srcParts=src.split("?");let[url]=srcParts;const[,queryString]=srcParts;const query=queryString?qs.parse(queryString):{};const videoId=query.v??url?.match(/\/([a-zA-Z0-9-_]*)$/)?.[1];url=`https://www.youtube.com/embed/${videoId}`;delete query.v;query.autoplay=autoplay?"1":"0";url+=`?${qs.stringify(query)}`;// TODO: https://developers.google.com/youtube/player_parameters
16
16
  // More query parameters can be exposed via the component props.
17
- return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.container,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Throbber.default,{theme:throbberTheme}),/*#__PURE__*/(0,_jsxRuntime.jsx)("iframe",{// eslint-disable-line react/iframe-missing-sandbox
18
- allow:"autoplay",allowFullScreen:true,className:theme.video,src:url,title:title})]})};var _default=exports.default=(0,_reactThemes.default)(YouTubeVideo,"YouTubeVideo",baseTheme);
17
+ return/*#__PURE__*/_jsxs("div",{className:theme.container,children:[/*#__PURE__*/_jsx(Throbber,{theme:throbberTheme}),/*#__PURE__*/_jsx("iframe",{// eslint-disable-line react/iframe-missing-sandbox
18
+ allow:"autoplay",allowFullScreen:true,className:theme.video,src:url,title:title})]})};export default/* #__PURE__ */themed(YouTubeVideo,"YouTubeVideo",baseTheme);
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_qs","_interopRequireDefault","require","_reactThemes","_Throbber","_jsxRuntime","baseTheme","throbberTheme","YouTubeVideo","autoplay","src","theme","title","srcParts","split","url","queryString","query","qs","parse","videoId","v","match","stringify","jsxs","className","container","children","jsx","default","allow","allowFullScreen","video","_default","exports","themed"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.tsx"],"sourcesContent":["import qs from 'qs';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport Throbber from 'components/Throbber';\n\nimport baseTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\ntype ComponentThemeT = Theme<'container' | 'video'>;\n\ntype PropsT = {\n autoplay?: boolean;\n src: string;\n theme: ComponentThemeT;\n title?: string;\n};\n\n/**\n * A component for embeding a YouTube video.\n * @param [props] Component properties.\n * @param [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nconst YouTubeVideo: React.FunctionComponent<PropsT> = ({\n autoplay,\n src,\n theme,\n title,\n}) => {\n const srcParts = src.split('?');\n let [url] = srcParts;\n const [, queryString] = srcParts;\n const query = queryString ? qs.parse(queryString) : {};\n\n const videoId = query.v ?? url?.match(/\\/([a-zA-Z0-9-_]*)$/)?.[1];\n url = `https://www.youtube.com/embed/${videoId as string}`;\n\n delete query.v;\n query.autoplay = autoplay ? '1' : '0';\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <div className={theme.container}>\n <Throbber theme={throbberTheme} />\n {/* TODO: I guess, we better add the sanbox, but right now I don't have\n time to carefully explore which restrictions should be lifted to allow\n embed YouTube player to work... sometime later we'll take care of it */\n }\n <iframe // eslint-disable-line react/iframe-missing-sandbox\n allow=\"autoplay\"\n allowFullScreen\n className={theme.video}\n src={url}\n title={title}\n />\n </div>\n );\n};\n\nexport default themed(YouTubeVideo, 'YouTubeVideo', baseTheme);\n"],"mappings":"gLAAA,IAAAA,GAAA,CAAAC,sBAAA,CAAAC,OAAA,QAEA,IAAAC,YAAA,CAAAF,sBAAA,CAAAC,OAAA,8BAEA,IAAAE,SAAA,CAAAH,sBAAA,CAAAC,OAAA,iBAA2C,IAAAG,WAAA,CAAAH,OAAA,4BAAAI,SAAA,+FAAAC,aAAA,0EAc3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,YAA6C,CAAGA,CA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","throbberTheme","jsx","_jsx","jsxs","_jsxs","YouTubeVideo","autoplay","src","theme","title","srcParts","split","url","queryString","query","parse","videoId","v","match","stringify","className","container","children","allow","allowFullScreen","video"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.tsx"],"sourcesContent":["import qs from 'qs';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport Throbber from 'components/Throbber';\n\nimport baseTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\ntype ComponentThemeT = Theme<'container' | 'video'>;\n\ntype PropsT = {\n autoplay?: boolean;\n src: string;\n theme: ComponentThemeT;\n title?: string;\n};\n\n/**\n * A component for embeding a YouTube video.\n * @param [props] Component properties.\n * @param [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nconst YouTubeVideo: React.FunctionComponent<PropsT> = ({\n autoplay,\n src,\n theme,\n title,\n}) => {\n const srcParts = src.split('?');\n let [url] = srcParts;\n const [, queryString] = srcParts;\n const query = queryString ? qs.parse(queryString) : {};\n\n const videoId = query.v ?? url?.match(/\\/([a-zA-Z0-9-_]*)$/)?.[1];\n url = `https://www.youtube.com/embed/${videoId as string}`;\n\n delete query.v;\n query.autoplay = autoplay ? '1' : '0';\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <div className={theme.container}>\n <Throbber theme={throbberTheme} />\n {/* TODO: I guess, we better add the sanbox, but right now I don't have\n time to carefully explore which restrictions should be lifted to allow\n embed YouTube player to work... sometime later we'll take care of it */\n }\n <iframe // eslint-disable-line react/iframe-missing-sandbox\n allow=\"autoplay\"\n allowFullScreen\n className={theme.video}\n src={url}\n title={title}\n />\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(YouTubeVideo, 'YouTubeVideo', baseTheme);\n"],"mappings":"AAAA,MAAO,CAAAA,EAAE,KAAM,IAAI,CAEnB,MAAO,CAAAC,MAAM,KAAsB,0BAA0B,OAEtD,CAAAC,QAAQ,kCAAAC,SAAA,+FAAAC,aAAA,yEAG6B,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAW5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,YAA6C,CAAGA,CAAC,CACrDC,QAAQ,CACRC,GAAG,CACHC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,QAAQ,CAAGH,GAAG,CAACI,KAAK,CAAC,GAAG,CAAC,CAC/B,GAAI,CAACC,GAAG,CAAC,CAAGF,QAAQ,CACpB,KAAM,EAAGG,WAAW,CAAC,CAAGH,QAAQ,CAChC,KAAM,CAAAI,KAAK,CAAGD,WAAW,CAAGjB,EAAE,CAACmB,KAAK,CAACF,WAAW,CAAC,CAAG,CAAC,CAAC,CAEtD,KAAM,CAAAG,OAAO,CAAGF,KAAK,CAACG,CAAC,EAAIL,GAAG,EAAEM,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CACjEN,GAAG,CAAG,iCAAiCI,OAAO,EAAY,CAE1D,MAAO,CAAAF,KAAK,CAACG,CAAC,CACdH,KAAK,CAACR,QAAQ,CAAGA,QAAQ,CAAG,GAAG,CAAG,GAAG,CACrCM,GAAG,EAAI,IAAIhB,EAAE,CAACuB,SAAS,CAACL,KAAK,CAAC,EAAE,CAEhC;AACA;AAEA,mBACEV,KAAA,QAAKgB,SAAS,CAAEZ,KAAK,CAACa,SAAU,CAAAC,QAAA,eAC9BpB,IAAA,CAACJ,QAAQ,EAACU,KAAK,CAAER,aAAc,CAAE,CAAC,cAKlCE,IAAA,WAAQ;AACNqB,KAAK,CAAC,UAAU,CAChBC,eAAe,MACfJ,SAAS,CAAEZ,KAAK,CAACiB,KAAM,CACvBlB,GAAG,CAAEK,GAAI,CACTH,KAAK,CAAEA,KAAM,CACd,CAAC,EACC,CAET,CAAC,CAED,cAAe,eAAgBZ,MAAM,CAACQ,YAAY,CAAE,cAAc,CAAEN,SAAS,CAAC","ignoreList":[]}
@@ -1,2 +1,4 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={MetaTags:true,Button:true,BaseButton:true,Checkbox:true,Input:true,Link:true,PageLayout:true,Modal:true,BaseModal:true,NavLink:true,Throbber:true,WithTooltip:true,YouTubeVideo:true,TextArea:true};Object.defineProperty(exports,"BaseButton",{enumerable:true,get:function(){return _Button.BaseButton}});Object.defineProperty(exports,"BaseModal",{enumerable:true,get:function(){return _Modal.BaseModal}});Object.defineProperty(exports,"Button",{enumerable:true,get:function(){return _Button.default}});Object.defineProperty(exports,"Checkbox",{enumerable:true,get:function(){return _Checkbox.default}});Object.defineProperty(exports,"Input",{enumerable:true,get:function(){return _Input.default}});Object.defineProperty(exports,"Link",{enumerable:true,get:function(){return _Link.default}});Object.defineProperty(exports,"MetaTags",{enumerable:true,get:function(){return _reactHelmet.MetaTags}});Object.defineProperty(exports,"Modal",{enumerable:true,get:function(){return _Modal.default}});Object.defineProperty(exports,"NavLink",{enumerable:true,get:function(){return _NavLink.default}});Object.defineProperty(exports,"PageLayout",{enumerable:true,get:function(){return _PageLayout.default}});Object.defineProperty(exports,"TextArea",{enumerable:true,get:function(){return _TextArea.default}});Object.defineProperty(exports,"Throbber",{enumerable:true,get:function(){return _Throbber.default}});Object.defineProperty(exports,"WithTooltip",{enumerable:true,get:function(){return _WithTooltip.default}});Object.defineProperty(exports,"YouTubeVideo",{enumerable:true,get:function(){return _YouTubeVideo.default}});var _reactHelmet=require("@dr.pogodin/react-helmet");var _selectors=require("./selectors");Object.keys(_selectors).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_selectors[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _selectors[key]}})});var _Button=_interopRequireWildcard(require("./Button"));var _Checkbox=_interopRequireDefault(require("./Checkbox"));var _Input=_interopRequireDefault(require("./Input"));var _Link=_interopRequireDefault(require("./Link"));var _PageLayout=_interopRequireDefault(require("./PageLayout"));var _Modal=_interopRequireWildcard(require("./Modal"));var _NavLink=_interopRequireDefault(require("./NavLink"));var _Throbber=_interopRequireDefault(require("./Throbber"));var _WithTooltip=_interopRequireDefault(require("./WithTooltip"));var _YouTubeVideo=_interopRequireDefault(require("./YouTubeVideo"));var _TextArea=_interopRequireDefault(require("./TextArea"));function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?o(f,t,i):f[t]=e[t]);return f})(e,t)}
1
+ /**
2
+ * Just an aggregation of all exported components into a single module.
3
+ */export{MetaTags}from"@dr.pogodin/react-helmet";export*from"./selectors/index.js";export{default as Button,BaseButton}from"./Button/index.js";export{default as Checkbox}from"./Checkbox/index.js";export{default as Input}from"./Input/index.js";export{default as Link}from"./Link.js";export{default as PageLayout}from"./PageLayout/index.js";export{default as Modal,BaseModal}from"./Modal/index.js";export{default as NavLink}from"./NavLink.js";export{default as Throbber}from"./Throbber/index.js";export{default as WithTooltip}from"./WithTooltip/index.js";export{default as YouTubeVideo}from"./YouTubeVideo/index.js";export{default as TextArea}from"./TextArea/index.js";
2
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_reactHelmet","require","_selectors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_Button","_interopRequireWildcard","_Checkbox","_interopRequireDefault","_Input","_Link","_PageLayout","_Modal","_NavLink","_Throbber","_WithTooltip","_YouTubeVideo","_TextArea","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor"],"sources":["../../../../src/shared/components/index.ts"],"sourcesContent":["/**\n * Just an aggregation of all exported components into a single module.\n */\n\nexport { MetaTags } from '@dr.pogodin/react-helmet';\n\nexport * from 'components/selectors';\n\nexport { default as Button, BaseButton } from 'components/Button';\nexport { default as Checkbox } from 'components/Checkbox';\nexport { default as Input } from 'components/Input';\nexport { default as Link } from 'components/Link';\nexport { default as PageLayout } from 'components/PageLayout';\nexport { default as Modal, BaseModal } from 'components/Modal';\nexport { default as NavLink } from 'components/NavLink';\nexport { default as Throbber } from 'components/Throbber';\nexport { default as WithTooltip } from 'components/WithTooltip';\nexport { default as YouTubeVideo } from 'components/YouTubeVideo';\n\nexport { default as TextArea } from './TextArea';\n"],"mappings":"ovDAIA,IAAAA,YAAA,CAAAC,OAAA,6BAEA,IAAAC,UAAA,CAAAD,OAAA,gBAAAE,MAAA,CAAAC,IAAA,CAAAF,UAAA,EAAAG,OAAA,UAAAC,GAAA,KAAAA,GAAA,cAAAA,GAAA,0BAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,CAAAJ,GAAA,YAAAA,GAAA,IAAAK,OAAA,EAAAA,OAAA,CAAAL,GAAA,IAAAJ,UAAA,CAAAI,GAAA,SAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,CAAAL,GAAA,EAAAO,UAAA,MAAAC,GAAA,SAAAA,CAAA,SAAAZ,UAAA,CAAAI,GAAA,OA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AT,MAAA,CAAAsC,wBAAA,CAAAb,CAAA,CAAAC,CAAA,KAAAM,CAAA,CAAArB,GAAA,EAAAqB,CAAA,CAAAK,GAAA,EAAAN,CAAA,CAAAE,CAAA,CAAAP,CAAA,CAAAM,CAAA,EAAAC,CAAA,CAAAP,CAAA,EAAAD,CAAA,CAAAC,CAAA,UAAAO,CAAA,GAAAR,CAAA,CAAAC,CAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["MetaTags","default","Button","BaseButton","Checkbox","Input","Link","PageLayout","Modal","BaseModal","NavLink","Throbber","WithTooltip","YouTubeVideo","TextArea"],"sources":["../../../../src/shared/components/index.ts"],"sourcesContent":["/**\n * Just an aggregation of all exported components into a single module.\n */\n\nexport { MetaTags } from '@dr.pogodin/react-helmet';\n\nexport * from 'components/selectors';\n\nexport { default as Button, BaseButton } from 'components/Button';\nexport { default as Checkbox } from 'components/Checkbox';\nexport { default as Input } from 'components/Input';\nexport { default as Link } from 'components/Link';\nexport { default as PageLayout } from 'components/PageLayout';\nexport { default as Modal, BaseModal } from 'components/Modal';\nexport { default as NavLink } from 'components/NavLink';\nexport { default as Throbber } from 'components/Throbber';\nexport { default as WithTooltip } from 'components/WithTooltip';\nexport { default as YouTubeVideo } from 'components/YouTubeVideo';\n\nexport { default as TextArea } from './TextArea';\n"],"mappings":"AAAA;AACA;AACA,GAEA,OAASA,QAAQ,KAAQ,0BAA0B,0CAI1CC,OAAO,GAAI,CAAAC,MAAM,CAAEC,UAAU,gCAC7BF,OAAO,GAAI,CAAAG,QAAQ,kCACnBH,OAAO,GAAI,CAAAI,KAAK,+BAChBJ,OAAO,GAAI,CAAAK,IAAI,wBACfL,OAAO,GAAI,CAAAM,UAAU,oCACrBN,OAAO,GAAI,CAAAO,KAAK,CAAEC,SAAS,+BAC3BR,OAAO,GAAI,CAAAS,OAAO,2BAClBT,OAAO,GAAI,CAAAU,QAAQ,kCACnBV,OAAO,GAAI,CAAAW,WAAW,qCACtBX,OAAO,GAAI,CAAAY,YAAY,sCAEvBZ,OAAO,GAAI,CAAAa,QAAQ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.areEqual=areEqual;exports.default=void 0;var _react=require("react");var _Modal=require("../../../Modal");var _common=require("../../common");var _jsxRuntime=require("react/jsx-runtime");const S={"overlay":"jKsMKG"};function areEqual(a,b){return a?.left===b?.left&&a?.top===b?.top&&a?.width===b?.width}const Options=({containerClass,containerStyle,filter,onCancel,onChange,optionClass,options,ref})=>{const opsRef=(0,_react.useRef)(null);(0,_react.useImperativeHandle)(ref,()=>({measure:()=>{const e=opsRef.current?.parentElement;if(!e)return undefined;const rect=opsRef.current.getBoundingClientRect();const style=window.getComputedStyle(e);const mBottom=parseFloat(style.marginBottom);const mTop=parseFloat(style.marginTop);rect.height+=mBottom+mTop;return rect}}),[]);const optionNodes=[];for(const option of options){if(!filter||filter(option)){const[iValue,iName]=(0,_common.optionValueName)(option);optionNodes.push(/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:optionClass,onClick:e=>{onChange(iValue);e.stopPropagation()},onKeyDown:e=>{if(e.key==="Enter"){onChange(iValue);e.stopPropagation()}},role:"button",tabIndex:0,children:iName},iValue))}}return/*#__PURE__*/(0,_jsxRuntime.jsx)(_Modal.BaseModal// Closes the dropdown (cancels the selection) on any page scrolling attempt.
1
+ import"core-js/modules/es.array.push.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";import{useImperativeHandle,useRef}from"react";import{BaseModal}from"../../../Modal/index.js";import{optionValueName}from"../../common.js";const S={"overlay":"ntZ5My"};import{jsx as _jsx}from"react/jsx-runtime";export function areEqual(a,b){return a?.left===b?.left&&a?.top===b?.top&&a?.width===b?.width}const Options=({containerClass,containerStyle,filter,onCancel,onChange,optionClass,options,ref})=>{const opsRef=useRef(null);useImperativeHandle(ref,()=>({measure:()=>{const e=opsRef.current?.parentElement;if(!e)return undefined;const rect=opsRef.current.getBoundingClientRect();const style=window.getComputedStyle(e);const mBottom=parseFloat(style.marginBottom);const mTop=parseFloat(style.marginTop);rect.height+=mBottom+mTop;return rect}}),[]);const optionNodes=[];for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);optionNodes.push(/*#__PURE__*/_jsx("div",{className:optionClass,onClick:e=>{onChange(iValue);e.stopPropagation()},onKeyDown:e=>{if(e.key==="Enter"){onChange(iValue);e.stopPropagation()}},role:"button",tabIndex:0,children:iName},iValue))}}return/*#__PURE__*/_jsx(BaseModal// Closes the dropdown (cancels the selection) on any page scrolling attempt.
2
2
  // This is the same native <select> elements do on scrolling, and at least for
3
3
  // now we have no reason to deal with complications needed to support open
4
4
  // dropdowns during the scrolling (that would need to re-position it in
5
5
  // response to the position changes of the root dropdown element).
6
- ,{cancelOnScrolling:true,dontDisableScrolling:true,onCancel:onCancel,style:containerStyle,theme:{ad:"",container:containerClass,context:"",hoc:"",overlay:S.overlay},children:/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{ref:opsRef,children:optionNodes})})};var _default=exports.default=Options;
6
+ ,{cancelOnScrolling:true,dontDisableScrolling:true,onCancel:onCancel,style:containerStyle,theme:{ad:"",container:containerClass,context:"",hoc:"",overlay:S.overlay},children:/*#__PURE__*/_jsx("div",{ref:opsRef,children:optionNodes})})};export default Options;
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","require","_Modal","_common","_jsxRuntime","S","areEqual","a","b","left","top","width","Options","containerClass","containerStyle","filter","onCancel","onChange","optionClass","options","ref","opsRef","useRef","useImperativeHandle","measure","e","current","parentElement","undefined","rect","getBoundingClientRect","style","window","getComputedStyle","mBottom","parseFloat","marginBottom","mTop","marginTop","height","optionNodes","option","iValue","iName","optionValueName","push","jsx","className","onClick","stopPropagation","onKeyDown","key","role","tabIndex","children","BaseModal","cancelOnScrolling","dontDisableScrolling","theme","ad","container","context","hoc","overlay","_default","exports","default"],"sources":["../../../../../../../src/shared/components/selectors/CustomDropdown/Options/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { BaseModal } from 'components/Modal';\n\nimport {\n type OptionT,\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../../common';\n\nimport S from './style.scss';\n\nexport type ContainerPosT = {\n left: number;\n top: number;\n width: number;\n};\n\nexport function areEqual(a?: ContainerPosT, b?: ContainerPosT): boolean {\n return a?.left === b?.left && a?.top === b?.top && a?.width === b?.width;\n}\n\nexport type RefT = {\n measure: () => DOMRect | undefined;\n};\n\ntype PropsT = {\n containerClass: string;\n containerStyle?: ContainerPosT;\n filter?: (item: OptionT<ReactNode> | ValueT) => boolean;\n optionClass: string;\n options: Readonly<OptionsT<ReactNode>>;\n onCancel: () => void;\n onChange: (value: ValueT) => void;\n ref?: RefObject<RefT | null>;\n};\n\nconst Options: FunctionComponent<PropsT> = ({\n containerClass,\n containerStyle,\n filter,\n onCancel,\n onChange,\n optionClass,\n options,\n ref,\n}) => {\n const opsRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({\n measure: () => {\n const e = opsRef.current?.parentElement;\n if (!e) return undefined;\n\n const rect = opsRef.current!.getBoundingClientRect();\n const style = window.getComputedStyle(e);\n const mBottom = parseFloat(style.marginBottom);\n const mTop = parseFloat(style.marginTop);\n\n rect.height += mBottom + mTop;\n\n return rect;\n },\n }), []);\n\n const optionNodes: ReactNode[] = [];\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n optionNodes.push(\n <div\n className={optionClass}\n key={iValue}\n onClick={(e) => {\n onChange(iValue);\n e.stopPropagation();\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onChange(iValue);\n e.stopPropagation();\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>,\n );\n }\n }\n\n return (\n <BaseModal\n // Closes the dropdown (cancels the selection) on any page scrolling attempt.\n // This is the same native <select> elements do on scrolling, and at least for\n // now we have no reason to deal with complications needed to support open\n // dropdowns during the scrolling (that would need to re-position it in\n // response to the position changes of the root dropdown element).\n cancelOnScrolling\n dontDisableScrolling\n onCancel={onCancel}\n style={containerStyle}\n theme={{\n ad: '',\n container: containerClass,\n context: '',\n hoc: '',\n overlay: S.overlay,\n }}\n >\n <div ref={opsRef}>{optionNodes}</div>\n </BaseModal>\n );\n};\n\nexport default Options;\n"],"mappings":"uHAAA,IAAAA,MAAA,CAAAC,OAAA,UAQA,IAAAC,MAAA,CAAAD,OAAA,mBAEA,IAAAE,OAAA,CAAAF,OAAA,iBAKsB,IAAAG,WAAA,CAAAH,OAAA,4BAAAI,CAAA,sBAUf,QAAS,CAAAC,QAAQA,CAACC,CAAiB,CAAEC,CAAiB,CAAW,CACtE,MAAO,CAAAD,CAAC,EAAEE,IAAI,GAAKD,CAAC,EAAEC,IAAI,EAAIF,CAAC,EAAEG,GAAG,GAAKF,CAAC,EAAEE,GAAG,EAAIH,CAAC,EAAEI,KAAK,GAAKH,CAAC,EAAEG,KACrE,CAiBA,KAAM,CAAAC,OAAkC,CAAGA,CAAC,CAC1CC,cAAc,CACdC,cAAc,CACdC,MAAM,CACNC,QAAQ,CACRC,QAAQ,CACRC,WAAW,CACXC,OAAO,CACPC,GACF,CAAC,GAAK,CACJ,KAAM,CAAAC,MAAM,CAAG,GAAAC,aAAM,EAAiB,IAAI,CAAC,CAE3C,GAAAC,0BAAmB,EAACH,GAAG,CAAE,KAAO,CAC9BI,OAAO,CAAEA,CAAA,GAAM,CACb,KAAM,CAAAC,CAAC,CAAGJ,MAAM,CAACK,OAAO,EAAEC,aAAa,CACvC,GAAI,CAACF,CAAC,CAAE,MAAO,CAAAG,SAAS,CAExB,KAAM,CAAAC,IAAI,CAAGR,MAAM,CAACK,OAAO,CAAEI,qBAAqB,CAAC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CACtB4C,KAAK,CAAE,CACLC,EAAE,CAAE,EAAE,CACNC,SAAS,CAAE/C,cAAc,CACzBgD,OAAO,CAAE,EAAE,CACXC,GAAG,CAAE,EAAE,CACPC,OAAO,CAAE1D,CAAC,CAAC0D,OACb,CAAE,CAAAT,QAAA,cAEF,GAAAlD,WAAA,CAAA0C,GAAA,SAAK1B,GAAG,CAAEC,MAAO,CAAAiC,QAAA,CAAEd,WAAW,CAAM,CAAC,CAC5B,CAEf,CAAC,CAAC,IAAAwB,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEatD,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useImperativeHandle","useRef","BaseModal","optionValueName","S","jsx","_jsx","areEqual","a","b","left","top","width","Options","containerClass","containerStyle","filter","onCancel","onChange","optionClass","options","ref","opsRef","measure","e","current","parentElement","undefined","rect","getBoundingClientRect","style","window","getComputedStyle","mBottom","parseFloat","marginBottom","mTop","marginTop","height","optionNodes","option","iValue","iName","push","className","onClick","stopPropagation","onKeyDown","key","role","tabIndex","children","cancelOnScrolling","dontDisableScrolling","theme","ad","container","context","hoc","overlay"],"sources":["../../../../../../../src/shared/components/selectors/CustomDropdown/Options/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { BaseModal } from 'components/Modal';\n\nimport {\n type OptionT,\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../../common';\n\nimport S from './style.scss';\n\nexport type ContainerPosT = {\n left: number;\n top: number;\n width: number;\n};\n\nexport function areEqual(a?: ContainerPosT, b?: ContainerPosT): boolean {\n return a?.left === b?.left && a?.top === b?.top && a?.width === b?.width;\n}\n\nexport type RefT = {\n measure: () => DOMRect | undefined;\n};\n\ntype PropsT = {\n containerClass: string;\n containerStyle?: ContainerPosT;\n filter?: (item: OptionT<ReactNode> | ValueT) => boolean;\n optionClass: string;\n options: Readonly<OptionsT<ReactNode>>;\n onCancel: () => void;\n onChange: (value: ValueT) => void;\n ref?: RefObject<RefT | null>;\n};\n\nconst Options: FunctionComponent<PropsT> = ({\n containerClass,\n containerStyle,\n filter,\n onCancel,\n onChange,\n optionClass,\n options,\n ref,\n}) => {\n const opsRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({\n measure: () => {\n const e = opsRef.current?.parentElement;\n if (!e) return undefined;\n\n const rect = opsRef.current!.getBoundingClientRect();\n const style = window.getComputedStyle(e);\n const mBottom = parseFloat(style.marginBottom);\n const mTop = parseFloat(style.marginTop);\n\n rect.height += mBottom + mTop;\n\n return rect;\n },\n }), []);\n\n const optionNodes: ReactNode[] = [];\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n optionNodes.push(\n <div\n className={optionClass}\n key={iValue}\n onClick={(e) => {\n onChange(iValue);\n e.stopPropagation();\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onChange(iValue);\n e.stopPropagation();\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>,\n );\n }\n }\n\n return (\n <BaseModal\n // Closes the dropdown (cancels the selection) on any page scrolling attempt.\n // This is the same native <select> elements do on scrolling, and at least for\n // now we have no reason to deal with complications needed to support open\n // dropdowns during the scrolling (that would need to re-position it in\n // response to the position changes of the root dropdown element).\n cancelOnScrolling\n dontDisableScrolling\n onCancel={onCancel}\n style={containerStyle}\n theme={{\n ad: '',\n container: containerClass,\n context: '',\n hoc: '',\n overlay: S.overlay,\n }}\n >\n <div ref={opsRef}>{optionNodes}</div>\n </BaseModal>\n );\n};\n\nexport default Options;\n"],"mappings":"oRAAA,OAIEA,mBAAmB,CACnBC,MAAM,KACD,OAAO,QAELC,SAAS,sCAMhBC,eAAe,6BAAAC,CAAA,sBAGY,OAAAC,GAAA,IAAAC,IAAA,yBAQ7B,MAAO,SAAS,CAAAC,QAAQA,CAACC,CAAiB,CAAEC,CAAiB,CAAW,CACtE,MAAO,CAAAD,CAAC,E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AAS,CAAEzB,WAAY,CAEvB0B,OAAO,CAAGrB,CAAC,EAAK,CACdN,QAAQ,CAACuB,MAAM,CAAC,CAChBjB,CAAC,CAACsB,eAAe,CAAC,CACpB,CAAE,CACFC,SAAS,CAAGvB,CAAC,EAAK,CAChB,GAAIA,CAAC,CAACwB,GAAG,GAAK,OAAO,CAAE,CACrB9B,QAAQ,CAACuB,MAAM,CAAC,CAChBjB,CAAC,CAACsB,eAAe,CAAC,CACpB,CACF,CAAE,CACFG,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAAC,QAAA,CAEXT,KAAK,EAdDD,MAeF,CACP,CACF,CACF,CAEA,mBACEnC,IAAA,CAACJ,SACC;AACA;AACA;AACA;AACA;AAAA,EACAkD,iBAAiB,MACjBC,oBAAoB,MACpBpC,QAAQ,CAAEA,QAAS,CACnBa,KAAK,CAAEf,cAAe,CACtBuC,KAAK,CAAE,CACLC,EAAE,CAAE,EAAE,CACNC,SAAS,CAAE1C,cAAc,CACzB2C,OAAO,CAAE,EAAE,CACXC,GAAG,CAAE,EAAE,CACPC,OAAO,CAAEvD,CAAC,CAACuD,OACb,CAAE,CAAAR,QAAA,cAEF7C,IAAA,QAAKe,GAAG,CAAEC,MAAO,CAAA6B,QAAA,CAAEZ,WAAW,CAAM,CAAC,CAC5B,CAEf,CAAC,CAED,cAAe,CAAA1B,OAAO","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=require("react");var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _common=require("../common");var _Options=_interopRequireWildcard(require("./Options"));var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?o(f,t,i):f[t]=e[t]);return f})(e,t)}const defaultTheme={"context":"_9Tod5r","ad":"R58zIg","hoc":"O-Tp1i","container":"oQKv0Y","label":"YUPUNs","dropdown":"pNEyAA","option":"LD2Kzy","select":"LP5azC","arrow":"-wscve","active":"k2UDsV","upward":"HWRvu4"};const BaseCustomDropdown=({filter,label,onChange,options,theme,value})=>{const[active,setActive]=(0,_react.useState)(false);const dropdownRef=(0,_react.useRef)(null);const opsRef=(0,_react.useRef)(null);const[opsPos,setOpsPos]=(0,_react.useState)();const[upward,setUpward]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{if(!active)return undefined;let id;const cb=()=>{const anchor=dropdownRef.current?.getBoundingClientRect();const opsRect=opsRef.current?.measure();if(anchor&&opsRect){const fitsDown=anchor.bottom+opsRect.height<(window.visualViewport?.height??0);const fitsUp=anchor.top-opsRect.height>0;const up=!fitsDown&&fitsUp;setUpward(up);const pos=up?{left:anchor.left,top:anchor.top-opsRect.height-1,width:anchor.width}:{left:anchor.left,top:anchor.bottom,width:anchor.width};setOpsPos(now=>(0,_Options.areEqual)(now,pos)?now:pos)}id=requestAnimationFrame(cb)};requestAnimationFrame(cb);return()=>{cancelAnimationFrame(id)}},[active]);const openList=e=>{const view=window.visualViewport;const rect=dropdownRef.current.getBoundingClientRect();setActive(true);// NOTE: This first opens the dropdown off-screen, where it is measured
1
+ import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";import{useEffect,useRef,useState}from"react";import themed from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";import Options,{areEqual}from"./Options/index.js";const defaultTheme={"context":"SNj3wp","ad":"T6eOJ-","hoc":"KG-OKN","container":"SzHHPE","label":"KTG4ai","dropdown":"xdotm7","option":"y-WCDM","select":"PP5Siy","arrow":"_7-A7Lh","active":"RoOAZK","upward":"_--5Xpy"};import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const BaseCustomDropdown=({filter,label,onChange,options,theme,value})=>{const[active,setActive]=useState(false);const dropdownRef=useRef(null);const opsRef=useRef(null);const[opsPos,setOpsPos]=useState();const[upward,setUpward]=useState(false);useEffect(()=>{if(!active)return undefined;let id;const cb=()=>{const anchor=dropdownRef.current?.getBoundingClientRect();const opsRect=opsRef.current?.measure();if(anchor&&opsRect){const fitsDown=anchor.bottom+opsRect.height<(window.visualViewport?.height??0);const fitsUp=anchor.top-opsRect.height>0;const up=!fitsDown&&fitsUp;setUpward(up);const pos=up?{left:anchor.left,top:anchor.top-opsRect.height-1,width:anchor.width}:{left:anchor.left,top:anchor.bottom,width:anchor.width};setOpsPos(now=>areEqual(now,pos)?now:pos)}id=requestAnimationFrame(cb)};requestAnimationFrame(cb);return()=>{cancelAnimationFrame(id)}},[active]);const openList=e=>{const view=window.visualViewport;const rect=dropdownRef.current.getBoundingClientRect();setActive(true);// NOTE: This first opens the dropdown off-screen, where it is measured
2
2
  // by an effect declared above, and then positioned below, or above
3
3
  // the original dropdown element, depending where it fits best
4
4
  // (if we first open it downward, it would flick if we immediately
5
5
  // move it above, at least with the current position update via local
6
6
  // react state, and not imperatively).
7
- setOpsPos({left:view?.width??0,top:view?.height??0,width:rect.width});e.stopPropagation()};let selected=/*#__PURE__*/(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:"\u200C"});for(const option of options){if(!filter||filter(option)){const[iValue,iName]=(0,_common.optionValueName)(option);if(iValue===value){selected=iName;break}}}let containerClassName=theme.container;if(active)containerClassName+=` ${theme.active}`;let opsContainerClass=theme.select??"";if(upward){containerClassName+=` ${theme.upward}`;opsContainerClass+=` ${theme.upward}`}return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.dropdown,onClick:openList,onKeyDown:e=>{if(e.key==="Enter")openList(e)},ref:dropdownRef,role:"listbox",tabIndex:0,children:[selected,/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.arrow})]}),active?/*#__PURE__*/(0,_jsxRuntime.jsx)(_Options.default,{containerClass:opsContainerClass,containerStyle:opsPos,onCancel:()=>{setActive(false)},onChange:newValue=>{setActive(false);if(onChange)onChange(newValue)},optionClass:theme.option??"",options:options,ref:opsRef}):null]})};var _default=exports.default=(0,_reactThemes.default)(BaseCustomDropdown,"CustomDropdown",defaultTheme);
7
+ setOpsPos({left:view?.width??0,top:view?.height??0,width:rect.width});e.stopPropagation()};let selected=/*#__PURE__*/_jsx(_Fragment,{children:"\u200C"});for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);if(iValue===value){selected=iName;break}}}let containerClassName=theme.container;if(active)containerClassName+=` ${theme.active}`;let opsContainerClass=theme.select??"";if(upward){containerClassName+=` ${theme.upward}`;opsContainerClass+=` ${theme.upward}`}return/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:theme.label,children:label}),/*#__PURE__*/_jsxs("div",{className:theme.dropdown,onClick:openList,onKeyDown:e=>{if(e.key==="Enter")openList(e)},ref:dropdownRef,role:"listbox",tabIndex:0,children:[selected,/*#__PURE__*/_jsx("div",{className:theme.arrow})]}),active?/*#__PURE__*/_jsx(Options,{containerClass:opsContainerClass,containerStyle:opsPos,onCancel:()=>{setActive(false)},onChange:newValue=>{setActive(false);if(onChange)onChange(newValue)},optionClass:theme.option??"",options:options,ref:opsRef}):null]})};export default/* #__PURE__ */themed(BaseCustomDropdown,"CustomDropdown",defaultTheme);
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","require","_reactThemes","_interopRequireDefault","_common","_Options","_interopRequireWildcard","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","defaultTheme","BaseCustomDropdown","filter","label","onChange","options","theme","value","active","setActive","useState","dropdownRef","useRef","opsRef","opsPos","setOpsPos","upward","setUpward","useEffect","undefined","id","cb","anchor","current","getBoundingClientRect","opsRect","measure","fitsDown","bottom","height","window","visualViewport","fitsUp","top","up","pos","left","width","now","areEqual","requestAnimationFrame","cancelAnimationFrame","openList","view","rect","stopPropagation","selected","jsx","Fragment","children","option","iValue","iName","optionValueName","containerClassName","container","opsContainerClass","select","jsxs","className","dropdown","onClick","onKeyDown","key","ref","role","tabIndex","arrow","containerClass","containerStyle","onCancel","newValue","optionClass","_default","exports","themed"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport themed from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst BaseCustomDropdown: React.FunctionComponent<\n PropsT<React.ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>&zwnj;</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = theme.container;\n if (active) containerClassName += ` ${theme.active}`;\n\n let opsContainerClass = theme.select ?? '';\n if (upward) {\n containerClassName += ` ${theme.upward}`;\n opsContainerClass += ` ${theme.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={theme.label}>{label}</div>}\n <div\n className={theme.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={theme.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={theme.option ?? ''}\n options={options}\n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EJ3D,MAAM,cACJ,GAAA5B,WAAA,CAAAmE,GAAA,EAACrE,QAAA,CAAAa,OAAO,EACN6E,cAAc,CAAEZ,iBAAkB,CAClCa,cAAc,CAAEvD,MAAO,CACvBwD,QAAQ,CAAEA,CAAA,GAAM,CACd7D,SAAS,CAAC,KAAK,CACjB,CAAE,CACFL,QAAQ,CAAGmE,QAAQ,EAAK,CACtB9D,SAAS,CAAC,KAAK,CAAC,CAChB,GAAIL,QAAQ,CAAEA,QAAQ,CAACmE,QAAQ,CACjC,CAAE,CACFC,WAAW,CAAElE,KAAK,CAAC4C,MAAM,EAAI,EAAG,CAChC7C,OAAO,CAAEA,OAAQ,CACjB2D,GAAG,CAAEnD,MAAO,CACb,CAAC,CACA,IAAI,EAEP,CAET,CAAC,CAAC,IAAA4D,QAAA,CAAAC,OAAA,CAAAnF,OAAA,CAEa,GAAAoF,oBAAM,EAAC1E,kBAAkB,CAAE,gBAAgB,CAAED,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useRef","useState","themed","optionValueName","Options","areEqual","defaultTheme","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","BaseCustomDropdown","filter","label","onChange","options","theme","value","active","setActive","dropdownRef","opsRef","opsPos","setOpsPos","upward","setUpward","undefined","id","cb","anchor","current","getBoundingClientRect","opsRect","measure","fitsDown","bottom","height","window","visualViewport","fitsUp","top","up","pos","left","width","now","requestAnimationFrame","cancelAnimationFrame","openList","e","view","rect","stopPropagation","selected","children","option","iValue","iName","containerClassName","container","opsContainerClass","select","className","dropdown","onClick","onKeyDown","key","ref","role","tabIndex","arrow","containerClass","containerStyle","onCancel","newValue","optionClass"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport themed from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst BaseCustomDropdown: React.FunctionComponent<\n PropsT<React.ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>&zwnj;</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = theme.container;\n if (active) containerClassName += ` ${theme.active}`;\n\n let opsContainerClass = theme.select ?? '';\n if (upward) {\n containerClassName += ` ${theme.upward}`;\n opsContainerClass += ` ${theme.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={theme.label}>{label}</div>}\n <div\n className={theme.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={theme.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={theme.option ?? ''}\n options={options}\n ref={opsRef}\n />\n ) : null\n }\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(BaseCustomDropdown, 'CustomDropdown', defaultTheme);\n"],"mappings":"kMAAA,OAASA,SAAS,CAAEC,MAAM,CAAEC,QAAQ,KAAQ,OAAO,CAEnD,MAAO,CAAAC,MAAM,KAAM,0BAA0B,QAEVC,eAAe,0BAE3C,CAAAC,OAAO,EAAmCC,QAAQ,gCAAAC,YAAA,wMAEjB,OAAAC,QAAA,IAAAC,SAAA,CAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAExC,KAAM,CAAAC,kBAEL,CAAGA,CAAC,CACHC,MAAM,CACNC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,KAAM,CAACC,MAAM,CAAEC,SAAS,CAAC,CAAGpB,QAAQ,CAAC,KAAK,CAAC,CAE3C,KAAM,CAAAqB,WAAW,CAAGtB,MAAM,CAAiB,IAAI,CAAC,CAChD,KAAM,CAAAuB,MAAM,CAAGvB,MAAM,CAAO,IAAI,CAAC,CAEjC,KAAM,CAACwB,MAAM,CAAEC,SAAS,CAAC,CAAGxB,QAAQ,CAAgB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"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _common=require("../common");var _jsxRuntime=require("react/jsx-runtime");// Implements dropdown based on the native HTML <select> element.
2
- const defaultTheme={"context":"xHyZo4","ad":"ADu59e","hoc":"FTP2bb","dropdown":"kI9A9U","arrow":"DubGkT","container":"WtSZPd","active":"ayMn7O","label":"K7JYKw","option":"_27pZ6W","hiddenOption":"clAKFJ","select":"N0Fc14","invalid":"wL4umU"};/**
1
+ import"core-js/modules/es.array.push.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";// Implements dropdown based on the native HTML <select> element.
2
+ import themed from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";const defaultTheme={"context":"WbwY1Y","ad":"AP5hsY","hoc":"ODAJeW","dropdown":"wabw76","arrow":"WFSB9z","container":"vE9M8Z","active":"sfLSJA","label":"bQLBhS","option":"wgCtdC","hiddenOption":"ty19C2","select":"ntbzPR","invalid":"_3CzMM4"};/**
3
3
  * Implements a themeable dropdown list. Internally it is rendered with help of
4
4
  * the standard HTML `<select>` element, thus the styling support is somewhat
5
5
  * limited.
@@ -17,9 +17,9 @@ const defaultTheme={"context":"xHyZo4","ad":"ADu59e","hoc":"FTP2bb","dropdown":"
17
17
  * @param [props.value] Currently selected value.
18
18
  * @param [props....]
19
19
  * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
20
- */const Dropdown=({filter,label,onChange,options,testId,theme,value})=>{let isValidValue=false;const optionElements=[];for(const option of options){if(!filter||filter(option)){const[iValue,iName]=(0,_common.optionValueName)(option);isValidValue||=iValue===value;optionElements.push(/*#__PURE__*/(0,_jsxRuntime.jsx)("option",{className:theme.option,value:iValue,children:iName},iValue))}}// NOTE: This element represents the current `value` when it does not match
20
+ */import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Dropdown=({filter,label,onChange,options,testId,theme,value})=>{let isValidValue=false;const optionElements=[];for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);isValidValue||=iValue===value;optionElements.push(/*#__PURE__*/_jsx("option",{className:theme.option,value:iValue,children:iName},iValue))}}// NOTE: This element represents the current `value` when it does not match
21
21
  // any valid option. In Chrome, and some other browsers, we are able to hide
22
22
  // it from the opened dropdown; in others, e.g. Safari, the best we can do is
23
23
  // to show it as disabled.
24
- const hiddenOption=isValidValue?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("option",{className:theme.hiddenOption,disabled:true,value:value,children:value},"__reactUtilsHiddenOption");let selectClassName=theme.select;if(!isValidValue)selectClassName+=` ${theme.invalid}`;return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.container,children:[label===undefined?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.dropdown,children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)("select",{className:selectClassName,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onChange:onChange,value:value,children:[hiddenOption,optionElements]}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.arrow})]})]})};var _default=exports.default=(0,_reactThemes.default)(Dropdown,"Dropdown",defaultTheme);
24
+ const hiddenOption=isValidValue?null:/*#__PURE__*/_jsx("option",{className:theme.hiddenOption,disabled:true,value:value,children:value},"__reactUtilsHiddenOption");let selectClassName=theme.select;if(!isValidValue)selectClassName+=` ${theme.invalid}`;return/*#__PURE__*/_jsxs("div",{className:theme.container,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:theme.label,children:label}),/*#__PURE__*/_jsxs("div",{className:theme.dropdown,children:[/*#__PURE__*/_jsxs("select",{className:selectClassName,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onChange:onChange,value:value,children:[hiddenOption,optionElements]}),/*#__PURE__*/_jsx("div",{className:theme.arrow})]})]})};export default/* #__PURE__ */themed(Dropdown,"Dropdown",defaultTheme);
25
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireDefault","require","_common","_jsxRuntime","defaultTheme","Dropdown","filter","label","onChange","options","testId","theme","value","isValidValue","optionElements","option","iValue","iName","optionValueName","push","jsx","className","children","hiddenOption","disabled","selectClassName","select","invalid","jsxs","container","undefined","dropdown","process","env","NODE_ENV","arrow","_default","exports","default","themed"],"sources":["../../../../../../src/shared/components/selectors/NativeDropdown/index.tsx"],"sourcesContent":["// Implements dropdown based on the native HTML <select> element.\n\nimport themed from '@dr.pogodin/react-themes';\n\nimport { type PropsT, optionValueName } from '../common';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param [props] Component properties.\n * @param [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param [props.label] Dropdown label.\n * @param [props.onChange] Selection event handler.\n * @param [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.value] Currently selected value.\n * @param [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Dropdown: React.FunctionComponent<PropsT<string>> = ({\n filter,\n label,\n onChange,\n options,\n testId,\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n isValidValue ||= iValue === value;\n optionElements.push(\n <option className={theme.option} key={iValue} value={iValue}>\n {iName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n className={theme.hiddenOption}\n disabled\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n let selectClassName = theme.select;\n if (!isValidValue) selectClassName += ` ${theme.invalid}`;\n\n return (\n <div className={theme.container}>\n { label === undefined\n ? null : <div className={theme.label}>{label}</div> }\n <div className={theme.dropdown}>\n <select\n className={selectClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={theme.arrow} />\n </div>\n </div>\n );\n};\n\nexport default themed(Dropdown, 'Dropdown', defaultTheme);\n"],"mappings":"gLAEA,IAAAA,YAAA,CAAAC,sBAAA,CAAAC,OAAA,8BAEA,IAAAC,OAAA,CAAAD,OAAA,cAAyD,IAAAE,WAAA,CAAAF,OAAA,sBAJzD;AAAA,MAAAG,YAAA,gOAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,QAAiD,CAAGA,CAAC,CACzDC,MAAM,CACNC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,MAAM,CACNC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,GAAI,CAAAC,YAAY,CAAG,KAAK,CACxB,KAAM,CAAAC,cAAc,CAAG,EAAE,CAEzB,IAAK,KAAM,CAAAC,MAAM,GAAI,CAAAN,OAAO,CAAE,CAC5B,GAAI,CAACH,MAAM,EAAIA,MAAM,CAACS,MAAM,CAAC,CAAE,CAC7B,KAAM,CAACC,MAAM,CAAEC,KAAK,CAAC,CAAG,GAAAC,uBAAe,EAACH,MAAM,CAAC,CAC/CF,YAAY,GAAKG,MAAM,GAAKJ,KAAK,CACjCE,cAAc,CAACK,IAAI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CAAAC,OAAA,CAAAC,OAAA,CAEa,GAAAC,oBAAM,EAAClC,QAAQ,CAAE,UAAU,CAAED,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["themed","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Dropdown","filter","label","onChange","options","testId","theme","value","isValidValue","optionElements","option","iValue","iName","push","className","children","hiddenOption","disabled","selectClassName","select","invalid","container","undefined","dropdown","process","env","NODE_ENV","arrow"],"sources":["../../../../../../src/shared/components/selectors/NativeDropdown/index.tsx"],"sourcesContent":["// Implements dropdown based on the native HTML <select> element.\n\nimport themed from '@dr.pogodin/react-themes';\n\nimport { type PropsT, optionValueName } from '../common';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param [props] Component properties.\n * @param [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param [props.label] Dropdown label.\n * @param [props.onChange] Selection event handler.\n * @param [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.value] Currently selected value.\n * @param [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Dropdown: React.FunctionComponent<PropsT<string>> = ({\n filter,\n label,\n onChange,\n options,\n testId,\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n isValidValue ||= iValue === value;\n optionElements.push(\n <option className={theme.option} key={iValue} value={iValue}>\n {iName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n className={theme.hiddenOption}\n disabled\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n let selectClassName = theme.select;\n if (!isValidValue) selectClassName += ` ${theme.invalid}`;\n\n return (\n <div className={theme.container}>\n { label === undefined\n ? null : <div className={theme.label}>{label}</div> }\n <div className={theme.dropdown}>\n <select\n className={selectClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={theme.arrow} />\n </div>\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(Dropdown, 'Dropdown', defaultTheme);\n"],"mappings":"oRAAA;AAEA,MAAO,CAAAA,MAAM,KAAM,0BAA0B,QAEvBC,eAAe,0BAAAC,YAAA,gOAIrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlBA,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAmBA,KAAM,CAAAC,QAAiD,CAAGA,CAAC,CACzDC,MAAM,CACNC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,MAAM,CACNC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,GAAI,CAAAC,YAAY,CAAG,KAAK,CACxB,KAAM,CAAAC,cAAc,CAAG,EAAE,CAEzB,IAAK,KAAM,CAAAC,MAAM,GAAI,CAAAN,OAAO,CAAE,CAC5B,GAAI,CAACH,MAAM,EAAIA,MAAM,CAACS,MAAM,CAAC,CAAE,CAC7B,KAAM,CAACC,MAAM,CAAEC,KAAK,CAAC,CAAGlB,eAAe,CAACgB,MAAM,CAAC,CAC/CF,YAAY,GAAKG,MAAM,GAAKJ,KAAK,CACjCE,cAAc,CAACI,IAAI,cACjBhB,IAAA,WAAQiB,SAAS,CAAER,KAAK,CAACI,MAAO,CAAcH,KAAK,CAAEI,MAAO,CAAAI,QAAA,CACzDH,KAAK,EAD8BD,MAE9B,CACV,CACF,CACF,CAEA;AACA;AACA;AACA;AACA,KAAM,CAAAK,YAAY,CAAGR,YAAY,CAAG,IAAI,cACtCX,IAAA,WACEiB,SAAS,CAAER,KAAK,CAACU,YAAa,CAC9BC,QAAQ,MAERV,KAAK,CAAEA,KAAM,CAAAQ,QAAA,CAEZR,KAAK,EAHF,0BAIE,CACT,CAED,GAAI,CAAAW,eAAe,CAAGZ,KAAK,CAACa,MAAM,CAClC,GAAI,CAACX,YAAY,CAAEU,eAAe,EAAI,IAAIZ,KAAK,CAACc,OAAO,EAAE,CAEzD,mBACErB,KAAA,QAAKe,SAAS,CAAER,KAAK,CAACe,SAAU,CAAAN,QAAA,EAC5Bb,KAAK,GAAKoB,SAAS,CACjB,IAAI,cAAGzB,IAAA,QAAKiB,SAAS,CAAER,KAAK,CAACJ,KAAM,CAAAa,QAAA,CAAEb,KAAK,CAAM,CAAC,cACrDH,KAAA,QAAKe,SAAS,CAAER,KAAK,CAACiB,QAAS,CAAAR,QAAA,eAC7BhB,KAAA,WACEe,SAAS,CAAEI,eAAgB,CAC3B,cAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGJ,SAAS,CAAGjB,MAAO,CACxEF,QAAQ,CAAEA,QAAS,CACnBI,KAAK,CAAEA,KAAM,CAAAQ,QAAA,EAEZC,YAAY,CACZP,cAAc,EACT,CAAC,cACTZ,IAAA,QAAKiB,SAAS,CAAER,KAAK,CAACqB,KAAM,CAAE,CAAC,EAC5B,CAAC,EACH,CAET,CAAC,CAED,cAAe,eAAgBlC,MAAM,CAACO,QAAQ,CAAE,UAAU,CAAEL,YAAY,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _common=require("../common");var _jsxRuntime=require("react/jsx-runtime");const defaultTheme={"context":"VMHfnP","ad":"HNliRC","hoc":"_2Ue-db","container":"AWNvRj","option":"fUfIAd","selected":"Wco-qk","options":"CZYtcC"};const BaseSwitch=({label,onChange,options,theme,value})=>{if(!options||!theme.option)throw Error("Internal error");const optionNodes=[];for(const option of options){const[iValue,iName]=(0,_common.optionValueName)(option);let className=theme.option;let onPress;if(iValue===value)className+=` ${theme.selected}`;else if(onChange){onPress=()=>{onChange(iValue)}}optionNodes.push(onPress?/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:className,onClick:onPress,onKeyDown:e=>{if(e.key==="Enter")onPress()},role:"button",tabIndex:0,children:iName},iValue):/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:className,children:iName},iValue))}return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.container,children:[label?/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.label,children:label}):null,/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.options,children:optionNodes})]})};var _default=exports.default=(0,_reactThemes.default)(BaseSwitch,"Switch",defaultTheme);
1
+ import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.push.js";import themed from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";const defaultTheme={"context":"akD3dQ","ad":"xcXtdE","hoc":"N3iziJ","container":"BYeWyJ","option":"_7MFXEN","selected":"CDbWAd","options":"_9-eOZo"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const BaseSwitch=({label,onChange,options,theme,value})=>{if(!options||!theme.option)throw Error("Internal error");const optionNodes=[];for(const option of options){const[iValue,iName]=optionValueName(option);let className=theme.option;let onPress;if(iValue===value)className+=` ${theme.selected}`;else if(onChange){onPress=()=>{onChange(iValue)}}optionNodes.push(onPress?/*#__PURE__*/_jsx("div",{className:className,onClick:onPress,onKeyDown:e=>{if(e.key==="Enter")onPress()},role:"button",tabIndex:0,children:iName},iValue):/*#__PURE__*/_jsx("div",{className:className,children:iName},iValue))}return/*#__PURE__*/_jsxs("div",{className:theme.container,children:[label?/*#__PURE__*/_jsx("div",{className:theme.label,children:label}):null,/*#__PURE__*/_jsx("div",{className:theme.options,children:optionNodes})]})};export default/* #__PURE__ */themed(BaseSwitch,"Switch",defaultTheme);
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireDefault","require","_common","_jsxRuntime","defaultTheme","BaseSwitch","label","onChange","options","theme","value","option","Error","optionNodes","iValue","iName","optionValueName","className","onPress","selected","push","jsx","onClick","onKeyDown","e","key","role","tabIndex","children","jsxs","container","_default","exports","default","themed"],"sources":["../../../../../../src/shared/components/selectors/Switch/index.tsx"],"sourcesContent":["import themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport {\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../common';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'container' | 'label' | 'option' | 'options' | 'selected';\n\ntype PropsT = {\n label?: React.ReactNode;\n onChange?: (value: ValueT) => void;\n options?: Readonly<OptionsT<React.ReactNode>>;\n theme: Theme<ThemeKeyT>;\n value?: ValueT;\n};\n\nconst BaseSwitch: React.FunctionComponent<PropsT> = ({\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n if (!options || !theme.option) throw Error('Internal error');\n\n const optionNodes: React.ReactNode[] = [];\n for (const option of options) {\n const [iValue, iName] = optionValueName(option);\n\n let className: string = theme.option;\n let onPress: (() => void) | undefined;\n if (iValue === value) className += ` ${theme.selected}`;\n else if (onChange) {\n onPress = () => {\n onChange(iValue);\n };\n }\n\n optionNodes.push(\n onPress\n ? (\n <div\n className={className}\n key={iValue}\n onClick={onPress}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onPress();\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>\n )\n : <div className={className} key={iValue}>{iName}</div>,\n );\n }\n\n return (\n <div className={theme.container}>\n {label ? <div className={theme.label}>{label}</div> : null}\n\n <div className={theme.options}>\n {optionNodes}\n </div>\n </div>\n );\n};\n\nexport default themed(BaseSwitch, 'Switch', defaultTheme);\n"],"mappings":"gLAAA,IAAAA,YAAA,CAAAC,sBAAA,CAAAC,OAAA,8BAEA,IAAAC,OAAA,CAAAD,OAAA,cAImB,IAAAE,WAAA,CAAAF,OAAA,4BAAAG,YAAA,kIAcnB,KAAM,CAAAC,UAA2C,CAAGA,CAAC,CACnDC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,GAAI,CAACF,OAAO,EAAI,CAACC,KAAK,CAACE,MAAM,CAAE,KAAM,CAAAC,KAAK,CAAC,gBAAgB,CAAC,CAE5D,KAAM,CAAAC,WAA8B,CAAG,EAAE,CACzC,IAAK,KAAM,CAAAF,MAAM,GAAI,CAAAH,OAAO,CAAE,CAC5B,KAAM,CAACM,MAAM,CAAEC,KAAK,CAAC,CAAG,GAAAC,uBAAe,EAACL,MAAM,CAAC,CAE/C,GAAI,CAAAM,SAAiB,CAAGR,KAAK,CAACE,MAAM,CACpC,GAAI,CAAAO,OAAiC,CACrC,GAAIJ,MAAM,GAAKJ,KAAK,CAAEO,SAAS,EAAI,IAAIR,KAAK,CAACU,QAAQ,EAAE,CAAC,IACnD,IAAIZ,QAAQ,CAAE,CACjBW,OAAO,CAAGA,CAAA,GAAM,CACdX,QAAQ,CAACO,MAAM,CACjB,CACF,CAEAD,WAAW,CAACO,IAAI,CACdF,OAAO,cAEH,GAAAf,WAAA,CAAAkB,GAAA,SACEJ,SAAS,CAAEA,SAAU,CAErBK,OAAO,CAAEJ,OAAQ,CACjBK,SAAS,CAAGC,CAAC,EAAK,CAChB,GAAIA,CAAC,CAACC,GAAG,GAAK,OAAO,CAAEP,OAAO,CAAC,CACjC,CAAE,CACFQ,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAAC,QAAA,CAEXb,KAAK,EARDD,MASF,CAAC,cAEN,GAAAX,WAAA,CAAAkB,GAAA,SAAKJ,SAAS,CAAEA,SAAU,CAAAW,QAAA,CAAeb,KAAK,EAAdD,MAAoB,CAC1D,CACF,CAEA,mBACE,GAAAX,WAAA,CAAA0B,IAAA,SAAKZ,SAAS,CAAER,KAAK,CAACqB,SAAU,CAAAF,QAAA,EAC7BtB,KAAK,cAAG,GAAAH,WAAA,CAAAkB,GAAA,SAAKJ,SAAS,CAAER,KAAK,CAACH,KAAM,CAAAsB,QAAA,CAAEtB,KAAK,CAAM,CAAC,CAAG,IAAI,cAE1D,GAAAH,WAAA,CAAAkB,GAAA,SAAKJ,SAAS,CAAER,KAAK,CAACD,OAAQ,CAAAoB,QAAA,CAC3Bf,WAAW,CACT,CAAC,EACH,CAET,CAAC,CAAC,IAAAkB,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEa,GAAAC,oBAAM,EAAC7B,UAAU,CAAE,QAAQ,CAAED,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["themed","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","BaseSwitch","label","onChange","options","theme","value","option","Error","optionNodes","iValue","iName","className","onPress","selected","push","onClick","onKeyDown","e","key","role","tabIndex","children","container"],"sources":["../../../../../../src/shared/components/selectors/Switch/index.tsx"],"sourcesContent":["import themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport {\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../common';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'container' | 'label' | 'option' | 'options' | 'selected';\n\ntype PropsT = {\n label?: React.ReactNode;\n onChange?: (value: ValueT) => void;\n options?: Readonly<OptionsT<React.ReactNode>>;\n theme: Theme<ThemeKeyT>;\n value?: ValueT;\n};\n\nconst BaseSwitch: React.FunctionComponent<PropsT> = ({\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n if (!options || !theme.option) throw Error('Internal error');\n\n const optionNodes: React.ReactNode[] = [];\n for (const option of options) {\n const [iValue, iName] = optionValueName(option);\n\n let className: string = theme.option;\n let onPress: (() => void) | undefined;\n if (iValue === value) className += ` ${theme.selected}`;\n else if (onChange) {\n onPress = () => {\n onChange(iValue);\n };\n }\n\n optionNodes.push(\n onPress\n ? (\n <div\n className={className}\n key={iValue}\n onClick={onPress}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onPress();\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>\n )\n : <div className={className} key={iValue}>{iName}</div>,\n );\n }\n\n return (\n <div className={theme.container}>\n {label ? <div className={theme.label}>{label}</div> : null}\n\n <div className={theme.options}>\n {optionNodes}\n </div>\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(BaseSwitch, 'Switch', defaultTheme);\n"],"mappings":"kFAAA,MAAO,CAAAA,MAAM,KAAsB,0BAA0B,QAK3DC,eAAe,0BAAAC,YAAA,mIAGuB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAYxC,KAAM,CAAAC,UAA2C,CAAGA,CAAC,CACnDC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,GAAI,CAACF,OAAO,EAAI,CAACC,KAAK,CAACE,MAAM,CAAE,KAAM,CAAAC,KAAK,CAAC,gBAAgB,CAAC,CAE5D,KAAM,CAAAC,WAA8B,CAAG,EAAE,CACzC,IAAK,KAAM,CAAAF,MAAM,GAAI,CAAAH,OAAO,CAAE,CAC5B,KAAM,CAACM,MAAM,CAAEC,KAAK,CAAC,CAAGhB,eAAe,CAACY,MAAM,CAAC,CAE/C,GAAI,CAAAK,SAAiB,CAAGP,KAAK,CAACE,MAAM,CACpC,GAAI,CAAAM,OAAiC,CACrC,GAAIH,MAAM,GAAKJ,KAAK,CAAEM,SAAS,EAAI,IAAIP,KAAK,CAACS,QAAQ,EAAE,CAAC,IACnD,IAAIX,QAAQ,CAAE,CACjBU,OAAO,CAAGA,CAAA,GAAM,CACdV,QAAQ,CAACO,MAAM,CACjB,CACF,CAEAD,WAAW,CAACM,IAAI,CACdF,OAAO,cAEHf,IAAA,QACEc,SAAS,CAAEA,SAAU,CAErBI,OAAO,CAAEH,OAAQ,CACjBI,SAAS,CAAGC,CAAC,EAAK,CAChB,GAAIA,CAAC,CAACC,GAAG,GAAK,OAAO,CAAEN,OAAO,CAAC,CACjC,CAAE,CACFO,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAAC,QAAA,CAEXX,KAAK,EARDD,MASF,CAAC,cAENZ,IAAA,QAAKc,SAAS,CAAEA,SAAU,CAAAU,QAAA,CAAeX,KAAK,EAAdD,MAAoB,CAC1D,CACF,CAEA,mBACEV,KAAA,QAAKY,SAAS,CAAEP,KAAK,CAACkB,SAAU,CAAAD,QAAA,EAC7BpB,KAAK,cAAGJ,IAAA,QAAKc,SAAS,CAAEP,KAAK,CAACH,KAAM,CAAAoB,QAAA,CAAEpB,KAAK,CAAM,CAAC,CAAG,IAAI,cAE1DJ,IAAA,QAAKc,SAAS,CAAEP,KAAK,CAACD,OAAQ,CAAAkB,QAAA,CAC3Bb,WAAW,CACT,CAAC,EACH,CAET,CAAC,CAED,cAAe,eAAgBf,MAAM,CAACO,UAAU,CAAE,QAAQ,CAAEL,YAAY,CAAC","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.optionValueName=optionValueName;// The stuff common between different dropdown implementations.
2
- function isValue(x){const type=typeof x;return type==="number"||type==="string"}/** Returns option value and name as a tuple. */function optionValueName(option){return isValue(option)?[option,option]:[option.value,option.name??option.value]}
1
+ // The stuff common between different dropdown implementations.
2
+ function isValue(x){const type=typeof x;return type==="number"||type==="string"}/** Returns option value and name as a tuple. */export function optionValueName(option){return isValue(option)?[option,option]:[option.value,option.name??option.value]}
3
3
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":["isValue","x","type","optionValueName","option","value","name"],"sources":["../../../../../src/shared/components/selectors/common.ts"],"sourcesContent":["// The stuff common between different dropdown implementations.\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\ntype ThemeKeyT = 'active'\n | 'arrow'\n | 'container'\n | 'dropdown'\n | 'hiddenOption'\n | 'label'\n | 'option'\n | 'select'\n\n // TODO: This is currently only valid for (native) <Dropdown>,\n // other kinds of selectors should be evaluated, and aligned with this\n // feature, if appropriate.\n | 'invalid'\n\n // TODO: This is only valid for <CustomDropdown>, thus we need to re-factor it\n // into a separate theme spec for that component.\n | 'upward';\n\nexport type ValueT = number | string;\n\nexport type OptionT<NameT> = {\n name?: NameT | null;\n value: ValueT;\n};\n\nexport type OptionsT<NameT> = Readonly<Array<OptionT<NameT> | ValueT>>;\n\nexport type PropsT<\n NameT,\n OnChangeT = React.ChangeEventHandler<HTMLSelectElement>,\n> = {\n filter?: (item: OptionT<NameT> | ValueT) => boolean;\n label?: React.ReactNode;\n onChange?: OnChangeT;\n options: Readonly<OptionsT<NameT>>;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n value?: ValueT;\n};\n\nfunction isValue<T>(x: OptionT<T> | ValueT): x is ValueT {\n const type = typeof x;\n return type === 'number' || type === 'string';\n}\n\n/** Returns option value and name as a tuple. */\nexport function optionValueName<NameT>(\n option: OptionT<NameT> | ValueT,\n): [ValueT, NameT | ValueT] {\n return isValue(option)\n ? [option, option]\n : [option.value, option.name ?? option.value];\n}\n"],"mappings":"8GAAA;AA4CA,QAAS,CAAAA,OAAOA,CAAIC,CAAsB,CAAe,CACvD,KAAM,CAAAC,IAAI,CAAG,MAAO,CAAAD,CAAC,CACrB,MAAO,CAAAC,IAAI,GAAK,QAAQ,EAAIA,IAAI,GAAK,QACvC,CAEA,gDACO,QAAS,CAAAC,eAAeA,CAC7BC,MAA+B,CACL,CAC1B,MAAO,CAAAJ,OAAO,CAACI,MAAM,CAAC,CAClB,CAACA,MAAM,CAAEA,MAAM,CAAC,CAChB,CAACA,MAAM,CAACC,KAAK,CAAED,MAAM,CAACE,IAAI,EAAIF,MAAM,CAACC,KAAK,CAChD","ignoreList":[]}
1
+ {"version":3,"file":"common.js","names":["isValue","x","type","optionValueName","option","value","name"],"sources":["../../../../../src/shared/components/selectors/common.ts"],"sourcesContent":["// The stuff common between different dropdown implementations.\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\ntype ThemeKeyT = 'active'\n | 'arrow'\n | 'container'\n | 'dropdown'\n | 'hiddenOption'\n | 'label'\n | 'option'\n | 'select'\n\n // TODO: This is currently only valid for (native) <Dropdown>,\n // other kinds of selectors should be evaluated, and aligned with this\n // feature, if appropriate.\n | 'invalid'\n\n // TODO: This is only valid for <CustomDropdown>, thus we need to re-factor it\n // into a separate theme spec for that component.\n | 'upward';\n\nexport type ValueT = number | string;\n\nexport type OptionT<NameT> = {\n name?: NameT | null;\n value: ValueT;\n};\n\nexport type OptionsT<NameT> = Readonly<Array<OptionT<NameT> | ValueT>>;\n\nexport type PropsT<\n NameT,\n OnChangeT = React.ChangeEventHandler<HTMLSelectElement>,\n> = {\n filter?: (item: OptionT<NameT> | ValueT) => boolean;\n label?: React.ReactNode;\n onChange?: OnChangeT;\n options: Readonly<OptionsT<NameT>>;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n value?: ValueT;\n};\n\nfunction isValue<T>(x: OptionT<T> | ValueT): x is ValueT {\n const type = typeof x;\n return type === 'number' || type === 'string';\n}\n\n/** Returns option value and name as a tuple. */\nexport function optionValueName<NameT>(\n option: OptionT<NameT> | ValueT,\n): [ValueT, NameT | ValueT] {\n return isValue(option)\n ? [option, option]\n : [option.value, option.name ?? option.value];\n}\n"],"mappings":"AAAA;AA4CA,QAAS,CAAAA,OAAOA,CAAIC,CAAsB,CAAe,CACvD,KAAM,CAAAC,IAAI,CAAG,MAAO,CAAAD,CAAC,CACrB,MAAO,CAAAC,IAAI,GAAK,QAAQ,EAAIA,IAAI,GAAK,QACvC,CAEA,gDACA,MAAO,SAAS,CAAAC,eAAeA,CAC7BC,MAA+B,CACL,CAC1B,MAAO,CAAAJ,OAAO,CAACI,MAAM,CAAC,CAClB,CAACA,MAAM,CAAEA,MAAM,CAAC,CAChB,CAACA,MAAM,CAACC,KAAK,CAAED,MAAM,CAACE,IAAI,EAAIF,MAAM,CAACC,KAAK,CAChD","ignoreList":[]}