@dr.pogodin/react-utils 1.40.2 → 1.40.4
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/client/init.js +1 -1
- package/build/development/client/init.js.map +1 -1
- package/build/development/server/renderer.js +1 -1
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +26 -14
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +3 -1
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy/buildInfo.js +4 -0
- package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/style.css +21 -0
- package/build/development/web.bundle.js +6 -6
- package/build/production/client/getInj.js +1 -1
- package/build/production/client/getInj.js.map +1 -1
- package/build/production/client/index.js +1 -1
- package/build/production/client/index.js.map +1 -1
- package/build/production/client/init.js +2 -2
- package/build/production/client/init.js.map +1 -1
- package/build/production/server/index.js +1 -1
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/server.js +3 -3
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js +5 -5
- package/build/production/server/utils/errors.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +1 -1
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Link.js +1 -1
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +2 -2
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js +1 -1
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js +6 -6
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/utils/isomorphy/buildInfo.js +3 -0
- package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js +2 -2
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/global.js +1 -1
- package/build/production/shared/utils/jest/global.js.map +1 -1
- package/build/production/shared/utils/jest/index.js +1 -1
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +1 -1
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js +3 -3
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/style.css +1 -1
- package/build/production/style.css.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/Checkbox/index.d.ts +6 -4
- package/build/types-code/shared/components/Modal/index.d.ts +1 -0
- package/build/types-code/shared/utils/isomorphy/buildInfo.d.ts +0 -3
- package/build/types-scss/src/shared/components/Checkbox/theme.scss.d.ts +2 -0
- package/package.json +21 -21
- package/src/client/init.ts +3 -1
- package/src/shared/components/Checkbox/index.tsx +36 -16
- package/src/shared/components/Checkbox/theme.scss +20 -0
- package/src/shared/components/Modal/index.tsx +6 -0
- package/src/shared/utils/isomorphy/buildInfo.ts +4 -6
- package/src/shared/utils/splitComponent.tsx +3 -3
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type Theme } from '@dr.pogodin/react-themes';
|
|
2
|
-
type PropT = {
|
|
3
|
-
checked?:
|
|
2
|
+
type PropT<ValueT> = {
|
|
3
|
+
checked?: ValueT;
|
|
4
|
+
disabled?: boolean;
|
|
4
5
|
label?: React.ReactNode;
|
|
5
6
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
6
|
-
|
|
7
|
+
testId?: string;
|
|
8
|
+
theme: Theme<'checkbox' | 'container' | 'disabled' | 'indeterminate' | 'label'>;
|
|
7
9
|
};
|
|
8
|
-
declare const _default: import("@dr.pogodin/react-themes").ThemedComponent<PropT
|
|
10
|
+
declare const _default: import("@dr.pogodin/react-themes").ThemedComponent<PropT<boolean | "indeterminate">>;
|
|
9
11
|
export default _default;
|
|
@@ -4,9 +4,6 @@ export type BuildInfoT = {
|
|
|
4
4
|
timestamp: string;
|
|
5
5
|
useServiceWorker: boolean;
|
|
6
6
|
};
|
|
7
|
-
declare global {
|
|
8
|
-
const BUILD_INFO: BuildInfoT | undefined;
|
|
9
|
-
}
|
|
10
7
|
/**
|
|
11
8
|
* In scenarious where "BUILD_INFO" is not injected by Webpack (server-side,
|
|
12
9
|
* tests, etc.) we expect the host codebase to explicitly set it before it is
|
|
@@ -2,5 +2,7 @@ export declare const ad: string;
|
|
|
2
2
|
export declare const checkbox: string;
|
|
3
3
|
export declare const container: string;
|
|
4
4
|
export declare const context: string;
|
|
5
|
+
export declare const disabled: string;
|
|
5
6
|
export declare const hoc: string;
|
|
7
|
+
export declare const indeterminate: string;
|
|
6
8
|
export declare const label: string;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.40.
|
|
2
|
+
"version": "1.40.4",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-setup": "bin/setup.js"
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
"url": "https://github.com/birdofpreyru/react-utils/issues"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@babel/runtime": "^7.25.
|
|
11
|
+
"@babel/runtime": "^7.25.6",
|
|
12
12
|
"@dr.pogodin/babel-plugin-react-css-modules": "^6.13.2",
|
|
13
13
|
"@dr.pogodin/csurf": "^1.13.0",
|
|
14
14
|
"@dr.pogodin/js-utils": "^0.0.12",
|
|
15
|
-
"@dr.pogodin/react-global-state": "^0.17.
|
|
15
|
+
"@dr.pogodin/react-global-state": "^0.17.1",
|
|
16
16
|
"@dr.pogodin/react-themes": "^1.7.0",
|
|
17
17
|
"@jest/environment": "^29.7.0",
|
|
18
|
-
"axios": "^1.7.
|
|
18
|
+
"axios": "^1.7.7",
|
|
19
19
|
"commander": "^12.1.0",
|
|
20
20
|
"compression": "^1.7.4",
|
|
21
21
|
"config": "^3.3.12",
|
|
22
22
|
"cookie": "^0.6.0",
|
|
23
23
|
"cookie-parser": "^1.4.6",
|
|
24
24
|
"cross-env": "^7.0.3",
|
|
25
|
-
"dayjs": "^1.11.
|
|
25
|
+
"dayjs": "^1.11.13",
|
|
26
26
|
"express": "^4.19.2",
|
|
27
27
|
"helmet": "^7.1.0",
|
|
28
28
|
"http-status-codes": "^2.3.0",
|
|
@@ -35,24 +35,24 @@
|
|
|
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.26.
|
|
38
|
+
"react-router-dom": "^6.26.1",
|
|
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": "^10.0.0",
|
|
45
|
-
"winston": "^3.14.
|
|
45
|
+
"winston": "^3.14.2"
|
|
46
46
|
},
|
|
47
47
|
"description": "Collection of generic ReactJS components and utils",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@babel/cli": "^7.
|
|
49
|
+
"@babel/cli": "^7.25.6",
|
|
50
50
|
"@babel/core": "^7.25.2",
|
|
51
51
|
"@babel/eslint-parser": "^7.25.1",
|
|
52
52
|
"@babel/eslint-plugin": "^7.25.1",
|
|
53
53
|
"@babel/node": "^7.25.0",
|
|
54
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
55
|
-
"@babel/preset-env": "^7.25.
|
|
54
|
+
"@babel/plugin-transform-runtime": "^7.25.4",
|
|
55
|
+
"@babel/preset-env": "^7.25.4",
|
|
56
56
|
"@babel/preset-react": "^7.24.7",
|
|
57
57
|
"@babel/preset-typescript": "^7.24.7",
|
|
58
58
|
"@babel/register": "^7.24.6",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@dr.pogodin/babel-preset-svgr": "^1.8.0",
|
|
61
61
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
|
62
62
|
"@testing-library/dom": "^10.4.0",
|
|
63
|
-
"@testing-library/react": "^16.0.
|
|
63
|
+
"@testing-library/react": "^16.0.1",
|
|
64
64
|
"@testing-library/user-event": "^14.5.2",
|
|
65
65
|
"@tsconfig/recommended": "^1.0.7",
|
|
66
66
|
"@types/compression": "^1.7.5",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@types/morgan": "^1.9.9",
|
|
75
75
|
"@types/node-forge": "^1.3.11",
|
|
76
76
|
"@types/pretty": "^2.0.3",
|
|
77
|
-
"@types/react": "^18.3.
|
|
77
|
+
"@types/react": "^18.3.5",
|
|
78
78
|
"@types/react-dom": "^18.3.0",
|
|
79
79
|
"@types/react-helmet": "^6.1.11",
|
|
80
80
|
"@types/request-ip": "^0.0.41",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"babel-jest": "^29.7.0",
|
|
88
88
|
"babel-loader": "^9.1.3",
|
|
89
89
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
90
|
-
"core-js": "^3.38.
|
|
90
|
+
"core-js": "^3.38.1",
|
|
91
91
|
"css-loader": "^7.1.2",
|
|
92
92
|
"css-minimizer-webpack-plugin": "^7.0.0",
|
|
93
93
|
"eslint": "^8.57.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
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.29.1",
|
|
98
|
-
"eslint-plugin-jest": "^28.8.
|
|
98
|
+
"eslint-plugin-jest": "^28.8.2",
|
|
99
99
|
"eslint-plugin-jsx-a11y": "^6.9.0",
|
|
100
100
|
"eslint-plugin-react": "^7.35.0",
|
|
101
101
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
@@ -103,10 +103,10 @@
|
|
|
103
103
|
"jest": "^29.7.0",
|
|
104
104
|
"jest-environment-jsdom": "^29.7.0",
|
|
105
105
|
"memfs": "^4.11.1",
|
|
106
|
-
"mini-css-extract-plugin": "^2.9.
|
|
106
|
+
"mini-css-extract-plugin": "^2.9.1",
|
|
107
107
|
"mockdate": "^3.0.5",
|
|
108
108
|
"nodelist-foreach-polyfill": "^1.2.0",
|
|
109
|
-
"postcss": "^8.4.
|
|
109
|
+
"postcss": "^8.4.44",
|
|
110
110
|
"postcss-loader": "^8.1.1",
|
|
111
111
|
"postcss-scss": "^4.0.9",
|
|
112
112
|
"pretty": "^2.0.0",
|
|
@@ -114,19 +114,19 @@
|
|
|
114
114
|
"regenerator-runtime": "^0.14.1",
|
|
115
115
|
"resolve-url-loader": "^5.0.0",
|
|
116
116
|
"sass": "^1.77.8",
|
|
117
|
-
"sass-loader": "^16.0.
|
|
117
|
+
"sass-loader": "^16.0.1",
|
|
118
118
|
"sitemap": "^8.0.0",
|
|
119
119
|
"source-map-loader": "^5.0.0",
|
|
120
|
-
"stylelint": "^16.
|
|
120
|
+
"stylelint": "^16.9.0",
|
|
121
121
|
"stylelint-config-standard-scss": "^13.1.0",
|
|
122
122
|
"supertest": "^7.0.0",
|
|
123
123
|
"tsc-alias": "^1.8.10",
|
|
124
124
|
"tstyche": "^2.1.1",
|
|
125
125
|
"typed-scss-modules": "^8.0.1",
|
|
126
126
|
"typescript": "^5.5.4",
|
|
127
|
-
"typescript-eslint": "^8.0
|
|
128
|
-
"webpack": "^5.
|
|
129
|
-
"webpack-dev-middleware": "^7.
|
|
127
|
+
"typescript-eslint": "^8.4.0",
|
|
128
|
+
"webpack": "^5.94.0",
|
|
129
|
+
"webpack-dev-middleware": "^7.4.2",
|
|
130
130
|
"webpack-hot-middleware": "^2.26.1",
|
|
131
131
|
"webpack-merge": "^6.0.1",
|
|
132
132
|
"workbox-core": "^7.1.0",
|
package/src/client/init.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Initialization of client-side environment.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
/* global
|
|
5
|
+
/* global window */
|
|
6
6
|
|
|
7
7
|
import { type BuildInfoT, getBuildInfo } from 'utils/isomorphy/buildInfo';
|
|
8
8
|
|
|
@@ -16,6 +16,8 @@ declare global {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
declare const BUILD_INFO: BuildInfoT | undefined;
|
|
20
|
+
|
|
19
21
|
if (process.env.NODE_ENV !== 'production') {
|
|
20
22
|
// eslint-disable-next-line no-console
|
|
21
23
|
console.warn('Dev mode: "BUILD_INFO" attached to the global "window"');
|
|
@@ -2,29 +2,49 @@ import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
|
2
2
|
|
|
3
3
|
import defaultTheme from './theme.scss';
|
|
4
4
|
|
|
5
|
-
type PropT = {
|
|
6
|
-
checked?:
|
|
5
|
+
type PropT<ValueT> = {
|
|
6
|
+
checked?: ValueT;
|
|
7
|
+
disabled?: boolean;
|
|
7
8
|
label?: React.ReactNode;
|
|
8
9
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
9
|
-
|
|
10
|
+
testId?: string;
|
|
11
|
+
theme: Theme<
|
|
12
|
+
| 'checkbox'
|
|
13
|
+
| 'container'
|
|
14
|
+
| 'disabled'
|
|
15
|
+
| 'indeterminate'
|
|
16
|
+
| 'label'
|
|
17
|
+
>;
|
|
10
18
|
};
|
|
11
19
|
|
|
12
|
-
const Checkbox
|
|
20
|
+
const Checkbox = <ValueT extends boolean | 'indeterminate' = boolean>({
|
|
13
21
|
checked,
|
|
22
|
+
disabled,
|
|
14
23
|
label,
|
|
15
24
|
onChange,
|
|
25
|
+
testId,
|
|
16
26
|
theme,
|
|
17
|
-
}) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
}: PropT<ValueT>) => {
|
|
28
|
+
let containerClassName = theme.container;
|
|
29
|
+
if (disabled) containerClassName += ` ${theme.disabled}`;
|
|
30
|
+
|
|
31
|
+
let checkboxClassName = theme.checkbox;
|
|
32
|
+
if (checked === 'indeterminate') checkboxClassName += ` ${theme.indeterminate}`;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className={containerClassName}>
|
|
36
|
+
{ label === undefined ? null : <div className={theme.label}>{label}</div> }
|
|
37
|
+
<input
|
|
38
|
+
checked={checked === undefined ? undefined : checked === true}
|
|
39
|
+
className={checkboxClassName}
|
|
40
|
+
data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
onChange={onChange}
|
|
43
|
+
onClick={(e) => e.stopPropagation()}
|
|
44
|
+
type="checkbox"
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
29
49
|
|
|
30
50
|
export default themed(Checkbox, 'Checkbox', defaultTheme);
|
|
@@ -29,6 +29,18 @@
|
|
|
29
29
|
border-color: blue;
|
|
30
30
|
box-shadow: 0 0 3px 1px lightblue;
|
|
31
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
|
+
}
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
&.container {
|
|
@@ -40,4 +52,12 @@
|
|
|
40
52
|
&.label {
|
|
41
53
|
margin: 0 0.6em 0 1.5em;
|
|
42
54
|
}
|
|
55
|
+
|
|
56
|
+
&.disabled {
|
|
57
|
+
opacity: 0.33;
|
|
58
|
+
|
|
59
|
+
.checkbox {
|
|
60
|
+
cursor: not-allowed !important;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
43
63
|
}
|
|
@@ -21,6 +21,7 @@ type PropsT = {
|
|
|
21
21
|
onCancel?: () => void;
|
|
22
22
|
style?: React.CSSProperties;
|
|
23
23
|
testId?: string;
|
|
24
|
+
testIdForOverlay?: string;
|
|
24
25
|
theme: Theme<'container' | 'overlay'>;
|
|
25
26
|
|
|
26
27
|
/** @deprecated */
|
|
@@ -46,6 +47,7 @@ const BaseModal: React.FunctionComponent<PropsT> = ({
|
|
|
46
47
|
onCancel,
|
|
47
48
|
style,
|
|
48
49
|
testId,
|
|
50
|
+
testIdForOverlay,
|
|
49
51
|
theme,
|
|
50
52
|
}) => {
|
|
51
53
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
@@ -110,6 +112,10 @@ const BaseModal: React.FunctionComponent<PropsT> = ({
|
|
|
110
112
|
<div
|
|
111
113
|
aria-label="Cancel"
|
|
112
114
|
className={theme.overlay}
|
|
115
|
+
data-testid={
|
|
116
|
+
process.env.NODE_ENV === 'production'
|
|
117
|
+
? undefined : testIdForOverlay
|
|
118
|
+
}
|
|
113
119
|
onClick={(e) => {
|
|
114
120
|
if (onCancel) {
|
|
115
121
|
onCancel();
|
|
@@ -10,12 +10,10 @@ export type BuildInfoT = {
|
|
|
10
10
|
useServiceWorker: boolean;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const BUILD_INFO: BuildInfoT | undefined;
|
|
18
|
-
}
|
|
13
|
+
// Depending on the build mode & environment, BUILD_INFO is either a global
|
|
14
|
+
// variable defined at the app launch, or it is replaced by the actual value
|
|
15
|
+
// by the Webpack build.
|
|
16
|
+
declare const BUILD_INFO: BuildInfoT | undefined;
|
|
19
17
|
|
|
20
18
|
let buildInfo: BuildInfoT | undefined;
|
|
21
19
|
|
|
@@ -210,8 +210,8 @@ export default function splitComponent<
|
|
|
210
210
|
await bookStyleSheets(chunkName, clientChunkGroups, false);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
const Wrapper = forwardRef((
|
|
214
|
-
{ children, ...rest }
|
|
213
|
+
const Wrapper = forwardRef<unknown, ComponentPropsT>((
|
|
214
|
+
{ children, ...rest },
|
|
215
215
|
ref,
|
|
216
216
|
) => {
|
|
217
217
|
// On the server side we'll assert the chunk name here,
|
|
@@ -230,7 +230,7 @@ export default function splitComponent<
|
|
|
230
230
|
}, []);
|
|
231
231
|
|
|
232
232
|
return (
|
|
233
|
-
<Component ref={ref} {...rest as ComponentPropsT}>
|
|
233
|
+
<Component ref={ref} {...(rest as unknown as ComponentPropsT)}>
|
|
234
234
|
{children}
|
|
235
235
|
</Component>
|
|
236
236
|
);
|