@dr.pogodin/react-utils 1.43.28 → 1.43.29

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.
@@ -1,4 +1,4 @@
1
- import type { Ref } from 'react';
1
+ import { type Ref } from 'react';
2
2
  import { type Theme } from '@dr.pogodin/react-themes';
3
3
  type ThemeKeyT = 'container' | 'input' | 'label';
4
4
  type PropsT = React.InputHTMLAttributes<HTMLInputElement> & {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.43.28",
2
+ "version": "1.43.29",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -16,7 +16,7 @@
16
16
  "@dr.pogodin/react-helmet": "^3.0.2",
17
17
  "@dr.pogodin/react-themes": "^1.9.2",
18
18
  "@jest/environment": "^30.0.5",
19
- "axios": "^1.10.0",
19
+ "axios": "^1.11.0",
20
20
  "commander": "^14.0.0",
21
21
  "compression": "^1.8.1",
22
22
  "config": "^4.0.1",
@@ -107,7 +107,7 @@
107
107
  "source-map-loader": "^5.0.0",
108
108
  "stylelint": "^16.22.0",
109
109
  "stylelint-config-standard-scss": "^15.0.1",
110
- "supertest": "^7.1.3",
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",
@@ -1,4 +1,4 @@
1
- import type { FunctionComponent, Ref } from 'react';
1
+ import { type FunctionComponent, type Ref, useRef } from 'react';
2
2
 
3
3
  import themed, { type Theme } from '@dr.pogodin/react-themes';
4
4
 
@@ -27,19 +27,31 @@ const Input: FunctionComponent<PropsT> = ({
27
27
  testId,
28
28
  theme,
29
29
  ...rest
30
- }) => (
31
- <span className={theme.container}>
32
- { label === undefined ? null : <div className={theme.label}>{label}</div> }
33
- <input
34
- className={theme.input}
35
- data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}
36
- ref={ref}
30
+ }) => {
31
+ const localRef = useRef<HTMLInputElement>(null);
32
+ return (
33
+ <span
34
+ className={theme.container}
35
+ onFocus={() => {
36
+ // TODO: It does not really work if a callback-style `ref` is passed in,
37
+ // we need a more complex logic to cover that case, but for now this serves
38
+ // the case we need it for.
39
+ if (typeof ref === 'object') ref?.current?.focus();
40
+ else localRef.current?.focus();
41
+ }}
42
+ >
43
+ {label === undefined ? null : <div className={theme.label}>{label}</div>}
44
+ <input
45
+ className={theme.input}
46
+ data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}
47
+ ref={ref ?? localRef}
37
48
 
38
- // TODO: Avoid the spreading later.
39
- // eslint-disable-next-line react/jsx-props-no-spreading
40
- {...rest}
41
- />
42
- </span>
43
- );
49
+ // TODO: Avoid the spreading later.
50
+ // eslint-disable-next-line react/jsx-props-no-spreading
51
+ {...rest}
52
+ />
53
+ </span>
54
+ );
55
+ };
44
56
 
45
57
  export default themed(Input, 'Input', defaultTheme);
@@ -23,5 +23,6 @@
23
23
 
24
24
  &.label {
25
25
  margin: 0 0.6em 0 1.5em;
26
+ pointer-events: none;
26
27
  }
27
28
  }
@@ -41,6 +41,8 @@ const TextArea: FunctionComponent<Props> = ({
41
41
  const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);
42
42
  const [height, setHeight] = useState<number | undefined>();
43
43
 
44
+ const textAreaRef = useRef<HTMLTextAreaElement>(null);
45
+
44
46
  const [localValue, setLocalValue] = useState(value ?? '');
45
47
  if (value !== undefined && localValue !== value) setLocalValue(value);
46
48
 
@@ -73,7 +75,12 @@ const TextArea: FunctionComponent<Props> = ({
73
75
  }, [localValue]);
74
76
 
75
77
  return (
76
- <div className={theme.container}>
78
+ <div
79
+ className={theme.container}
80
+ onFocus={() => {
81
+ textAreaRef.current?.focus();
82
+ }}
83
+ >
77
84
  {label === undefined ? null : <div className={theme.label}>{label}</div>}
78
85
  <textarea
79
86
  className={`${theme.textarea} ${theme.hidden}`}
@@ -111,6 +118,7 @@ const TextArea: FunctionComponent<Props> = ({
111
118
  }
112
119
  onKeyDown={onKeyDown}
113
120
  placeholder={placeholder}
121
+ ref={textAreaRef}
114
122
  style={{ height }}
115
123
  value={localValue}
116
124
  />
@@ -45,6 +45,7 @@
45
45
 
46
46
  &.label {
47
47
  margin: 0 0.6em 0 1.5em;
48
+ pointer-events: none;
48
49
  }
49
50
 
50
51
  &.option { color: black; }