@dr.pogodin/react-utils 1.31.0 → 1.31.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 (46) hide show
  1. package/build/development/index.js +1 -1
  2. package/build/development/index.js.map +1 -1
  3. package/build/development/server/index.js +1 -1
  4. package/build/development/server/index.js.map +1 -1
  5. package/build/development/server/utils/index.js +1 -1
  6. package/build/development/shared/components/Modal/index.js +15 -0
  7. package/build/development/shared/components/Modal/index.js.map +1 -1
  8. package/build/development/shared/components/WithTooltip/index.js +1 -1
  9. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  10. package/build/development/shared/components/index.js +1 -1
  11. package/build/development/shared/components/index.js.map +1 -1
  12. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +8 -16
  13. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  14. package/build/development/shared/utils/index.js +1 -1
  15. package/build/development/shared/utils/index.js.map +1 -1
  16. package/build/development/shared/utils/jest/E2eSsrEnv.js +3 -0
  17. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  18. package/build/development/shared/utils/jest/index.js +1 -1
  19. package/build/development/shared/utils/jest/index.js.map +1 -1
  20. package/build/development/web.bundle.js +13 -13
  21. package/build/production/index.js +1 -1
  22. package/build/production/index.js.map +1 -1
  23. package/build/production/server/index.js +1 -1
  24. package/build/production/server/index.js.map +1 -1
  25. package/build/production/server/utils/index.js +1 -1
  26. package/build/production/shared/components/Modal/index.js +3 -2
  27. package/build/production/shared/components/Modal/index.js.map +1 -1
  28. package/build/production/shared/components/WithTooltip/index.js +1 -1
  29. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  30. package/build/production/shared/components/index.js +1 -1
  31. package/build/production/shared/components/index.js.map +1 -1
  32. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
  33. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  34. package/build/production/shared/utils/index.js +1 -1
  35. package/build/production/shared/utils/index.js.map +1 -1
  36. package/build/production/shared/utils/jest/E2eSsrEnv.js +3 -1
  37. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  38. package/build/production/shared/utils/jest/index.js +1 -1
  39. package/build/production/shared/utils/jest/index.js.map +1 -1
  40. package/build/production/web.bundle.js +1 -1
  41. package/build/production/web.bundle.js.map +1 -1
  42. package/build/types-code/shared/components/Modal/index.d.ts +1 -0
  43. package/package.json +27 -27
  44. package/src/shared/components/Modal/index.tsx +16 -0
  45. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +6 -16
  46. package/src/shared/utils/jest/E2eSsrEnv.ts +5 -1
@@ -2,6 +2,7 @@ import { type ReactNode } from 'react';
2
2
  import { type Theme } from '@dr.pogodin/react-themes';
3
3
  declare const validThemeKeys: readonly ["container", "overlay"];
4
4
  type PropsT = {
5
+ cancelOnScrolling?: boolean;
5
6
  children?: ReactNode;
6
7
  containerStyle?: React.CSSProperties;
7
8
  dontDisableScrolling?: boolean;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.31.0",
2
+ "version": "1.31.1",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -8,14 +8,14 @@
8
8
  "url": "https://github.com/birdofpreyru/react-utils/issues"
9
9
  },
10
10
  "dependencies": {
11
- "@babel/runtime": "^7.24.0",
11
+ "@babel/runtime": "^7.24.1",
12
12
  "@dr.pogodin/babel-plugin-react-css-modules": "^6.12.0",
13
13
  "@dr.pogodin/csurf": "^1.13.0",
14
14
  "@dr.pogodin/js-utils": "^0.0.9",
15
15
  "@dr.pogodin/react-global-state": "^0.13.0",
16
16
  "@dr.pogodin/react-themes": "^1.6.0",
17
17
  "@jest/environment": "^29.7.0",
18
- "axios": "^1.6.7",
18
+ "axios": "^1.6.8",
19
19
  "commander": "^12.0.0",
20
20
  "compression": "^1.7.4",
21
21
  "config": "^3.3.11",
@@ -23,7 +23,7 @@
23
23
  "cookie-parser": "^1.4.6",
24
24
  "cross-env": "^7.0.3",
25
25
  "dayjs": "^1.11.10",
26
- "express": "^4.18.3",
26
+ "express": "^4.19.2",
27
27
  "helmet": "^7.1.0",
28
28
  "http-status-codes": "^2.3.0",
29
29
  "joi": "^17.12.2",
@@ -43,27 +43,27 @@
43
43
  "serve-favicon": "^2.5.0",
44
44
  "source-map-support": "^0.5.21",
45
45
  "uuid": "^9.0.1",
46
- "winston": "^3.12.0"
46
+ "winston": "^3.13.0"
47
47
  },
48
48
  "description": "Collection of generic ReactJS components and utils",
49
49
  "devDependencies": {
50
- "@babel/cli": "^7.23.9",
51
- "@babel/core": "^7.24.0",
52
- "@babel/eslint-parser": "^7.23.10",
50
+ "@babel/cli": "^7.24.1",
51
+ "@babel/core": "^7.24.3",
52
+ "@babel/eslint-parser": "^7.24.1",
53
53
  "@babel/eslint-plugin": "^7.23.5",
54
54
  "@babel/node": "^7.23.9",
55
- "@babel/plugin-transform-runtime": "^7.24.0",
56
- "@babel/preset-env": "^7.24.0",
57
- "@babel/preset-react": "^7.23.3",
58
- "@babel/preset-typescript": "^7.23.3",
55
+ "@babel/plugin-transform-runtime": "^7.24.3",
56
+ "@babel/preset-env": "^7.24.3",
57
+ "@babel/preset-react": "^7.24.1",
58
+ "@babel/preset-typescript": "^7.24.1",
59
59
  "@babel/register": "^7.23.7",
60
60
  "@dr.pogodin/babel-plugin-transform-assets": "^1.2.2",
61
61
  "@dr.pogodin/babel-preset-svgr": "^1.8.0",
62
62
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
63
- "@tsconfig/recommended": "^1.0.3",
64
- "@tsd/typescript": "^5.3.3",
63
+ "@tsconfig/recommended": "^1.0.4",
64
+ "@tsd/typescript": "^5.4.3",
65
65
  "@types/compression": "^1.7.5",
66
- "@types/config": "^3.3.3",
66
+ "@types/config": "^3.3.4",
67
67
  "@types/cookie": "^0.6.0",
68
68
  "@types/cookie-parser": "^1.4.7",
69
69
  "@types/csurf": "^1.11.5",
@@ -73,7 +73,7 @@
73
73
  "@types/morgan": "^1.9.9",
74
74
  "@types/node-forge": "^1.3.11",
75
75
  "@types/pretty": "^2.0.3",
76
- "@types/react": "^18.2.66",
76
+ "@types/react": "^18.2.70",
77
77
  "@types/react-dom": "^18.2.22",
78
78
  "@types/react-helmet": "^6.1.11",
79
79
  "@types/react-test-renderer": "^18.0.7",
@@ -83,11 +83,11 @@
83
83
  "@types/supertest": "^6.0.2",
84
84
  "@types/uuid": "^9.0.8",
85
85
  "@types/webpack": "^5.28.5",
86
- "autoprefixer": "^10.4.18",
86
+ "autoprefixer": "^10.4.19",
87
87
  "babel-jest": "^29.7.0",
88
88
  "babel-loader": "^9.1.3",
89
89
  "babel-plugin-module-resolver": "^5.0.0",
90
- "core-js": "^3.36.0",
90
+ "core-js": "^3.36.1",
91
91
  "css-loader": "^6.10.0",
92
92
  "css-minimizer-webpack-plugin": "^6.0.0",
93
93
  "eslint": "^8.57.0",
@@ -97,16 +97,16 @@
97
97
  "eslint-plugin-import": "^2.29.1",
98
98
  "eslint-plugin-jest": "^27.9.0",
99
99
  "eslint-plugin-jsx-a11y": "^6.8.0",
100
- "eslint-plugin-react": "^7.34.0",
100
+ "eslint-plugin-react": "^7.34.1",
101
101
  "eslint-plugin-react-hooks": "^4.6.0",
102
102
  "identity-obj-proxy": "^3.0.0",
103
103
  "jest": "^29.7.0",
104
104
  "jest-environment-jsdom": "^29.7.0",
105
- "memfs": "^4.7.7",
105
+ "memfs": "^4.8.0",
106
106
  "mini-css-extract-plugin": "^2.8.1",
107
107
  "mockdate": "^3.0.5",
108
108
  "nodelist-foreach-polyfill": "^1.2.0",
109
- "postcss": "^8.4.35",
109
+ "postcss": "^8.4.38",
110
110
  "postcss-loader": "^8.1.1",
111
111
  "postcss-scss": "^4.0.9",
112
112
  "pretty": "^2.0.0",
@@ -117,15 +117,15 @@
117
117
  "sass": "^1.72.0",
118
118
  "sass-loader": "^14.1.1",
119
119
  "sitemap": "^7.1.1",
120
- "stylelint": "^16.2.1",
120
+ "stylelint": "^16.3.0",
121
121
  "stylelint-config-standard-scss": "^13.0.0",
122
122
  "supertest": "^6.3.4",
123
123
  "tsc-alias": "^1.8.8",
124
- "typed-scss-modules": "^8.0.0",
125
- "typescript": "^5.4.2",
126
- "typescript-eslint": "^7.2.0",
127
- "webpack": "^5.90.3",
128
- "webpack-dev-middleware": "^7.0.0",
124
+ "typed-scss-modules": "^8.0.1",
125
+ "typescript": "^5.4.3",
126
+ "typescript-eslint": "^7.4.0",
127
+ "webpack": "^5.91.0",
128
+ "webpack-dev-middleware": "^7.1.1",
129
129
  "webpack-hot-middleware": "^2.26.1",
130
130
  "webpack-merge": "^5.10.0",
131
131
  "workbox-core": "^7.0.0",
@@ -20,6 +20,7 @@ import S from './styles.scss';
20
20
  const validThemeKeys = ['container', 'overlay'] as const;
21
21
 
22
22
  type PropsT = {
23
+ cancelOnScrolling?: boolean;
23
24
  children?: ReactNode;
24
25
  containerStyle?: React.CSSProperties;
25
26
  dontDisableScrolling?: boolean;
@@ -39,6 +40,7 @@ type PropsT = {
39
40
  * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
40
41
  */
41
42
  const BaseModal: React.FunctionComponent<PropsT> = ({
43
+ cancelOnScrolling,
42
44
  children,
43
45
  containerStyle,
44
46
  dontDisableScrolling,
@@ -58,6 +60,18 @@ const BaseModal: React.FunctionComponent<PropsT> = ({
58
60
  };
59
61
  }, []);
60
62
 
63
+ // Sets up modal cancellation of scrolling, if opted-in.
64
+ useEffect(() => {
65
+ if (cancelOnScrolling && onCancel) {
66
+ window.addEventListener('scroll', onCancel);
67
+ }
68
+ return () => {
69
+ if (cancelOnScrolling && onCancel) {
70
+ window.removeEventListener('scroll', onCancel);
71
+ }
72
+ };
73
+ }, [cancelOnScrolling, onCancel]);
74
+
61
75
  // Disables window scrolling, if it is not opted-out.
62
76
  useEffect(() => {
63
77
  if (!dontDisableScrolling) {
@@ -139,6 +153,7 @@ const ThemedModal = themed(
139
153
  );
140
154
 
141
155
  BaseModal.propTypes = {
156
+ cancelOnScrolling: PT.bool,
142
157
  children: PT.node,
143
158
  containerStyle: PT.shape({}),
144
159
  dontDisableScrolling: PT.bool,
@@ -147,6 +162,7 @@ BaseModal.propTypes = {
147
162
  };
148
163
 
149
164
  BaseModal.defaultProps = {
165
+ cancelOnScrolling: false,
150
166
  children: null,
151
167
  containerStyle: undefined,
152
168
  dontDisableScrolling: false,
@@ -1,5 +1,4 @@
1
1
  import PT from 'prop-types';
2
- import { useEffect } from 'react';
3
2
 
4
3
  import { BaseModal } from 'components/Modal';
5
4
 
@@ -35,21 +34,6 @@ const Options: React.FunctionComponent<PropsT> = ({
35
34
  optionClass,
36
35
  options,
37
36
  }) => {
38
- // Closes the dropdown (cancels the selection) on any page scrolling attempt.
39
- // This is the same native <select> elements do on scrolling, and at least for
40
- // now we have no reason to deal with complications needed to support open
41
- // dropdowns during the scrolling (that would need to re-position it in
42
- // response to the position changes of the root dropdown element).
43
- useEffect(() => {
44
- const listener = () => {
45
- onCancel();
46
- };
47
- window.addEventListener('scroll', listener);
48
- return () => {
49
- window.removeEventListener('scroll', listener);
50
- };
51
- }, [onCancel]);
52
-
53
37
  const optionNodes: React.ReactNode[] = [];
54
38
  for (let i = 0; i < options.length; ++i) {
55
39
  const option = options[i];
@@ -76,6 +60,12 @@ const Options: React.FunctionComponent<PropsT> = ({
76
60
 
77
61
  return (
78
62
  <BaseModal
63
+ // Closes the dropdown (cancels the selection) on any page scrolling attempt.
64
+ // This is the same native <select> elements do on scrolling, and at least for
65
+ // now we have no reason to deal with complications needed to support open
66
+ // dropdowns during the scrolling (that would need to re-position it in
67
+ // response to the position changes of the root dropdown element).
68
+ cancelOnScrolling
79
69
  containerStyle={{
80
70
  left: anchorRect.left,
81
71
  top: anchorRect.bottom,
@@ -87,7 +87,11 @@ export default class E2eSsrEnv extends JsdomEnv {
87
87
  this.loadWebpackConfig();
88
88
 
89
89
  const compiler = webpack(this.global.webpackConfig as webpack.Configuration);
90
- compiler.outputFileSystem = this.global.webpackOutputFs;
90
+
91
+ // TODO: The "as typeof compiler.outputFileSystem" piece below is a workaround
92
+ // for the Webpack regression: https://github.com/webpack/webpack/issues/18242
93
+ compiler.outputFileSystem = this.global.webpackOutputFs as typeof compiler.outputFileSystem;
94
+
91
95
  return new Promise<void>((done, fail) => {
92
96
  compiler.run((err, stats) => {
93
97
  if (err) fail(err);