@dr.pogodin/react-utils 1.33.4 → 1.34.0

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 (93) hide show
  1. package/build/development/shared/components/Button/index.js +0 -38
  2. package/build/development/shared/components/Button/index.js.map +1 -1
  3. package/build/development/shared/components/Checkbox/index.js +0 -5
  4. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  5. package/build/development/shared/components/GenericLink/index.js +0 -12
  6. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  7. package/build/development/shared/components/Input/index.js +0 -3
  8. package/build/development/shared/components/Input/index.js.map +1 -1
  9. package/build/development/shared/components/MetaTags.js +0 -8
  10. package/build/development/shared/components/MetaTags.js.map +1 -1
  11. package/build/development/shared/components/Modal/index.js +0 -8
  12. package/build/development/shared/components/Modal/index.js.map +1 -1
  13. package/build/development/shared/components/PageLayout/index.js +0 -5
  14. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  15. package/build/development/shared/components/TextArea/index.js +0 -7
  16. package/build/development/shared/components/TextArea/index.js.map +1 -1
  17. package/build/development/shared/components/WithTooltip/Tooltip.js +0 -3
  18. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  19. package/build/development/shared/components/WithTooltip/index.js +1 -6
  20. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  21. package/build/development/shared/components/YouTubeVideo/index.js +0 -4
  22. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  23. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +0 -4
  24. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  25. package/build/development/shared/components/selectors/CustomDropdown/index.js +0 -7
  26. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  27. package/build/development/shared/components/selectors/NativeDropdown/index.js +0 -7
  28. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  29. package/build/development/shared/components/selectors/Switch/index.js +0 -6
  30. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  31. package/build/development/shared/utils/jest/index.js +16 -75
  32. package/build/development/shared/utils/jest/index.js.map +1 -1
  33. package/build/development/shared/utils/splitComponent.js +0 -3
  34. package/build/development/shared/utils/splitComponent.js.map +1 -1
  35. package/build/development/web.bundle.js +22 -32
  36. package/build/production/shared/components/Button/index.js +1 -26
  37. package/build/production/shared/components/Button/index.js.map +1 -1
  38. package/build/production/shared/components/Checkbox/index.js +1 -1
  39. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  40. package/build/production/shared/components/GenericLink/index.js +1 -1
  41. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  42. package/build/production/shared/components/Input/index.js +1 -1
  43. package/build/production/shared/components/Input/index.js.map +1 -1
  44. package/build/production/shared/components/MetaTags.js +1 -1
  45. package/build/production/shared/components/MetaTags.js.map +1 -1
  46. package/build/production/shared/components/Modal/index.js +2 -2
  47. package/build/production/shared/components/Modal/index.js.map +1 -1
  48. package/build/production/shared/components/PageLayout/index.js +1 -1
  49. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  50. package/build/production/shared/components/TextArea/index.js +1 -1
  51. package/build/production/shared/components/TextArea/index.js.map +1 -1
  52. package/build/production/shared/components/WithTooltip/Tooltip.js +1 -1
  53. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  54. package/build/production/shared/components/WithTooltip/index.js +2 -2
  55. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  56. package/build/production/shared/components/YouTubeVideo/index.js +1 -1
  57. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  58. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
  59. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  60. package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -1
  61. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  62. package/build/production/shared/components/selectors/NativeDropdown/index.js +1 -1
  63. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  64. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  65. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  66. package/build/production/shared/utils/jest/index.js +7 -33
  67. package/build/production/shared/utils/jest/index.js.map +1 -1
  68. package/build/production/shared/utils/splitComponent.js +1 -1
  69. package/build/production/shared/utils/splitComponent.js.map +1 -1
  70. package/build/production/web.bundle.js +1 -1
  71. package/build/production/web.bundle.js.map +1 -1
  72. package/build/types-code/shared/utils/jest/index.d.ts +3 -43
  73. package/config/eslint/default.json +2 -1
  74. package/config/eslint/jest.json +2 -1
  75. package/config/eslint/typescript.js +5 -0
  76. package/package.json +40 -39
  77. package/src/shared/components/Button/index.tsx +0 -38
  78. package/src/shared/components/Checkbox/index.tsx +0 -6
  79. package/src/shared/components/GenericLink/index.tsx +0 -13
  80. package/src/shared/components/Input/index.tsx +0 -4
  81. package/src/shared/components/MetaTags.tsx +0 -9
  82. package/src/shared/components/Modal/index.tsx +0 -10
  83. package/src/shared/components/PageLayout/index.tsx +0 -6
  84. package/src/shared/components/TextArea/index.tsx +0 -8
  85. package/src/shared/components/WithTooltip/Tooltip.tsx +0 -4
  86. package/src/shared/components/WithTooltip/index.tsx +1 -7
  87. package/src/shared/components/YouTubeVideo/index.tsx +0 -5
  88. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +0 -5
  89. package/src/shared/components/selectors/CustomDropdown/index.tsx +0 -8
  90. package/src/shared/components/selectors/NativeDropdown/index.tsx +0 -8
  91. package/src/shared/components/selectors/Switch/index.tsx +0 -7
  92. package/src/shared/utils/jest/index.tsx +14 -64
  93. package/src/shared/utils/splitComponent.tsx +1 -5
@@ -1,11 +1,8 @@
1
1
  /// <reference types="trusted-types" />
2
- import { type ReactElement, type ReactNode } from 'react';
3
- import TU, { act } from 'react-dom/test-utils';
4
- import Renderer from 'react-test-renderer';
2
+ import { type ReactNode, act } from 'react';
5
3
  /**
6
4
  * An alias for [act(..)](https://reactjs.org/docs/test-utils.html#act)
7
- * from `react-dom/test-utils`.
8
- * @param {function} action
5
+ * from `react`.
9
6
  */
10
7
  export { act };
11
8
  export { default as getGlobal } from './global';
@@ -45,41 +42,4 @@ export type MountedSceneT = HTMLElement & {
45
42
  * attached.
46
43
  */
47
44
  export declare function mount(scene: ReactNode): MountedSceneT;
48
- /**
49
- * Renders provided ReactJS component into JSON representation of the component
50
- * tree, using [`react-test-renderer`](https://www.npmjs.com/package/react-test-renderer).
51
- * @param {object} component ReactJS component to render.
52
- * @return {object} JSON representation of the rendered tree.
53
- * @example
54
- * import { JU } from '@dr.pogodin/react-utils';
55
- * console.log(JU.render(<div>Example</div>));
56
- */
57
- export declare function render(component: ReactElement): Renderer.ReactTestRendererJSON | Renderer.ReactTestRendererJSON[] | null;
58
- /**
59
- * Generates a shallow render of given ReactJS component, using
60
- * [react-test-renderer/shallow](https://reactjs.org/docs/shallow-renderer.html)
61
- * and returns the result.
62
- * @param {object} component ReactJS component to render.
63
- * @return {object} JSON representation of the shallow component's render tree.
64
- */
65
- export declare function shallowRender(component: ReactElement): ReactElement<any, string | React.JSXElementConstructor<any>>;
66
- /**
67
- * Makes a shallow snapshot test of the given ReactJS component, and also
68
- * returns JSON representation of the rendered component tree. Under the hood
69
- * it uses {@link module:JU.shallowRender shallowRender(..)} to generate
70
- * the render, then executes `expect(RENDER_RESULT).toMatchSnapshot()`,
71
- * and finally returns the `RENDER_RESULT` to the caller.
72
- * @param {object} component ReactJS component to render.
73
- * @return {object} JSON representation of shallow render.
74
- */
75
- export declare function shallowSnapshot(component: ReactElement): ReactElement<any, string | React.JSXElementConstructor<any>>;
76
- /**
77
- * Makes snapshot test of the given ReactJS component, and also returns JSON
78
- * representation of the rendered component tree. Under the hood, it uses
79
- * {@link module:JU.render render(..)} to render it, then executes
80
- * `expect(RENDER_RESULT).toMatchSnapshot()`, and then returns `RENDER_RESULT`.
81
- * @param {object} component ReactJS component to render.
82
- * @return {object} JSON render of the component.
83
- */
84
- export declare function snapshot(component: ReactElement): Renderer.ReactTestRendererJSON | Renderer.ReactTestRendererJSON[] | null;
85
- export declare const simulate: typeof TU.Simulate;
45
+ export declare function snapshot(element: React.ReactElement): ChildNode | null;
@@ -18,7 +18,8 @@
18
18
  "react/no-unknown-property": ["error", {
19
19
  "ignore": ["styleName"]
20
20
  }],
21
- "react/react-in-jsx-scope": 0
21
+ "react/react-in-jsx-scope": 0,
22
+ "react/require-default-props": 0
22
23
  },
23
24
  "settings": {
24
25
  "import/resolver": {
@@ -12,6 +12,7 @@
12
12
  "import/no-dynamic-require": 0,
13
13
  "import/no-extraneous-dependencies": 0,
14
14
  "no-console": 0,
15
- "no-new-func": 0
15
+ "no-new-func": 0,
16
+ "react/require-default-props": 0
16
17
  }
17
18
  }
@@ -25,6 +25,11 @@ module.exports = {
25
25
  ignore: ['styleName'],
26
26
  }],
27
27
  'react/react-in-jsx-scope': 0,
28
+
29
+ // TODO: .defaultProps will be deprecated in React@19.
30
+ // Remove this rule override once AirBnB ESLint config is updated.
31
+ // (also remove it from sibling .json configs)
32
+ 'react/require-default-props': 0,
28
33
  },
29
34
  settings: {
30
35
  'import/resolver': {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.33.4",
2
+ "version": "1.34.0",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -8,12 +8,12 @@
8
8
  "url": "https://github.com/birdofpreyru/react-utils/issues"
9
9
  },
10
10
  "dependencies": {
11
- "@babel/runtime": "^7.24.4",
11
+ "@babel/runtime": "^7.24.5",
12
12
  "@dr.pogodin/babel-plugin-react-css-modules": "^6.13.1",
13
13
  "@dr.pogodin/csurf": "^1.13.0",
14
14
  "@dr.pogodin/js-utils": "^0.0.9",
15
- "@dr.pogodin/react-global-state": "^0.14.0",
16
- "@dr.pogodin/react-themes": "^1.6.0",
15
+ "@dr.pogodin/react-global-state": "^0.14.1",
16
+ "@dr.pogodin/react-themes": "^1.6.1",
17
17
  "@jest/environment": "^29.7.0",
18
18
  "axios": "^1.6.8",
19
19
  "commander": "^12.0.0",
@@ -22,21 +22,21 @@
22
22
  "cookie": "^0.6.0",
23
23
  "cookie-parser": "^1.4.6",
24
24
  "cross-env": "^7.0.3",
25
- "dayjs": "^1.11.10",
25
+ "dayjs": "^1.11.11",
26
26
  "express": "^4.19.2",
27
27
  "helmet": "^7.1.0",
28
28
  "http-status-codes": "^2.3.0",
29
- "joi": "^17.12.3",
29
+ "joi": "^17.13.1",
30
30
  "lodash": "^4.17.21",
31
31
  "morgan": "^1.10.0",
32
32
  "node-forge": "^1.3.1",
33
33
  "prop-types": "^15.8.1",
34
- "qs": "^6.12.0",
34
+ "qs": "^6.12.1",
35
35
  "raf": "^3.4.1",
36
- "react": "^18.2.0",
37
- "react-dom": "^18.2.0",
36
+ "react": "^18.3.1",
37
+ "react-dom": "^18.3.1",
38
38
  "react-helmet": "^6.1.0",
39
- "react-router-dom": "^6.22.3",
39
+ "react-router-dom": "^6.23.0",
40
40
  "request-ip": "^3.3.0",
41
41
  "rimraf": "^5.0.5",
42
42
  "serialize-javascript": "^6.0.2",
@@ -47,21 +47,24 @@
47
47
  },
48
48
  "description": "Collection of generic ReactJS components and utils",
49
49
  "devDependencies": {
50
- "@babel/cli": "^7.24.1",
51
- "@babel/core": "^7.24.4",
52
- "@babel/eslint-parser": "^7.24.1",
53
- "@babel/eslint-plugin": "^7.23.5",
50
+ "@babel/cli": "^7.24.5",
51
+ "@babel/core": "^7.24.5",
52
+ "@babel/eslint-parser": "^7.24.5",
53
+ "@babel/eslint-plugin": "^7.24.5",
54
54
  "@babel/node": "^7.23.9",
55
55
  "@babel/plugin-transform-runtime": "^7.24.3",
56
- "@babel/preset-env": "^7.24.4",
56
+ "@babel/preset-env": "^7.24.5",
57
57
  "@babel/preset-react": "^7.24.1",
58
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
- "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
62
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.13",
63
+ "@testing-library/dom": "^10.1.0",
64
+ "@testing-library/react": "^15.0.6",
65
+ "@testing-library/user-event": "^14.5.2",
63
66
  "@tsconfig/recommended": "^1.0.6",
64
- "@tsd/typescript": "^5.4.4",
67
+ "@tsd/typescript": "^5.4.5",
65
68
  "@types/compression": "^1.7.5",
66
69
  "@types/config": "^3.3.4",
67
70
  "@types/cookie": "^0.6.0",
@@ -69,14 +72,13 @@
69
72
  "@types/csurf": "^1.11.5",
70
73
  "@types/express": "^4.17.21",
71
74
  "@types/jest": "^29.5.12",
72
- "@types/lodash": "^4.17.0",
75
+ "@types/lodash": "^4.17.1",
73
76
  "@types/morgan": "^1.9.9",
74
77
  "@types/node-forge": "^1.3.11",
75
78
  "@types/pretty": "^2.0.3",
76
- "@types/react": "^18.2.74",
77
- "@types/react-dom": "^18.2.24",
79
+ "@types/react": "^18.3.1",
80
+ "@types/react-dom": "^18.3.0",
78
81
  "@types/react-helmet": "^6.1.11",
79
- "@types/react-test-renderer": "^18.0.7",
80
82
  "@types/request-ip": "^0.0.41",
81
83
  "@types/serialize-javascript": "^5.0.4",
82
84
  "@types/serve-favicon": "^2.5.7",
@@ -86,51 +88,50 @@
86
88
  "autoprefixer": "^10.4.19",
87
89
  "babel-jest": "^29.7.0",
88
90
  "babel-loader": "^9.1.3",
89
- "babel-plugin-module-resolver": "^5.0.0",
90
- "core-js": "^3.36.1",
91
- "css-loader": "^7.1.0",
91
+ "babel-plugin-module-resolver": "^5.0.2",
92
+ "core-js": "^3.37.0",
93
+ "css-loader": "^7.1.1",
92
94
  "css-minimizer-webpack-plugin": "^6.0.0",
93
95
  "eslint": "^8.57.0",
94
96
  "eslint-config-airbnb": "^19.0.4",
95
97
  "eslint-config-airbnb-typescript": "^18.0.0",
96
98
  "eslint-import-resolver-babel-module": "^5.3.2",
97
99
  "eslint-plugin-import": "^2.29.1",
98
- "eslint-plugin-jest": "^28.2.0",
100
+ "eslint-plugin-jest": "^28.5.0",
99
101
  "eslint-plugin-jsx-a11y": "^6.8.0",
100
102
  "eslint-plugin-react": "^7.34.1",
101
- "eslint-plugin-react-hooks": "^4.6.0",
103
+ "eslint-plugin-react-hooks": "^4.6.2",
102
104
  "identity-obj-proxy": "^3.0.0",
103
105
  "jest": "^29.7.0",
104
106
  "jest-environment-jsdom": "^29.7.0",
105
- "memfs": "^4.8.1",
106
- "mini-css-extract-plugin": "^2.8.1",
107
+ "memfs": "^4.9.2",
108
+ "mini-css-extract-plugin": "^2.9.0",
107
109
  "mockdate": "^3.0.5",
108
110
  "nodelist-foreach-polyfill": "^1.2.0",
109
111
  "postcss": "^8.4.38",
110
112
  "postcss-loader": "^8.1.1",
111
113
  "postcss-scss": "^4.0.9",
112
114
  "pretty": "^2.0.0",
113
- "react-refresh": "^0.14.0",
114
- "react-test-renderer": "^18.2.0",
115
+ "react-refresh": "^0.14.2",
115
116
  "regenerator-runtime": "^0.14.1",
116
117
  "resolve-url-loader": "^5.0.0",
117
- "sass": "^1.74.1",
118
- "sass-loader": "^14.1.1",
118
+ "sass": "^1.76.0",
119
+ "sass-loader": "^14.2.1",
119
120
  "sitemap": "^7.1.1",
120
- "stylelint": "^16.3.1",
121
+ "stylelint": "^16.5.0",
121
122
  "stylelint-config-standard-scss": "^13.1.0",
122
- "supertest": "^6.3.4",
123
+ "supertest": "^7.0.0",
123
124
  "tsc-alias": "^1.8.8",
124
125
  "typed-scss-modules": "^8.0.1",
125
- "typescript": "^5.4.4",
126
- "typescript-eslint": "^7.6.0",
126
+ "typescript": "^5.4.5",
127
+ "typescript-eslint": "^7.8.0",
127
128
  "webpack": "^5.91.0",
128
129
  "webpack-dev-middleware": "^7.2.1",
129
130
  "webpack-hot-middleware": "^2.26.1",
130
131
  "webpack-merge": "^5.10.0",
131
- "workbox-core": "^7.0.0",
132
- "workbox-precaching": "^7.0.0",
133
- "workbox-webpack-plugin": "^7.0.0"
132
+ "workbox-core": "^7.1.0",
133
+ "workbox-precaching": "^7.1.0",
134
+ "workbox-webpack-plugin": "^7.1.0"
134
135
  },
135
136
  "engines": {
136
137
  "node": ">=18",
@@ -89,44 +89,6 @@ const BaseButton: React.FunctionComponent<PropsT> = ({
89
89
  */
90
90
  const ThemedButton = themed(BaseButton, 'Button', validThemeKeys, defaultTheme);
91
91
 
92
- /**
93
- * Implements themeable buttons, and button-line links (elements which look
94
- * like buttons, but behave as links) in the same uniform manner.
95
- * @param {object} [props] Component props.
96
- * @param {boolean} [props.active] Set `true` to render the button as
97
- * active, even if it is not active otherwise.
98
- * @param {boolean} [props.disabled] Set `true` to disable the button.
99
- * @param {boolean} [props.enforceA] When the button is rendered as `<Link>`
100
- * component, this prop enforces it to be rendered as a simple `<a>` element
101
- * (external link), rather than the React router's internal link.
102
- * See `<Link>` documentation to learn when links are rendered as `<a>`
103
- * by default.
104
- * @param {function} [props.onClick] Click event handler.
105
- * @param {function} [props.onMouseDown] Mouse down event handler.
106
- * @param {boolean} [props.openNewTab] Set `true` to open link in the new tab.
107
- * @param {boolean} [props.replace] When the button is rendered as
108
- * `<Link>`, and the target URL is internal, this property tells that
109
- * the new route should replace the last record in the browser's history,
110
- * rather than to be pushed as a new entry into the history stack.
111
- * @param {ButtonTheme} [props.theme] _Ad hoc_ button theme.
112
- * @param {object|string} [props.to] If specified, the button will be rendered
113
- * as `<Link>` (if not disabled), and it will point to the specified location
114
- * or URL.
115
- * @param {...any} [props....]
116
- * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
117
- */
118
- BaseButton.defaultProps = {
119
- active: false,
120
- children: undefined,
121
- disabled: false,
122
- enforceA: false,
123
- onClick: undefined,
124
- onMouseDown: undefined,
125
- openNewTab: false,
126
- replace: false,
127
- to: undefined,
128
- };
129
-
130
92
  BaseButton.propTypes = {
131
93
  active: PT.bool,
132
94
  children: PT.node,
@@ -62,10 +62,4 @@ Checkbox.propTypes = {
62
62
  theme: ThemedCheckbox.themeType.isRequired,
63
63
  };
64
64
 
65
- Checkbox.defaultProps = {
66
- checked: undefined,
67
- label: undefined,
68
- onChange: undefined,
69
- };
70
-
71
65
  export default ThemedCheckbox;
@@ -127,19 +127,6 @@ const GenericLink: React.FunctionComponent<PropsT> = ({
127
127
  );
128
128
  };
129
129
 
130
- GenericLink.defaultProps = {
131
- children: null,
132
- className: '',
133
- disabled: false,
134
- enforceA: false,
135
- keepScrollPosition: false,
136
- onClick: undefined,
137
- onMouseDown: undefined,
138
- openNewTab: false,
139
- replace: false,
140
- to: '',
141
- };
142
-
143
130
  GenericLink.propTypes = {
144
131
  children: PT.node,
145
132
  className: PT.string,
@@ -50,8 +50,4 @@ Input.propTypes = {
50
50
  theme: ThemedInput.themeType.isRequired,
51
51
  };
52
52
 
53
- Input.defaultProps = {
54
- label: undefined,
55
- };
56
-
57
53
  export default ThemedInput;
@@ -147,15 +147,6 @@ const MetaTags: React.FunctionComponent<PropsT> & {
147
147
 
148
148
  MetaTags.Context = Context;
149
149
 
150
- MetaTags.defaultProps = {
151
- children: null,
152
- image: '',
153
- siteName: '',
154
- socialDescription: '',
155
- socialTitle: '',
156
- url: '',
157
- };
158
-
159
150
  MetaTags.propTypes = {
160
151
  children: PT.node,
161
152
  description: PT.string.isRequired,
@@ -1,7 +1,5 @@
1
1
  /* global document */
2
2
 
3
- import { noop } from 'lodash';
4
-
5
3
  import {
6
4
  type ReactNode,
7
5
  useEffect,
@@ -187,14 +185,6 @@ BaseModal.propTypes = {
187
185
  theme: ThemedModal.themeType.isRequired,
188
186
  };
189
187
 
190
- BaseModal.defaultProps = {
191
- cancelOnScrolling: false,
192
- children: null,
193
- containerStyle: undefined,
194
- dontDisableScrolling: false,
195
- onCancel: noop,
196
- };
197
-
198
188
  export default ThemedModal;
199
189
 
200
190
  /* Non-themed version of the Modal. */
@@ -68,10 +68,4 @@ PageLayout.propTypes = {
68
68
  theme: ThemedPageLayout.themeType.isRequired,
69
69
  };
70
70
 
71
- PageLayout.defaultProps = {
72
- children: null,
73
- leftSidePanelContent: null,
74
- rightSidePanelContent: null,
75
- };
76
-
77
71
  export default ThemedPageLayout;
@@ -101,12 +101,4 @@ TextArea.propTypes = {
101
101
  value: PT.string,
102
102
  };
103
103
 
104
- TextArea.defaultProps = {
105
- disabled: false,
106
- onChange: undefined,
107
- onKeyDown: undefined,
108
- placeholder: '',
109
- value: undefined,
110
- };
111
-
112
104
  export default ThemedTextArea;
@@ -350,8 +350,4 @@ Tooltip.propTypes = {
350
350
  theme: PT.shape({}).isRequired,
351
351
  };
352
352
 
353
- Tooltip.defaultProps = {
354
- children: null,
355
- };
356
-
357
353
  export default Tooltip;
@@ -59,7 +59,7 @@ type HeapT = {
59
59
  */
60
60
  const Wrapper: React.FunctionComponent<PropsT> = ({
61
61
  children,
62
- placement,
62
+ placement = PLACEMENTS.ABOVE_CURSOR,
63
63
  tip,
64
64
  theme,
65
65
  }) => {
@@ -198,10 +198,4 @@ Wrapper.propTypes = {
198
198
  tip: PT.node,
199
199
  };
200
200
 
201
- Wrapper.defaultProps = {
202
- children: null,
203
- placement: PLACEMENTS.ABOVE_CURSOR,
204
- tip: null,
205
- };
206
-
207
201
  export default e;
@@ -83,9 +83,4 @@ YouTubeVideo.propTypes = {
83
83
  title: PT.string,
84
84
  };
85
85
 
86
- YouTubeVideo.defaultProps = {
87
- autoplay: false,
88
- title: '',
89
- };
90
-
91
86
  export default ThemedYouTubeVideo;
@@ -132,9 +132,4 @@ Options.propTypes = {
132
132
  options: optionsValidator.isRequired,
133
133
  };
134
134
 
135
- Options.defaultProps = {
136
- containerStyle: undefined,
137
- filter: undefined,
138
- };
139
-
140
135
  export default Options;
@@ -171,12 +171,4 @@ BaseCustomDropdown.propTypes = {
171
171
  value: valueValidator,
172
172
  };
173
173
 
174
- BaseCustomDropdown.defaultProps = {
175
- filter: undefined,
176
- label: undefined,
177
- onChange: undefined,
178
- options: [],
179
- value: undefined,
180
- };
181
-
182
174
  export default ThemedCustomDropdown;
@@ -108,12 +108,4 @@ Dropdown.propTypes = {
108
108
  value: valueValidator,
109
109
  };
110
110
 
111
- Dropdown.defaultProps = {
112
- filter: undefined,
113
- label: undefined,
114
- onChange: undefined,
115
- options: [],
116
- value: '',
117
- };
118
-
119
111
  export default ThemedDropdown;
@@ -90,11 +90,4 @@ BaseSwitch.propTypes = {
90
90
  value: valueValidator,
91
91
  };
92
92
 
93
- BaseSwitch.defaultProps = {
94
- label: undefined,
95
- onChange: undefined,
96
- options: [],
97
- value: undefined,
98
- };
99
-
100
93
  export default ThemedSwitch;
@@ -1,20 +1,15 @@
1
- /* global expect, jest, document */
1
+ /* global jest, document */
2
2
  /* eslint-disable import/no-extraneous-dependencies */
3
3
 
4
4
  import mockdate from 'mockdate';
5
- import { type ReactElement, type ReactNode } from 'react';
5
+ import { type ReactNode, act } from 'react';
6
6
  import { type Root, createRoot } from 'react-dom/client';
7
- import TU, { act } from 'react-dom/test-utils';
8
7
 
9
- /* eslint-disable import/no-extraneous-dependencies */
10
- import Renderer from 'react-test-renderer';
11
- import { type ShallowRenderer, createRenderer } from 'react-test-renderer/shallow';
12
- /* eslint-enable import/no-extraneous-dependencies */
8
+ import { render } from '@testing-library/react';
13
9
 
14
10
  /**
15
11
  * An alias for [act(..)](https://reactjs.org/docs/test-utils.html#act)
16
- * from `react-dom/test-utils`.
17
- * @param {function} action
12
+ * from `react`.
18
13
  */
19
14
  export { act };
20
15
 
@@ -86,10 +81,18 @@ export function mount(scene: ReactNode): MountedSceneT {
86
81
 
87
82
  const res: MountedSceneT = (element as unknown) as MountedSceneT;
88
83
  res.destroy = () => {
84
+ // NOTE: As it seems @testing-library may reset this flag to false
85
+ // when it is simulating user events.
86
+ global.IS_REACT_ACT_ENVIRONMENT = true;
87
+
89
88
  act(() => root.unmount());
90
89
  res.remove();
91
90
  };
92
91
 
92
+ // NOTE: As it seems @testing-library may reset this flag to false
93
+ // when it is simulating user events.
94
+ global.IS_REACT_ACT_ENVIRONMENT = true;
95
+
93
96
  act(() => {
94
97
  root = createRoot(res);
95
98
  root.render(scene);
@@ -97,61 +100,8 @@ export function mount(scene: ReactNode): MountedSceneT {
97
100
  return res;
98
101
  }
99
102
 
100
- /* OLD STUFF BELOW THIS MARK */
101
-
102
- /**
103
- * Renders provided ReactJS component into JSON representation of the component
104
- * tree, using [`react-test-renderer`](https://www.npmjs.com/package/react-test-renderer).
105
- * @param {object} component ReactJS component to render.
106
- * @return {object} JSON representation of the rendered tree.
107
- * @example
108
- * import { JU } from '@dr.pogodin/react-utils';
109
- * console.log(JU.render(<div>Example</div>));
110
- */
111
- export function render(component: ReactElement) {
112
- return Renderer.create(component).toJSON();
113
- }
114
-
115
- /**
116
- * Generates a shallow render of given ReactJS component, using
117
- * [react-test-renderer/shallow](https://reactjs.org/docs/shallow-renderer.html)
118
- * and returns the result.
119
- * @param {object} component ReactJS component to render.
120
- * @return {object} JSON representation of the shallow component's render tree.
121
- */
122
- export function shallowRender(component: ReactElement) {
123
- const renderer: ShallowRenderer = createRenderer();
124
- renderer.render(component);
125
- return renderer.getRenderOutput();
126
- }
127
-
128
- /**
129
- * Makes a shallow snapshot test of the given ReactJS component, and also
130
- * returns JSON representation of the rendered component tree. Under the hood
131
- * it uses {@link module:JU.shallowRender shallowRender(..)} to generate
132
- * the render, then executes `expect(RENDER_RESULT).toMatchSnapshot()`,
133
- * and finally returns the `RENDER_RESULT` to the caller.
134
- * @param {object} component ReactJS component to render.
135
- * @return {object} JSON representation of shallow render.
136
- */
137
- export function shallowSnapshot(component: ReactElement) {
138
- const res = shallowRender(component);
139
- expect(res).toMatchSnapshot();
140
- return res;
141
- }
142
-
143
- /**
144
- * Makes snapshot test of the given ReactJS component, and also returns JSON
145
- * representation of the rendered component tree. Under the hood, it uses
146
- * {@link module:JU.render render(..)} to render it, then executes
147
- * `expect(RENDER_RESULT).toMatchSnapshot()`, and then returns `RENDER_RESULT`.
148
- * @param {object} component ReactJS component to render.
149
- * @return {object} JSON render of the component.
150
- */
151
- export function snapshot(component: ReactElement) {
152
- const res = render(component);
103
+ export function snapshot(element: React.ReactElement) {
104
+ const res = render(element).asFragment().firstChild;
153
105
  expect(res).toMatchSnapshot();
154
106
  return res;
155
107
  }
156
-
157
- export const simulate = TU.Simulate;
@@ -245,11 +245,7 @@ export default function splitComponent<
245
245
 
246
246
  CodeSplit.propTypes = {
247
247
  children: PT.node,
248
- } as React.WeakValidationMap<ComponentPropsT>;
249
-
250
- CodeSplit.defaultProps = {
251
- children: undefined,
252
- } as Partial<ComponentPropsT>;
248
+ } as PT.WeakValidationMap<ComponentPropsT>;
253
249
 
254
250
  return CodeSplit;
255
251
  }