@dr.pogodin/react-utils 1.40.10 → 1.40.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 (48) hide show
  1. package/bin/setup.js +38 -10
  2. package/build/development/client/index.js +2 -1
  3. package/build/development/client/index.js.map +1 -1
  4. package/build/development/server/renderer.js +2 -1
  5. package/build/development/server/renderer.js.map +1 -1
  6. package/build/development/server/utils/errors.js.map +1 -1
  7. package/build/development/shared/components/GenericLink/index.js +0 -4
  8. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  9. package/build/development/shared/components/Link.js.map +1 -1
  10. package/build/development/shared/components/NavLink.js.map +1 -1
  11. package/build/development/shared/utils/webpack.js +12 -9
  12. package/build/development/shared/utils/webpack.js.map +1 -1
  13. package/build/development/style.css +0 -78
  14. package/build/development/web.bundle.js +3 -3
  15. package/build/production/client/index.js +1 -1
  16. package/build/production/client/index.js.map +1 -1
  17. package/build/production/server/renderer.js +1 -1
  18. package/build/production/server/renderer.js.map +1 -1
  19. package/build/production/server/utils/errors.js.map +1 -1
  20. package/build/production/shared/components/GenericLink/index.js +1 -1
  21. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  22. package/build/production/shared/components/Link.js.map +1 -1
  23. package/build/production/shared/components/NavLink.js.map +1 -1
  24. package/build/production/shared/utils/webpack.js +1 -1
  25. package/build/production/shared/utils/webpack.js.map +1 -1
  26. package/build/production/style.css.map +1 -1
  27. package/build/production/web.bundle.js +1 -1
  28. package/build/production/web.bundle.js.map +1 -1
  29. package/build/types-code/server/utils/errors.d.ts +1 -1
  30. package/build/types-code/shared/components/GenericLink/index.d.ts +7 -7
  31. package/build/types-code/shared/components/Link.d.ts +2 -1
  32. package/build/types-code/shared/components/NavLink.d.ts +2 -1
  33. package/build/types-code/shared/utils/webpack.d.ts +1 -1
  34. package/config/stylelint/default.js +1 -0
  35. package/package.json +8 -8
  36. package/src/client/index.tsx +6 -1
  37. package/src/server/renderer.tsx +4 -1
  38. package/src/server/utils/errors.ts +1 -1
  39. package/src/shared/components/GenericLink/index.tsx +15 -11
  40. package/src/shared/components/Link.tsx +2 -2
  41. package/src/shared/components/Modal/base-theme.scss +1 -1
  42. package/src/shared/components/NavLink.tsx +2 -2
  43. package/src/shared/components/PageLayout/base-theme.scss +1 -1
  44. package/src/shared/components/TextArea/style.scss +0 -1
  45. package/src/shared/components/selectors/NativeDropdown/theme.scss +0 -2
  46. package/src/shared/utils/webpack.ts +14 -9
  47. package/src/styles/global.scss +1 -1
  48. package/src/styles/mixins.scss +3 -3
@@ -80,7 +80,7 @@ export declare function newError(message: string, statusCode?: CODES): ErrorWith
80
80
  /**
81
81
  * Throws an error with given message and HTTP status code.
82
82
  */
83
- export declare function fail(message: string, statusCode?: CODES): never;
83
+ export declare function fail(message: string, statusCode?: CODES): Error;
84
84
  /**
85
85
  * ```js
86
86
  * import { server } from '@dr.pogodin/react-utils';
@@ -1,9 +1,9 @@
1
- import { type ReactNode } from 'react';
2
- import { type Link } from 'react-router-dom';
1
+ import type { ReactNode } from 'react';
2
+ import type { Link, LinkProps, NavLink, NavLinkProps } from 'react-router-dom';
3
3
  import './style.scss';
4
+ type LinkT = typeof Link;
5
+ type NavLinkT = typeof NavLink;
4
6
  type ToT = Parameters<typeof Link>[0]['to'];
5
- interface LinkI {
6
- }
7
7
  export type PropsT = {
8
8
  children?: ReactNode;
9
9
  className?: string;
@@ -14,8 +14,8 @@ export type PropsT = {
14
14
  onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;
15
15
  openNewTab?: boolean;
16
16
  replace?: boolean;
17
- routerLinkType: LinkI;
18
- to?: ToT;
17
+ routerLinkType: LinkT | NavLinkT;
18
+ to: ToT;
19
19
  };
20
20
  /**
21
21
  * The `<Link>` component, and almost identical `<NavLink>` component, are
@@ -57,5 +57,5 @@ export type PropsT = {
57
57
  * determining if the location matches the current URL. See the `<Route strict>`
58
58
  * documentation for more information.
59
59
  */
60
- declare const GenericLink: React.FunctionComponent<PropsT>;
60
+ declare const GenericLink: ({ children, className, disabled, enforceA, keepScrollPosition, onClick, onMouseDown, openNewTab, replace, routerLinkType, to, ...rest }: (LinkProps | NavLinkProps) & PropsT) => ReactNode;
61
61
  export default GenericLink;
@@ -5,7 +5,8 @@
5
5
  * - User opts to open the reference in a new tab;
6
6
  * - User explicitely opts to use <a>.
7
7
  */
8
+ import { type LinkProps } from 'react-router-dom';
8
9
  import { type PropsT as GenericLinkPropsT } from './GenericLink';
9
- type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'>;
10
+ type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & LinkProps;
10
11
  declare const Link: React.FunctionComponent<PropsT>;
11
12
  export default Link;
@@ -1,4 +1,5 @@
1
+ import { type NavLinkProps } from 'react-router-dom';
1
2
  import { type PropsT as GenericLinkPropsT } from './GenericLink';
2
- type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'>;
3
+ type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & NavLinkProps;
3
4
  declare const NavLink: React.FunctionComponent<PropsT>;
4
5
  export default NavLink;
@@ -5,7 +5,7 @@
5
5
  * @param [basePath]
6
6
  * @return Required module.
7
7
  */
8
- export declare function requireWeak(modulePath: string, basePath?: string): NodeJS.Module | null;
8
+ export declare function requireWeak<Module extends NodeJS.Module>(modulePath: string, basePath?: string): Module | null;
9
9
  /**
10
10
  * Resolves specified module path with help of Babel's module resolver.
11
11
  * Yes, the function itself just returns its argument to the caller, but Babel
@@ -14,6 +14,7 @@ module.exports = {
14
14
  'each',
15
15
  'extend',
16
16
  'for',
17
+ 'forward',
17
18
  'include',
18
19
  'mixin',
19
20
  'use',
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.40.10",
2
+ "version": "1.40.11",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -35,14 +35,14 @@
35
35
  "react": "^18.3.1",
36
36
  "react-dom": "^18.3.1",
37
37
  "react-helmet": "^6.1.0",
38
- "react-router-dom": "^6.27.0",
38
+ "react-router-dom": "^6.28.0",
39
39
  "request-ip": "^3.3.0",
40
40
  "rimraf": "^6.0.0",
41
41
  "serialize-javascript": "^6.0.2",
42
42
  "serve-favicon": "^2.5.0",
43
43
  "source-map-support": "^0.5.21",
44
44
  "uuid": "^11.0.2",
45
- "winston": "^3.16.0"
45
+ "winston": "^3.17.0"
46
46
  },
47
47
  "description": "Collection of generic ReactJS components and utils",
48
48
  "devDependencies": {
@@ -95,10 +95,10 @@
95
95
  "eslint-config-airbnb-typescript": "^18.0.0",
96
96
  "eslint-import-resolver-babel-module": "^5.3.2",
97
97
  "eslint-plugin-import": "^2.31.0",
98
- "eslint-plugin-jest": "^28.8.3",
98
+ "eslint-plugin-jest": "^28.9.0",
99
99
  "eslint-plugin-jsx-a11y": "^6.10.2",
100
100
  "eslint-plugin-react": "^7.37.2",
101
- "eslint-plugin-react-hooks": "^4.3.0",
101
+ "eslint-plugin-react-hooks": "^4.6.2",
102
102
  "identity-obj-proxy": "^3.0.0",
103
103
  "jest": "^29.7.0",
104
104
  "jest-environment-jsdom": "^29.7.0",
@@ -106,7 +106,7 @@
106
106
  "mini-css-extract-plugin": "^2.9.2",
107
107
  "mockdate": "^3.0.5",
108
108
  "nodelist-foreach-polyfill": "^1.2.0",
109
- "postcss": "^8.4.47",
109
+ "postcss": "^8.4.49",
110
110
  "postcss-loader": "^8.1.1",
111
111
  "postcss-scss": "^4.0.9",
112
112
  "pretty": "^2.0.0",
@@ -121,10 +121,10 @@
121
121
  "stylelint-config-standard-scss": "^13.1.0",
122
122
  "supertest": "^7.0.0",
123
123
  "tsc-alias": "^1.8.10",
124
- "tstyche": "^2.1.1",
124
+ "tstyche": "^3.0.0",
125
125
  "typed-scss-modules": "^8.0.1",
126
126
  "typescript": "^5.6.3",
127
- "typescript-eslint": "^8.12.2",
127
+ "typescript-eslint": "^8.14.0",
128
128
  "webpack": "^5.96.1",
129
129
  "webpack-dev-middleware": "^7.4.2",
130
130
  "webpack-hot-middleware": "^2.26.1",
@@ -28,7 +28,12 @@ export default function Launch(
28
28
  if (!container) throw Error('Failed to find container for React app');
29
29
  const scene = (
30
30
  <GlobalStateProvider initialState={getInj().ISTATE || options.initialState}>
31
- <BrowserRouter future={{ v7_relativeSplatPath: true }}>
31
+ <BrowserRouter
32
+ future={{
33
+ v7_relativeSplatPath: true,
34
+ v7_startTransition: true,
35
+ }}
36
+ >
32
37
  <Application />
33
38
  </BrowserRouter>
34
39
  </GlobalStateProvider>
@@ -443,7 +443,10 @@ export default function factory(
443
443
  ssrContext={ssrContext}
444
444
  >
445
445
  <StaticRouter
446
- future={{ v7_relativeSplatPath: true }}
446
+ future={{
447
+ v7_relativeSplatPath: true,
448
+ v7_startTransition: true,
449
+ }}
447
450
  location={req.url}
448
451
  >
449
452
  <App2 />
@@ -101,7 +101,7 @@ export function newError(message: string, statusCode = CODES.INTERNAL_SERVER_ERR
101
101
  export function fail(
102
102
  message: string,
103
103
  statusCode: CODES = CODES.INTERNAL_SERVER_ERROR,
104
- ): never {
104
+ ): Error {
105
105
  throw newError(message, statusCode);
106
106
  }
107
107
 
@@ -1,14 +1,18 @@
1
- /* global window */
1
+ import type { ReactNode } from 'react';
2
2
 
3
- import { type ReactNode } from 'react';
4
-
5
- import { type Link, type NavLink } from 'react-router-dom';
3
+ import type {
4
+ Link,
5
+ LinkProps,
6
+ NavLink,
7
+ NavLinkProps,
8
+ } from 'react-router-dom';
6
9
 
7
10
  import './style.scss';
8
11
 
9
- type ToT = Parameters<typeof Link>[0]['to'];
12
+ type LinkT = typeof Link;
13
+ type NavLinkT = typeof NavLink;
10
14
 
11
- interface LinkI {}
15
+ type ToT = Parameters<typeof Link>[0]['to'];
12
16
 
13
17
  export type PropsT = {
14
18
  children?: ReactNode;
@@ -20,8 +24,8 @@ export type PropsT = {
20
24
  onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;
21
25
  openNewTab?: boolean;
22
26
  replace?: boolean;
23
- routerLinkType: LinkI;
24
- to?: ToT;
27
+ routerLinkType: LinkT | NavLinkT;
28
+ to: ToT;
25
29
  };
26
30
 
27
31
  /**
@@ -64,7 +68,7 @@ export type PropsT = {
64
68
  * determining if the location matches the current URL. See the `<Route strict>`
65
69
  * documentation for more information.
66
70
  */
67
- const GenericLink: React.FunctionComponent<PropsT> = ({
71
+ const GenericLink = ({
68
72
  children,
69
73
  className,
70
74
  disabled,
@@ -77,7 +81,7 @@ const GenericLink: React.FunctionComponent<PropsT> = ({
77
81
  routerLinkType,
78
82
  to,
79
83
  ...rest
80
- }) => {
84
+ }: (LinkProps | NavLinkProps) & PropsT): ReactNode => {
81
85
  /* Renders Link as <a> element if:
82
86
  * - It is opted explicitely by `enforceA` prop;
83
87
  * - It should be opened in a new tab;
@@ -103,7 +107,7 @@ const GenericLink: React.FunctionComponent<PropsT> = ({
103
107
  );
104
108
  }
105
109
 
106
- const L = routerLinkType as typeof NavLink;
110
+ const L = routerLinkType;
107
111
 
108
112
  return (
109
113
  <L
@@ -6,11 +6,11 @@
6
6
  * - User explicitely opts to use <a>.
7
7
  */
8
8
 
9
- import { Link as RrLink } from 'react-router-dom';
9
+ import { type LinkProps, Link as RrLink } from 'react-router-dom';
10
10
 
11
11
  import GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';
12
12
 
13
- type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'>;
13
+ type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & LinkProps;
14
14
 
15
15
  const Link: React.FunctionComponent<PropsT> = (props) => (
16
16
  /* eslint-disable react/jsx-props-no-spreading */
@@ -1,4 +1,4 @@
1
- @import "styles/mixins";
1
+ @use "styles/mixins" as *;
2
2
 
3
3
  *,
4
4
  .context,
@@ -1,8 +1,8 @@
1
- import { NavLink as RrNavLink } from 'react-router-dom';
1
+ import { type NavLinkProps, NavLink as RrNavLink } from 'react-router-dom';
2
2
 
3
3
  import GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';
4
4
 
5
- type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'>;
5
+ type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & NavLinkProps;
6
6
 
7
7
  const NavLink: React.FunctionComponent<PropsT> = (props) => (
8
8
  /* eslint-disable react/jsx-props-no-spreading */
@@ -5,7 +5,7 @@
5
5
  * columns on left and right.
6
6
  */
7
7
 
8
- @import "styles/mixins";
8
+ @use "styles/mixins" as *;
9
9
 
10
10
  *,
11
11
  .context,
@@ -1,5 +1,4 @@
1
1
  @use "sass:color";
2
- @import "styles/mixins";
3
2
 
4
3
  *,
5
4
  .context,
@@ -1,5 +1,3 @@
1
- @import "styles/mixins";
2
-
3
1
  *,
4
2
  .context,
5
3
  .ad.hoc {
@@ -7,29 +7,34 @@ import { IS_CLIENT_SIDE } from './isomorphy';
7
7
  * @param [basePath]
8
8
  * @return Required module.
9
9
  */
10
- export function requireWeak(
10
+ export function requireWeak<Module extends NodeJS.Module>(
11
11
  modulePath: string,
12
12
  basePath?: string,
13
- ): NodeJS.Module | null {
13
+ ): Module | null {
14
14
  if (IS_CLIENT_SIDE) return null;
15
15
 
16
16
  try {
17
17
  /* eslint-disable no-eval */
18
18
  const { resolve } = eval('require')('path');
19
19
  const path = basePath ? resolve(basePath, modulePath) : modulePath;
20
- const { default: def, ...named } = eval('require')(path);
20
+ const module = eval('require')(path) as Module;
21
21
  /* eslint-enable no-eval */
22
22
 
23
- if (!def) return named;
23
+ if (!('default' in module)) return module;
24
24
 
25
- Object.entries(named).forEach(([key, value]) => {
26
- if (def[key]) {
27
- if (def[key] !== value) {
25
+ const { default: def, ...named } = module;
26
+
27
+ const res = def as Module;
28
+
29
+ Object.entries(named).forEach(([name, value]) => {
30
+ const assigned = res[name as keyof Module];
31
+ if (assigned !== undefined) {
32
+ if (assigned !== value) {
28
33
  throw Error('Conflict between default and named exports');
29
34
  }
30
- } else def[key] = value;
35
+ } else res[name as keyof Module] = value;
31
36
  });
32
- return def;
37
+ return res;
33
38
  } catch {
34
39
  return null;
35
40
  }
@@ -1,6 +1,6 @@
1
1
  /* Global styles. */
2
2
 
3
- @import "_global/reset";
3
+ @use "_global/reset";
4
4
 
5
5
  body {
6
6
  text-rendering: auto;
@@ -1,6 +1,6 @@
1
1
  /* Collection of standard mixins, being used all around. */
2
- @import "_mixins/fonts";
3
- @import "_mixins/media";
4
- @import "_mixins/typography";
2
+ @forward "_mixins/fonts";
3
+ @forward "_mixins/media";
4
+ @forward "_mixins/typography";
5
5
 
6
6
  $zIndexOfDefaultModalOverlay: 998;