@dr.pogodin/react-utils 1.35.5 → 1.36.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/LICENSE.md +1 -1
- package/build/development/index.js +0 -6
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js +19 -19
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/renderer.js +7 -4
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +4 -1
- package/build/development/server/server.js.map +1 -1
- package/build/development/shared/components/Button/index.js +1 -16
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +1 -29
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +0 -15
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +1 -8
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/MetaTags.js +0 -12
- package/build/development/shared/components/MetaTags.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +2 -13
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +1 -10
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +1 -12
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +1 -6
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +1 -8
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +1 -9
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +2 -11
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +1 -16
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +2 -12
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +2 -12
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +21 -28
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/components/selectors/common.js +0 -19
- package/build/development/shared/components/selectors/common.js.map +1 -1
- package/build/development/shared/components/selectors/index.js +0 -13
- package/build/development/shared/components/selectors/index.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +4 -2
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +11 -12
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/web.bundle.js +26 -36
- package/build/production/index.js +1 -1
- package/build/production/index.js.map +1 -1
- package/build/production/server/Cache.js +3 -3
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/renderer.js +2 -2
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +1 -1
- package/build/production/server/server.js.map +1 -1
- package/build/production/shared/components/Button/index.js +3 -3
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +1 -16
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +2 -2
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +2 -2
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/MetaTags.js +2 -2
- package/build/production/shared/components/MetaTags.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/PageLayout/index.js +2 -2
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/TextArea/index.js +2 -2
- package/build/production/shared/components/TextArea/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js +2 -2
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js +3 -3
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +2 -2
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +3 -3
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js +3 -3
- package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/Switch/index.js +1 -1
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/production/shared/components/selectors/common.js +2 -4
- package/build/production/shared/components/selectors/common.js.map +1 -1
- package/build/production/shared/components/selectors/index.js +1 -1
- package/build/production/shared/components/selectors/index.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 +5 -5
- package/build/production/shared/utils/splitComponent.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/index.d.ts +1 -2
- package/build/types-code/server/Cache.d.ts +3 -11
- package/build/types-code/server/index.d.ts +0 -2
- package/build/types-code/server/renderer.d.ts +0 -1
- package/build/types-code/server/server.d.ts +0 -1
- package/build/types-code/shared/components/Button/index.d.ts +3 -4
- package/build/types-code/shared/components/Checkbox/index.d.ts +3 -12
- package/build/types-code/shared/components/Input/index.d.ts +4 -5
- package/build/types-code/shared/components/Link.d.ts +0 -1
- package/build/types-code/shared/components/Modal/index.d.ts +3 -4
- package/build/types-code/shared/components/NavLink.d.ts +0 -1
- package/build/types-code/shared/components/PageLayout/index.d.ts +4 -4
- package/build/types-code/shared/components/TextArea/index.d.ts +4 -5
- package/build/types-code/shared/components/Throbber/index.d.ts +4 -4
- package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +1 -1
- package/build/types-code/shared/components/WithTooltip/index.d.ts +2 -3
- package/build/types-code/shared/components/YouTubeVideo/index.d.ts +3 -4
- package/build/types-code/shared/components/selectors/CustomDropdown/Options/index.d.ts +1 -2
- package/build/types-code/shared/components/selectors/CustomDropdown/index.d.ts +2 -3
- package/build/types-code/shared/components/selectors/NativeDropdown/index.d.ts +2 -2
- package/build/types-code/shared/components/selectors/Switch/index.d.ts +4 -5
- package/build/types-code/shared/components/selectors/common.d.ts +4 -10
- package/build/types-code/shared/components/selectors/index.d.ts +1 -1
- package/build/types-code/shared/utils/globalState.d.ts +1 -2
- package/build/types-code/shared/utils/jest/index.d.ts +4 -1
- package/build/types-code/shared/utils/splitComponent.d.ts +0 -1
- package/build/types-code/shared/utils/webpack.d.ts +0 -1
- package/config/babel/node-ssr.js +1 -1
- package/config/babel/webpack.js +1 -1
- package/config/eslint/default.json +1 -0
- package/config/eslint/jest.json +1 -0
- package/config/eslint/typescript.js +7 -0
- package/config/typescript/base.json +9 -0
- package/config/webpack/app-base.d.ts +0 -1
- package/config/webpack/app-base.js +1 -1
- package/config/webpack/app-development.js +1 -1
- package/config/webpack/app-production.js +1 -1
- package/config/webpack/lib-base.js +1 -2
- package/config/webpack/lib-development.js +1 -1
- package/config/webpack/lib-production.js +1 -1
- package/package.json +14 -13
- package/src/index.ts +0 -1
- package/src/server/Cache.ts +31 -30
- package/src/server/renderer.tsx +8 -5
- package/src/server/server.ts +6 -1
- package/src/shared/components/Button/index.tsx +2 -20
- package/src/shared/components/Checkbox/index.tsx +2 -37
- package/src/shared/components/GenericLink/index.tsx +0 -15
- package/src/shared/components/Input/index.tsx +6 -15
- package/src/shared/components/MetaTags.tsx +0 -12
- package/src/shared/components/Modal/index.tsx +3 -22
- package/src/shared/components/PageLayout/index.tsx +8 -24
- package/src/shared/components/TextArea/index.tsx +6 -24
- package/src/shared/components/Throbber/index.tsx +6 -18
- package/src/shared/components/WithTooltip/Tooltip.tsx +6 -14
- package/src/shared/components/WithTooltip/index.tsx +3 -24
- package/src/shared/components/YouTubeVideo/index.tsx +3 -20
- package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +2 -20
- package/src/shared/components/selectors/CustomDropdown/index.tsx +3 -27
- package/src/shared/components/selectors/NativeDropdown/index.tsx +3 -27
- package/src/shared/components/selectors/Switch/index.tsx +34 -50
- package/src/shared/components/selectors/common.ts +12 -44
- package/src/shared/components/selectors/index.ts +0 -2
- package/src/shared/utils/jest/index.tsx +13 -2
- package/src/shared/utils/splitComponent.tsx +14 -11
- package/tsconfig.configs.json +7 -3
- package/tsconfig.json +3 -10
- package/tsconfig.types.json +1 -7
- package/tstyche.config.json +6 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.36.0",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-setup": "bin/setup.js"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@dr.pogodin/csurf": "^1.13.0",
|
|
14
14
|
"@dr.pogodin/js-utils": "^0.0.12",
|
|
15
15
|
"@dr.pogodin/react-global-state": "^0.14.2",
|
|
16
|
-
"@dr.pogodin/react-themes": "^1.
|
|
16
|
+
"@dr.pogodin/react-themes": "^1.7.0",
|
|
17
17
|
"@jest/environment": "^29.7.0",
|
|
18
18
|
"axios": "^1.7.2",
|
|
19
19
|
"commander": "^12.1.0",
|
|
@@ -26,11 +26,10 @@
|
|
|
26
26
|
"express": "^4.19.2",
|
|
27
27
|
"helmet": "^7.1.0",
|
|
28
28
|
"http-status-codes": "^2.3.0",
|
|
29
|
-
"joi": "^17.13.
|
|
29
|
+
"joi": "^17.13.3",
|
|
30
30
|
"lodash": "^4.17.21",
|
|
31
31
|
"morgan": "^1.10.0",
|
|
32
32
|
"node-forge": "^1.3.1",
|
|
33
|
-
"prop-types": "^15.8.1",
|
|
34
33
|
"qs": "^6.12.1",
|
|
35
34
|
"raf": "^3.4.1",
|
|
36
35
|
"react": "^18.3.1",
|
|
@@ -82,7 +81,7 @@
|
|
|
82
81
|
"@types/serialize-javascript": "^5.0.4",
|
|
83
82
|
"@types/serve-favicon": "^2.5.7",
|
|
84
83
|
"@types/supertest": "^6.0.2",
|
|
85
|
-
"@types/uuid": "^
|
|
84
|
+
"@types/uuid": "^10.0.0",
|
|
86
85
|
"@types/webpack": "^5.28.5",
|
|
87
86
|
"autoprefixer": "^10.4.19",
|
|
88
87
|
"babel-jest": "^29.7.0",
|
|
@@ -97,13 +96,13 @@
|
|
|
97
96
|
"eslint-import-resolver-babel-module": "^5.3.2",
|
|
98
97
|
"eslint-plugin-import": "^2.29.1",
|
|
99
98
|
"eslint-plugin-jest": "^28.6.0",
|
|
100
|
-
"eslint-plugin-jsx-a11y": "^6.
|
|
101
|
-
"eslint-plugin-react": "^7.34.
|
|
99
|
+
"eslint-plugin-jsx-a11y": "^6.9.0",
|
|
100
|
+
"eslint-plugin-react": "^7.34.3",
|
|
102
101
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
103
102
|
"identity-obj-proxy": "^3.0.0",
|
|
104
103
|
"jest": "^29.7.0",
|
|
105
104
|
"jest-environment-jsdom": "^29.7.0",
|
|
106
|
-
"memfs": "^4.9.
|
|
105
|
+
"memfs": "^4.9.3",
|
|
107
106
|
"mini-css-extract-plugin": "^2.9.0",
|
|
108
107
|
"mockdate": "^3.0.5",
|
|
109
108
|
"nodelist-foreach-polyfill": "^1.2.0",
|
|
@@ -114,17 +113,18 @@
|
|
|
114
113
|
"react-refresh": "^0.14.2",
|
|
115
114
|
"regenerator-runtime": "^0.14.1",
|
|
116
115
|
"resolve-url-loader": "^5.0.0",
|
|
117
|
-
"sass": "^1.77.
|
|
116
|
+
"sass": "^1.77.6",
|
|
118
117
|
"sass-loader": "^14.2.1",
|
|
119
118
|
"sitemap": "^8.0.0",
|
|
120
119
|
"stylelint": "^16.6.1",
|
|
121
120
|
"stylelint-config-standard-scss": "^13.1.0",
|
|
122
121
|
"supertest": "^7.0.0",
|
|
123
122
|
"tsc-alias": "^1.8.10",
|
|
123
|
+
"tstyche": "^2.0.0",
|
|
124
124
|
"typed-scss-modules": "^8.0.1",
|
|
125
|
-
"typescript": "^5.
|
|
126
|
-
"typescript-eslint": "^7.
|
|
127
|
-
"webpack": "^5.
|
|
125
|
+
"typescript": "^5.5.2",
|
|
126
|
+
"typescript-eslint": "^7.13.1",
|
|
127
|
+
"webpack": "^5.92.1",
|
|
128
128
|
"webpack-dev-middleware": "^7.2.1",
|
|
129
129
|
"webpack-hot-middleware": "^2.26.1",
|
|
130
130
|
"webpack-merge": "^5.10.0",
|
|
@@ -200,7 +200,8 @@
|
|
|
200
200
|
"jest:2": "NODE_CONFIG_ENV=test jest --no-cache -w 1 --config config/jest/default.js --shard=2/4",
|
|
201
201
|
"jest:3": "NODE_CONFIG_ENV=test jest --no-cache -w 1 --config config/jest/default.js --shard=3/4",
|
|
202
202
|
"jest:4": "NODE_CONFIG_ENV=test jest --no-cache -w 1 --config config/jest/default.js --shard=4/4",
|
|
203
|
-
"jest
|
|
203
|
+
"jest:types": "tstyche",
|
|
204
|
+
"jest": "npm run jest:types && npm run jest:1 && npm run jest:2 && npm run jest:3 && npm run jest:4",
|
|
204
205
|
"lint": "npm run lint:code && npm run lint:scss",
|
|
205
206
|
"lint:code": "eslint --ext .js,.jsx,.ts,.tsx .",
|
|
206
207
|
"lint:scss": "stylelint -- **/*.{css,scss}",
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ const server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) |
|
|
|
9
9
|
const client = server ? undefined : require('./client').default;
|
|
10
10
|
|
|
11
11
|
export { default as api } from 'axios';
|
|
12
|
-
export * as PT from 'prop-types';
|
|
13
12
|
|
|
14
13
|
export {
|
|
15
14
|
type AsyncCollectionLoaderT,
|
package/src/server/Cache.ts
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
+
type CachedItemT<DatumT> = {
|
|
2
|
+
data: DatumT;
|
|
3
|
+
size: number;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* Implements the static cache.
|
|
3
9
|
*/
|
|
4
10
|
export default class Cache<DatumT> {
|
|
5
|
-
private: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
timestamp: number;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
maxSize: number;
|
|
14
|
-
size: number;
|
|
15
|
-
};
|
|
11
|
+
private items: Record<string, CachedItemT<DatumT>> = {};
|
|
12
|
+
|
|
13
|
+
private maxSize: number;
|
|
14
|
+
|
|
15
|
+
private size = 0;
|
|
16
16
|
|
|
17
17
|
constructor(maxSize: number) {
|
|
18
|
-
this.
|
|
19
|
-
items: {},
|
|
20
|
-
maxSize,
|
|
21
|
-
size: 0,
|
|
22
|
-
};
|
|
18
|
+
this.maxSize = maxSize;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
/**
|
|
@@ -37,7 +33,7 @@ export default class Cache<DatumT> {
|
|
|
37
33
|
key: string;
|
|
38
34
|
maxage?: number;
|
|
39
35
|
}): DatumT | null {
|
|
40
|
-
const item = this.
|
|
36
|
+
const item = this.items[key];
|
|
41
37
|
return item && Date.now() - item.timestamp < maxage ? item.data : null;
|
|
42
38
|
}
|
|
43
39
|
|
|
@@ -49,19 +45,24 @@ export default class Cache<DatumT> {
|
|
|
49
45
|
* @param size Byte size of the item.
|
|
50
46
|
*/
|
|
51
47
|
add(data: DatumT, key: string, size: number) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (
|
|
48
|
+
const cached = this.items[key];
|
|
49
|
+
if (cached) this.size -= cached.size;
|
|
50
|
+
|
|
51
|
+
this.items[key] = { data, size, timestamp: Date.now() };
|
|
52
|
+
this.size += size;
|
|
53
|
+
|
|
54
|
+
if (this.size > this.maxSize) {
|
|
55
|
+
const entries = Object.entries(this.items);
|
|
56
|
+
entries.sort((a, b) => a[1].timestamp - b[1].timestamp);
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < entries.length; ++i) {
|
|
59
|
+
const entry = entries[i];
|
|
60
|
+
if (entry) {
|
|
61
|
+
const [itemKey, item] = entry;
|
|
62
|
+
delete this.items[itemKey];
|
|
63
|
+
this.size -= item.size;
|
|
64
|
+
if (this.size < this.maxSize / 2) break;
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
package/src/server/renderer.tsx
CHANGED
|
@@ -159,10 +159,13 @@ export function isBrotliAcceptable(req: Request) {
|
|
|
159
159
|
if (acceptable) {
|
|
160
160
|
const ops = acceptable.split(',');
|
|
161
161
|
for (let i = 0; i < ops.length; ++i) {
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
const op = ops[i];
|
|
163
|
+
if (op) {
|
|
164
|
+
const [type, priority] = op.trim().split(';q=');
|
|
165
|
+
if ((type === '*' || type === 'br')
|
|
166
|
+
&& (!priority || parseFloat(priority) > 0)) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
166
169
|
}
|
|
167
170
|
}
|
|
168
171
|
}
|
|
@@ -193,7 +196,7 @@ function groupExtraScripts(scripts: Array<string | ScriptT> = []) {
|
|
|
193
196
|
const script = scripts[i];
|
|
194
197
|
if (isString(script)) {
|
|
195
198
|
if (script) res[SCRIPT_LOCATIONS.DEFAULT] += script;
|
|
196
|
-
} else if (script
|
|
199
|
+
} else if (script?.code) {
|
|
197
200
|
if (res[script.location] !== undefined) {
|
|
198
201
|
res[script.location] += script.code;
|
|
199
202
|
} else throw Error(`Invalid location "${script.location}"`);
|
package/src/server/server.ts
CHANGED
|
@@ -71,7 +71,12 @@ defaultCspSettings.directives['frame-src'] = [
|
|
|
71
71
|
// out of box.
|
|
72
72
|
'https://*.youtube.com',
|
|
73
73
|
];
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
{
|
|
76
|
+
const directives = defaultCspSettings.directives['script-src'];
|
|
77
|
+
if (directives) directives.push("'unsafe-eval'");
|
|
78
|
+
else defaultCspSettings.directives['script-src'] = ["'unsafe-eval'"];
|
|
79
|
+
}
|
|
75
80
|
|
|
76
81
|
// No need for automatic re-writes via Content Security Policy settings:
|
|
77
82
|
// the forefront Apache or Nginx server is supposed to take care of this
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// The <Button> component implements a standard button / button-like link.
|
|
2
2
|
|
|
3
|
-
import PT from 'prop-types';
|
|
4
3
|
import { type ReactNode } from 'react';
|
|
5
4
|
|
|
6
5
|
import Link from 'components/Link';
|
|
@@ -9,8 +8,6 @@ import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
|
9
8
|
|
|
10
9
|
import defaultTheme from './style.scss';
|
|
11
10
|
|
|
12
|
-
const validThemeKeys = ['active', 'button', 'disabled'] as const;
|
|
13
|
-
|
|
14
11
|
type PropsT = {
|
|
15
12
|
active?: boolean;
|
|
16
13
|
children?: ReactNode;
|
|
@@ -20,7 +17,7 @@ type PropsT = {
|
|
|
20
17
|
onMouseDown?: React.MouseEventHandler;
|
|
21
18
|
openNewTab?: boolean;
|
|
22
19
|
replace?: boolean;
|
|
23
|
-
theme: Theme<
|
|
20
|
+
theme: Theme<'active' | 'button' | 'disabled'>;
|
|
24
21
|
// TODO: It needs a more precise typing of the object option.
|
|
25
22
|
to?: object | string;
|
|
26
23
|
};
|
|
@@ -87,19 +84,4 @@ export const BaseButton: React.FunctionComponent<PropsT> = ({
|
|
|
87
84
|
* @prop {string} [button] to the root element of any button.
|
|
88
85
|
* @prop {string} [disabled] to the root element of disabled button.
|
|
89
86
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
BaseButton.propTypes = {
|
|
93
|
-
active: PT.bool,
|
|
94
|
-
children: PT.node,
|
|
95
|
-
disabled: PT.bool,
|
|
96
|
-
enforceA: PT.bool,
|
|
97
|
-
onClick: PT.func,
|
|
98
|
-
onMouseDown: PT.func,
|
|
99
|
-
openNewTab: PT.bool,
|
|
100
|
-
replace: PT.bool,
|
|
101
|
-
theme: ThemedButton.themeType.isRequired,
|
|
102
|
-
to: PT.oneOfType([PT.object, PT.string]),
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default ThemedButton;
|
|
87
|
+
export default themed(BaseButton, 'Button', defaultTheme);
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import PT from 'prop-types';
|
|
2
|
-
|
|
3
1
|
import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
4
2
|
|
|
5
3
|
import defaultTheme from './theme.scss';
|
|
6
4
|
|
|
7
|
-
const validThemeKeys = ['checkbox', 'container', 'label'] as const;
|
|
8
|
-
|
|
9
5
|
type PropT = {
|
|
10
6
|
checked?: boolean;
|
|
11
7
|
label?: React.ReactNode;
|
|
12
8
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
13
|
-
theme: Theme<
|
|
9
|
+
theme: Theme<'checkbox' | 'container' | 'label'>;
|
|
14
10
|
};
|
|
15
11
|
|
|
16
12
|
const Checkbox: React.FunctionComponent<PropT> = ({
|
|
@@ -31,35 +27,4 @@ const Checkbox: React.FunctionComponent<PropT> = ({
|
|
|
31
27
|
</div>
|
|
32
28
|
);
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
* Checkbox component theme: a map of
|
|
36
|
-
* CSS classes to append to its elements:
|
|
37
|
-
* @prop [checkbox] to the underlying checkbox `<input>` element.
|
|
38
|
-
* @prop [container] to the root checkbox element.
|
|
39
|
-
* @prop [label] to the checkbox label element.
|
|
40
|
-
*/
|
|
41
|
-
const ThemedCheckbox = themed(
|
|
42
|
-
Checkbox,
|
|
43
|
-
'Checkbox',
|
|
44
|
-
validThemeKeys,
|
|
45
|
-
defaultTheme,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The `<Checkbox>` component implements themeable checkboxes.
|
|
50
|
-
* @param [props] Component properties.
|
|
51
|
-
* @param [props.checked] Checkbox value.
|
|
52
|
-
* @param [props.label] Checkbox label.
|
|
53
|
-
* @param [props.onChange] State change handler.
|
|
54
|
-
* @param [props.theme] _Ad hoc_ theme.
|
|
55
|
-
* @param [props....]
|
|
56
|
-
* [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties).
|
|
57
|
-
*/
|
|
58
|
-
Checkbox.propTypes = {
|
|
59
|
-
checked: PT.bool,
|
|
60
|
-
label: PT.node,
|
|
61
|
-
onChange: PT.func,
|
|
62
|
-
theme: ThemedCheckbox.themeType.isRequired,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default ThemedCheckbox;
|
|
30
|
+
export default themed(Checkbox, 'Checkbox', defaultTheme);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* global window */
|
|
2
2
|
|
|
3
|
-
import PT from 'prop-types';
|
|
4
3
|
import { type ReactNode } from 'react';
|
|
5
4
|
|
|
6
5
|
import { type Link, type NavLink } from 'react-router-dom';
|
|
@@ -127,18 +126,4 @@ const GenericLink: React.FunctionComponent<PropsT> = ({
|
|
|
127
126
|
);
|
|
128
127
|
};
|
|
129
128
|
|
|
130
|
-
GenericLink.propTypes = {
|
|
131
|
-
children: PT.node,
|
|
132
|
-
className: PT.string,
|
|
133
|
-
disabled: PT.bool,
|
|
134
|
-
enforceA: PT.bool,
|
|
135
|
-
keepScrollPosition: PT.bool,
|
|
136
|
-
onClick: PT.func,
|
|
137
|
-
onMouseDown: PT.func,
|
|
138
|
-
openNewTab: PT.bool,
|
|
139
|
-
replace: PT.bool,
|
|
140
|
-
routerLinkType: PT.elementType.isRequired,
|
|
141
|
-
to: PT.oneOfType([PT.object, PT.string]),
|
|
142
|
-
};
|
|
143
|
-
|
|
144
129
|
export default GenericLink;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import PT from 'prop-types';
|
|
2
1
|
import { forwardRef } from 'react';
|
|
3
2
|
|
|
4
3
|
import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
5
4
|
|
|
6
5
|
import defaultTheme from './theme.scss';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
'container'
|
|
10
|
-
'input'
|
|
11
|
-
'label'
|
|
12
|
-
] as const;
|
|
7
|
+
type ThemeKeyT =
|
|
8
|
+
| 'container'
|
|
9
|
+
| 'input'
|
|
10
|
+
| 'label';
|
|
13
11
|
|
|
14
12
|
type PropsT = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
15
13
|
label?: React.ReactNode;
|
|
16
|
-
theme: Theme<
|
|
14
|
+
theme: Theme<ThemeKeyT>;
|
|
17
15
|
};
|
|
18
16
|
|
|
19
17
|
/**
|
|
@@ -43,11 +41,4 @@ const Input = forwardRef<HTMLInputElement, PropsT>((
|
|
|
43
41
|
</span>
|
|
44
42
|
));
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Input.propTypes = {
|
|
49
|
-
label: PT.node,
|
|
50
|
-
theme: ThemedInput.themeType.isRequired,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default ThemedInput;
|
|
44
|
+
export default themed(Input, 'Input', defaultTheme);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import PT from 'prop-types';
|
|
2
1
|
import { type ReactNode, createContext, useMemo } from 'react';
|
|
3
2
|
import { Helmet } from 'react-helmet';
|
|
4
3
|
|
|
@@ -147,15 +146,4 @@ const MetaTags: React.FunctionComponent<PropsT> & {
|
|
|
147
146
|
|
|
148
147
|
MetaTags.Context = Context;
|
|
149
148
|
|
|
150
|
-
MetaTags.propTypes = {
|
|
151
|
-
children: PT.node,
|
|
152
|
-
description: PT.string.isRequired,
|
|
153
|
-
image: PT.string,
|
|
154
|
-
siteName: PT.string,
|
|
155
|
-
socialDescription: PT.string,
|
|
156
|
-
socialTitle: PT.string,
|
|
157
|
-
title: PT.string.isRequired,
|
|
158
|
-
url: PT.string,
|
|
159
|
-
};
|
|
160
|
-
|
|
161
149
|
export default MetaTags;
|
|
@@ -9,21 +9,18 @@ import {
|
|
|
9
9
|
} from 'react';
|
|
10
10
|
|
|
11
11
|
import ReactDom from 'react-dom';
|
|
12
|
-
import PT from 'prop-types';
|
|
13
12
|
import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
14
13
|
|
|
15
14
|
import baseTheme from './base-theme.scss';
|
|
16
15
|
import S from './styles.scss';
|
|
17
16
|
|
|
18
|
-
const validThemeKeys = ['container', 'overlay'] as const;
|
|
19
|
-
|
|
20
17
|
type PropsT = {
|
|
21
18
|
cancelOnScrolling?: boolean;
|
|
22
19
|
children?: ReactNode;
|
|
23
20
|
containerStyle?: React.CSSProperties;
|
|
24
21
|
dontDisableScrolling?: boolean;
|
|
25
22
|
onCancel?: () => void;
|
|
26
|
-
theme: Theme<
|
|
23
|
+
theme: Theme<'container' | 'overlay'>;
|
|
27
24
|
};
|
|
28
25
|
|
|
29
26
|
/**
|
|
@@ -89,7 +86,7 @@ const BaseModal: React.FunctionComponent<PropsT> = ({
|
|
|
89
86
|
onFocus={() => {
|
|
90
87
|
const elems = containerRef.current?.querySelectorAll('*') as NodeListOf<HTMLElement>;
|
|
91
88
|
for (let i = elems.length - 1; i >= 0; --i) {
|
|
92
|
-
elems[i]
|
|
89
|
+
elems[i]?.focus();
|
|
93
90
|
if (document.activeElement === elems[i]) return;
|
|
94
91
|
}
|
|
95
92
|
overlayRef.current?.focus();
|
|
@@ -169,23 +166,7 @@ const BaseModal: React.FunctionComponent<PropsT> = ({
|
|
|
169
166
|
) : null;
|
|
170
167
|
};
|
|
171
168
|
|
|
172
|
-
|
|
173
|
-
BaseModal,
|
|
174
|
-
'Modal',
|
|
175
|
-
validThemeKeys,
|
|
176
|
-
baseTheme,
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
BaseModal.propTypes = {
|
|
180
|
-
cancelOnScrolling: PT.bool,
|
|
181
|
-
children: PT.node,
|
|
182
|
-
containerStyle: PT.shape({}),
|
|
183
|
-
dontDisableScrolling: PT.bool,
|
|
184
|
-
onCancel: PT.func,
|
|
185
|
-
theme: ThemedModal.themeType.isRequired,
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export default ThemedModal;
|
|
169
|
+
export default themed(BaseModal, 'Modal', baseTheme);
|
|
189
170
|
|
|
190
171
|
/* Non-themed version of the Modal. */
|
|
191
172
|
export { BaseModal };
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import PT from 'prop-types';
|
|
2
1
|
import type { ReactNode } from 'react';
|
|
3
2
|
|
|
4
3
|
import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
5
4
|
|
|
6
5
|
import baseTheme from './base-theme.scss';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
'container'
|
|
10
|
-
'leftSidePanel'
|
|
11
|
-
'mainPanel'
|
|
12
|
-
'rightSidePanel'
|
|
13
|
-
'sidePanel'
|
|
14
|
-
] as const;
|
|
7
|
+
type ThemeKeyT =
|
|
8
|
+
| 'container'
|
|
9
|
+
| 'leftSidePanel'
|
|
10
|
+
| 'mainPanel'
|
|
11
|
+
| 'rightSidePanel'
|
|
12
|
+
| 'sidePanel';
|
|
15
13
|
|
|
16
14
|
type PropsT = {
|
|
17
15
|
children?: ReactNode;
|
|
18
16
|
leftSidePanelContent?: ReactNode;
|
|
19
17
|
rightSidePanelContent?: ReactNode;
|
|
20
|
-
theme: Theme<
|
|
18
|
+
theme: Theme<ThemeKeyT>;
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
/**
|
|
@@ -54,18 +52,4 @@ const PageLayout: React.FunctionComponent<PropsT> = ({
|
|
|
54
52
|
</div>
|
|
55
53
|
);
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
PageLayout,
|
|
59
|
-
'PageLayout',
|
|
60
|
-
validThemeKeys,
|
|
61
|
-
baseTheme,
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
PageLayout.propTypes = {
|
|
65
|
-
children: PT.node,
|
|
66
|
-
leftSidePanelContent: PT.node,
|
|
67
|
-
rightSidePanelContent: PT.node,
|
|
68
|
-
theme: ThemedPageLayout.themeType.isRequired,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export default ThemedPageLayout;
|
|
55
|
+
export default themed(PageLayout, 'PageLayout', baseTheme);
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import PT from 'prop-types';
|
|
3
2
|
|
|
4
3
|
import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
5
4
|
|
|
6
5
|
import defaultTheme from './style.scss';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
'container'
|
|
10
|
-
'hidden'
|
|
11
|
-
'textarea'
|
|
12
|
-
] as const;
|
|
7
|
+
type ThemeKeyT =
|
|
8
|
+
| 'container'
|
|
9
|
+
| 'hidden'
|
|
10
|
+
| 'textarea';
|
|
13
11
|
|
|
14
12
|
type Props = {
|
|
15
13
|
disabled?: boolean;
|
|
16
14
|
onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;
|
|
17
15
|
onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;
|
|
18
16
|
placeholder?: string;
|
|
19
|
-
theme: Theme<
|
|
17
|
+
theme: Theme<ThemeKeyT>;
|
|
20
18
|
value?: string;
|
|
21
19
|
};
|
|
22
20
|
|
|
@@ -85,20 +83,4 @@ const TextArea: React.FunctionComponent<Props> = ({
|
|
|
85
83
|
);
|
|
86
84
|
};
|
|
87
85
|
|
|
88
|
-
|
|
89
|
-
TextArea,
|
|
90
|
-
'TextArea',
|
|
91
|
-
validThemeKeys,
|
|
92
|
-
defaultTheme,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
TextArea.propTypes = {
|
|
96
|
-
disabled: PT.bool,
|
|
97
|
-
onChange: PT.func,
|
|
98
|
-
onKeyDown: PT.func,
|
|
99
|
-
placeholder: PT.string,
|
|
100
|
-
theme: ThemedTextArea.themeType.isRequired,
|
|
101
|
-
value: PT.string,
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export default ThemedTextArea;
|
|
86
|
+
export default themed(TextArea, 'TextArea', defaultTheme);
|
|
@@ -2,14 +2,13 @@ import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
|
2
2
|
|
|
3
3
|
import defaultTheme from './theme.scss';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
'bouncing'
|
|
7
|
-
'circle'
|
|
8
|
-
'container'
|
|
9
|
-
] as const;
|
|
5
|
+
type ThemeKeyT =
|
|
6
|
+
| 'bouncing'
|
|
7
|
+
| 'circle'
|
|
8
|
+
| 'container';
|
|
10
9
|
|
|
11
10
|
type PropsT = {
|
|
12
|
-
theme: Theme<
|
|
11
|
+
theme: Theme<ThemeKeyT>;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -29,15 +28,4 @@ const Throbber: React.FunctionComponent<PropsT> = ({ theme }) => (
|
|
|
29
28
|
</span>
|
|
30
29
|
);
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
Throbber,
|
|
34
|
-
'Throbber',
|
|
35
|
-
validThemeKeys,
|
|
36
|
-
defaultTheme,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
Throbber.propTypes = {
|
|
40
|
-
theme: ThemedThrobber.themeType.isRequired,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default ThemedThrobber;
|
|
31
|
+
export default themed(Throbber, 'Throbber', defaultTheme);
|
|
@@ -16,8 +16,6 @@ import {
|
|
|
16
16
|
|
|
17
17
|
import { createPortal } from 'react-dom';
|
|
18
18
|
|
|
19
|
-
import PT from 'prop-types';
|
|
20
|
-
|
|
21
19
|
import type { Theme } from '@dr.pogodin/react-themes';
|
|
22
20
|
|
|
23
21
|
/* Valid placements of the rendered tooltip. They will be overriden when
|
|
@@ -54,14 +52,13 @@ type HeapT = {
|
|
|
54
52
|
lastPlacement?: PLACEMENTS | undefined;
|
|
55
53
|
};
|
|
56
54
|
|
|
57
|
-
export
|
|
58
|
-
'appearance'
|
|
59
|
-
'arrow'
|
|
60
|
-
'content'
|
|
61
|
-
'container'
|
|
62
|
-
] as const;
|
|
55
|
+
export type ThemeKeysT =
|
|
56
|
+
| 'appearance'
|
|
57
|
+
| 'arrow'
|
|
58
|
+
| 'content'
|
|
59
|
+
| 'container';
|
|
63
60
|
|
|
64
|
-
type TooltipThemeT = Theme<
|
|
61
|
+
type TooltipThemeT = Theme<ThemeKeysT>;
|
|
65
62
|
|
|
66
63
|
/**
|
|
67
64
|
* Creates tooltip components.
|
|
@@ -345,9 +342,4 @@ const Tooltip = forwardRef<unknown, {
|
|
|
345
342
|
return components ? createPortal(children, components.content) : null;
|
|
346
343
|
});
|
|
347
344
|
|
|
348
|
-
Tooltip.propTypes = {
|
|
349
|
-
children: PT.node,
|
|
350
|
-
theme: PT.shape({}).isRequired,
|
|
351
|
-
};
|
|
352
|
-
|
|
353
345
|
export default Tooltip;
|