@dr.pogodin/react-utils 1.44.9 → 1.45.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.
- package/build/development/shared/components/Modal/index.js +2 -11
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +23 -62
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/utils/webpack.js +18 -2
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/development/web.bundle.js +9 -9
- package/build/production/shared/components/Modal/index.js +3 -3
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js +2 -15
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/utils/webpack.js +5 -2
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/build/types-code/shared/components/selectors/CustomDropdown/index.d.ts +1 -1
- package/build/types-code/shared/utils/webpack.d.ts +5 -1
- package/package.json +28 -28
- package/src/shared/components/Modal/index.tsx +5 -16
- package/src/shared/components/WithTooltip/{Tooltip.ts → Tooltip.tsx} +20 -84
- package/src/shared/utils/webpack.ts +22 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type PropsT, type ValueT } from '../common';
|
|
2
|
-
declare const _default: import("@dr.pogodin/react-themes").ThemedComponent<PropsT<
|
|
2
|
+
declare const _default: import("@dr.pogodin/react-themes").ThemedComponent<PropsT<import("react").ReactNode, (value: ValueT) => void>>;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
type RequireWeakOptionsT = {
|
|
2
|
+
basePath?: string;
|
|
3
|
+
throwOnError?: boolean;
|
|
4
|
+
};
|
|
1
5
|
type RequireWeakResT<T> = T extends {
|
|
2
6
|
default: infer D;
|
|
3
7
|
} ? (D extends null | undefined ? T : D & Omit<T, 'default'>) : T;
|
|
@@ -8,7 +12,7 @@ type RequireWeakResT<T> = T extends {
|
|
|
8
12
|
* @param [basePath]
|
|
9
13
|
* @return Required module.
|
|
10
14
|
*/
|
|
11
|
-
export declare function requireWeak<T extends object>(modulePath: string,
|
|
15
|
+
export declare function requireWeak<T extends object>(modulePath: string, basePathOrOptions?: string | RequireWeakOptionsT): RequireWeakResT<T> | null;
|
|
12
16
|
/**
|
|
13
17
|
* Resolves specified module path with help of Babel's module resolver.
|
|
14
18
|
* Yes, the function itself just returns its argument to the caller, but Babel
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.45.0",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-setup": "bin/setup.js"
|
|
@@ -9,20 +9,20 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@babel/runtime": "^7.28.4",
|
|
12
|
-
"@dr.pogodin/babel-plugin-react-css-modules": "^6.13.
|
|
13
|
-
"@dr.pogodin/csurf": "^1.16.
|
|
12
|
+
"@dr.pogodin/babel-plugin-react-css-modules": "^6.13.8",
|
|
13
|
+
"@dr.pogodin/csurf": "^1.16.6",
|
|
14
14
|
"@dr.pogodin/js-utils": "^0.1.3",
|
|
15
|
-
"@dr.pogodin/react-global-state": "^0.
|
|
15
|
+
"@dr.pogodin/react-global-state": "^0.20.0",
|
|
16
16
|
"@dr.pogodin/react-helmet": "^3.0.4",
|
|
17
|
-
"@dr.pogodin/react-themes": "^1.9.
|
|
18
|
-
"@jest/environment": "^30.
|
|
17
|
+
"@dr.pogodin/react-themes": "^1.9.3",
|
|
18
|
+
"@jest/environment": "^30.2.0",
|
|
19
19
|
"axios": "^1.12.2",
|
|
20
20
|
"commander": "^14.0.1",
|
|
21
21
|
"compression": "^1.8.1",
|
|
22
22
|
"config": "^4.1.1",
|
|
23
23
|
"cookie": "^1.0.2",
|
|
24
24
|
"cookie-parser": "^1.4.7",
|
|
25
|
-
"cross-env": "^10.
|
|
25
|
+
"cross-env": "^10.1.0",
|
|
26
26
|
"dayjs": "^1.11.18",
|
|
27
27
|
"express": "^5.1.0",
|
|
28
28
|
"helmet": "^8.1.0",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"node-forge": "^1.3.1",
|
|
33
33
|
"qs": "^6.14.0",
|
|
34
34
|
"raf": "^3.4.1",
|
|
35
|
-
"react": "^19.
|
|
36
|
-
"react-dom": "^19.
|
|
37
|
-
"react-router": "^7.9.
|
|
35
|
+
"react": "^19.2.0",
|
|
36
|
+
"react-dom": "^19.2.0",
|
|
37
|
+
"react-router": "^7.9.4",
|
|
38
38
|
"request-ip": "^3.3.0",
|
|
39
39
|
"rimraf": "^6.0.0",
|
|
40
|
-
"serialize-javascript": "^
|
|
40
|
+
"serialize-javascript": "^7.0.0",
|
|
41
41
|
"serve-favicon": "^2.5.1",
|
|
42
42
|
"source-map-support": "^0.5.21",
|
|
43
43
|
"uuid": "^13.0.0",
|
|
44
|
-
"winston": "^3.
|
|
44
|
+
"winston": "^3.18.3"
|
|
45
45
|
},
|
|
46
46
|
"description": "Collection of generic ReactJS components and utils",
|
|
47
47
|
"devDependencies": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@babel/register": "^7.28.3",
|
|
56
56
|
"@dr.pogodin/babel-plugin-transform-assets": "^1.2.5",
|
|
57
57
|
"@dr.pogodin/babel-preset-svgr": "^1.9.2",
|
|
58
|
-
"@dr.pogodin/eslint-configs": "^0.0
|
|
58
|
+
"@dr.pogodin/eslint-configs": "^0.1.0",
|
|
59
59
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.1",
|
|
60
60
|
"@standard-schema/spec": "^1.0.0",
|
|
61
61
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -72,25 +72,25 @@
|
|
|
72
72
|
"@types/morgan": "^1.9.10",
|
|
73
73
|
"@types/node-forge": "^1.3.14",
|
|
74
74
|
"@types/pretty": "^2.0.3",
|
|
75
|
-
"@types/react": "^19.
|
|
76
|
-
"@types/react-dom": "^19.1
|
|
75
|
+
"@types/react": "^19.2.2",
|
|
76
|
+
"@types/react-dom": "^19.2.1",
|
|
77
77
|
"@types/request-ip": "^0.0.41",
|
|
78
78
|
"@types/serialize-javascript": "^5.0.4",
|
|
79
79
|
"@types/serve-favicon": "^2.5.7",
|
|
80
80
|
"@types/supertest": "^6.0.3",
|
|
81
81
|
"@types/webpack": "^5.28.5",
|
|
82
|
-
"@types/webpack-hot-middleware": "^2.25.
|
|
82
|
+
"@types/webpack-hot-middleware": "^2.25.11",
|
|
83
83
|
"autoprefixer": "^10.4.21",
|
|
84
|
-
"babel-jest": "^30.
|
|
84
|
+
"babel-jest": "^30.2.0",
|
|
85
85
|
"babel-loader": "^10.0.0",
|
|
86
86
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
87
|
-
"core-js": "^3.
|
|
87
|
+
"core-js": "^3.46.0",
|
|
88
88
|
"css-loader": "^7.1.2",
|
|
89
89
|
"css-minimizer-webpack-plugin": "^7.0.2",
|
|
90
90
|
"identity-obj-proxy": "^3.0.0",
|
|
91
|
-
"jest": "^30.
|
|
92
|
-
"jest-environment-jsdom": "^30.
|
|
93
|
-
"memfs": "^4.
|
|
91
|
+
"jest": "^30.2.0",
|
|
92
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
93
|
+
"memfs": "^4.49.0",
|
|
94
94
|
"mini-css-extract-plugin": "^2.9.4",
|
|
95
95
|
"mockdate": "^3.0.5",
|
|
96
96
|
"nodelist-foreach-polyfill": "^1.2.0",
|
|
@@ -98,22 +98,22 @@
|
|
|
98
98
|
"postcss-loader": "^8.2.0",
|
|
99
99
|
"postcss-scss": "^4.0.9",
|
|
100
100
|
"pretty": "^2.0.0",
|
|
101
|
-
"react-refresh": "^0.
|
|
101
|
+
"react-refresh": "^0.18.0",
|
|
102
102
|
"regenerator-runtime": "^0.14.1",
|
|
103
103
|
"resolve-url-loader": "^5.0.0",
|
|
104
104
|
"sass": "^1.93.2",
|
|
105
105
|
"sass-loader": "^16.0.5",
|
|
106
106
|
"sitemap": "^8.0.0",
|
|
107
107
|
"source-map-loader": "^5.0.0",
|
|
108
|
-
"stylelint": "^16.
|
|
108
|
+
"stylelint": "^16.25.0",
|
|
109
109
|
"stylelint-config-standard-scss": "^16.0.0",
|
|
110
110
|
"supertest": "^7.1.4",
|
|
111
111
|
"tsc-alias": "1.8.16",
|
|
112
112
|
"tstyche": "^4.3.0",
|
|
113
113
|
"typed-scss-modules": "^8.1.1",
|
|
114
|
-
"typescript": "^5.9.
|
|
115
|
-
"webpack": "^5.
|
|
116
|
-
"webpack-dev-middleware": "^7.4.
|
|
114
|
+
"typescript": "^5.9.3",
|
|
115
|
+
"webpack": "^5.102.1",
|
|
116
|
+
"webpack-dev-middleware": "^7.4.5",
|
|
117
117
|
"webpack-hot-middleware": "^2.26.1",
|
|
118
118
|
"webpack-merge": "^6.0.1",
|
|
119
119
|
"workbox-core": "^7.3.0",
|
|
@@ -121,8 +121,8 @@
|
|
|
121
121
|
"workbox-webpack-plugin": "^7.3.0"
|
|
122
122
|
},
|
|
123
123
|
"engines": {
|
|
124
|
-
"node": ">=
|
|
125
|
-
"npm": ">=
|
|
124
|
+
"node": ">=20",
|
|
125
|
+
"npm": ">=10"
|
|
126
126
|
},
|
|
127
127
|
"main": "./node-entry.js",
|
|
128
128
|
"source": "./src/index.ts",
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
useEffect,
|
|
6
6
|
useMemo,
|
|
7
7
|
useRef,
|
|
8
|
-
useState,
|
|
9
8
|
} from 'react';
|
|
10
9
|
|
|
11
10
|
import ReactDom from 'react-dom';
|
|
@@ -54,16 +53,6 @@ const BaseModal: FunctionComponent<PropsT> = ({
|
|
|
54
53
|
}) => {
|
|
55
54
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
56
55
|
const overlayRef = useRef<HTMLDivElement | null>(null);
|
|
57
|
-
const [portal, setPortal] = useState<HTMLDivElement>();
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
const p = document.createElement('div');
|
|
61
|
-
document.body.appendChild(p);
|
|
62
|
-
setPortal(p);
|
|
63
|
-
return () => {
|
|
64
|
-
document.body.removeChild(p);
|
|
65
|
-
};
|
|
66
|
-
}, []);
|
|
67
56
|
|
|
68
57
|
// Sets up modal cancellation of scrolling, if opted-in.
|
|
69
58
|
useEffect(() => {
|
|
@@ -107,9 +96,9 @@ const BaseModal: FunctionComponent<PropsT> = ({
|
|
|
107
96
|
/>
|
|
108
97
|
), []);
|
|
109
98
|
|
|
110
|
-
return
|
|
99
|
+
return ReactDom.createPortal(
|
|
111
100
|
(
|
|
112
|
-
|
|
101
|
+
<div>
|
|
113
102
|
{focusLast}
|
|
114
103
|
<div
|
|
115
104
|
aria-label="Cancel"
|
|
@@ -176,10 +165,10 @@ const BaseModal: FunctionComponent<PropsT> = ({
|
|
|
176
165
|
tabIndex={0}
|
|
177
166
|
/>
|
|
178
167
|
{focusLast}
|
|
179
|
-
|
|
168
|
+
</div>
|
|
180
169
|
),
|
|
181
|
-
|
|
182
|
-
)
|
|
170
|
+
document.body,
|
|
171
|
+
);
|
|
183
172
|
};
|
|
184
173
|
|
|
185
174
|
export default themed(BaseModal, 'Modal', baseTheme);
|
|
@@ -8,10 +8,8 @@ import {
|
|
|
8
8
|
type FunctionComponent,
|
|
9
9
|
type ReactNode,
|
|
10
10
|
type RefObject,
|
|
11
|
-
useEffect,
|
|
12
11
|
useImperativeHandle,
|
|
13
12
|
useRef,
|
|
14
|
-
useState,
|
|
15
13
|
} from 'react';
|
|
16
14
|
|
|
17
15
|
import { createPortal } from 'react-dom';
|
|
@@ -47,42 +45,10 @@ type ComponentsT = {
|
|
|
47
45
|
content: HTMLDivElement;
|
|
48
46
|
};
|
|
49
47
|
|
|
50
|
-
type HeapT = {
|
|
51
|
-
lastElement?: HTMLElement;
|
|
52
|
-
lastPageX: number;
|
|
53
|
-
lastPageY: number;
|
|
54
|
-
lastPlacement?: PLACEMENTS | undefined;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
48
|
export type ThemeKeysT = 'appearance' | 'arrow' | 'content' | 'container';
|
|
58
49
|
|
|
59
50
|
type TooltipThemeT = Theme<ThemeKeysT>;
|
|
60
51
|
|
|
61
|
-
/**
|
|
62
|
-
* Creates tooltip components.
|
|
63
|
-
* @ignore
|
|
64
|
-
* @param {object} theme Themes to use for tooltip container, arrow,
|
|
65
|
-
* and content.
|
|
66
|
-
* @return {object} Object with DOM references to the container components:
|
|
67
|
-
* container, arrow, content.
|
|
68
|
-
*/
|
|
69
|
-
function createTooltipComponents(theme: TooltipThemeT): ComponentsT {
|
|
70
|
-
const arrow = document.createElement('div');
|
|
71
|
-
if (theme.arrow) arrow.setAttribute('class', theme.arrow);
|
|
72
|
-
|
|
73
|
-
const content = document.createElement('div');
|
|
74
|
-
if (theme.content) content.setAttribute('class', theme.content);
|
|
75
|
-
|
|
76
|
-
const container = document.createElement('div');
|
|
77
|
-
if (theme.container) container.setAttribute('class', theme.container);
|
|
78
|
-
|
|
79
|
-
container.appendChild(arrow);
|
|
80
|
-
container.appendChild(content);
|
|
81
|
-
document.body.appendChild(container);
|
|
82
|
-
|
|
83
|
-
return { arrow, container, content };
|
|
84
|
-
}
|
|
85
|
-
|
|
86
52
|
type TooltipRectsT = {
|
|
87
53
|
arrow: DOMRect;
|
|
88
54
|
container: DOMRect;
|
|
@@ -272,14 +238,9 @@ const Tooltip: FunctionComponent<{
|
|
|
272
238
|
// Thus, when we create the <Tooltip> we have to record its target positioning
|
|
273
239
|
// details, and then apply them when it is created.
|
|
274
240
|
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
lastPageY: 0,
|
|
279
|
-
lastPlacement: undefined,
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
const [components, setComponents] = useState<ComponentsT | null>(null);
|
|
241
|
+
const arrowRef = useRef<HTMLDivElement>(null);
|
|
242
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
243
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
283
244
|
|
|
284
245
|
const pointTo = (
|
|
285
246
|
pageX: number,
|
|
@@ -287,52 +248,27 @@ const Tooltip: FunctionComponent<{
|
|
|
287
248
|
placement: PLACEMENTS,
|
|
288
249
|
element: HTMLElement,
|
|
289
250
|
) => {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
heap.lastPageY = pageY;
|
|
293
|
-
heap.lastPlacement = placement;
|
|
294
|
-
|
|
295
|
-
if (components) {
|
|
296
|
-
setComponentPositions(pageX, pageY, placement, element, components);
|
|
251
|
+
if (!arrowRef.current || !containerRef.current || !contentRef.current) {
|
|
252
|
+
throw Error('Internal error');
|
|
297
253
|
}
|
|
254
|
+
|
|
255
|
+
setComponentPositions(pageX, pageY, placement, element, {
|
|
256
|
+
arrow: arrowRef.current,
|
|
257
|
+
container: containerRef.current,
|
|
258
|
+
content: contentRef.current,
|
|
259
|
+
});
|
|
298
260
|
};
|
|
299
261
|
useImperativeHandle(ref, () => ({ pointTo }));
|
|
300
262
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
useEffect(() => {
|
|
312
|
-
if (components) {
|
|
313
|
-
setComponentPositions(
|
|
314
|
-
heap.lastPageX,
|
|
315
|
-
heap.lastPageY,
|
|
316
|
-
heap.lastPlacement,
|
|
317
|
-
heap.lastElement,
|
|
318
|
-
components,
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
}, [
|
|
322
|
-
components,
|
|
323
|
-
// BEWARE: Careful about these dependencies - they are updated when mouse
|
|
324
|
-
// is moved over the tool-tipped element, thus potentially may cause
|
|
325
|
-
// unnecessary firing of this effect on each mouse event. It does not
|
|
326
|
-
// happen now just because the mouse movements themselves are not causing
|
|
327
|
-
// the component re-rendering, thus dependencies of this effect are not
|
|
328
|
-
// really re-evaluated.
|
|
329
|
-
heap.lastPageX,
|
|
330
|
-
heap.lastPageY,
|
|
331
|
-
heap.lastPlacement,
|
|
332
|
-
heap.lastElement,
|
|
333
|
-
]);
|
|
334
|
-
|
|
335
|
-
return components ? createPortal(children, components.content) : null;
|
|
263
|
+
return createPortal(
|
|
264
|
+
(
|
|
265
|
+
<div className={theme.container} ref={containerRef}>
|
|
266
|
+
<div className={theme.arrow} ref={arrowRef} />
|
|
267
|
+
<div className={theme.content} ref={contentRef}>{children}</div>
|
|
268
|
+
</div>
|
|
269
|
+
),
|
|
270
|
+
document.body,
|
|
271
|
+
);
|
|
336
272
|
};
|
|
337
273
|
|
|
338
274
|
export default Tooltip;
|
|
@@ -2,6 +2,11 @@ import type PathNS from 'node:path';
|
|
|
2
2
|
|
|
3
3
|
import { IS_CLIENT_SIDE } from './isomorphy';
|
|
4
4
|
|
|
5
|
+
type RequireWeakOptionsT = {
|
|
6
|
+
basePath?: string;
|
|
7
|
+
throwOnError?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
5
10
|
type RequireWeakResT<T> = T extends { default: infer D }
|
|
6
11
|
? (D extends null | undefined ? T : D & Omit<T, 'default'>)
|
|
7
12
|
: T;
|
|
@@ -15,10 +20,24 @@ type RequireWeakResT<T> = T extends { default: infer D }
|
|
|
15
20
|
*/
|
|
16
21
|
export function requireWeak<T extends object>(
|
|
17
22
|
modulePath: string,
|
|
18
|
-
|
|
23
|
+
|
|
24
|
+
// TODO: For now `basePath` can be provided directly as a string here,
|
|
25
|
+
// for backward compatibility. Deprecate it in future, if any other
|
|
26
|
+
// breaking changes are done for requireWeak().
|
|
27
|
+
basePathOrOptions?: string | RequireWeakOptionsT,
|
|
19
28
|
): RequireWeakResT<T> | null {
|
|
20
29
|
if (IS_CLIENT_SIDE) return null;
|
|
21
30
|
|
|
31
|
+
let basePath: string | undefined;
|
|
32
|
+
let ops: RequireWeakOptionsT;
|
|
33
|
+
if (typeof basePathOrOptions === 'string') {
|
|
34
|
+
basePath = basePathOrOptions;
|
|
35
|
+
ops = {};
|
|
36
|
+
} else {
|
|
37
|
+
ops = basePathOrOptions ?? {};
|
|
38
|
+
({ basePath } = ops);
|
|
39
|
+
}
|
|
40
|
+
|
|
22
41
|
// TODO: On one hand, this try/catch wrap silencing errors is bad, as it may
|
|
23
42
|
// hide legit errors, in a way difficult to notice and understand; but on the
|
|
24
43
|
// other hand it fails for some (unclear, but legit?) reasons in some
|
|
@@ -49,7 +68,8 @@ export function requireWeak<T extends object>(
|
|
|
49
68
|
}
|
|
50
69
|
});
|
|
51
70
|
return res;
|
|
52
|
-
} catch {
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (ops.throwOnError) throw error;
|
|
53
73
|
return null;
|
|
54
74
|
}
|
|
55
75
|
}
|