react-responsive-tools 2.6.2 → 2.6.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.
@@ -15,7 +15,7 @@
15
15
  * which causes an overlap. By shifting one of them by 1px we guarantee
16
16
  * that a given pixel belongs to only one range.
17
17
  */
18
- export const PREFERRED_VARIANT = 'MtF'; // DESKTOP_TO_FIRST
18
+ export const PREFERRED_VARIANT = 'MtF'; // Mobile to first
19
19
  const HORIZONTAL_BREAKPOINTS = {
20
20
  "xs": 320,
21
21
  "sm": 576,
@@ -1,5 +1,5 @@
1
1
  // breakpointConfig.js
2
- const PREFERRED_VARIANT = 'MtF'; // DESKTOP_TO_FIRST
2
+ const PREFERRED_VARIANT = 'MtF'; // Mobile to first
3
3
  const HORIZONTAL_BREAKPOINTS = {
4
4
  "xs": 320,
5
5
  "sm": 576,
@@ -24,8 +24,12 @@ import { PREFERRED_VARIANT, HORIZONTAL_BREAKPOINTS } from '../breakpoints.config
24
24
  export function useBreakpoint(b, variant = PREFERRED_VARIANT) {
25
25
  let _bp = typeof b === 'number' ? b : HORIZONTAL_BREAKPOINTS[b];
26
26
  const v = variant === 'MtF' ? 'min' : 'max';
27
- if (variant !== PREFERRED_VARIANT)
27
+ if ('DtF' === variant && PREFERRED_VARIANT === 'MtF') {
28
28
  _bp = _bp - 1;
29
+ }
30
+ else if ('MtF' === variant && PREFERRED_VARIANT === 'DtF') {
31
+ _bp = _bp + 1;
32
+ }
29
33
  return useMediaQuery({ query: `(${v}-width: ${_bp}px)` });
30
34
  }
31
35
  /**
@@ -64,7 +68,7 @@ export function useBreakpointBetween(min, max, preferredVariant = PREFERRED_VARI
64
68
  _max = _max - 1;
65
69
  break;
66
70
  case 'DtF':
67
- _min = _min - 1;
71
+ _min = _min + 1;
68
72
  break;
69
73
  }
70
74
  return useMediaQuery({ minWidth: _min, maxWidth: _max });
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { TBreakpoint, TVerticalBreakpoint } from './interfaces/TBreakpoint';
2
2
  import { TBreakpoints, TVerticalBreakpoints } from './interfaces/TBreakpoints';
3
+ import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from './breakpoints.config';
3
4
  import { useBreakpointBetween, useBreakpoint } from './hooks/useBreakpoint.js';
4
5
  import { useVBreakpoint } from './hooks/useVBreakpoint.js';
5
6
  export type { TBreakpoints, TBreakpoint, TVerticalBreakpoint, TVerticalBreakpoints, };
6
- export { useBreakpointBetween, useBreakpoint, useVBreakpoint, };
7
+ export { useBreakpointBetween, useBreakpoint, useVBreakpoint, VERTICAL_BREAKPOINTS, HORIZONTAL_BREAKPOINTS, };
7
8
  export * from './components/horizontal.js';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
+ import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from './breakpoints.config';
1
2
  import { useBreakpointBetween, useBreakpoint } from './hooks/useBreakpoint.js';
2
3
  import { useVBreakpoint } from './hooks/useVBreakpoint.js';
3
- export { useBreakpointBetween, useBreakpoint, useVBreakpoint, };
4
+ export { useBreakpointBetween, useBreakpoint, useVBreakpoint, VERTICAL_BREAKPOINTS, HORIZONTAL_BREAKPOINTS, };
4
5
  export * from './components/horizontal.js';
@@ -1,3 +1,2 @@
1
- import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from "../breakpoints.config";
2
- export type TBreakpoint = keyof typeof HORIZONTAL_BREAKPOINTS;
3
- export type TVerticalBreakpoint = keyof typeof VERTICAL_BREAKPOINTS;
1
+ export type TBreakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'lt' | 'ltm' | 'ltl' | 'xl' | 'xxl' | 'qxl';
2
+ export type TVerticalBreakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
@@ -0,0 +1 @@
1
+ import e from"fs";import r from"path";import{fileURLToPath as t}from"url";import{HORIZONTAL_BREAKPOINTS as o,VERTICAL_BREAKPOINTS as n}from"../breakpoints.config.js";const i=t(import.meta.url),p=r.dirname(i),s=(e,r)=>`export type ${r} =\n${Object.keys(e).map((e=>` | '${e}'`)).join("\n")}\n`,a=`\n${s(o,"TBreakpoint")}\n\n${s(n,"TVerticalBreakpoint")}\n`;e.writeFileSync(r.resolve(p,"../interfaces/TBreakpoint.d.ts"),a.trim()),console.log("TBreakpoint.ts file has been generated successfully.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-responsive-tools",
3
- "version": "2.6.2",
3
+ "version": "2.6.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/reinit.sh CHANGED
@@ -47,8 +47,8 @@
47
47
  fi
48
48
 
49
49
  # Run generateTBreakpoint.mjs from dist/scripts
50
- # echo "Running generateTBreakpoint.mjs from package..."
51
- # node "$SCRIPT_DIR/generateTBreakpoint.mjs"
50
+ echo "Running generateTBreakpoint.mjs from package..."
51
+ node "$SCRIPT_DIR/generateTBreakpoint.mjs"
52
52
 
53
53
  if [ $? -ne 0 ]; then
54
54
  echo "Error occurred while running generateTBreakpoint.mjs"