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

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 (237) hide show
  1. package/babel.config.js +1 -0
  2. package/babel.libweb.config.js +16 -0
  3. package/bin/build.js +16 -10
  4. package/bin/setup.js +11 -8
  5. package/build/development/client/getInj.js.map +1 -1
  6. package/build/development/client/index.js.map +1 -1
  7. package/build/development/client/init.js.map +1 -1
  8. package/build/development/index.js +7 -1
  9. package/build/development/index.js.map +1 -1
  10. package/build/development/server/Cache.js.map +1 -1
  11. package/build/development/server/index.js +13 -8
  12. package/build/development/server/index.js.map +1 -1
  13. package/build/development/server/renderer.js +15 -8
  14. package/build/development/server/renderer.js.map +1 -1
  15. package/build/development/server/server.js +7 -5
  16. package/build/development/server/server.js.map +1 -1
  17. package/build/development/shared/components/Button/index.js +6 -6
  18. package/build/development/shared/components/Button/index.js.map +1 -1
  19. package/build/development/shared/components/Checkbox/index.js +8 -8
  20. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  21. package/build/development/shared/components/GenericLink/index.js +5 -1
  22. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  23. package/build/development/shared/components/Input/index.js +10 -9
  24. package/build/development/shared/components/Input/index.js.map +1 -1
  25. package/build/development/shared/components/Link.js.map +1 -1
  26. package/build/development/shared/components/Modal/index.js +8 -6
  27. package/build/development/shared/components/Modal/index.js.map +1 -1
  28. package/build/development/shared/components/NavLink.js.map +1 -1
  29. package/build/development/shared/components/PageLayout/index.js +6 -6
  30. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  31. package/build/development/shared/components/TextArea/index.js +13 -9
  32. package/build/development/shared/components/TextArea/index.js.map +1 -1
  33. package/build/development/shared/components/Throbber/index.js +6 -6
  34. package/build/development/shared/components/Throbber/index.js.map +1 -1
  35. package/build/development/shared/components/WithTooltip/Tooltip.js +1 -0
  36. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  37. package/build/development/shared/components/WithTooltip/index.js +7 -7
  38. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  39. package/build/development/shared/components/YouTubeVideo/index.js +9 -9
  40. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  41. package/build/development/shared/components/index.js.map +1 -1
  42. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
  43. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  44. package/build/development/shared/components/selectors/CustomDropdown/index.js +11 -11
  45. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  46. package/build/development/shared/components/selectors/NativeDropdown/index.js +12 -12
  47. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  48. package/build/development/shared/components/selectors/Switch/index.js +7 -7
  49. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  50. package/build/development/shared/utils/config.js.map +1 -1
  51. package/build/development/shared/utils/globalState.js.map +1 -1
  52. package/build/development/shared/utils/index.js.map +1 -1
  53. package/build/development/shared/utils/jest/E2eSsrEnv.js +14 -10
  54. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  55. package/build/development/shared/utils/splitComponent.js +1 -0
  56. package/build/development/shared/utils/splitComponent.js.map +1 -1
  57. package/build/development/shared/utils/time.js.map +1 -1
  58. package/build/production/client/getInj.js.map +1 -1
  59. package/build/production/client/index.js.map +1 -1
  60. package/build/production/client/init.js.map +1 -1
  61. package/build/production/index.js +4 -1
  62. package/build/production/index.js.map +1 -1
  63. package/build/production/server/Cache.js.map +1 -1
  64. package/build/production/server/index.js +5 -5
  65. package/build/production/server/index.js.map +1 -1
  66. package/build/production/server/renderer.js +7 -7
  67. package/build/production/server/renderer.js.map +1 -1
  68. package/build/production/server/server.js +4 -4
  69. package/build/production/server/server.js.map +1 -1
  70. package/build/production/shared/components/Button/index.js +1 -1
  71. package/build/production/shared/components/Button/index.js.map +1 -1
  72. package/build/production/shared/components/Checkbox/index.js +1 -1
  73. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  74. package/build/production/shared/components/GenericLink/index.js +2 -2
  75. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  76. package/build/production/shared/components/Input/index.js +1 -1
  77. package/build/production/shared/components/Input/index.js.map +1 -1
  78. package/build/production/shared/components/Link.js.map +1 -1
  79. package/build/production/shared/components/Modal/index.js +1 -1
  80. package/build/production/shared/components/Modal/index.js.map +1 -1
  81. package/build/production/shared/components/NavLink.js.map +1 -1
  82. package/build/production/shared/components/PageLayout/index.js +1 -1
  83. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  84. package/build/production/shared/components/TextArea/index.js +1 -1
  85. package/build/production/shared/components/TextArea/index.js.map +1 -1
  86. package/build/production/shared/components/Throbber/index.js +1 -1
  87. package/build/production/shared/components/Throbber/index.js.map +1 -1
  88. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  89. package/build/production/shared/components/WithTooltip/index.js +1 -1
  90. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  91. package/build/production/shared/components/YouTubeVideo/index.js +1 -1
  92. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  93. package/build/production/shared/components/index.js.map +1 -1
  94. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
  95. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  96. package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -1
  97. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  98. package/build/production/shared/components/selectors/NativeDropdown/index.js +1 -1
  99. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  100. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  101. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  102. package/build/production/shared/utils/config.js.map +1 -1
  103. package/build/production/shared/utils/globalState.js.map +1 -1
  104. package/build/production/shared/utils/index.js.map +1 -1
  105. package/build/production/shared/utils/jest/E2eSsrEnv.js +8 -7
  106. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  107. package/build/production/shared/utils/splitComponent.js.map +1 -1
  108. package/build/production/shared/utils/time.js.map +1 -1
  109. package/build/web/client/getInj.js +54 -0
  110. package/build/web/client/getInj.js.map +1 -0
  111. package/build/web/client/index.js +38 -0
  112. package/build/web/client/index.js.map +1 -0
  113. package/build/web/client/init.js +49 -0
  114. package/build/web/client/init.js.map +1 -0
  115. package/build/web/index.js +25 -0
  116. package/build/web/index.js.map +1 -0
  117. package/build/web/server/Cache.js +54 -0
  118. package/build/web/server/Cache.js.map +1 -0
  119. package/build/web/server/index.js +211 -0
  120. package/build/web/server/index.js.map +1 -0
  121. package/build/web/server/renderer.js +516 -0
  122. package/build/web/server/renderer.js.map +1 -0
  123. package/build/web/server/server.js +231 -0
  124. package/build/web/server/server.js.map +1 -0
  125. package/build/web/server/utils/errors.js +103 -0
  126. package/build/web/server/utils/errors.js.map +1 -0
  127. package/build/web/server/utils/index.js +4 -0
  128. package/build/web/server/utils/index.js.map +1 -0
  129. package/build/web/shared/components/Button/index.js +90 -0
  130. package/build/web/shared/components/Button/index.js.map +1 -0
  131. package/build/web/shared/components/Button/style.scss +54 -0
  132. package/build/web/shared/components/Checkbox/index.js +35 -0
  133. package/build/web/shared/components/Checkbox/index.js.map +1 -0
  134. package/build/web/shared/components/Checkbox/theme.scss +63 -0
  135. package/build/web/shared/components/GenericLink/index.js +107 -0
  136. package/build/web/shared/components/GenericLink/index.js.map +1 -0
  137. package/build/web/shared/components/GenericLink/style.scss +3 -0
  138. package/build/web/shared/components/Input/index.js +71 -0
  139. package/build/web/shared/components/Input/index.js.map +1 -0
  140. package/build/web/shared/components/Input/theme.scss +52 -0
  141. package/build/web/shared/components/Link.js +20 -0
  142. package/build/web/shared/components/Link.js.map +1 -0
  143. package/build/web/shared/components/Modal/base-theme.scss +38 -0
  144. package/build/web/shared/components/Modal/index.js +128 -0
  145. package/build/web/shared/components/Modal/index.js.map +1 -0
  146. package/build/web/shared/components/Modal/styles.scss +3 -0
  147. package/build/web/shared/components/NavLink.js +13 -0
  148. package/build/web/shared/components/NavLink.js.map +1 -0
  149. package/build/web/shared/components/PageLayout/base-theme.scss +30 -0
  150. package/build/web/shared/components/PageLayout/index.js +38 -0
  151. package/build/web/shared/components/PageLayout/index.js.map +1 -0
  152. package/build/web/shared/components/TextArea/index.js +106 -0
  153. package/build/web/shared/components/TextArea/index.js.map +1 -0
  154. package/build/web/shared/components/TextArea/style.scss +68 -0
  155. package/build/web/shared/components/Throbber/index.js +26 -0
  156. package/build/web/shared/components/Throbber/index.js.map +1 -0
  157. package/build/web/shared/components/Throbber/theme.scss +26 -0
  158. package/build/web/shared/components/WithTooltip/Tooltip.js +226 -0
  159. package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -0
  160. package/build/web/shared/components/WithTooltip/default-theme.scss +36 -0
  161. package/build/web/shared/components/WithTooltip/index.js +117 -0
  162. package/build/web/shared/components/WithTooltip/index.js.map +1 -0
  163. package/build/web/shared/components/YouTubeVideo/base.scss +15 -0
  164. package/build/web/shared/components/YouTubeVideo/index.js +56 -0
  165. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -0
  166. package/build/web/shared/components/YouTubeVideo/throbber.scss +11 -0
  167. package/build/web/shared/components/index.js +18 -0
  168. package/build/web/shared/components/index.js.map +1 -0
  169. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +79 -0
  170. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
  171. package/build/web/shared/components/selectors/CustomDropdown/Options/style.scss +6 -0
  172. package/build/web/shared/components/selectors/CustomDropdown/index.js +120 -0
  173. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -0
  174. package/build/web/shared/components/selectors/CustomDropdown/theme.scss +118 -0
  175. package/build/web/shared/components/selectors/NativeDropdown/index.js +82 -0
  176. package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -0
  177. package/build/web/shared/components/selectors/NativeDropdown/theme.scss +81 -0
  178. package/build/web/shared/components/selectors/Switch/index.js +49 -0
  179. package/build/web/shared/components/selectors/Switch/index.js.map +1 -0
  180. package/build/web/shared/components/selectors/Switch/theme.scss +39 -0
  181. package/build/web/shared/components/selectors/common.js +12 -0
  182. package/build/web/shared/components/selectors/common.js.map +1 -0
  183. package/build/web/shared/components/selectors/index.js +4 -0
  184. package/build/web/shared/components/selectors/index.js.map +1 -0
  185. package/build/web/shared/utils/config.js +21 -0
  186. package/build/web/shared/utils/config.js.map +1 -0
  187. package/build/web/shared/utils/globalState.js +15 -0
  188. package/build/web/shared/utils/globalState.js.map +1 -0
  189. package/build/web/shared/utils/index.js +13 -0
  190. package/build/web/shared/utils/index.js.map +1 -0
  191. package/build/web/shared/utils/isomorphy/buildInfo.js +44 -0
  192. package/build/web/shared/utils/isomorphy/buildInfo.js.map +1 -0
  193. package/build/web/shared/utils/isomorphy/environment-check.js +17 -0
  194. package/build/web/shared/utils/isomorphy/environment-check.js.map +1 -0
  195. package/build/web/shared/utils/isomorphy/index.js +36 -0
  196. package/build/web/shared/utils/isomorphy/index.js.map +1 -0
  197. package/build/web/shared/utils/jest/E2eSsrEnv.js +230 -0
  198. package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -0
  199. package/build/web/shared/utils/jest/global.js +4 -0
  200. package/build/web/shared/utils/jest/global.js.map +1 -0
  201. package/build/web/shared/utils/jest/index.js +165 -0
  202. package/build/web/shared/utils/jest/index.js.map +1 -0
  203. package/build/web/shared/utils/splitComponent.js +221 -0
  204. package/build/web/shared/utils/splitComponent.js.map +1 -0
  205. package/build/web/shared/utils/time.js +85 -0
  206. package/build/web/shared/utils/time.js.map +1 -0
  207. package/build/web/shared/utils/webpack.js +61 -0
  208. package/build/web/shared/utils/webpack.js.map +1 -0
  209. package/build/web/styles/_global/reset.css +52 -0
  210. package/build/web/styles/_mixins/fonts.scss +40 -0
  211. package/build/web/styles/_mixins/media.scss +150 -0
  212. package/build/web/styles/_mixins/typography.scss +83 -0
  213. package/build/web/styles/global.scss +11 -0
  214. package/build/web/styles/mixins.scss +6 -0
  215. package/config/babel/node-ssr.js +5 -2
  216. package/config/webpack/app-base.js +10 -7
  217. package/config/webpack/app-development.js +3 -2
  218. package/package.json +16 -27
  219. package/src/index.ts +7 -1
  220. package/src/server/index.ts +6 -8
  221. package/src/server/renderer.tsx +7 -9
  222. package/src/server/server.ts +3 -5
  223. package/src/shared/components/Modal/base-theme.scss +1 -1
  224. package/src/shared/components/PageLayout/base-theme.scss +1 -1
  225. package/src/shared/utils/jest/E2eSsrEnv.ts +8 -1
  226. package/build/development/__chunk_groups__.json +0 -6
  227. package/build/development/style.css +0 -909
  228. package/build/development/web.bundle.js +0 -752
  229. package/build/production/__chunk_groups__.json +0 -6
  230. package/build/production/style.css +0 -2
  231. package/build/production/style.css.map +0 -1
  232. package/build/production/web.bundle.js +0 -3
  233. package/build/production/web.bundle.js.LICENSE.txt +0 -9
  234. package/build/production/web.bundle.js.map +0 -1
  235. package/dev-styles.js +0 -1
  236. package/null.js +0 -1
  237. package/prod-styles.js +0 -1
@@ -0,0 +1,63 @@
1
+ *,
2
+ .context,
3
+ .ad.hoc {
4
+ &.checkbox {
5
+ appearance: none;
6
+ background: white;
7
+ border: 1px solid gray;
8
+ border-radius: 0.3em;
9
+ cursor: pointer;
10
+ font: inherit;
11
+ height: 1.5em;
12
+ outline: none;
13
+ margin: 0;
14
+ width: 1.5em;
15
+
16
+ &:checked {
17
+ &::after {
18
+ background: black;
19
+ border-radius: 0.3em;
20
+ content: "";
21
+ display: block;
22
+ height: 1em;
23
+ margin: 0.2em;
24
+ width: 1em;
25
+ }
26
+ }
27
+
28
+ &:focus {
29
+ border-color: blue;
30
+ box-shadow: 0 0 3px 1px lightblue;
31
+ }
32
+
33
+ &.indeterminate {
34
+ &::after {
35
+ background: black;
36
+ border-radius: 0.2em;
37
+ content: "";
38
+ display: block;
39
+ height: 0.2em;
40
+ margin: 0.6em 0.2em;
41
+ width: 1em;
42
+ }
43
+ }
44
+ }
45
+
46
+ &.container {
47
+ align-items: center;
48
+ display: inline-flex;
49
+ margin: 0.1em;
50
+ }
51
+
52
+ &.label {
53
+ margin: 0 0.6em 0 1.5em;
54
+ }
55
+
56
+ &.disabled {
57
+ opacity: 0.33;
58
+
59
+ .checkbox {
60
+ cursor: not-allowed !important;
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,107 @@
1
+ import "./style.scss";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ /**
4
+ * The `<Link>` component, and almost identical `<NavLink>` component, are
5
+ * auxiliary wrappers around
6
+ * [React Router](https://github.com/ReactTraining/react-router)'s
7
+ * `<Link>` and `<NavLink>` components; they help to handle external and
8
+ * internal links in uniform manner.
9
+ *
10
+ * @param [props] Component properties.
11
+ * @param [props.className] CSS classes to apply to the link.
12
+ * @param [props.disabled] Disables the link.
13
+ * @param [props.enforceA] `true` enforces rendering of the link as
14
+ * a simple `<a>` element.
15
+ * @param [props.keepScrollPosition] If `true`, and the link is
16
+ * rendered as a React Router's component, it won't reset the viewport scrolling
17
+ * position to the origin when clicked.
18
+ * @param [props.onClick] Event handler to trigger upon click.
19
+ * @param [props.onMouseDown] Event handler to trigger on MouseDown
20
+ * event.
21
+ * @param [props.openNewTab] If `true` the link opens in a new tab.
22
+ * @param [props.replace] When `true`, the link will replace current
23
+ * entry in the history stack instead of adding a new one.
24
+ * @param [props.to] Link URL.
25
+ * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)
26
+ * to apply to rendered link when it is active.
27
+ * @param [props.activeStyle] **`<NavLink>`** only: CSS styles
28
+ * to apply to the rendered link when it is active.
29
+ * @param [props.exact] **`<NavLink>`** only: if `true`, the active
30
+ * class/style will only be applied if the location is matched exactly.
31
+ * @param [props.isActive] **`<NavLink>`** only: Add extra
32
+ * logic for determining whether the link is active. This should be used if you
33
+ * want to do more than verify that the link’s pathname matches the current URL
34
+ * pathname.
35
+ * @param [props.location] **`<NavLink>`** only: `isActive` compares
36
+ * current history location (usually the current browser URL). To compare to
37
+ * a different location, a custom `location` can be passed.
38
+ * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing
39
+ * slash on a location’s pathname will be taken into consideration when
40
+ * determining if the location matches the current URL. See the `<Route strict>`
41
+ * documentation for more information.
42
+ */
43
+ const GenericLink = ({
44
+ children,
45
+ className,
46
+ disabled,
47
+ enforceA,
48
+ keepScrollPosition,
49
+ onClick,
50
+ onMouseDown,
51
+ openNewTab,
52
+ replace,
53
+ routerLinkType,
54
+ to,
55
+ ...rest
56
+ }) => {
57
+ /* Renders Link as <a> element if:
58
+ * - It is opted explicitely by `enforceA` prop;
59
+ * - It should be opened in a new tab;
60
+ * - It is an absolte URL (starts with http:// or https://);
61
+ * - It is anchor link (starts with #). */
62
+ if (disabled || enforceA || openNewTab || to.match(/^(#|(https?|mailto):)/)) {
63
+ return /*#__PURE__*/_jsx("a", {
64
+ className: className
65
+ // TODO: This requires a fix: disabled is not really an attribute of <a>
66
+ // tag, thus for disabled option we rather should render a plain text
67
+ // styled as a link.
68
+ // disabled={disabled}
69
+ ,
70
+ href: to,
71
+ onClick: disabled ? e => {
72
+ e.preventDefault();
73
+ } : onClick,
74
+ onMouseDown: disabled ? e => {
75
+ e.preventDefault();
76
+ } : onMouseDown,
77
+ rel: "noopener noreferrer",
78
+ styleName: "link",
79
+ target: openNewTab ? '_blank' : '',
80
+ children: children
81
+ });
82
+ }
83
+ const L = routerLinkType;
84
+ return /*#__PURE__*/_jsx(L, {
85
+ className: className,
86
+ discover: "none"
87
+ // disabled
88
+ ,
89
+ onClick: e => {
90
+ // Executes the user-provided event handler, if any.
91
+ if (onClick) onClick(e);
92
+
93
+ // By default, clicking the link scrolls the page to beginning.
94
+ if (!keepScrollPosition) window.scroll(0, 0);
95
+ },
96
+ onMouseDown: onMouseDown,
97
+ replace: replace,
98
+ to: to
99
+ // TODO: Refactor it later.
100
+ // eslint-disable-next-line react/jsx-props-no-spreading
101
+ ,
102
+ ...rest,
103
+ children: children
104
+ });
105
+ };
106
+ export default GenericLink;
107
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["jsx","_jsx","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","href","e","preventDefault","rel","styleName","target","L","discover","window","scroll"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type {\n Link,\n LinkProps,\n NavLink,\n NavLinkProps,\n} from 'react-router';\n\nimport './style.scss';\n\ntype LinkT = typeof Link;\ntype NavLinkT = typeof NavLink;\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkT | NavLinkT;\n to: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink = ({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}: (LinkProps | NavLinkProps) & PropsT): ReactNode => {\n /* Renders Link as <a> element if:\n * - It is opted explicitely by `enforceA` prop;\n * - It should be opened in a new tab;\n * - It is an absolte URL (starts with http:// or https://);\n * - It is anchor link (starts with #). */\n if (disabled || enforceA || openNewTab\n || (to as string).match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => {\n e.preventDefault();\n } : onClick}\n onMouseDown={disabled ? (e) => {\n e.preventDefault();\n } : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType;\n\n return (\n <L\n className={className}\n discover=\"none\"\n // disabled\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n onMouseDown={onMouseDown}\n replace={replace}\n to={to}\n // TODO: Refactor it later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n >\n {children}\n </L>\n );\n};\n\nexport default GenericLink;\n"],"mappings":"AASA;AAAsB,SAAAA,GAAA,IAAAC,IAAA;AAqBtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAGA,CAAC;EACnBC,QAAQ;EACRC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRC,kBAAkB;EAClBC,OAAO;EACPC,WAAW;EACXC,UAAU;EACVC,OAAO;EACPC,cAAc;EACdC,EAAE;EACF,GAAGC;AACgC,CAAC,KAAgB;EACpD;AACF;AACA;AACA;AACA;EACE,IAAIT,QAAQ,IAAIC,QAAQ,IAAII,UAAU,IAChCG,EAAE,CAAYE,KAAK,CAAC,uBAAuB,CAAC,EAAE;IAClD,oBACEd,IAAA;MACEG,SAAS,EAAEA;MACX;MACA;MACA;MACA;MAAA;MACAY,IAAI,EAAEH,EAAa;MACnBL,OAAO,EAAEH,QAAQ,GAAIY,CAAC,IAAK;QACzBA,CAAC,CAACC,cAAc,CAAC,CAAC;MACpB,CAAC,GAAGV,OAAQ;MACZC,WAAW,EAAEJ,QAAQ,GAAIY,CAAC,IAAK;QAC7BA,CAAC,CAACC,cAAc,CAAC,CAAC;MACpB,CAAC,GAAGT,WAAY;MAChBU,GAAG,EAAC,qBAAqB;MACzBC,SAAS,EAAC,MAAM;MAChBC,MAAM,EAAEX,UAAU,GAAG,QAAQ,GAAG,EAAG;MAAAP,QAAA,EAElCA;IAAQ,CACR,CAAC;EAER;EAEA,MAAMmB,CAAC,GAAGV,cAAc;EAExB,oBACEX,IAAA,CAACqB,CAAC;IACAlB,SAAS,EAAEA,SAAU;IACrBmB,QAAQ,EAAC;IACT;IAAA;IACAf,OAAO,EAAGS,CAAsC,IAAK;MACnD;MACA,IAAIT,OAAO,EAAEA,OAAO,CAACS,CAAC,CAAC;;MAEvB;MACA,IAAI,CAACV,kBAAkB,EAAEiB,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAE;IACFhB,WAAW,EAAEA,WAAY;IACzBE,OAAO,EAAEA,OAAQ;IACjBE,EAAE,EAAEA;IACJ;IACA;IAAA;IAAA,GACIC,IAAI;IAAAX,QAAA,EAEPA;EAAQ,CACR,CAAC;AAER,CAAC;AAED,eAAeD,WAAW","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ .link[disabled] {
2
+ cursor: not-allowed;
3
+ }
@@ -0,0 +1,71 @@
1
+ import { useRef, useState } from 'react';
2
+ import themed from '@dr.pogodin/react-themes';
3
+ import defaultTheme from "./theme.scss";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ /**
6
+ * Themeable input field, based on the standard HTML `<input>` element.
7
+ * @param [props.label] Input label.
8
+ * @param [props.theme] _Ad hoc_ theme.
9
+ * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
10
+ * @param [props...] Any other properties are passed to the underlying
11
+ * `<input>` element.
12
+ */
13
+ const Input = ({
14
+ children,
15
+ error,
16
+ label,
17
+ ref,
18
+ testId,
19
+ theme,
20
+ ...rest
21
+ }) => {
22
+ // NOTE: As of now, it is only updated when "theme.focused" is defined,
23
+ // as otherwise its value is not used.
24
+ const [focused, setFocused] = useState(false);
25
+ const localRef = useRef(null);
26
+ let containerClassName = theme.container;
27
+
28
+ // NOTE: As of now, "focused" can be true only when "theme.focused"
29
+ // is provided.
30
+ if (focused /* && theme.focused */) containerClassName += ` ${theme.focused}`;
31
+ if (!rest.value && theme.empty) containerClassName += ` ${theme.empty}`;
32
+ if (error) containerClassName += ` ${theme.error}`;
33
+ return /*#__PURE__*/_jsxs("div", {
34
+ className: containerClassName,
35
+ onFocus: () => {
36
+ // TODO: It does not really work if a callback-style `ref` is passed in,
37
+ // we need a more complex logic to cover that case, but for now this serves
38
+ // the case we need it for.
39
+ if (typeof ref === 'object') ref?.current?.focus();else localRef.current?.focus();
40
+ },
41
+ children: [label === undefined ? null : /*#__PURE__*/_jsx("div", {
42
+ className: theme.label,
43
+ children: label
44
+ }), /*#__PURE__*/_jsx("input", {
45
+ className: theme.input,
46
+ "data-testid": process.env.NODE_ENV === 'production' ? undefined : testId,
47
+ ref: ref ?? localRef
48
+
49
+ // TODO: Avoid the spreading later.
50
+ // eslint-disable-next-line react/jsx-props-no-spreading
51
+ ,
52
+ ...rest,
53
+ onBlur: theme.focused ? e => {
54
+ setFocused(false);
55
+ rest.onBlur?.(e);
56
+ } : rest.onBlur,
57
+ onFocus: theme.focused ? e => {
58
+ setFocused(true);
59
+ rest.onFocus?.(e);
60
+ } : rest.onFocus
61
+ }), error && error !== true ? /*#__PURE__*/_jsx("div", {
62
+ className: theme.errorMessage,
63
+ children: error
64
+ }) : null, children ? /*#__PURE__*/_jsx("div", {
65
+ className: theme.children,
66
+ children: children
67
+ }) : null]
68
+ });
69
+ };
70
+ export default themed(Input, 'Input', defaultTheme);
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["useRef","useState","themed","defaultTheme","jsx","_jsx","jsxs","_jsxs","Input","children","error","label","ref","testId","theme","rest","focused","setFocused","localRef","containerClassName","container","value","empty","className","onFocus","current","focus","undefined","input","process","env","NODE_ENV","onBlur","e","errorMessage"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type Ref,\n useRef,\n useState,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'\n | 'focused' | 'input' | 'label';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n children?: ReactNode;\n error?: ReactNode;\n label?: React.ReactNode;\n ref?: Ref<HTMLInputElement>;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props.label] Input label.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n * @param [props...] Any other properties are passed to the underlying\n * `<input>` element.\n */\nconst Input: FunctionComponent<PropsT> = ({\n children,\n error,\n label,\n ref,\n testId,\n theme,\n ...rest\n}) => {\n // NOTE: As of now, it is only updated when \"theme.focused\" is defined,\n // as otherwise its value is not used.\n const [focused, setFocused] = useState(false);\n\n const localRef = useRef<HTMLInputElement>(null);\n\n let containerClassName = theme.container;\n\n // NOTE: As of now, \"focused\" can be true only when \"theme.focused\"\n // is provided.\n if (focused /* && theme.focused */) containerClassName += ` ${theme.focused}`;\n\n if (!rest.value && theme.empty) containerClassName += ` ${theme.empty}`;\n\n if (error) containerClassName += ` ${theme.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n // TODO: It does not really work if a callback-style `ref` is passed in,\n // we need a more complex logic to cover that case, but for now this serves\n // the case we need it for.\n if (typeof ref === 'object') ref?.current?.focus();\n else localRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={theme.label}>{label}</div>}\n <input\n className={theme.input}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n ref={ref ?? localRef}\n\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n\n onBlur={theme.focused ? (e) => {\n setFocused(false);\n rest.onBlur?.(e);\n } : rest.onBlur}\n onFocus={theme.focused ? (e) => {\n setFocused(true);\n rest.onFocus?.(e);\n } : rest.onFocus}\n />\n {error && error !== true\n ? <div className={theme.errorMessage}>{error}</div>\n : null}\n {children ? <div className={theme.children}>{children}</div> : null}\n </div>\n );\n};\n\nexport default themed(Input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,CAAM,CAAC,eACxEN,IAAA;MACEkB,SAAS,EAAET,KAAK,CAACc,KAAM;MACvB,eAAaC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAAGJ,SAAS,GAAGd,MAAO;MACxED,GAAG,EAAEA,GAAG,IAAIM;;MAEZ;MACA;MAAA;MAAA,GACIH,IAAI;MAERiB,MAAM,EAAElB,KAAK,CAACE,OAAO,GAAIiB,CAAC,IAAK;QAC7BhB,UAAU,CAAC,KAAK,CAAC;QACjBF,IAAI,CAACiB,MAAM,GAAGC,CAAC,CAAC;MAClB,CAAC,GAAGlB,IAAI,CAACiB,MAAO;MAChBR,OAAO,EAAEV,KAAK,CAACE,OAAO,GAAIiB,CAAC,IAAK;QAC9BhB,UAAU,CAAC,IAAI,CAAC;QAChBF,IAAI,CAACS,OAAO,GAAGS,CAAC,CAAC;MACnB,CAAC,GAAGlB,IAAI,CAACS;IAAQ,CAClB,CAAC,EACDd,KAAK,IAAIA,KAAK,KAAK,IAAI,gBACpBL,IAAA;MAAKkB,SAAS,EAAET,KAAK,CAACoB,YAAa;MAAAzB,QAAA,EAAEC;IAAK,CAAM,CAAC,GACjD,IAAI,EACPD,QAAQ,gBAAGJ,IAAA;MAAKkB,SAAS,EAAET,KAAK,CAACL,QAAS;MAAAA,QAAA,EAAEA;IAAQ,CAAM,CAAC,GAAG,IAAI;EAAA,CAChE,CAAC;AAEV,CAAC;AAED,eAAeP,MAAM,CAACM,KAAK,EAAE,OAAO,EAAEL,YAAY,CAAC","ignoreList":[]}
@@ -0,0 +1,52 @@
1
+ *,
2
+ .context,
3
+ .ad.hoc {
4
+ &.container {
5
+ align-items: center;
6
+ display: inline-flex;
7
+ flex-wrap: wrap;
8
+ margin: 0.1em;
9
+ position: relative;
10
+ }
11
+
12
+ &.children {
13
+ width: 100%;
14
+ }
15
+
16
+ &.input {
17
+ border: 1px solid gray;
18
+ border-radius: 0.3em;
19
+ cursor: text;
20
+ font: inherit;
21
+ flex: 1;
22
+ outline: none;
23
+ padding: 0.3em 0.3em calc(0.3em + 1px);
24
+
25
+ &:focus {
26
+ border-color: blue;
27
+ box-shadow: 0 0 3px 1px lightblue;
28
+ }
29
+ }
30
+
31
+ &.label {
32
+ margin: 0 0.6em 0 1.5em;
33
+ pointer-events: none;
34
+ }
35
+
36
+ &.error &.input {
37
+ border-color: red;
38
+
39
+ &:focus {
40
+ box-shadow: 0 0 3px 1px orangered;
41
+ }
42
+ }
43
+
44
+ &.errorMessage {
45
+ color: red;
46
+ font-size: 0.8em;
47
+ font-style: italic;
48
+ padding-right: 0.6em;
49
+ text-align: right;
50
+ width: 100%;
51
+ }
52
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The Link wraps around React Router's Link component, to automatically replace
3
+ * it by the regular <a> element when:
4
+ * - The target reference points to another domain;
5
+ * - User opts to open the reference in a new tab;
6
+ * - User explicitely opts to use <a>.
7
+ */
8
+
9
+ import { Link as RrLink } from 'react-router';
10
+ import GenericLink from "./GenericLink";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const Link = props => /*#__PURE__*/_jsx(GenericLink
13
+ // TODO: Avoid the spreading later.
14
+ // eslint-disable-next-line react/jsx-props-no-spreading
15
+ , {
16
+ ...props,
17
+ routerLinkType: RrLink
18
+ });
19
+ export default Link;
20
+ //# sourceMappingURL=Link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.js","names":["Link","RrLink","GenericLink","jsx","_jsx","props","routerLinkType"],"sources":["../../../../src/shared/components/Link.tsx"],"sourcesContent":["/**\n * The Link wraps around React Router's Link component, to automatically replace\n * it by the regular <a> element when:\n * - The target reference points to another domain;\n * - User opts to open the reference in a new tab;\n * - User explicitely opts to use <a>.\n */\n\nimport { type LinkProps, Link as RrLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & LinkProps;\n\nconst Link: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrLink}\n />\n );\n\nexport default Link;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAyBA,IAAI,IAAIC,MAAM,QAAQ,cAAc;AAE7D,OAAOC,WAAW;AAA4D,SAAAC,GAAA,IAAAC,IAAA;AAI9E,MAAMJ,IAAqC,GACtCK,KAAK,iBACND,IAAA,CAACF;AACC;AACA;AAAA;EAAA,GACIG,KAAK;EACTC,cAAc,EAAEL;AAAO,CACxB,CACF;AAEH,eAAeD,IAAI","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ @use "../../../styles/mixins" as *;
2
+
3
+ *,
4
+ .context,
5
+ .ad.hoc {
6
+ &.overlay {
7
+ background: #eee;
8
+ height: 100%;
9
+ left: 0;
10
+ opacity: 0.8;
11
+ position: fixed;
12
+ top: 0;
13
+ width: 100%;
14
+ z-index: $zIndexOfDefaultModalOverlay;
15
+
16
+ &:focus { outline: none; }
17
+ }
18
+
19
+ &.container {
20
+ background: #fff;
21
+ box-shadow: 0 0 14px 1px rgb(38 38 40 / 15%);
22
+ border-radius: 0.3em;
23
+ max-height: 95vh;
24
+ max-width: $screen-md;
25
+ overflow: hidden;
26
+ padding: 0.6em 1.2em;
27
+ width: 480px;
28
+ position: fixed;
29
+ top: 50%;
30
+ left: 50%;
31
+ transform: translate(-50%, -50%);
32
+ z-index: $zIndexOfDefaultModalOverlay + 1;
33
+
34
+ @include xs-to-lg {
35
+ max-width: 95vw;
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,128 @@
1
+ import { useEffect, useMemo, useRef } from 'react';
2
+ import ReactDom from 'react-dom';
3
+ import themed from '@dr.pogodin/react-themes';
4
+ import baseTheme from "./base-theme.scss";
5
+ import S from "./styles.scss";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ /**
8
+ * The `<Modal>` component implements a simple themeable modal window, wrapped
9
+ * into the default theme. `<BaseModal>` exposes the base non-themed component.
10
+ * **Children:** Component children are rendered as the modal content.
11
+ * @param {object} props Component properties. Beside props documented below,
12
+ * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.
13
+ * @param {function} [props.onCancel] The callback to trigger when user
14
+ * clicks outside the modal, or presses Escape. It is expected to hide the
15
+ * modal.
16
+ * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
17
+ */
18
+ const BaseModal = ({
19
+ cancelOnScrolling,
20
+ children,
21
+ containerStyle,
22
+ dontDisableScrolling,
23
+ onCancel,
24
+ overlayStyle,
25
+ style,
26
+ testId,
27
+ testIdForOverlay,
28
+ theme
29
+ }) => {
30
+ const containerRef = useRef(null);
31
+ const overlayRef = useRef(null);
32
+
33
+ // Sets up modal cancellation of scrolling, if opted-in.
34
+ useEffect(() => {
35
+ if (cancelOnScrolling && onCancel) {
36
+ window.addEventListener('scroll', onCancel);
37
+ window.addEventListener('wheel', onCancel);
38
+ }
39
+ return () => {
40
+ if (cancelOnScrolling && onCancel) {
41
+ window.removeEventListener('scroll', onCancel);
42
+ window.removeEventListener('wheel', onCancel);
43
+ }
44
+ };
45
+ }, [cancelOnScrolling, onCancel]);
46
+
47
+ // Disables window scrolling, if it is not opted-out.
48
+ useEffect(() => {
49
+ if (!dontDisableScrolling) {
50
+ document.body.classList.add(S.scrollingDisabledByModal);
51
+ }
52
+ return () => {
53
+ if (!dontDisableScrolling) {
54
+ document.body.classList.remove(S.scrollingDisabledByModal);
55
+ }
56
+ };
57
+ }, [dontDisableScrolling]);
58
+ const focusLast = useMemo(() => /*#__PURE__*/_jsx("div", {
59
+ onFocus: () => {
60
+ const elems = containerRef.current.querySelectorAll('*');
61
+ for (let i = elems.length - 1; i >= 0; --i) {
62
+ elems[i].focus();
63
+ if (document.activeElement === elems[i]) return;
64
+ }
65
+ overlayRef.current?.focus();
66
+ }
67
+ // TODO: Have a look at this later.
68
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
69
+ ,
70
+ tabIndex: 0
71
+ }), []);
72
+ return /*#__PURE__*/ReactDom.createPortal(/*#__PURE__*/_jsxs("div", {
73
+ children: [focusLast, /*#__PURE__*/_jsx("div", {
74
+ "aria-label": "Cancel",
75
+ className: theme.overlay,
76
+ "data-testid": process.env.NODE_ENV === 'production' ? undefined : testIdForOverlay,
77
+ onClick: e => {
78
+ if (onCancel) {
79
+ onCancel();
80
+ e.stopPropagation();
81
+ }
82
+ },
83
+ onKeyDown: e => {
84
+ if (e.key === 'Escape' && onCancel) {
85
+ onCancel();
86
+ e.stopPropagation();
87
+ }
88
+ },
89
+ ref: node => {
90
+ if (node && node !== overlayRef.current) {
91
+ overlayRef.current = node;
92
+ node.focus();
93
+ }
94
+ },
95
+ role: "button",
96
+ style: overlayStyle,
97
+ tabIndex: 0
98
+ }), /*#__PURE__*/_jsx("div", {
99
+ // eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
100
+ "aria-modal": "true",
101
+ className: theme.container,
102
+ "data-testid": process.env.NODE_ENV === 'production' ? undefined : testId,
103
+ onClick: e => {
104
+ e.stopPropagation();
105
+ },
106
+ onWheel: event => {
107
+ event.stopPropagation();
108
+ },
109
+ ref: containerRef,
110
+ role: "dialog",
111
+ style: style ?? containerStyle,
112
+ children: children
113
+ }), /*#__PURE__*/_jsx("div", {
114
+ onFocus: () => {
115
+ overlayRef.current?.focus();
116
+ }
117
+ // TODO: Have a look at this later.
118
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
119
+ ,
120
+ tabIndex: 0
121
+ }), focusLast]
122
+ }), document.body);
123
+ };
124
+ export default themed(BaseModal, 'Modal', baseTheme);
125
+
126
+ /* Non-themed version of the Modal. */
127
+ export { BaseModal };
128
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["useEffect","useMemo","useRef","ReactDom","themed","baseTheme","S","jsx","_jsx","jsxs","_jsxs","BaseModal","cancelOnScrolling","children","containerStyle","dontDisableScrolling","onCancel","overlayStyle","style","testId","testIdForOverlay","theme","containerRef","overlayRef","window","addEventListener","removeEventListener","document","body","classList","add","scrollingDisabledByModal","remove","focusLast","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","createPortal","className","overlay","process","env","NODE_ENV","undefined","onClick","e","stopPropagation","onKeyDown","key","ref","node","role","container","onWheel","event"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport ReactDom from 'react-dom';\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport S from './styles.scss';\n\ntype PropsT = {\n cancelOnScrolling?: boolean;\n children?: ReactNode;\n dontDisableScrolling?: boolean;\n onCancel?: () => void;\n overlayStyle?: CSSProperties;\n style?: CSSProperties;\n testId?: string;\n testIdForOverlay?: string;\n theme: Theme<'container' | 'overlay'>;\n\n /** @deprecated */\n containerStyle?: CSSProperties;\n};\n\n/**\n * The `<Modal>` component implements a simple themeable modal window, wrapped\n * into the default theme. `<BaseModal>` exposes the base non-themed component.\n * **Children:** Component children are rendered as the modal content.\n * @param {object} props Component properties. Beside props documented below,\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.\n * @param {function} [props.onCancel] The callback to trigger when user\n * clicks outside the modal, or presses Escape. It is expected to hide the\n * modal.\n * @param {ModalTheme} [props.theme] _Ad hoc_ theme.\n */\nconst BaseModal: FunctionComponent<PropsT> = ({\n cancelOnScrolling,\n children,\n containerStyle,\n dontDisableScrolling,\n onCancel,\n overlayStyle,\n style,\n testId,\n testIdForOverlay,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n\n // Sets up modal cancellation of scrolling, if opted-in.\n useEffect(() => {\n if (cancelOnScrolling && onCancel) {\n window.addEventListener('scroll', onCancel);\n window.addEventListener('wheel', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', onCancel);\n window.removeEventListener('wheel', onCancel);\n }\n };\n }, [cancelOnScrolling, onCancel]);\n\n // Disables window scrolling, if it is not opted-out.\n useEffect(() => {\n if (!dontDisableScrolling) {\n document.body.classList.add(S.scrollingDisabledByModal);\n }\n return () => {\n if (!dontDisableScrolling) {\n document.body.classList.remove(S.scrollingDisabledByModal);\n }\n };\n }, [dontDisableScrolling]);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current!.querySelectorAll('*');\n for (let i = elems.length - 1; i >= 0; --i) {\n (elems[i] as HTMLElement).focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n ), []);\n\n return ReactDom.createPortal(\n (\n <div>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n data-testid={\n process.env.NODE_ENV === 'production'\n ? undefined : testIdForOverlay\n }\n onClick={(e) => {\n if (onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n style={overlayStyle}\n tabIndex={0}\n />\n {\n // NOTE: These rules are disabled because our intention is to keep\n // the element non-interactive (thus not on the keyboard focus chain),\n // and it has `onClick` handler merely to stop propagation of click\n // events to its parent container. This is needed because, for example\n // when the modal is wrapped into an interactive element we don't want\n // any clicks inside the modal to bubble-up to that parent element\n // (because visually and logically the modal dialog does not belong\n // to its parent container, where it technically belongs from\n // the HTML mark-up perpective).\n }\n <div // eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n aria-modal=\"true\"\n className={theme.container}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={(e) => {\n e.stopPropagation();\n }}\n onWheel={(event) => {\n event.stopPropagation();\n }}\n ref={containerRef}\n role=\"dialog\"\n style={style ?? containerStyle}\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n {focusLast}\n </div>\n ),\n document.body,\n );\n};\n\nexport default themed(BaseModal, 'Modal', baseTheme);\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":"AAAA,SAIEA,SAAS,EACTC,OAAO,EACPC,MAAM,QACD,OAAO;AAEd,OAAOC,QAAQ,MAAM,WAAW;AAChC,OAAOC,MAAM,MAAsB,0BAA0B;AAE7D,OAAOC,SAAS;AAChB,OAAOC,CAAC;AAAsB,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAiB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAoC,GAAGA,CAAC;EAC5CC,iBAAiB;EACjBC,QAAQ;EACRC,cAAc;EACdC,oBAAoB;EACpBC,QAAQ;EACRC,YAAY;EACZC,KAAK;EACLC,MAAM;EACNC,gBAAgB;EAChBC;AACF,CAAC,KAAK;EACJ,MAAMC,YAAY,GAAGpB,MAAM,CAAwB,IAAI,CAAC;EACxD,MAAMqB,UAAU,GAAGrB,MAAM,CAAwB,IAAI,CAAC;;EAEtD;EACAF,SAAS,CAAC,MAAM;IACd,IAAIY,iBAAiB,IAAII,QAAQ,EAAE;MACjCQ,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAET,QAAQ,CAAC;MAC3CQ,MAAM,CAACC,gBAAgB,CAAC,OAAO,EAAET,QAAQ,CAAC;IAC5C;I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AO,EAAEA,CAAA,KAAM;QACbX,UAAU,CAACa,OAAO,EAAEI,KAAK,CAAC,CAAC;MAC7B;MACA;MACA;MAAA;MACAE,QAAQ,EAAE;IAAE,CACb,CAAC,EACDT,SAAS;EAAA,CACP,CAAC,EAERN,QAAQ,CAACC,IACX,CAAC;AACH,CAAC;AAED,eAAexB,MAAM,CAACO,SAAS,EAAE,OAAO,EAAEN,SAAS,CAAC;;AAEpD;AACA,SAASM,SAAS","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ .scrollingDisabledByModal {
2
+ overflow: hidden;
3
+ }
@@ -0,0 +1,13 @@
1
+ import { NavLink as RrNavLink } from 'react-router';
2
+ import GenericLink from "./GenericLink";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const NavLink = props => /*#__PURE__*/_jsx(GenericLink
5
+ // TODO: I guess, we better re-write it to avoid the props spreading,
6
+ // but no need to spend time on it right now.
7
+ // eslint-disable-next-line react/jsx-props-no-spreading
8
+ , {
9
+ ...props,
10
+ routerLinkType: RrNavLink
11
+ });
12
+ export default NavLink;
13
+ //# sourceMappingURL=NavLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavLink.js","names":["NavLink","RrNavLink","GenericLink","jsx","_jsx","props","routerLinkType"],"sources":["../../../../src/shared/components/NavLink.tsx"],"sourcesContent":["import { type NavLinkProps, NavLink as RrNavLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & NavLinkProps;\n\nconst NavLink: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: I guess, we better re-write it to avoid the props spreading,\n // but no need to spend time on it right now.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrNavLink}\n />\n );\n\nexport default NavLink;\n"],"mappings":"AAAA,SAA4BA,OAAO,IAAIC,SAAS,QAAQ,cAAc;AAEtE,OAAOC,WAAW;AAA4D,SAAAC,GAAA,IAAAC,IAAA;AAI9E,MAAMJ,OAAwC,GACzCK,KAAK,iBACND,IAAA,CAACF;AACC;AACA;AACA;AAAA;EAAA,GACIG,KAAK;EACTC,cAAc,EAAEL;AAAU,CAC3B,CACF;AAEH,eAAeD,OAAO","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Base theme: symmetric 3-columns layout, with the center column occupying all
3
+ * screen up to mid screen size. For larger screen sizes the main column is
4
+ * limited by the mid screen size, and the free space is filled with side
5
+ * columns on left and right.
6
+ */
7
+
8
+ @use "../../../styles/mixins" as *;
9
+
10
+ *,
11
+ .context,
12
+ .ad.hoc {
13
+ &.container {
14
+ display: flex;
15
+ min-height: 100vh;
16
+ overflow: hidden;
17
+ width: 100%;
18
+ }
19
+
20
+ &.mainPanel {
21
+ overflow: hidden;
22
+ padding: 1.2em;
23
+ width: $screen-md;
24
+ }
25
+
26
+ &.sidePanel {
27
+ flex: 1;
28
+ overflow: hidden;
29
+ }
30
+ }
@@ -0,0 +1,38 @@
1
+ import themed from '@dr.pogodin/react-themes';
2
+ import baseTheme from "./base-theme.scss";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ /**
5
+ * Simple and themeable page layout. It keeps the main content centered in
6
+ * a column of limited width, which fills entire viewport on small screens
7
+ * (under `$screen-md = 1024px` size). At larger screens the column keeps
8
+ * `$screen-md` size, and it is centered at the page, surrounded by side
9
+ * panels, where additional content can be displayed.
10
+ *
11
+ * **Children:** Component children are rendered as the content of main panel.
12
+ * @param {object} [props] Component properties.
13
+ * @param {Node} [props.leftSidePanelContent] The content for left side panel.
14
+ * @param {Node} [props.rightSidePanelContent] The content for right side panel.
15
+ * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.
16
+ * @param {...any} [props....]
17
+ * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
18
+ */
19
+ const PageLayout = ({
20
+ children,
21
+ leftSidePanelContent,
22
+ rightSidePanelContent,
23
+ theme
24
+ }) => /*#__PURE__*/_jsxs("div", {
25
+ className: theme.container,
26
+ children: [/*#__PURE__*/_jsx("div", {
27
+ className: [theme.sidePanel, theme.leftSidePanel].join(' '),
28
+ children: leftSidePanelContent
29
+ }), /*#__PURE__*/_jsx("div", {
30
+ className: theme.mainPanel,
31
+ children: children
32
+ }), /*#__PURE__*/_jsx("div", {
33
+ className: [theme.sidePanel, theme.rightSidePanel].join(' '),
34
+ children: rightSidePanelContent
35
+ })]
36
+ });
37
+ export default themed(PageLayout, 'PageLayout', baseTheme);
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["themed","baseTheme","jsx","_jsx","jsxs","_jsxs","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","className","container","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\ntype ThemeKeyT = 'container' | 'leftSidePanel' | 'mainPanel' | 'rightSidePanel'\n | 'sidePanel';\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme: Theme<ThemeKeyT>;\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: React.FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n);\n\nexport default themed(PageLayout, 'PageLayout', baseTheme);\n"],"mappings":"AAEA,OAAOA,MAAM,MAAsB,0BAA0B;AAE7D,OAAOC,SAAS;AAA0B,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAY1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAA2C,GAAGA,CAAC;EACnDC,QAAQ;EACRC,oBAAoB;EACpBC,qBAAqB;EACrBC;AACF,CAAC,kBACCL,KAAA;EAAKM,SAAS,EAAED,KAAK,CAACE,SAAU;EAAAL,QAAA,gBAC9BJ,IAAA;IAAKQ,SAAS,EAAE,CAACD,KAAK,CAACG,SAAS,EAAEH,KAAK,CAACI,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;IAAAR,QAAA,EAC9DC;EAAoB,CAClB,CAAC,eACNL,IAAA;IAAKQ,SAAS,EAAED,KAAK,CAACM,SAAU;IAAAT,QAAA,EAC7BA;EAAQ,CACN,CAAC,eACNJ,IAAA;IAAKQ,SAAS,EAAE,CAACD,KAAK,CAACG,SAAS,EAAEH,KAAK,CAACO,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE;IAAAR,QAAA,EAC/DE;EAAqB,CACnB,CAAC;AAAA,CACH,CACN;AAED,eAAeT,MAAM,CAACM,UAAU,EAAE,YAAY,EAAEL,SAAS,CAAC","ignoreList":[]}