@dr.pogodin/react-utils 1.43.27 → 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> & {
@@ -125,7 +125,7 @@ const utils_1 = require("@dr.pogodin/babel-plugin-react-css-modules/utils");
125
125
  * - **`timestamp`** &mdash; The value set for `BUILD_TIMESTAMP`.
126
126
  */
127
127
  function configFactory(ops) {
128
- var _a, _b;
128
+ var _a, _b, _c;
129
129
  const o = (0, lodash_1.defaults)((0, lodash_1.clone)(ops), {
130
130
  babelLoaderOptions: {},
131
131
  cssLocalIdent: '[hash:base64:6]',
@@ -211,7 +211,7 @@ function configFactory(ops) {
211
211
  o.workbox = {};
212
212
  plugins.push(new workbox_webpack_plugin_1.default.InjectManifest(Object.assign(Object.assign({ swSrc: node_path_1.default.resolve(__dirname, '../workbox/default.js') }, o.workbox), { swDest: '__service-worker.js' })));
213
213
  }
214
- return {
214
+ const res = {
215
215
  context: o.context,
216
216
  entry,
217
217
  mode: o.mode,
@@ -302,12 +302,6 @@ function configFactory(ops) {
302
302
  plugins,
303
303
  resolve: {
304
304
  alias: {
305
- // NOTE: The "conditionNames" workaround below messes up the loading of
306
- // Babel's runtime helper for require of CJS and ES styles of modules
307
- // (without this alias it is resolved to
308
- // @babel/runtime/helpers/esm/interopRequireDefault, which has
309
- // the hepler function attached to "default" export).
310
- '@babel/runtime/helpers/interopRequireDefault': node_path_1.default.resolve(o.context, 'node_modules/@babel/runtime/helpers/interopRequireDefault'),
311
305
  // Aliases to JS an JSX files are handled by Babel.
312
306
  assets: node_path_1.default.resolve(o.context, 'src/assets'),
313
307
  components: node_path_1.default.resolve(o.context, 'src/shared/components'),
@@ -333,4 +327,26 @@ function configFactory(ops) {
333
327
  symlinks: false,
334
328
  },
335
329
  };
330
+ // TODO: Can we do anything better about it? Otherwise, we potentially
331
+ // have to alias all Babel's runtime helpers, otherwise if it tries to
332
+ // use a new helper it breaks (probably only production) build in a very
333
+ // confusing, hard to debug way. Not sure what to do, as the problem with
334
+ // RR exports is still there, and we still can't fully move to ES modules
335
+ // because Jest and other tools. Also such aliases easily break E2E tests
336
+ // with Jest (with our setup), that's why they are avoided when NODE_ENV
337
+ // is test (but it might be not the solution that always helps).
338
+ //
339
+ // NOTE: The "conditionNames" workaround below messes up the loading of
340
+ // Babel's runtime helper for require of CJS and ES styles of modules
341
+ // (without this alias it is resolved to
342
+ // @babel/runtime/helpers/esm/interopRequireDefault, which has
343
+ // the hepler function attached to "default" export).
344
+ if (process.env.NODE_ENV !== 'test') {
345
+ const aliases = (_c = res.resolve) === null || _c === void 0 ? void 0 : _c.alias;
346
+ aliases['@babel/runtime/helpers/defineProperty']
347
+ = node_path_1.default.resolve(o.context, 'node_modules/@babel/runtime/helpers/defineProperty');
348
+ aliases['@babel/runtime/helpers/interopRequireDefault']
349
+ = node_path_1.default.resolve(o.context, 'node_modules/@babel/runtime/helpers/interopRequireDefault');
350
+ }
351
+ return res;
336
352
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.43.27",
2
+ "version": "1.43.29",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -11,12 +11,12 @@
11
11
  "@babel/runtime": "^7.27.4",
12
12
  "@dr.pogodin/babel-plugin-react-css-modules": "^6.13.6",
13
13
  "@dr.pogodin/csurf": "^1.16.5",
14
- "@dr.pogodin/js-utils": "^0.1.1",
14
+ "@dr.pogodin/js-utils": "^0.1.3",
15
15
  "@dr.pogodin/react-global-state": "^0.19.3",
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",
@@ -55,7 +55,7 @@
55
55
  "@babel/preset-typescript": "^7.27.1",
56
56
  "@babel/register": "^7.27.1",
57
57
  "@dr.pogodin/babel-plugin-transform-assets": "^1.2.5",
58
- "@dr.pogodin/babel-preset-svgr": "^1.9.1",
58
+ "@dr.pogodin/babel-preset-svgr": "^1.9.2",
59
59
  "@dr.pogodin/eslint-configs": "^0.0.9",
60
60
  "@pmmmwh/react-refresh-webpack-plugin": "^0.6.1",
61
61
  "@testing-library/dom": "^10.4.0",
@@ -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; }