@dr.pogodin/react-utils 1.47.0-alpha.7 → 1.47.0-alpha.8

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 (165) hide show
  1. package/build/development/client/index.js +1 -1
  2. package/build/development/client/index.js.map +1 -1
  3. package/build/development/index.js +1 -11
  4. package/build/development/index.js.map +1 -1
  5. package/build/development/server/index.js +3 -6
  6. package/build/development/server/index.js.map +1 -1
  7. package/build/development/server/utils/index.js +1 -1
  8. package/build/development/server/utils/index.js.map +1 -1
  9. package/build/development/shared/components/Button/index.js +1 -1
  10. package/build/development/shared/components/Button/index.js.map +1 -1
  11. package/build/development/shared/components/Checkbox/index.js +1 -1
  12. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  13. package/build/development/shared/components/Input/index.js +1 -1
  14. package/build/development/shared/components/Input/index.js.map +1 -1
  15. package/build/development/shared/components/Modal/index.js +1 -1
  16. package/build/development/shared/components/Modal/index.js.map +1 -1
  17. package/build/development/shared/components/PageLayout/index.js +1 -1
  18. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  19. package/build/development/shared/components/TextArea/index.js +1 -1
  20. package/build/development/shared/components/TextArea/index.js.map +1 -1
  21. package/build/development/shared/components/Throbber/index.js +1 -1
  22. package/build/development/shared/components/Throbber/index.js.map +1 -1
  23. package/build/development/shared/components/WithTooltip/index.js +1 -1
  24. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  25. package/build/development/shared/components/YouTubeVideo/index.js +1 -1
  26. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  27. package/build/development/shared/components/selectors/CustomDropdown/index.js +1 -1
  28. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  29. package/build/development/shared/components/selectors/NativeDropdown/index.js +1 -1
  30. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  31. package/build/development/shared/components/selectors/Switch/index.js +1 -1
  32. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  33. package/build/production/client/index.js +1 -1
  34. package/build/production/client/index.js.map +1 -1
  35. package/build/production/index.js +2 -6
  36. package/build/production/index.js.map +1 -1
  37. package/build/production/server/index.js +3 -3
  38. package/build/production/server/index.js.map +1 -1
  39. package/build/production/server/utils/index.js +1 -1
  40. package/build/production/server/utils/index.js.map +1 -1
  41. package/build/production/shared/components/Button/index.js +1 -1
  42. package/build/production/shared/components/Button/index.js.map +1 -1
  43. package/build/production/shared/components/Checkbox/index.js +1 -1
  44. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  45. package/build/production/shared/components/Input/index.js +1 -1
  46. package/build/production/shared/components/Input/index.js.map +1 -1
  47. package/build/production/shared/components/Modal/index.js +1 -1
  48. package/build/production/shared/components/Modal/index.js.map +1 -1
  49. package/build/production/shared/components/PageLayout/index.js +1 -1
  50. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  51. package/build/production/shared/components/TextArea/index.js +1 -1
  52. package/build/production/shared/components/TextArea/index.js.map +1 -1
  53. package/build/production/shared/components/Throbber/index.js +1 -1
  54. package/build/production/shared/components/Throbber/index.js.map +1 -1
  55. package/build/production/shared/components/WithTooltip/index.js +1 -1
  56. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  57. package/build/production/shared/components/YouTubeVideo/index.js +1 -1
  58. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  59. package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -1
  60. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  61. package/build/production/shared/components/selectors/NativeDropdown/index.js +1 -1
  62. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  63. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  64. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  65. package/build/types-code/client/index.d.ts +1 -1
  66. package/build/types-code/index.d.ts +0 -5
  67. package/build/types-code/server/index.d.ts +4 -9
  68. package/build/types-code/server/utils/index.d.ts +1 -1
  69. package/build/web/client/index.js +1 -1
  70. package/build/web/client/index.js.map +1 -1
  71. package/build/web/index.js +1 -11
  72. package/build/web/index.js.map +1 -1
  73. package/build/web/server/index.js +3 -6
  74. package/build/web/server/index.js.map +1 -1
  75. package/build/web/server/utils/index.js +1 -1
  76. package/build/web/server/utils/index.js.map +1 -1
  77. package/build/web/shared/components/Button/index.js +1 -1
  78. package/build/web/shared/components/Button/index.js.map +1 -1
  79. package/build/web/shared/components/Checkbox/index.js +1 -1
  80. package/build/web/shared/components/Checkbox/index.js.map +1 -1
  81. package/build/web/shared/components/Input/index.js +1 -1
  82. package/build/web/shared/components/Input/index.js.map +1 -1
  83. package/build/web/shared/components/Modal/index.js +1 -1
  84. package/build/web/shared/components/Modal/index.js.map +1 -1
  85. package/build/web/shared/components/PageLayout/index.js +1 -1
  86. package/build/web/shared/components/PageLayout/index.js.map +1 -1
  87. package/build/web/shared/components/TextArea/index.js +1 -1
  88. package/build/web/shared/components/TextArea/index.js.map +1 -1
  89. package/build/web/shared/components/Throbber/index.js +1 -1
  90. package/build/web/shared/components/Throbber/index.js.map +1 -1
  91. package/build/web/shared/components/WithTooltip/index.js +1 -1
  92. package/build/web/shared/components/WithTooltip/index.js.map +1 -1
  93. package/build/web/shared/components/YouTubeVideo/index.js +1 -1
  94. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
  95. package/build/web/shared/components/selectors/CustomDropdown/index.js +1 -1
  96. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  97. package/build/web/shared/components/selectors/NativeDropdown/index.js +1 -1
  98. package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  99. package/build/web/shared/components/selectors/Switch/index.js +1 -1
  100. package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
  101. package/package.json +17 -6
  102. package/src/client/getInj.ts +0 -71
  103. package/src/client/index.tsx +0 -45
  104. package/src/client/init.ts +0 -52
  105. package/src/index.ts +0 -75
  106. package/src/server/Cache.ts +0 -61
  107. package/src/server/index.ts +0 -243
  108. package/src/server/renderer.tsx +0 -635
  109. package/src/server/server.ts +0 -330
  110. package/src/server/utils/errors.ts +0 -122
  111. package/src/server/utils/index.ts +0 -3
  112. package/src/shared/components/Button/index.tsx +0 -130
  113. package/src/shared/components/Button/style.scss +0 -54
  114. package/src/shared/components/Checkbox/index.tsx +0 -53
  115. package/src/shared/components/Checkbox/theme.scss +0 -63
  116. package/src/shared/components/GenericLink/index.tsx +0 -141
  117. package/src/shared/components/GenericLink/style.scss +0 -3
  118. package/src/shared/components/Input/index.tsx +0 -96
  119. package/src/shared/components/Input/theme.scss +0 -52
  120. package/src/shared/components/Link.tsx +0 -25
  121. package/src/shared/components/Modal/base-theme.scss +0 -38
  122. package/src/shared/components/Modal/index.tsx +0 -177
  123. package/src/shared/components/Modal/styles.scss +0 -3
  124. package/src/shared/components/NavLink.tsx +0 -18
  125. package/src/shared/components/PageLayout/base-theme.scss +0 -30
  126. package/src/shared/components/PageLayout/index.tsx +0 -51
  127. package/src/shared/components/TextArea/index.tsx +0 -139
  128. package/src/shared/components/TextArea/style.scss +0 -68
  129. package/src/shared/components/Throbber/index.tsx +0 -28
  130. package/src/shared/components/Throbber/theme.scss +0 -26
  131. package/src/shared/components/WithTooltip/Tooltip.tsx +0 -274
  132. package/src/shared/components/WithTooltip/default-theme.scss +0 -36
  133. package/src/shared/components/WithTooltip/index.tsx +0 -186
  134. package/src/shared/components/YouTubeVideo/base.scss +0 -15
  135. package/src/shared/components/YouTubeVideo/index.tsx +0 -73
  136. package/src/shared/components/YouTubeVideo/throbber.scss +0 -11
  137. package/src/shared/components/index.ts +0 -20
  138. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +0 -124
  139. package/src/shared/components/selectors/CustomDropdown/Options/style.scss +0 -6
  140. package/src/shared/components/selectors/CustomDropdown/index.tsx +0 -146
  141. package/src/shared/components/selectors/CustomDropdown/theme.scss +0 -118
  142. package/src/shared/components/selectors/NativeDropdown/index.tsx +0 -90
  143. package/src/shared/components/selectors/NativeDropdown/theme.scss +0 -81
  144. package/src/shared/components/selectors/Switch/index.tsx +0 -74
  145. package/src/shared/components/selectors/Switch/theme.scss +0 -39
  146. package/src/shared/components/selectors/common.ts +0 -57
  147. package/src/shared/components/selectors/index.ts +0 -8
  148. package/src/shared/utils/config.ts +0 -59
  149. package/src/shared/utils/globalState.ts +0 -44
  150. package/src/shared/utils/index.ts +0 -45
  151. package/src/shared/utils/isomorphy/buildInfo.ts +0 -50
  152. package/src/shared/utils/isomorphy/environment-check.ts +0 -18
  153. package/src/shared/utils/isomorphy/index.ts +0 -36
  154. package/src/shared/utils/jest/E2eSsrEnv.ts +0 -304
  155. package/src/shared/utils/jest/global.ts +0 -17
  156. package/src/shared/utils/jest/index.ts +0 -215
  157. package/src/shared/utils/splitComponent.tsx +0 -284
  158. package/src/shared/utils/time.ts +0 -101
  159. package/src/shared/utils/webpack.ts +0 -80
  160. package/src/styles/_global/reset.css +0 -52
  161. package/src/styles/_mixins/fonts.scss +0 -40
  162. package/src/styles/_mixins/media.scss +0 -150
  163. package/src/styles/_mixins/typography.scss +0 -83
  164. package/src/styles/global.scss +0 -11
  165. package/src/styles/mixins.scss +0 -6
@@ -1,63 +0,0 @@
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
- }
@@ -1,141 +0,0 @@
1
- import type { ReactNode } from 'react';
2
-
3
- import type {
4
- Link,
5
- LinkProps,
6
- NavLink,
7
- NavLinkProps,
8
- } from 'react-router';
9
-
10
- import './style.scss';
11
-
12
- type LinkT = typeof Link;
13
- type NavLinkT = typeof NavLink;
14
-
15
- type ToT = Parameters<typeof Link>[0]['to'];
16
-
17
- export type PropsT = {
18
- children?: ReactNode;
19
- className?: string;
20
- disabled?: boolean;
21
- enforceA?: boolean;
22
- keepScrollPosition?: boolean;
23
- onClick?: React.MouseEventHandler<HTMLAnchorElement>;
24
- onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;
25
- openNewTab?: boolean;
26
- replace?: boolean;
27
- routerLinkType: LinkT | NavLinkT;
28
- to: ToT;
29
- };
30
-
31
- /**
32
- * The `<Link>` component, and almost identical `<NavLink>` component, are
33
- * auxiliary wrappers around
34
- * [React Router](https://github.com/ReactTraining/react-router)'s
35
- * `<Link>` and `<NavLink>` components; they help to handle external and
36
- * internal links in uniform manner.
37
- *
38
- * @param [props] Component properties.
39
- * @param [props.className] CSS classes to apply to the link.
40
- * @param [props.disabled] Disables the link.
41
- * @param [props.enforceA] `true` enforces rendering of the link as
42
- * a simple `<a>` element.
43
- * @param [props.keepScrollPosition] If `true`, and the link is
44
- * rendered as a React Router's component, it won't reset the viewport scrolling
45
- * position to the origin when clicked.
46
- * @param [props.onClick] Event handler to trigger upon click.
47
- * @param [props.onMouseDown] Event handler to trigger on MouseDown
48
- * event.
49
- * @param [props.openNewTab] If `true` the link opens in a new tab.
50
- * @param [props.replace] When `true`, the link will replace current
51
- * entry in the history stack instead of adding a new one.
52
- * @param [props.to] Link URL.
53
- * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)
54
- * to apply to rendered link when it is active.
55
- * @param [props.activeStyle] **`<NavLink>`** only: CSS styles
56
- * to apply to the rendered link when it is active.
57
- * @param [props.exact] **`<NavLink>`** only: if `true`, the active
58
- * class/style will only be applied if the location is matched exactly.
59
- * @param [props.isActive] **`<NavLink>`** only: Add extra
60
- * logic for determining whether the link is active. This should be used if you
61
- * want to do more than verify that the link’s pathname matches the current URL
62
- * pathname.
63
- * @param [props.location] **`<NavLink>`** only: `isActive` compares
64
- * current history location (usually the current browser URL). To compare to
65
- * a different location, a custom `location` can be passed.
66
- * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing
67
- * slash on a location’s pathname will be taken into consideration when
68
- * determining if the location matches the current URL. See the `<Route strict>`
69
- * documentation for more information.
70
- */
71
- const GenericLink = ({
72
- children,
73
- className,
74
- disabled,
75
- enforceA,
76
- keepScrollPosition,
77
- onClick,
78
- onMouseDown,
79
- openNewTab,
80
- replace,
81
- routerLinkType,
82
- to,
83
- ...rest
84
- }: (LinkProps | NavLinkProps) & PropsT): ReactNode => {
85
- /* Renders Link as <a> element if:
86
- * - It is opted explicitely by `enforceA` prop;
87
- * - It should be opened in a new tab;
88
- * - It is an absolte URL (starts with http:// or https://);
89
- * - It is anchor link (starts with #). */
90
- if (disabled || enforceA || openNewTab
91
- || (to as string).match(/^(#|(https?|mailto):)/)) {
92
- return (
93
- <a
94
- className={className}
95
- // TODO: This requires a fix: disabled is not really an attribute of <a>
96
- // tag, thus for disabled option we rather should render a plain text
97
- // styled as a link.
98
- // disabled={disabled}
99
- href={to as string}
100
- onClick={disabled ? (e) => {
101
- e.preventDefault();
102
- } : onClick}
103
- onMouseDown={disabled ? (e) => {
104
- e.preventDefault();
105
- } : onMouseDown}
106
- rel="noopener noreferrer"
107
- styleName="link"
108
- target={openNewTab ? '_blank' : ''}
109
- >
110
- {children}
111
- </a>
112
- );
113
- }
114
-
115
- const L = routerLinkType;
116
-
117
- return (
118
- <L
119
- className={className}
120
- discover="none"
121
- // disabled
122
- onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
123
- // Executes the user-provided event handler, if any.
124
- if (onClick) onClick(e);
125
-
126
- // By default, clicking the link scrolls the page to beginning.
127
- if (!keepScrollPosition) window.scroll(0, 0);
128
- }}
129
- onMouseDown={onMouseDown}
130
- replace={replace}
131
- to={to}
132
- // TODO: Refactor it later.
133
- // eslint-disable-next-line react/jsx-props-no-spreading
134
- {...rest}
135
- >
136
- {children}
137
- </L>
138
- );
139
- };
140
-
141
- export default GenericLink;
@@ -1,3 +0,0 @@
1
- .link[disabled] {
2
- cursor: not-allowed;
3
- }
@@ -1,96 +0,0 @@
1
- import {
2
- type FunctionComponent,
3
- type ReactNode,
4
- type Ref,
5
- useRef,
6
- useState,
7
- } from 'react';
8
-
9
- import themed, { type Theme } from '@dr.pogodin/react-themes';
10
-
11
- import defaultTheme from './theme.scss';
12
-
13
- type ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'
14
- | 'focused' | 'input' | 'label';
15
-
16
- type PropsT = React.InputHTMLAttributes<HTMLInputElement> & {
17
- children?: ReactNode;
18
- error?: ReactNode;
19
- label?: React.ReactNode;
20
- ref?: Ref<HTMLInputElement>;
21
- testId?: string;
22
- theme: Theme<ThemeKeyT>;
23
- };
24
-
25
- /**
26
- * Themeable input field, based on the standard HTML `<input>` element.
27
- * @param [props.label] Input label.
28
- * @param [props.theme] _Ad hoc_ theme.
29
- * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
30
- * @param [props...] Any other properties are passed to the underlying
31
- * `<input>` element.
32
- */
33
- const Input: FunctionComponent<PropsT> = ({
34
- children,
35
- error,
36
- label,
37
- ref,
38
- testId,
39
- theme,
40
- ...rest
41
- }) => {
42
- // NOTE: As of now, it is only updated when "theme.focused" is defined,
43
- // as otherwise its value is not used.
44
- const [focused, setFocused] = useState(false);
45
-
46
- const localRef = useRef<HTMLInputElement>(null);
47
-
48
- let containerClassName = theme.container;
49
-
50
- // NOTE: As of now, "focused" can be true only when "theme.focused"
51
- // is provided.
52
- if (focused /* && theme.focused */) containerClassName += ` ${theme.focused}`;
53
-
54
- if (!rest.value && theme.empty) containerClassName += ` ${theme.empty}`;
55
-
56
- if (error) containerClassName += ` ${theme.error}`;
57
-
58
- return (
59
- <div
60
- className={containerClassName}
61
- onFocus={() => {
62
- // TODO: It does not really work if a callback-style `ref` is passed in,
63
- // we need a more complex logic to cover that case, but for now this serves
64
- // the case we need it for.
65
- if (typeof ref === 'object') ref?.current?.focus();
66
- else localRef.current?.focus();
67
- }}
68
- >
69
- {label === undefined ? null : <div className={theme.label}>{label}</div>}
70
- <input
71
- className={theme.input}
72
- data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}
73
- ref={ref ?? localRef}
74
-
75
- // TODO: Avoid the spreading later.
76
- // eslint-disable-next-line react/jsx-props-no-spreading
77
- {...rest}
78
-
79
- onBlur={theme.focused ? (e) => {
80
- setFocused(false);
81
- rest.onBlur?.(e);
82
- } : rest.onBlur}
83
- onFocus={theme.focused ? (e) => {
84
- setFocused(true);
85
- rest.onFocus?.(e);
86
- } : rest.onFocus}
87
- />
88
- {error && error !== true
89
- ? <div className={theme.errorMessage}>{error}</div>
90
- : null}
91
- {children ? <div className={theme.children}>{children}</div> : null}
92
- </div>
93
- );
94
- };
95
-
96
- export default themed(Input, 'Input', defaultTheme);
@@ -1,52 +0,0 @@
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
- }
@@ -1,25 +0,0 @@
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 { type LinkProps, Link as RrLink } from 'react-router';
10
-
11
- import GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';
12
-
13
- type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & LinkProps;
14
-
15
- const Link: React.FunctionComponent<PropsT>
16
- = (props) => (
17
- <GenericLink
18
- // TODO: Avoid the spreading later.
19
- // eslint-disable-next-line react/jsx-props-no-spreading
20
- {...props}
21
- routerLinkType={RrLink}
22
- />
23
- );
24
-
25
- export default Link;
@@ -1,38 +0,0 @@
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
- }
@@ -1,177 +0,0 @@
1
- import {
2
- type CSSProperties,
3
- type FunctionComponent,
4
- type ReactNode,
5
- useEffect,
6
- useMemo,
7
- useRef,
8
- } from 'react';
9
-
10
- import { createPortal } from 'react-dom';
11
- import themed, { type Theme } from '@dr.pogodin/react-themes';
12
-
13
- import baseTheme from './base-theme.scss';
14
- import S from './styles.scss';
15
-
16
- type PropsT = {
17
- cancelOnScrolling?: boolean;
18
- children?: ReactNode;
19
- dontDisableScrolling?: boolean;
20
- onCancel?: () => void;
21
- overlayStyle?: CSSProperties;
22
- style?: CSSProperties;
23
- testId?: string;
24
- testIdForOverlay?: string;
25
- theme: Theme<'container' | 'overlay'>;
26
-
27
- /** @deprecated */
28
- containerStyle?: CSSProperties;
29
- };
30
-
31
- /**
32
- * The `<Modal>` component implements a simple themeable modal window, wrapped
33
- * into the default theme. `<BaseModal>` exposes the base non-themed component.
34
- * **Children:** Component children are rendered as the modal content.
35
- * @param {object} props Component properties. Beside props documented below,
36
- * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.
37
- * @param {function} [props.onCancel] The callback to trigger when user
38
- * clicks outside the modal, or presses Escape. It is expected to hide the
39
- * modal.
40
- * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
41
- */
42
- const BaseModal: FunctionComponent<PropsT> = ({
43
- cancelOnScrolling,
44
- children,
45
- containerStyle,
46
- dontDisableScrolling,
47
- onCancel,
48
- overlayStyle,
49
- style,
50
- testId,
51
- testIdForOverlay,
52
- theme,
53
- }) => {
54
- const containerRef = useRef<HTMLDivElement | null>(null);
55
- const overlayRef = useRef<HTMLDivElement | null>(null);
56
-
57
- // Sets up modal cancellation of scrolling, if opted-in.
58
- useEffect(() => {
59
- if (cancelOnScrolling && onCancel) {
60
- window.addEventListener('scroll', onCancel);
61
- window.addEventListener('wheel', onCancel);
62
- }
63
- return () => {
64
- if (cancelOnScrolling && onCancel) {
65
- window.removeEventListener('scroll', onCancel);
66
- window.removeEventListener('wheel', onCancel);
67
- }
68
- };
69
- }, [cancelOnScrolling, onCancel]);
70
-
71
- // Disables window scrolling, if it is not opted-out.
72
- useEffect(() => {
73
- if (!dontDisableScrolling) {
74
- document.body.classList.add(S.scrollingDisabledByModal);
75
- }
76
- return () => {
77
- if (!dontDisableScrolling) {
78
- document.body.classList.remove(S.scrollingDisabledByModal);
79
- }
80
- };
81
- }, [dontDisableScrolling]);
82
-
83
- const focusLast = useMemo(() => (
84
- <div
85
- onFocus={() => {
86
- const elems = containerRef.current!.querySelectorAll('*');
87
- for (let i = elems.length - 1; i >= 0; --i) {
88
- (elems[i] as HTMLElement).focus();
89
- if (document.activeElement === elems[i]) return;
90
- }
91
- overlayRef.current?.focus();
92
- }}
93
- // TODO: Have a look at this later.
94
- // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
95
- tabIndex={0}
96
- />
97
- ), []);
98
-
99
- return createPortal(
100
- (
101
- <div>
102
- {focusLast}
103
- <div
104
- aria-label="Cancel"
105
- className={theme.overlay}
106
- data-testid={
107
- process.env.NODE_ENV === 'production'
108
- ? undefined : testIdForOverlay
109
- }
110
- onClick={(e) => {
111
- if (onCancel) {
112
- onCancel();
113
- e.stopPropagation();
114
- }
115
- }}
116
- onKeyDown={(e) => {
117
- if (e.key === 'Escape' && onCancel) {
118
- onCancel();
119
- e.stopPropagation();
120
- }
121
- }}
122
- ref={(node) => {
123
- if (node && node !== overlayRef.current) {
124
- overlayRef.current = node;
125
- node.focus();
126
- }
127
- }}
128
- role="button"
129
- style={overlayStyle}
130
- tabIndex={0}
131
- />
132
- {
133
- // NOTE: These rules are disabled because our intention is to keep
134
- // the element non-interactive (thus not on the keyboard focus chain),
135
- // and it has `onClick` handler merely to stop propagation of click
136
- // events to its parent container. This is needed because, for example
137
- // when the modal is wrapped into an interactive element we don't want
138
- // any clicks inside the modal to bubble-up to that parent element
139
- // (because visually and logically the modal dialog does not belong
140
- // to its parent container, where it technically belongs from
141
- // the HTML mark-up perpective).
142
- }
143
- <div // eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
144
- aria-modal="true"
145
- className={theme.container}
146
- data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}
147
- onClick={(e) => {
148
- e.stopPropagation();
149
- }}
150
- onWheel={(event) => {
151
- event.stopPropagation();
152
- }}
153
- ref={containerRef}
154
- role="dialog"
155
- style={style ?? containerStyle}
156
- >
157
- {children}
158
- </div>
159
- <div
160
- onFocus={() => {
161
- overlayRef.current?.focus();
162
- }}
163
- // TODO: Have a look at this later.
164
- // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
165
- tabIndex={0}
166
- />
167
- {focusLast}
168
- </div>
169
- ),
170
- document.body,
171
- );
172
- };
173
-
174
- export default themed(BaseModal, 'Modal', baseTheme);
175
-
176
- /* Non-themed version of the Modal. */
177
- export { BaseModal };
@@ -1,3 +0,0 @@
1
- .scrollingDisabledByModal {
2
- overflow: hidden;
3
- }
@@ -1,18 +0,0 @@
1
- import { type NavLinkProps, NavLink as RrNavLink } from 'react-router';
2
-
3
- import GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';
4
-
5
- type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & NavLinkProps;
6
-
7
- const NavLink: React.FunctionComponent<PropsT>
8
- = (props) => (
9
- <GenericLink
10
- // TODO: I guess, we better re-write it to avoid the props spreading,
11
- // but no need to spend time on it right now.
12
- // eslint-disable-next-line react/jsx-props-no-spreading
13
- {...props}
14
- routerLinkType={RrNavLink}
15
- />
16
- );
17
-
18
- export default NavLink;
@@ -1,30 +0,0 @@
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
- }