@dr.pogodin/react-utils 1.40.3 → 1.40.5
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/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 +2 -0
- package/build/development/shared/components/Modal/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/style.css +21 -0
- package/build/development/web.bundle.js +86 -36
- package/build/production/client/init.js +1 -1
- package/build/production/client/init.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/Modal/index.js +2 -2
- package/build/production/shared/components/Modal/index.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/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/config/babel/webpack.js +2 -2
- package/package.json +13 -13
- 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
|
@@ -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/config/babel/webpack.js
CHANGED
|
@@ -26,8 +26,8 @@ function newBaseConfig(options) {
|
|
|
26
26
|
['@babel/env', {
|
|
27
27
|
// Leaves it to the Webpack to deal with modules.
|
|
28
28
|
modules: (_a = options.modules) !== null && _a !== void 0 ? _a : false,
|
|
29
|
-
// Chrome
|
|
30
|
-
targets: options.targets || 'defaults or chrome >=
|
|
29
|
+
// Chrome 44 is the browser/WebView for Android 6.0 (API level 23).
|
|
30
|
+
targets: options.targets || 'defaults or chrome >= 44',
|
|
31
31
|
}],
|
|
32
32
|
// TODO: Starting from Babel 8, "automatic" will be the default runtime,
|
|
33
33
|
// thus once upgraded to Babel 8, runtime should be removed from
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.40.
|
|
2
|
+
"version": "1.40.5",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-setup": "bin/setup.js"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
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",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"cookie-parser": "^1.4.6",
|
|
24
24
|
"cross-env": "^7.0.3",
|
|
25
25
|
"dayjs": "^1.11.13",
|
|
26
|
-
"express": "^4.
|
|
26
|
+
"express": "^4.20.0",
|
|
27
27
|
"helmet": "^7.1.0",
|
|
28
28
|
"http-status-codes": "^2.3.0",
|
|
29
29
|
"joi": "^17.13.3",
|
|
@@ -35,7 +35,7 @@
|
|
|
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.2",
|
|
39
39
|
"request-ip": "^3.3.0",
|
|
40
40
|
"rimraf": "^6.0.0",
|
|
41
41
|
"serialize-javascript": "^6.0.2",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@testing-library/user-event": "^14.5.2",
|
|
65
65
|
"@tsconfig/recommended": "^1.0.7",
|
|
66
66
|
"@types/compression": "^1.7.5",
|
|
67
|
-
"@types/config": "^3.3.
|
|
67
|
+
"@types/config": "^3.3.5",
|
|
68
68
|
"@types/cookie": "^0.6.0",
|
|
69
69
|
"@types/cookie-parser": "^1.4.7",
|
|
70
70
|
"@types/csurf": "^1.11.5",
|
|
@@ -94,10 +94,10 @@
|
|
|
94
94
|
"eslint-config-airbnb": "^19.0.4",
|
|
95
95
|
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
96
96
|
"eslint-import-resolver-babel-module": "^5.3.2",
|
|
97
|
-
"eslint-plugin-import": "^2.
|
|
98
|
-
"eslint-plugin-jest": "^28.8.
|
|
99
|
-
"eslint-plugin-jsx-a11y": "^6.
|
|
100
|
-
"eslint-plugin-react": "^7.35.
|
|
97
|
+
"eslint-plugin-import": "^2.30.0",
|
|
98
|
+
"eslint-plugin-jest": "^28.8.3",
|
|
99
|
+
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
100
|
+
"eslint-plugin-react": "^7.35.2",
|
|
101
101
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
102
102
|
"identity-obj-proxy": "^3.0.0",
|
|
103
103
|
"jest": "^29.7.0",
|
|
@@ -106,14 +106,14 @@
|
|
|
106
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.45",
|
|
110
110
|
"postcss-loader": "^8.1.1",
|
|
111
111
|
"postcss-scss": "^4.0.9",
|
|
112
112
|
"pretty": "^2.0.0",
|
|
113
113
|
"react-refresh": "^0.14.2",
|
|
114
114
|
"regenerator-runtime": "^0.14.1",
|
|
115
115
|
"resolve-url-loader": "^5.0.0",
|
|
116
|
-
"sass": "^1.
|
|
116
|
+
"sass": "^1.78.0",
|
|
117
117
|
"sass-loader": "^16.0.1",
|
|
118
118
|
"sitemap": "^8.0.0",
|
|
119
119
|
"source-map-loader": "^5.0.0",
|
|
@@ -123,8 +123,8 @@
|
|
|
123
123
|
"tsc-alias": "^1.8.10",
|
|
124
124
|
"tstyche": "^2.1.1",
|
|
125
125
|
"typed-scss-modules": "^8.0.1",
|
|
126
|
-
"typescript": "^5.
|
|
127
|
-
"typescript-eslint": "^8.
|
|
126
|
+
"typescript": "^5.6.2",
|
|
127
|
+
"typescript-eslint": "^8.5.0",
|
|
128
128
|
"webpack": "^5.94.0",
|
|
129
129
|
"webpack-dev-middleware": "^7.4.2",
|
|
130
130
|
"webpack-hot-middleware": "^2.26.1",
|
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
|
|