@dr.pogodin/react-utils 1.44.2 → 1.44.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/shared/components/Input/index.js +15 -3
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/style.css +40 -0
- package/build/development/web.bundle.js +2 -2
- package/build/production/shared/components/Input/index.js +4 -4
- package/build/production/shared/components/Input/index.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/Input/index.d.ts +4 -2
- package/build/types-scss/src/shared/components/Input/theme.scss.d.ts +3 -0
- package/package.json +7 -7
- package/src/shared/components/Input/index.tsx +15 -3
- package/src/shared/components/Input/theme.scss +24 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { type Ref } from 'react';
|
|
1
|
+
import { type ReactNode, type Ref } from 'react';
|
|
2
2
|
import { type Theme } from '@dr.pogodin/react-themes';
|
|
3
|
-
type ThemeKeyT = 'container' | 'empty' | 'focused' | 'input' | 'label';
|
|
3
|
+
type ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage' | 'focused' | 'input' | 'label';
|
|
4
4
|
type PropsT = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
error?: ReactNode;
|
|
5
7
|
label?: React.ReactNode;
|
|
6
8
|
ref?: Ref<HTMLInputElement>;
|
|
7
9
|
testId?: string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export declare const ad: string;
|
|
2
|
+
export declare const children: string;
|
|
2
3
|
export declare const container: string;
|
|
3
4
|
export declare const context: string;
|
|
5
|
+
export declare const error: string;
|
|
6
|
+
export declare const errorMessage: string;
|
|
4
7
|
export declare const hoc: string;
|
|
5
8
|
export declare const input: string;
|
|
6
9
|
export declare const label: string;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.44.
|
|
2
|
+
"version": "1.44.4",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-setup": "bin/setup.js"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"axios": "^1.11.0",
|
|
20
20
|
"commander": "^14.0.0",
|
|
21
21
|
"compression": "^1.8.1",
|
|
22
|
-
"config": "^4.1.
|
|
22
|
+
"config": "^4.1.1",
|
|
23
23
|
"cookie": "^1.0.2",
|
|
24
24
|
"cookie-parser": "^1.4.7",
|
|
25
25
|
"cross-env": "^10.0.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"raf": "^3.4.1",
|
|
35
35
|
"react": "^19.1.1",
|
|
36
36
|
"react-dom": "^19.1.1",
|
|
37
|
-
"react-router": "^7.8.
|
|
37
|
+
"react-router": "^7.8.1",
|
|
38
38
|
"request-ip": "^3.3.0",
|
|
39
39
|
"rimraf": "^6.0.0",
|
|
40
40
|
"serialize-javascript": "^6.0.2",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/jest": "^30.0.0",
|
|
71
71
|
"@types/lodash": "^4.17.20",
|
|
72
72
|
"@types/morgan": "^1.9.10",
|
|
73
|
-
"@types/node-forge": "^1.3.
|
|
73
|
+
"@types/node-forge": "^1.3.14",
|
|
74
74
|
"@types/pretty": "^2.0.3",
|
|
75
75
|
"@types/react": "^19.1.10",
|
|
76
76
|
"@types/react-dom": "^19.1.7",
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
"babel-jest": "^30.0.5",
|
|
85
85
|
"babel-loader": "^10.0.0",
|
|
86
86
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
87
|
-
"core-js": "^3.45.
|
|
87
|
+
"core-js": "^3.45.1",
|
|
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
91
|
"jest": "^30.0.5",
|
|
92
92
|
"jest-environment-jsdom": "^30.0.5",
|
|
93
|
-
"memfs": "^4.36.
|
|
93
|
+
"memfs": "^4.36.3",
|
|
94
94
|
"mini-css-extract-plugin": "^2.9.4",
|
|
95
95
|
"mockdate": "^3.0.5",
|
|
96
96
|
"nodelist-foreach-polyfill": "^1.2.0",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"tstyche": "^4.3.0",
|
|
113
113
|
"typed-scss-modules": "^8.1.1",
|
|
114
114
|
"typescript": "^5.9.2",
|
|
115
|
-
"webpack": "^5.101.
|
|
115
|
+
"webpack": "^5.101.3",
|
|
116
116
|
"webpack-dev-middleware": "^7.4.2",
|
|
117
117
|
"webpack-hot-middleware": "^2.26.1",
|
|
118
118
|
"webpack-merge": "^6.0.1",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type FunctionComponent,
|
|
3
|
+
type ReactNode,
|
|
3
4
|
type Ref,
|
|
4
5
|
useRef,
|
|
5
6
|
useState,
|
|
@@ -9,9 +10,12 @@ import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
|
9
10
|
|
|
10
11
|
import defaultTheme from './theme.scss';
|
|
11
12
|
|
|
12
|
-
type ThemeKeyT = '
|
|
13
|
+
type ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'
|
|
14
|
+
| 'focused' | 'input' | 'label';
|
|
13
15
|
|
|
14
16
|
type PropsT = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
error?: ReactNode;
|
|
15
19
|
label?: React.ReactNode;
|
|
16
20
|
ref?: Ref<HTMLInputElement>;
|
|
17
21
|
testId?: string;
|
|
@@ -27,6 +31,8 @@ type PropsT = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
|
27
31
|
* `<input>` element.
|
|
28
32
|
*/
|
|
29
33
|
const Input: FunctionComponent<PropsT> = ({
|
|
34
|
+
children,
|
|
35
|
+
error,
|
|
30
36
|
label,
|
|
31
37
|
ref,
|
|
32
38
|
testId,
|
|
@@ -47,8 +53,10 @@ const Input: FunctionComponent<PropsT> = ({
|
|
|
47
53
|
|
|
48
54
|
if (!rest.value && theme.empty) containerClassName += ` ${theme.empty}`;
|
|
49
55
|
|
|
56
|
+
if (error) containerClassName += ` ${theme.error}`;
|
|
57
|
+
|
|
50
58
|
return (
|
|
51
|
-
<
|
|
59
|
+
<div
|
|
52
60
|
className={containerClassName}
|
|
53
61
|
onFocus={() => {
|
|
54
62
|
// TODO: It does not really work if a callback-style `ref` is passed in,
|
|
@@ -77,7 +85,11 @@ const Input: FunctionComponent<PropsT> = ({
|
|
|
77
85
|
rest.onFocus?.(e);
|
|
78
86
|
} : rest.onFocus}
|
|
79
87
|
/>
|
|
80
|
-
|
|
88
|
+
{error && error !== true
|
|
89
|
+
? <div className={theme.errorMessage}>{error}</div>
|
|
90
|
+
: null}
|
|
91
|
+
{children ? <div className={theme.children}>{children}</div> : null}
|
|
92
|
+
</div>
|
|
81
93
|
);
|
|
82
94
|
};
|
|
83
95
|
|
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
&.container {
|
|
5
5
|
align-items: center;
|
|
6
6
|
display: inline-flex;
|
|
7
|
+
flex-wrap: wrap;
|
|
7
8
|
margin: 0.1em;
|
|
9
|
+
position: relative;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&.children {
|
|
13
|
+
width: 100%;
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
&.input {
|
|
@@ -12,6 +18,7 @@
|
|
|
12
18
|
border-radius: 0.3em;
|
|
13
19
|
cursor: text;
|
|
14
20
|
font: inherit;
|
|
21
|
+
flex: 1;
|
|
15
22
|
outline: none;
|
|
16
23
|
padding: 0.3em 0.3em calc(0.3em + 1px);
|
|
17
24
|
|
|
@@ -25,4 +32,21 @@
|
|
|
25
32
|
margin: 0 0.6em 0 1.5em;
|
|
26
33
|
pointer-events: none;
|
|
27
34
|
}
|
|
35
|
+
|
|
36
|
+
&.error &.input {
|
|
37
|
+
border-color: red;
|
|
38
|
+
|
|
39
|
+
&:focus {
|
|
40
|
+
box-shadow: 0 0 3px 1px orangered;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&.errorMessage {
|
|
45
|
+
color: red;
|
|
46
|
+
font-size: 0.8em;
|
|
47
|
+
font-style: italic;
|
|
48
|
+
padding-right: 0.6em;
|
|
49
|
+
text-align: right;
|
|
50
|
+
width: 100%;
|
|
51
|
+
}
|
|
28
52
|
}
|