@pedidopago/ui 1.5.1 → 1.5.2

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,3 @@
1
- import { ReactNode } from 'react';
2
1
  declare type BreakpointsConfig = {
3
2
  base: number;
4
3
  sm: number;
@@ -8,8 +7,8 @@ declare type BreakpointsConfig = {
8
7
  xxl: number;
9
8
  };
10
9
  declare type BreakpointName = 'base' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
11
- declare type BreakpointValue = {
12
- [key in BreakpointName]?: ReactNode | string | number | undefined;
10
+ declare type BreakpointValue<T> = {
11
+ [key in BreakpointName]?: T;
13
12
  };
14
13
  /**
15
14
  * It returns a function that takes a breakpoint value object and returns the value
@@ -20,7 +19,7 @@ declare type BreakpointValue = {
20
19
  * @example const flexDirection = breapointPicker({ sm: 'column', lg: 'row' });
21
20
  */
22
21
  export declare const useBreakpoints: (breakpointsConfig?: BreakpointsConfig | undefined) => {
23
- breakpointPicker: (breakpointValues: BreakpointValue) => ReactNode;
22
+ breakpointPicker: <T = string>(breakpointValues: BreakpointValue<T>) => T | undefined;
24
23
  };
25
24
  export {};
26
25
  //# sourceMappingURL=useBreakpoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBreakpoints.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useBreakpoints.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAGvD,aAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,aAAK,cAAc,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAEjE,aAAK,eAAe,GAAG;KAEpB,GAAG,IAAI,cAAc,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS;CAClE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;yCAcmB,eAAe;CAkF5D,CAAC"}
1
+ {"version":3,"file":"useBreakpoints.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useBreakpoints.tsx"],"names":[],"mappings":"AAGA,aAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,aAAK,cAAc,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAEjE,aAAK,eAAe,CAAC,CAAC,IAAI;KAEvB,GAAG,IAAI,cAAc,CAAC,CAAC,EAAE,CAAC;CAC5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;CAoG1B,CAAC"}
@@ -36,7 +36,7 @@ var useBreakpoints = function useBreakpoints(breakpointsConfig) {
36
36
  setBreakpoint = _useState2[1];
37
37
 
38
38
  var defaultBreakpoints = {
39
- base: 0,
39
+ base: 1,
40
40
  sm: 480,
41
41
  md: 768,
42
42
  lg: 1024,
@@ -56,27 +56,27 @@ var useBreakpoints = function useBreakpoints(breakpointsConfig) {
56
56
  function currentBreakpointWidth(windowSize, breakpoints) {
57
57
  var response;
58
58
 
59
- if (breakpoints.base < windowSize.width) {
59
+ if (breakpoints.base <= windowSize.width) {
60
60
  response = breakpoints.base;
61
61
  }
62
62
 
63
- if (breakpoints.sm < windowSize.width) {
63
+ if (breakpoints.sm <= windowSize.width) {
64
64
  response = breakpoints.sm;
65
65
  }
66
66
 
67
- if (breakpoints.md < windowSize.width) {
67
+ if (breakpoints.md <= windowSize.width) {
68
68
  response = breakpoints.md;
69
69
  }
70
70
 
71
- if (breakpoints.lg < windowSize.width) {
71
+ if (breakpoints.lg <= windowSize.width) {
72
72
  response = breakpoints.lg;
73
73
  }
74
74
 
75
- if (breakpoints.xl < windowSize.width) {
75
+ if (breakpoints.xl <= windowSize.width) {
76
76
  response = breakpoints.xl;
77
77
  }
78
78
 
79
- if (breakpoints.xxl < windowSize.width) {
79
+ if (breakpoints.xxl <= windowSize.width) {
80
80
  response = breakpoints.xxl;
81
81
  }
82
82
 
@@ -1,2 +1,2 @@
1
- export declare const useDisableBodyScroll: (disable: boolean, type?: 'modal' | 'child_element') => void;
1
+ export declare const useDisableBodyScroll: (isDisabled: boolean, type?: 'modal' | 'child_element', noScrollbarPadding?: boolean) => void;
2
2
  //# sourceMappingURL=useDisableBodyScroll.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDisableBodyScroll.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useDisableBodyScroll.tsx"],"names":[],"mappings":"AAoCA,eAAO,MAAM,oBAAoB,YACtB,OAAO,SACV,OAAO,GAAG,eAAe,SAehC,CAAC"}
1
+ {"version":3,"file":"useDisableBodyScroll.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useDisableBodyScroll.tsx"],"names":[],"mappings":"AA4CA,eAAO,MAAM,oBAAoB,eACnB,OAAO,SACb,OAAO,GAAG,eAAe,uCAgBhC,CAAC"}
@@ -7,10 +7,15 @@ exports.useDisableBodyScroll = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- function disableBodyOverflow() {
11
- var scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
12
- document.body.style.paddingRight = "".concat(scrollBarWidth, "px");
13
- document.body.style.overflow = 'hidden';
10
+ function disableBodyOverflow(noScrollbarPadding) {
11
+ if (noScrollbarPadding) {
12
+ document.body.style.paddingRight = "0px";
13
+ document.body.style.overflow = 'hidden';
14
+ } else {
15
+ var scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
16
+ document.body.style.paddingRight = "".concat(scrollBarWidth, "px");
17
+ document.body.style.overflow = 'hidden';
18
+ }
14
19
  }
15
20
 
16
21
  function enableBodyOverflow() {
@@ -18,45 +23,44 @@ function enableBodyOverflow() {
18
23
  document.body.style.paddingRight = '';
19
24
  }
20
25
 
21
- function setBodyOverflow(disable, type) {
22
- // disable body scroll when type modal:
23
- if (disable && type === 'modal') {
26
+ function setBodyOverflow(isDisabled, type, noScrollbarPadding) {
27
+ // isDisabled body scroll when type modal:
28
+ if (isDisabled && type === 'modal') {
24
29
  document.body.setAttribute('data-modal-open', 'true');
25
- return disableBodyOverflow();
30
+ return disableBodyOverflow(noScrollbarPadding);
26
31
  } // enable body scroll when type modal:
27
32
 
28
33
 
29
- if (!disable && type === 'modal') {
34
+ if (!isDisabled && type === 'modal') {
30
35
  document.body.setAttribute('data-modal-open', 'false');
31
36
  return enableBodyOverflow();
32
- } // disable body scroll when type child_element:
37
+ } // isDisabled body scroll when type child_element:
33
38
 
34
39
 
35
- if (disable && type === 'child_element') {
36
- if (document.body.getAttribute('data-modal-open') === 'true') return;
37
- return disableBodyOverflow();
40
+ if (isDisabled && type === 'child_element') {
41
+ if (document.body.getAttribute('data-modal-open') === 'false') return disableBodyOverflow(noScrollbarPadding);
38
42
  } // enable body scroll when type child_element:
39
43
 
40
44
 
41
- if (!disable && type === 'child_element') {
42
- if (document.body.getAttribute('data-modal-open') === 'true') return;
43
- return enableBodyOverflow();
45
+ if (!isDisabled && type === 'child_element') {
46
+ if (document.body.getAttribute('data-modal-open') === 'false') return enableBodyOverflow();
44
47
  }
45
48
  }
46
49
 
47
- var useDisableBodyScroll = function useDisableBodyScroll(disable) {
50
+ var useDisableBodyScroll = function useDisableBodyScroll(isDisabled) {
48
51
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'child_element';
52
+ var noScrollbarPadding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
49
53
  (0, _react.useEffect)(function () {
50
- setBodyOverflow(disable, type);
54
+ setBodyOverflow(isDisabled, type, noScrollbarPadding);
51
55
  document.body.addEventListener('data-modal-open', function () {
52
- setBodyOverflow(disable, type);
56
+ setBodyOverflow(isDisabled, type, noScrollbarPadding);
53
57
  });
54
58
  return function () {
55
59
  document.body.removeEventListener('data-modal-open', function () {
56
- setBodyOverflow(disable, type);
60
+ setBodyOverflow(isDisabled, type, noScrollbarPadding);
57
61
  });
58
62
  };
59
- }, [disable, type]);
63
+ }, [isDisabled, type, noScrollbarPadding]);
60
64
  };
61
65
 
62
66
  exports.useDisableBodyScroll = useDisableBodyScroll;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pedidopago/ui",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Quick build beatiful Pedido Pago apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",