react-responsive-tools 2.1.5 → 2.2.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.
- package/README.MD +8 -0
- package/dist/index.js +4 -0
- package/package.json +16 -11
- package/reinit.sh +25 -19
- package/src/{breakpoints.config.mjs → breakpoints.config.ts} +3 -3
- package/src/components/horizontal.tsx +3 -1
- package/src/functions/getBreakpoint.ts +1 -1
- package/src/hooks/useVBreakpoint.ts +1 -1
- package/src/index.scss +4 -0
- package/src/scripts/generateCustomBreakpointsSCSS.mjs +1 -1
- package/src/scripts/generateSCSS.mjs +1 -1
- package/src/scripts/generateTBreakpoint.mjs +1 -1
- package/declarations.d.ts +0 -5
- package/index.scss +0 -4
- package/index.ts +0 -1
- package/reset.scss +0 -99
- package/src/breakpoints.config.d.ts +0 -4
- package/src/hooks/useBreakpoint.test.ts +0 -56
- package/src/scss/index.scss +0 -5
- /package/src/scripts/{copyDefaultConfig.js → copyDefaultConfig.mjs} +0 -0
package/README.MD
CHANGED
@@ -8,6 +8,14 @@ The package is based on [react-responsive](https://www.npmjs.com/package/react-r
|
|
8
8
|
|
9
9
|
To install the project, run the following command:
|
10
10
|
|
11
|
+
### Установка
|
12
|
+
|
13
|
+
Пожалуйста, убедитесь, что вы установили следующие зависимости:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
yarn add react-responsive
|
17
|
+
```
|
18
|
+
|
11
19
|
```sh
|
12
20
|
# Using Yarn
|
13
21
|
yarn add react-responsive-tools
|
package/dist/index.js
ADDED
package/package.json
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-responsive-tools",
|
3
|
-
"version": "2.1
|
3
|
+
"version": "2.2.1",
|
4
4
|
"description": "",
|
5
|
-
"main": "index.js",
|
6
|
-
"module": "index.js",
|
7
|
-
"types": "index.d.ts",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"module": "dist/index.js",
|
7
|
+
"types": "dist/index.d.ts",
|
8
8
|
"type": "module",
|
9
9
|
"scripts": {
|
10
10
|
"dev": "webpack --mode development --watch",
|
11
|
+
"start": "webpack serve --config webpack.config.js --env development=true",
|
11
12
|
"tsc": "tsc",
|
12
13
|
"test": "jest",
|
13
14
|
"lint": "eslint \"{**/*,*}.{js,ts,jsx,tsx}\"",
|
@@ -18,11 +19,7 @@
|
|
18
19
|
},
|
19
20
|
"files": [
|
20
21
|
"src",
|
21
|
-
"
|
22
|
-
"*.scss",
|
23
|
-
"index.js",
|
24
|
-
"reinit.sh",
|
25
|
-
"index.d.ts"
|
22
|
+
"reinit.sh"
|
26
23
|
],
|
27
24
|
"keywords": [
|
28
25
|
"react",
|
@@ -33,6 +30,8 @@
|
|
33
30
|
"author": "westprophet",
|
34
31
|
"license": "ISC",
|
35
32
|
"peerDependencies": {
|
33
|
+
"react": "^18.3.1",
|
34
|
+
"react-dom": "^18.3.1",
|
36
35
|
"react-responsive": "^10.0.0"
|
37
36
|
},
|
38
37
|
"devDependencies": {
|
@@ -45,8 +44,8 @@
|
|
45
44
|
"@types/jest": "^29.5.12",
|
46
45
|
"@types/node": "^22.5.4",
|
47
46
|
"@types/react-dom": "^18.3.0",
|
48
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
49
|
-
"@typescript-eslint/parser": "^8.
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.5.0",
|
48
|
+
"@typescript-eslint/parser": "^8.5.0",
|
50
49
|
"babel-loader": "^9.1.3",
|
51
50
|
"copy-webpack-plugin": "^12.0.2",
|
52
51
|
"css-loader": "^7.1.2",
|
@@ -56,10 +55,13 @@
|
|
56
55
|
"eslint-import-resolver-typescript": "^3.6.3",
|
57
56
|
"eslint-plugin-import": "^2.30.0",
|
58
57
|
"eslint-plugin-jsx-a11y": "^6.10.0",
|
58
|
+
"eslint-plugin-react": "^7.35.2",
|
59
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
59
60
|
"eslint-webpack-plugin": "^4.2.0",
|
60
61
|
"file-loader": "^6.2.0",
|
61
62
|
"husky": "^9.1.5",
|
62
63
|
"jest": "^29.7.0",
|
64
|
+
"react": "^18.3.1",
|
63
65
|
"react-dom": "^18.3.1",
|
64
66
|
"react-test-renderer": "^18.3.1",
|
65
67
|
"sass": "^1.78.0",
|
@@ -74,5 +76,8 @@
|
|
74
76
|
},
|
75
77
|
"bin": {
|
76
78
|
"react-responsive-tools": "bin/react-responsive-tools.mjs"
|
79
|
+
},
|
80
|
+
"dependencies": {
|
81
|
+
"react-responsive": "^10.0.0"
|
77
82
|
}
|
78
83
|
}
|
package/reinit.sh
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
#
|
4
|
-
|
5
|
-
|
3
|
+
# Путь до каталога dist
|
4
|
+
DIST_DIR="./dist"
|
5
|
+
SCRIPT_DIR="$DIST_DIR/scripts"
|
6
|
+
|
7
|
+
# Проверка наличия каталога dist/scripts
|
8
|
+
if [ ! -d "$SCRIPT_DIR" ]; then
|
9
|
+
echo "Scripts directory $SCRIPT_DIR does not exist."
|
10
|
+
exit 1
|
11
|
+
fi
|
6
12
|
|
7
|
-
# Запуск createConfig.mjs из
|
13
|
+
# Запуск createConfig.mjs из dist/scripts
|
8
14
|
echo "Running createConfig.mjs from package..."
|
9
|
-
node "$
|
15
|
+
node "$SCRIPT_DIR/createConfig.mjs"
|
10
16
|
|
11
17
|
if [ $? -ne 0 ]; then
|
12
|
-
echo "Error occurred while running createConfig.mjs"
|
13
|
-
exit 1
|
18
|
+
echo "Error occurred while running createConfig.mjs"
|
19
|
+
exit 1
|
14
20
|
fi
|
15
21
|
|
16
|
-
# Запуск generateCustomBreakpointsSCSS.mjs из
|
22
|
+
# Запуск generateCustomBreakpointsSCSS.mjs из dist/scripts
|
17
23
|
echo "Running generateCustomBreakpointsSCSS.mjs from package..."
|
18
|
-
node "$
|
24
|
+
node "$SCRIPT_DIR/generateCustomBreakpointsSCSS.mjs"
|
19
25
|
|
20
26
|
if [ $? -ne 0 ]; then
|
21
|
-
echo "Error occurred while running generateCustomBreakpointsSCSS.mjs"
|
22
|
-
exit 1
|
27
|
+
echo "Error occurred while running generateCustomBreakpointsSCSS.mjs"
|
28
|
+
exit 1
|
23
29
|
fi
|
24
30
|
|
25
|
-
# Запуск generateSCSS.mjs из
|
31
|
+
# Запуск generateSCSS.mjs из dist/scripts
|
26
32
|
echo "Running generateSCSS.mjs from package..."
|
27
|
-
node "$
|
33
|
+
node "$SCRIPT_DIR/generateSCSS.mjs"
|
28
34
|
|
29
35
|
if [ $? -ne 0 ]; then
|
30
|
-
echo "Error occurred while running generateSCSS.mjs"
|
31
|
-
exit 1
|
36
|
+
echo "Error occurred while running generateSCSS.mjs"
|
37
|
+
exit 1
|
32
38
|
fi
|
33
39
|
|
34
|
-
# Запуск generateTBreakpoint.mjs из
|
40
|
+
# Запуск generateTBreakpoint.mjs из dist/scripts
|
35
41
|
echo "Running generateTBreakpoint.mjs from package..."
|
36
|
-
node "$
|
42
|
+
node "$SCRIPT_DIR/generateTBreakpoint.mjs"
|
37
43
|
|
38
44
|
if [ $? -ne 0 ]; then
|
39
|
-
echo "Error occurred while running generateTBreakpoint.mjs"
|
40
|
-
exit 1
|
45
|
+
echo "Error occurred while running generateTBreakpoint.mjs"
|
46
|
+
exit 1
|
41
47
|
fi
|
42
48
|
|
43
49
|
echo "All scripts have been executed successfully."
|
@@ -1,6 +1,6 @@
|
|
1
|
+
// src/breakpoints.config.ts
|
1
2
|
|
2
|
-
|
3
|
-
const HORIZONTAL_BREAKPOINTS = {
|
3
|
+
const HORIZONTAL_BREAKPOINTS: Record<string, string> = {
|
4
4
|
"xs": "320px",
|
5
5
|
"sm": "576px",
|
6
6
|
"md": "768px",
|
@@ -13,7 +13,7 @@ const HORIZONTAL_BREAKPOINTS = {
|
|
13
13
|
"qxl": "3840px"
|
14
14
|
};
|
15
15
|
|
16
|
-
const VERTICAL_BREAKPOINTS = {
|
16
|
+
const VERTICAL_BREAKPOINTS: Record<string, string> = {
|
17
17
|
"xs": "600px",
|
18
18
|
"sm": "800px",
|
19
19
|
"md": "1000px",
|
@@ -2,11 +2,13 @@
|
|
2
2
|
* Created by westp on 15.05.2023
|
3
3
|
*/
|
4
4
|
|
5
|
+
import React from "react";
|
6
|
+
|
5
7
|
import { TBreakpoint } from '../interfaces/TBreakpoint';
|
6
8
|
import { useBreakpointDF, useBreakpointMF } from '../hooks/useBreakpoint';
|
7
9
|
|
8
10
|
interface Props {
|
9
|
-
children:
|
11
|
+
children: React.ReactNode;
|
10
12
|
}
|
11
13
|
|
12
14
|
interface ForComponentProps extends Props {
|
@@ -3,7 +3,7 @@ import { useMediaQuery } from 'react-responsive';
|
|
3
3
|
import { TVerticalBreakpoint } from '../interfaces/TBreakpoint';
|
4
4
|
import { TAdaptiveVariant } from '../interfaces/TAdaptiveVariant';
|
5
5
|
import useVariant from './useVariant';
|
6
|
-
import
|
6
|
+
import {getVBreakpoint} from "../functions/getBreakpoint";
|
7
7
|
|
8
8
|
export default function useVBreakpoint(b: TVerticalBreakpoint | number, variant: TAdaptiveVariant = 'MtF') {
|
9
9
|
const _bp = typeof b === 'number' ? b + 'px' : getVBreakpoint(b);
|
package/src/index.scss
ADDED
@@ -2,7 +2,7 @@
|
|
2
2
|
import fs from 'fs';
|
3
3
|
import path from 'path';
|
4
4
|
import { fileURLToPath } from 'url'; // Импортируем необходимую функцию из 'url'
|
5
|
-
import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.
|
5
|
+
import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.ts';
|
6
6
|
|
7
7
|
// Определение __filename и __dirname
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import fs from 'fs';
|
3
3
|
import path from 'path';
|
4
4
|
import { fileURLToPath } from 'url';
|
5
|
-
import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.
|
5
|
+
import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.ts';
|
6
6
|
|
7
7
|
// Определение __filename и __dirname
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import fs from 'fs';
|
3
3
|
import path from 'path';
|
4
4
|
import { fileURLToPath } from 'url';
|
5
|
-
import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.
|
5
|
+
import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.ts';
|
6
6
|
|
7
7
|
// Определение __filename и __dirname
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
package/declarations.d.ts
DELETED
package/index.scss
DELETED
package/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './src'
|
package/reset.scss
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
/***
|
2
|
-
The new CSS reset - version 1.8.4 (last updated 14.2.2023)
|
3
|
-
GitHub page: https://github.com/elad2412/the-new-css-reset
|
4
|
-
***/
|
5
|
-
|
6
|
-
/*
|
7
|
-
Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property
|
8
|
-
- The "symbol *" part is to solve Firefox SVG sprite bug
|
9
|
-
*/
|
10
|
-
*:where(:not(html, iframe, canvas, img, svg, video, audio):not(svg *, symbol *)) {
|
11
|
-
all: unset;
|
12
|
-
display: revert;
|
13
|
-
}
|
14
|
-
|
15
|
-
/* Preferred box-sizing value */
|
16
|
-
*,
|
17
|
-
*::before,
|
18
|
-
*::after {
|
19
|
-
box-sizing: border-box;
|
20
|
-
}
|
21
|
-
|
22
|
-
/* Reapply the pointer cursor for anchor tags */
|
23
|
-
a, button {
|
24
|
-
cursor: revert;
|
25
|
-
}
|
26
|
-
|
27
|
-
/* Remove list styles (bullets/numbers) */
|
28
|
-
ol, ul, menu {
|
29
|
-
list-style: none;
|
30
|
-
}
|
31
|
-
|
32
|
-
/* For images to not be able to exceed their container */
|
33
|
-
img {
|
34
|
-
max-inline-size: 100%;
|
35
|
-
max-block-size: 100%;
|
36
|
-
}
|
37
|
-
|
38
|
-
/* removes spacing between cells in tables */
|
39
|
-
table {
|
40
|
-
border-collapse: collapse;
|
41
|
-
}
|
42
|
-
|
43
|
-
/* Safari - solving issue when using user-select:none on the <body> text input doesn't working */
|
44
|
-
input, textarea {
|
45
|
-
-webkit-user-select: auto;
|
46
|
-
}
|
47
|
-
|
48
|
-
/* revert the 'white-space' property for textarea elements on Safari */
|
49
|
-
textarea {
|
50
|
-
white-space: revert;
|
51
|
-
}
|
52
|
-
|
53
|
-
/* minimum style to allow to style meter element */
|
54
|
-
meter {
|
55
|
-
-webkit-appearance: revert;
|
56
|
-
appearance: revert;
|
57
|
-
}
|
58
|
-
|
59
|
-
/* preformatted text - use only for this feature */
|
60
|
-
:where(pre) {
|
61
|
-
all: revert;
|
62
|
-
}
|
63
|
-
|
64
|
-
/* reset default text opacity of input placeholder */
|
65
|
-
::placeholder {
|
66
|
-
color: unset;
|
67
|
-
}
|
68
|
-
|
69
|
-
/* remove default dot (•) sign */
|
70
|
-
::marker {
|
71
|
-
content: initial;
|
72
|
-
}
|
73
|
-
|
74
|
-
/* fix the feature of 'hidden' attribute.
|
75
|
-
display:revert; revert to element instead of attribute */
|
76
|
-
:where([hidden]) {
|
77
|
-
display: none;
|
78
|
-
}
|
79
|
-
|
80
|
-
/* revert for bug in Chromium browsers
|
81
|
-
- fix for the content editable attribute will work properly.
|
82
|
-
- webkit-user-select: auto; added for Safari in case of using user-select:none on wrapper element*/
|
83
|
-
:where([contenteditable]:not([contenteditable="false"])) {
|
84
|
-
-moz-user-modify: read-write;
|
85
|
-
-webkit-user-modify: read-write;
|
86
|
-
overflow-wrap: break-word;
|
87
|
-
-webkit-line-break: after-white-space;
|
88
|
-
-webkit-user-select: auto;
|
89
|
-
}
|
90
|
-
|
91
|
-
/* apply back the draggable feature - exist only in Chromium and Safari */
|
92
|
-
:where([draggable="true"]) {
|
93
|
-
-webkit-user-drag: element;
|
94
|
-
}
|
95
|
-
|
96
|
-
/* Revert Modal native behavior */
|
97
|
-
:where(dialog:modal) {
|
98
|
-
all: revert;
|
99
|
-
}
|
@@ -1,56 +0,0 @@
|
|
1
|
-
// src/hooks/__tests__/useBreakpoint.test.tsx
|
2
|
-
import { renderHook } from '@testing-library/react';
|
3
|
-
import useBreakpoint, { useBreakpointMF, useBreakpointDF } from './useBreakpoint';
|
4
|
-
import breakpoints from '../../scss/_horizontal.export.scss';
|
5
|
-
|
6
|
-
jest.mock('react-responsive', () => ({
|
7
|
-
useMediaQuery: jest.fn(),
|
8
|
-
}));
|
9
|
-
|
10
|
-
jest.mock('./useVariant', () => jest.fn(() => 'min'));
|
11
|
-
|
12
|
-
describe('useBreakpoint', () => {
|
13
|
-
it('should return true for the media query that matches the breakpoint', () => {
|
14
|
-
const mockedUseMediaQuery = require('react-responsive').useMediaQuery as jest.Mock;
|
15
|
-
mockedUseMediaQuery.mockReturnValue(true);
|
16
|
-
|
17
|
-
const { result } = renderHook(() => useBreakpoint('sm'));
|
18
|
-
|
19
|
-
expect(result.current).toBe(true);
|
20
|
-
expect(mockedUseMediaQuery).toHaveBeenCalledWith({ query: `(min-width: ${breakpoints.sm}px)` });
|
21
|
-
});
|
22
|
-
|
23
|
-
it('should return false for the media query that does not match the breakpoint', () => {
|
24
|
-
const mockedUseMediaQuery = require('react-responsive').useMediaQuery as jest.Mock;
|
25
|
-
mockedUseMediaQuery.mockReturnValue(false);
|
26
|
-
|
27
|
-
const { result } = renderHook(() => useBreakpoint('sm'));
|
28
|
-
|
29
|
-
expect(result.current).toBe(false);
|
30
|
-
expect(mockedUseMediaQuery).toHaveBeenCalledWith({ query: `(min-width: ${breakpoints.sm}px)` });
|
31
|
-
});
|
32
|
-
});
|
33
|
-
|
34
|
-
describe('useBreakpointMF', () => {
|
35
|
-
it('should return true for the `MtF` variant', () => {
|
36
|
-
const mockedUseMediaQuery = require('react-responsive').useMediaQuery as jest.Mock;
|
37
|
-
mockedUseMediaQuery.mockReturnValue(true);
|
38
|
-
|
39
|
-
const { result } = renderHook(() => useBreakpointMF('md'));
|
40
|
-
|
41
|
-
expect(result.current).toBe(true);
|
42
|
-
expect(mockedUseMediaQuery).toHaveBeenCalledWith({ query: `(min-width: ${breakpoints.md}px)` });
|
43
|
-
});
|
44
|
-
});
|
45
|
-
|
46
|
-
describe('useBreakpointDF', () => {
|
47
|
-
it('should return true for the `DtF` variant', () => {
|
48
|
-
const mockedUseMediaQuery = require('react-responsive').useMediaQuery as jest.Mock;
|
49
|
-
mockedUseMediaQuery.mockReturnValue(true);
|
50
|
-
|
51
|
-
const { result } = renderHook(() => useBreakpointDF('lg'));
|
52
|
-
|
53
|
-
expect(result.current).toBe(true);
|
54
|
-
expect(mockedUseMediaQuery).toHaveBeenCalledWith({ query: `(min-width: ${breakpoints.lg}px)` });
|
55
|
-
});
|
56
|
-
});
|
package/src/scss/index.scss
DELETED
File without changes
|