@pedidopago/ui 1.13.52 → 1.13.53-beta.0
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/dist/shared/hooks/useBreakpoints.d.ts +14 -7
- package/dist/shared/hooks/useBreakpoints.d.ts.map +1 -1
- package/dist/shared/hooks/useBreakpoints.js +2 -2
- package/dist/shared/hooks/useWindowSize.d.ts +8 -3
- package/dist/shared/hooks/useWindowSize.d.ts.map +1 -1
- package/dist/shared/hooks/useWindowSize.js +1 -1
- package/dist/utils/breakpoints.d.ts +2 -2
- package/dist/utils/breakpoints.d.ts.map +1 -1
- package/dist/utils/breakpoints.js +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type BreakpointsConfig = {
|
|
2
|
+
base: number;
|
|
3
|
+
sm: number;
|
|
4
|
+
md: number;
|
|
5
|
+
lg: number;
|
|
6
|
+
xl: number;
|
|
7
|
+
xxl: number;
|
|
5
8
|
};
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
export type BreakpointName = 'base' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
10
|
+
export type BreakpointValue<T> = {
|
|
11
|
+
[Key in BreakpointName]?: T;
|
|
12
|
+
};
|
|
13
|
+
export declare function useBreakpoints(breakpointsConfig?: BreakpointsConfig): {
|
|
14
|
+
breakpoint: BreakpointName;
|
|
15
|
+
breakpointPicker: <T>(breakpointValues: BreakpointValue<T>) => T | undefined;
|
|
9
16
|
};
|
|
10
17
|
export {};
|
|
11
18
|
//# sourceMappingURL=useBreakpoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoints.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useBreakpoints.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBreakpoints.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useBreakpoints.tsx"],"names":[],"mappings":"AAGA,KAAK,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,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAExE,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;KAE9B,GAAG,IAAI,cAAc,CAAC,CAAC,EAAE,CAAC;CAC5B,CAAC;AAoBF,wBAAgB,cAAc,CAAC,iBAAiB,CAAC,EAAE,iBAAiB;;;EA+CnE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBreakpoints=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBreakpoints=useBreakpoints;var _react=require("react"),_breakpoints=require("../../utils/breakpoints");function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}/**
|
|
2
2
|
* It returns a function that takes a breakpoint value object and returns the value
|
|
3
3
|
* of the closest breakpoint to the current window size
|
|
4
4
|
* @param {BreakpointsConfig} [breakpointsConfig] - This is an optional parameter
|
|
5
5
|
* that allows you to pass in your own breakpoints.
|
|
6
6
|
* @returns a `breakpointPicker` function, which receives an object with breakpoint keys and values.
|
|
7
7
|
* @example const flexDirection = breapointPicker({ sm: 'column', lg: 'row' });
|
|
8
|
-
*/var defaultBreakpoints={base:1,sm:480,md:768,lg:1024,xl:1280,xxl:1600}
|
|
8
|
+
*/var defaultBreakpoints={base:1,sm:480,md:768,lg:1024,xl:1280,xxl:1600};function useBreakpoints(breakpointsConfig){var breakpoints=breakpointsConfig||defaultBreakpoints,isClientSide="undefined"!=typeof window,useIsomorphicLayoutEffect=isClientSide?_react.useLayoutEffect:_react.useEffect,_useState=(0,_react.useState)(function(){return isClientSide?(0,_breakpoints.getCurrentBreakpoint)(breakpoints):"base"}),_useState2=_slicedToArray(_useState,2),breakpoint=_useState2[0],setBreakpoint=_useState2[1],breakpointPicker=(0,_react.useCallback)(function(breakpointValues){for(var key,breakpointEntries=Object.entries(breakpoints).sort(function(a,b){return a[1]-b[1]}),sortedBreakpointNames=breakpointEntries.map(function(_ref){var _ref2=_slicedToArray(_ref,1),key=_ref2[0];return key}),activeIndex=sortedBreakpointNames.indexOf(breakpoint),i=activeIndex;0<=i;i--)if(key=sortedBreakpointNames[i],void 0!==breakpointValues[key])return breakpointValues[key]},[breakpoint]);return useIsomorphicLayoutEffect(function(){function handleResize(){var activeBreakpoint=(0,_breakpoints.getCurrentBreakpoint)(breakpoints);setBreakpoint(activeBreakpoint)}return window.addEventListener("resize",handleResize),function(){return window.removeEventListener("resize",handleResize)}},[breakpoints]),{breakpoint:breakpoint,breakpointPicker:breakpointPicker}}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export type WindowSize = {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function useWindowSize(): {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
4
9
|
//# sourceMappingURL=useWindowSize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowSize.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useWindowSize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWindowSize.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useWindowSize.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,aAAa;WACe,MAAM;YAAU,MAAM;EAuBjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useWindowSize=useWindowSize;
|
|
1
|
+
"use strict";var _react=require("react");Object.defineProperty(exports,"__esModule",{value:!0}),exports.useWindowSize=useWindowSize;function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function useWindowSize(){function onWindowResize(){setSize({width:window.innerWidth,height:window.innerHeight})}var _useState=(0,_react.useState)({width:0,height:0}),_useState2=_slicedToArray(_useState,2),size=_useState2[0],setSize=_useState2[1];return(0,_react.useEffect)(function(){return onWindowResize(),window.addEventListener("resize",onWindowResize),function(){window.removeEventListener("resize",onWindowResize)}},[]),size}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { BreakpointName } from '../shared/hooks/useBreakpoints';
|
|
1
2
|
import { BreakpointsConfig } from '../shared/types/breakpoints';
|
|
2
|
-
|
|
3
|
-
export declare function currentBreakpointWidth(windowSize: WindowSize, breakpoints: BreakpointsConfig): number | undefined;
|
|
3
|
+
export declare function getCurrentBreakpoint(breakpoints: BreakpointsConfig): BreakpointName;
|
|
4
4
|
//# sourceMappingURL=breakpoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../src/utils/breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../src/utils/breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,iBAAiB,GAAG,cAAc,CAenF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getCurrentBreakpoint=getCurrentBreakpoint;function getCurrentBreakpoint(breakpoints){if("undefined"==typeof window)return"base";var width=window.innerWidth,activeBreakpoint="base";return width>=breakpoints.base&&(activeBreakpoint="base"),width>=breakpoints.sm&&(activeBreakpoint="sm"),width>=breakpoints.md&&(activeBreakpoint="md"),width>=breakpoints.lg&&(activeBreakpoint="lg"),width>=breakpoints.xl&&(activeBreakpoint="xl"),width>=breakpoints.xxl&&(activeBreakpoint="xxl"),activeBreakpoint}
|