@dr.pogodin/react-utils 1.38.0 → 1.38.1

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.
Files changed (31) hide show
  1. package/build/development/shared/components/Button/index.js +4 -0
  2. package/build/development/shared/components/Button/index.js.map +1 -1
  3. package/build/development/shared/components/Modal/index.js +4 -1
  4. package/build/development/shared/components/Modal/index.js.map +1 -1
  5. package/build/development/shared/components/selectors/NativeDropdown/index.js +2 -0
  6. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  7. package/build/development/shared/components/selectors/common.js.map +1 -1
  8. package/build/development/shared/utils/jest/index.js +3 -0
  9. package/build/development/shared/utils/jest/index.js.map +1 -1
  10. package/build/development/web.bundle.js +3 -3
  11. package/build/production/shared/components/Button/index.js +1 -1
  12. package/build/production/shared/components/Button/index.js.map +1 -1
  13. package/build/production/shared/components/Modal/index.js +2 -2
  14. package/build/production/shared/components/Modal/index.js.map +1 -1
  15. package/build/production/shared/components/selectors/NativeDropdown/index.js +2 -2
  16. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  17. package/build/production/shared/components/selectors/common.js.map +1 -1
  18. package/build/production/shared/utils/jest/index.js +1 -1
  19. package/build/production/shared/utils/jest/index.js.map +1 -1
  20. package/build/production/web.bundle.js +1 -1
  21. package/build/production/web.bundle.js.map +1 -1
  22. package/build/types-code/shared/components/Button/index.d.ts +1 -0
  23. package/build/types-code/shared/components/Modal/index.d.ts +4 -1
  24. package/build/types-code/shared/components/selectors/common.d.ts +1 -0
  25. package/build/types-code/shared/utils/jest/index.d.ts +1 -0
  26. package/package.json +3 -3
  27. package/src/shared/components/Button/index.tsx +5 -1
  28. package/src/shared/components/Modal/index.tsx +9 -2
  29. package/src/shared/components/selectors/NativeDropdown/index.tsx +2 -0
  30. package/src/shared/components/selectors/common.ts +1 -0
  31. package/src/shared/utils/jest/index.tsx +5 -0
@@ -9,6 +9,7 @@ type PropsT = {
9
9
  onMouseDown?: React.MouseEventHandler;
10
10
  openNewTab?: boolean;
11
11
  replace?: boolean;
12
+ testId?: string;
12
13
  theme: Theme<'active' | 'button' | 'disabled'>;
13
14
  to?: object | string;
14
15
  };
@@ -3,10 +3,13 @@ import { type Theme } from '@dr.pogodin/react-themes';
3
3
  type PropsT = {
4
4
  cancelOnScrolling?: boolean;
5
5
  children?: ReactNode;
6
- containerStyle?: React.CSSProperties;
7
6
  dontDisableScrolling?: boolean;
8
7
  onCancel?: () => void;
8
+ style?: React.CSSProperties;
9
+ testId?: string;
9
10
  theme: Theme<'container' | 'overlay'>;
11
+ /** @deprecated */
12
+ containerStyle?: React.CSSProperties;
10
13
  };
11
14
  /**
12
15
  * The `<Modal>` component implements a simple themeable modal window, wrapped
@@ -11,6 +11,7 @@ export type PropsT<NameT, OnChangeT = React.ChangeEventHandler<HTMLSelectElement
11
11
  label?: React.ReactNode;
12
12
  onChange?: OnChangeT;
13
13
  options?: Readonly<OptionsT<NameT>>;
14
+ testId?: string;
14
15
  theme: Theme<ThemeKeyT>;
15
16
  value?: ValueT;
16
17
  };
@@ -34,6 +34,7 @@ export declare function getMockUuid(seed?: number): string;
34
34
  export declare function mockTimer(time: number): Promise<void>;
35
35
  export type MountedSceneT = HTMLElement & {
36
36
  destroy: () => void;
37
+ snapshot: () => void;
37
38
  };
38
39
  /**
39
40
  * Mounts `scene` to the DOM, and returns the root scene element.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.38.0",
2
+ "version": "1.38.1",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -37,7 +37,7 @@
37
37
  "react-helmet": "^6.1.0",
38
38
  "react-router-dom": "^6.24.1",
39
39
  "request-ip": "^3.3.0",
40
- "rimraf": "^5.0.7",
40
+ "rimraf": "^5.0.8",
41
41
  "serialize-javascript": "^6.0.2",
42
42
  "serve-favicon": "^2.5.0",
43
43
  "source-map-support": "^0.5.21",
@@ -59,7 +59,7 @@
59
59
  "@dr.pogodin/babel-plugin-transform-assets": "^1.2.2",
60
60
  "@dr.pogodin/babel-preset-svgr": "^1.8.0",
61
61
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
62
- "@testing-library/dom": "^10.3.0",
62
+ "@testing-library/dom": "^10.3.1",
63
63
  "@testing-library/react": "^16.0.0",
64
64
  "@testing-library/user-event": "^14.5.2",
65
65
  "@tsconfig/recommended": "^1.0.7",
@@ -17,6 +17,7 @@ type PropsT = {
17
17
  onMouseDown?: React.MouseEventHandler;
18
18
  openNewTab?: boolean;
19
19
  replace?: boolean;
20
+ testId?: string;
20
21
  theme: Theme<'active' | 'button' | 'disabled'>;
21
22
  // TODO: It needs a more precise typing of the object option.
22
23
  to?: object | string;
@@ -32,6 +33,7 @@ export const BaseButton: React.FunctionComponent<PropsT> = ({
32
33
  onMouseDown,
33
34
  openNewTab,
34
35
  replace,
36
+ testId,
35
37
  theme,
36
38
  to,
37
39
  }) => {
@@ -40,7 +42,7 @@ export const BaseButton: React.FunctionComponent<PropsT> = ({
40
42
  if (disabled) {
41
43
  if (theme.disabled) className += ` ${theme.disabled}`;
42
44
  return (
43
- <div className={className}>
45
+ <div className={className} data-testid={testId}>
44
46
  {children}
45
47
  </div>
46
48
  );
@@ -49,6 +51,7 @@ export const BaseButton: React.FunctionComponent<PropsT> = ({
49
51
  return (
50
52
  <Link
51
53
  className={className}
54
+ data-testid={testId}
52
55
  enforceA={enforceA}
53
56
  onClick={onClick}
54
57
  onMouseDown={onMouseDown}
@@ -64,6 +67,7 @@ export const BaseButton: React.FunctionComponent<PropsT> = ({
64
67
  return (
65
68
  <div
66
69
  className={className}
70
+ data-testid={testId}
67
71
  onClick={onClick}
68
72
  onKeyDown={onClick && ((e) => {
69
73
  if (e.key === 'Enter') onClick(e);
@@ -17,10 +17,14 @@ import S from './styles.scss';
17
17
  type PropsT = {
18
18
  cancelOnScrolling?: boolean;
19
19
  children?: ReactNode;
20
- containerStyle?: React.CSSProperties;
21
20
  dontDisableScrolling?: boolean;
22
21
  onCancel?: () => void;
22
+ style?: React.CSSProperties;
23
+ testId?: string;
23
24
  theme: Theme<'container' | 'overlay'>;
25
+
26
+ /** @deprecated */
27
+ containerStyle?: React.CSSProperties;
24
28
  };
25
29
 
26
30
  /**
@@ -40,6 +44,8 @@ const BaseModal: React.FunctionComponent<PropsT> = ({
40
44
  containerStyle,
41
45
  dontDisableScrolling,
42
46
  onCancel,
47
+ style,
48
+ testId,
43
49
  theme,
44
50
  }) => {
45
51
  const containerRef = useRef<HTMLDivElement | null>(null);
@@ -141,11 +147,12 @@ const BaseModal: React.FunctionComponent<PropsT> = ({
141
147
  <div
142
148
  aria-modal="true"
143
149
  className={theme.container}
150
+ data-testid={testId}
144
151
  onClick={(e) => e.stopPropagation()}
145
152
  onWheel={(event) => event.stopPropagation()}
146
153
  ref={containerRef}
147
154
  role="dialog"
148
- style={containerStyle}
155
+ style={style ?? containerStyle}
149
156
  >
150
157
  {children}
151
158
  </div>
@@ -30,6 +30,7 @@ const Dropdown: React.FunctionComponent<PropsT<string>> = ({
30
30
  label,
31
31
  onChange,
32
32
  options,
33
+ testId,
33
34
  theme,
34
35
  value,
35
36
  }) => {
@@ -75,6 +76,7 @@ const Dropdown: React.FunctionComponent<PropsT<string>> = ({
75
76
  <div className={theme.dropdown}>
76
77
  <select
77
78
  className={selectClassName}
79
+ data-testid={testId}
78
80
  onChange={onChange}
79
81
  value={value}
80
82
  >
@@ -38,6 +38,7 @@ export type PropsT<
38
38
  label?: React.ReactNode;
39
39
  onChange?: OnChangeT;
40
40
  options?: Readonly<OptionsT<NameT>>;
41
+ testId?: string;
41
42
  theme: Theme<ThemeKeyT>;
42
43
  value?: ValueT;
43
44
  };
@@ -66,6 +66,7 @@ export async function mockTimer(time: number) {
66
66
 
67
67
  export type MountedSceneT = HTMLElement & {
68
68
  destroy: () => void;
69
+ snapshot: () => void;
69
70
  };
70
71
 
71
72
  /**
@@ -89,6 +90,10 @@ export function mount(scene: ReactNode): MountedSceneT {
89
90
  res.remove();
90
91
  };
91
92
 
93
+ res.snapshot = () => {
94
+ expect(res).toMatchSnapshot();
95
+ };
96
+
92
97
  // NOTE: As it seems @testing-library may reset this flag to false
93
98
  // when it is simulating user events.
94
99
  global.IS_REACT_ACT_ENVIRONMENT = true;