@shopgate/engage 7.27.3-alpha.6 → 7.27.3-alpha.8

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 (97) hide show
  1. package/components/ResponsiveContainer/breakpoints.js +2 -2
  2. package/components/View/components/Content/style.js +1 -1
  3. package/components/View/context.js +1 -1
  4. package/core/constants/index.js +1 -7
  5. package/core/contexts/ThemeResourcesContext.d.ts +1 -10
  6. package/core/contexts/ThemeResourcesContext.js +1 -1
  7. package/core/helpers/scrollContainer.js +2 -2
  8. package/core/hocs/withThemeResources.js +1 -4
  9. package/core/hooks/events/index.js +1 -1
  10. package/core/hooks/useThemeResources.js +5 -6
  11. package/core/providers/ThemeResourcesProvider.js +5 -9
  12. package/locations/subscriptions.js +2 -2
  13. package/package.json +7 -9
  14. package/page/components/index.js +1 -1
  15. package/page/constants/index.js +1 -5
  16. package/page/index.js +2 -1
  17. package/page/selectors/index.js +2 -48
  18. package/product/components/index.js +1 -1
  19. package/styles/helpers/index.js +1 -1
  20. package/styles/helpers/setPageBackgroundColor.js +2 -2
  21. package/styles/index.js +1 -1
  22. package/tracking/selectors/cookieConsent.js +2 -2
  23. package/core/hooks/events/usePressHandler.js +0 -38
  24. package/page/action-creators/index.js +0 -22
  25. package/page/components/Widgets/Overlay.js +0 -51
  26. package/page/components/Widgets/Tooltip.js +0 -22
  27. package/page/components/Widgets/Widget.js +0 -15
  28. package/page/components/Widgets/WidgetContext.d.ts +0 -42
  29. package/page/components/Widgets/WidgetContext.js +0 -9
  30. package/page/components/Widgets/WidgetProvider.js +0 -8
  31. package/page/components/Widgets/Widgets.js +0 -11
  32. package/page/components/Widgets/WidgetsPreviewContext.js +0 -9
  33. package/page/components/Widgets/WidgetsPreviewProvider.js +0 -8
  34. package/page/components/Widgets/constants.js +0 -4
  35. package/page/components/Widgets/events.js +0 -23
  36. package/page/components/Widgets/helpers.js +0 -23
  37. package/page/components/Widgets/hooks.js +0 -69
  38. package/page/components/Widgets/index.js +0 -1
  39. package/page/components/Widgets/types.d.ts +0 -127
  40. package/page/constants/actionTypes.js +0 -1
  41. package/page/hooks/index.d.ts +0 -60
  42. package/page/hooks/index.js +0 -25
  43. package/page/reducers/index.js +0 -6
  44. package/page/subscriptions/index.js +0 -4
  45. package/page/widgets/Placeholder/Placeholder.js +0 -5
  46. package/page/widgets/Placeholder/hooks.js +0 -12
  47. package/page/widgets/Placeholder/index.js +0 -1
  48. package/page/widgets/ProductList/ProductList.js +0 -5
  49. package/page/widgets/ProductList/hooks.js +0 -25
  50. package/page/widgets/ProductList/index.js +0 -1
  51. package/page/widgets/index.js +0 -1
  52. package/page/widgets/widgets.json +0 -8
  53. package/product/components/ProductGrid/components/Item/components/ItemDetails/index.js +0 -8
  54. package/product/components/ProductGrid/components/Item/components/ItemDetails/spec.js +0 -1
  55. package/product/components/ProductGrid/components/Item/components/ItemDiscount/index.js +0 -5
  56. package/product/components/ProductGrid/components/Item/components/ItemFavoritesButton/index.js +0 -5
  57. package/product/components/ProductGrid/components/Item/components/ItemFavoritesButton/spec.js +0 -1
  58. package/product/components/ProductGrid/components/Item/components/ItemImage/index.js +0 -5
  59. package/product/components/ProductGrid/components/Item/components/ItemImage/spec.js +0 -1
  60. package/product/components/ProductGrid/components/Item/components/ItemName/index.js +0 -5
  61. package/product/components/ProductGrid/components/Item/components/ItemName/spec.js +0 -1
  62. package/product/components/ProductGrid/components/Item/components/ItemPrice/index.js +0 -5
  63. package/product/components/ProductGrid/components/Item/components/ItemPrice/spec.js +0 -1
  64. package/product/components/ProductGrid/components/Item/index.js +0 -7
  65. package/product/components/ProductGrid/components/Iterator/index.js +0 -5
  66. package/product/components/ProductGrid/components/Layout/index.js +0 -5
  67. package/product/components/ProductGrid/index.js +0 -22
  68. package/product/components/ProductGrid/spec.js +0 -1
  69. package/styles/helpers/color.js +0 -23
  70. package/styles/index.d.ts +0 -17
  71. package/styles/theme/createTheme/createBreakpoints.d.ts +0 -114
  72. package/styles/theme/createTheme/createBreakpoints.js +0 -41
  73. package/styles/theme/createTheme/createSpacing.d.ts +0 -23
  74. package/styles/theme/createTheme/createSpacing.js +0 -14
  75. package/styles/theme/createTheme/index.d.ts +0 -19
  76. package/styles/theme/createTheme/index.js +0 -5
  77. package/styles/theme/createTheme/transitions.d.ts +0 -100
  78. package/styles/theme/createTheme/transitions.js +0 -26
  79. package/styles/theme/createTheme/zIndex.d.ts +0 -12
  80. package/styles/theme/createTheme/zIndex.js +0 -3
  81. package/styles/theme/hooks/index.d.ts +0 -4
  82. package/styles/theme/hooks/index.js +0 -1
  83. package/styles/theme/hooks/useActiveBreakpoint.d.ts +0 -18
  84. package/styles/theme/hooks/useActiveBreakpoint.js +0 -4
  85. package/styles/theme/hooks/useMediaQuery.d.ts +0 -33
  86. package/styles/theme/hooks/useMediaQuery.js +0 -20
  87. package/styles/theme/hooks/useResponsiveValue.d.ts +0 -27
  88. package/styles/theme/hooks/useResponsiveValue.js +0 -4
  89. package/styles/theme/hooks/useTheme.d.ts +0 -8
  90. package/styles/theme/hooks/useTheme.js +0 -4
  91. package/styles/theme/index.d.ts +0 -8
  92. package/styles/theme/index.js +0 -1
  93. package/styles/theme/providers/ActiveBreakpointProvider.d.ts +0 -21
  94. package/styles/theme/providers/ActiveBreakpointProvider.js +0 -13
  95. package/styles/theme/providers/ThemeProvider.d.ts +0 -18
  96. package/styles/theme/providers/ThemeProvider.js +0 -7
  97. package/styles/tss/index.js +0 -3
@@ -1,5 +0,0 @@
1
- import React,{memo,useMemo}from'react';import PropTypes from'prop-types';import{PRODUCT_ITEM_NAME,PRODUCT_ITEM_NAME_BEFORE,PRODUCT_ITEM_NAME_AFTER}from'@shopgate/engage/category/constants';import{Portal}from'@shopgate/engage/components';import{ProductName}from'@shopgate/engage/product';import{makeStyles}from'@shopgate/engage/styles';var useStyles=makeStyles()({root:{fontWeight:'500',lineHeight:1.15,marginTop:1,wordBreak:['keep-all','break-word'],hyphens:'auto'}});/**
2
- * The item name component.
3
- * @param {Object} props The component props.
4
- * @returns {JSX.Element|null}
5
- */var ItemName=function ItemName(_ref){var display=_ref.display,productId=_ref.productId,name=_ref.name;var _useStyles=useStyles(),classes=_useStyles.classes,cx=_useStyles.cx;var portalProps=useMemo(function(){return{productId:productId,display:display};},[display,productId]);if(display&&!display.name){return React.createElement(React.Fragment,null,React.createElement(Portal,{name:PRODUCT_ITEM_NAME_BEFORE,props:portalProps}),React.createElement(Portal,{name:PRODUCT_ITEM_NAME_AFTER,props:portalProps}));}return React.createElement(ProductName,{name:name,className:cx(classes.root,'theme__product-grid__item__item-name'),portalName:PRODUCT_ITEM_NAME,portalProps:portalProps,testId:"Productname: ".concat(name)});};ItemName.defaultProps={display:null,name:null};export default memo(ItemName);
@@ -1 +0,0 @@
1
- import React from'react';import{shallow}from'enzyme';import ItemName from"./index";jest.mock('@shopgate/engage/product',function(){return{ProductName:function ProductName(){return null;}};});var props={productId:'1234',name:'Foo'};describe('<ItemName />',function(){it('should render with minimal props',function(){var wrapper=shallow(React.createElement(ItemName,props));expect(wrapper).toMatchSnapshot();});});
@@ -1,5 +0,0 @@
1
- import React,{memo,useMemo}from'react';import PropTypes from'prop-types';import{SurroundPortals}from'@shopgate/engage/components';import{PRODUCT_ITEM_PRICE}from'@shopgate/engage/category';import{ProductGridPrice}from'@shopgate/engage/product';/**
2
- * The item price component.
3
- * @param {Object} props The component props.
4
- * @returns {JSX.Element|null}
5
- */var ItemPrice=function ItemPrice(_ref){var display=_ref.display,product=_ref.product;var productId=product.id;var portalProps=useMemo(function(){return{productId:productId,location:'productGrid'};},[productId]);if(display&&!display.price){return null;}return React.createElement(SurroundPortals,{portalName:PRODUCT_ITEM_PRICE,portalProps:portalProps},React.createElement(ProductGridPrice,{product:product}));};ItemPrice.defaultProps={display:null};export default memo(ItemPrice);
@@ -1 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import{shallow}from'enzyme';import ItemPrice from"./index";jest.mock('@shopgate/engage/product',function(){return{ProductGridPrice:function ProductGridPrice(){return null;}};});jest.mock('@shopgate/engage/components',function(){return{Portal:function Portal(_ref){var children=_ref.children;return children;}};});jest.mock('@shopgate/engage/category',function(){return{PRODUCT_ITEM_PRICE:'PRODUCT_ITEM_PRICE',PRODUCT_ITEM_PRICE_AFTER:'PRODUCT_ITEM_PRICE_AFTER',PRODUCT_ITEM_PRICE_BEFORE:'PRODUCT_ITEM_PRICE_BEFORE'};});var props={product:{id:'1234',price:{}}};var display={price:false};describe('<ItemPrice />',function(){it('should render with minimal props',function(){var wrapper=shallow(React.createElement(ItemPrice,props));expect(wrapper).toMatchSnapshot();});it('should not render with display props set',function(){var wrapper=shallow(React.createElement(ItemPrice,_extends({},props,{display:display})));expect(wrapper).toBeEmptyRender();});});
@@ -1,7 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{memo}from'react';import PropTypes from'prop-types';import{isBeta}from'@shopgate/engage/core';import{getProductRoute,FeaturedMedia,ProductBadges}from'@shopgate/engage/product';import{Link}from'@shopgate/engage/components';import{useProductListType}from'@shopgate/engage/product/hooks';import{themeConfig}from'@shopgate/engage';import{makeStyles}from'@shopgate/engage/styles';import ItemImage from"./components/ItemImage";import ItemDiscount from"./components/ItemDiscount";import ItemFavoritesButton from"./components/ItemFavoritesButton";import ItemDetails from"./components/ItemDetails";var colors=themeConfig.colors;var useStyles=makeStyles()(function(theme,_ref){var display=_ref.display;return{root:{position:'relative',display:'flex',flexDirection:'column',background:colors.light,height:'100%'},itemDetails:_extends({position:'relative'},display&&!display.name&&!display.price&&!display.reviews&&{paddingBottom:30})};});/**
2
- * The Product Grid Item component.
3
- * @param {Object} props The component props.
4
- * @param {Object} props.product The product.
5
- * @param {Object} props.display The display object.
6
- * @return {JSX.Element}
7
- */var Item=function Item(_ref2){var product=_ref2.product,display=_ref2.display;var _useStyles=useStyles({display:display}),classes=_useStyles.classes,cx=_useStyles.cx;var _useProductListType=useProductListType(),meta=_useProductListType.meta;return React.createElement("div",{className:cx(classes.root,'theme__product-grid__item')},React.createElement(Link,{role:"none",href:getProductRoute(product.id),state:_extends({title:product.name},meta)},isBeta()&&product.featuredMedia?React.createElement(FeaturedMedia,{type:product.featuredMedia.type,url:product.featuredMedia.url}):React.createElement(ItemImage,{productId:product.id,name:product.name,imageUrl:product.featuredImageBaseUrl})),React.createElement(ProductBadges,{location:"productGrid",productId:product.id},React.createElement(ItemDiscount,{productId:product.id,discount:product.price.discount||null})),React.createElement("div",{className:classes.itemDetails},React.createElement(ItemDetails,{product:product,display:display,productListTypeMeta:meta}),React.createElement(ItemFavoritesButton,{productId:product.id})));};Item.defaultProps={display:null};export default memo(Item);
@@ -1,5 +0,0 @@
1
- import React from'react';import PropTypes from'prop-types';import{Grid,SurroundPortals}from'@shopgate/engage/components';import{PRODUCT_ITEM}from'@shopgate/engage/category';import{ProductListEntryProvider}from'@shopgate/engage/product';import Item from"../Item";/**
2
- * The Product Grid Iterator component.
3
- * @param {Object} props The component props.
4
- * @returns {JSX}
5
- */var Iterator=function Iterator(props){var portalProps={productId:props.id};var id=props.id,display=props.display;return React.createElement(Grid.Item,{key:id,"data-test-id":props.name,className:"theme__product-grid__item__container"},React.createElement(ProductListEntryProvider,{productId:props.id},React.createElement(SurroundPortals,{portalName:PRODUCT_ITEM,portalProps:portalProps},React.createElement(Item,{product:props,display:display}))));};Iterator.defaultProps={display:null,name:null};export default Iterator;
@@ -1,5 +0,0 @@
1
- import React from'react';import PropTypes from'prop-types';import{Grid}from'@shopgate/engage/components';import{makeStyles}from'@shopgate/engage/styles';var useStyles=makeStyles()(function(theme,_ref){var columns=_ref.columns;return{root:{padding:'0 16px',':not(:empty)':{marginTop:16},display:'grid',gridGap:'0 16px',gridTemplateColumns:"repeat(".concat(columns,", 1fr)")}};});/**
2
- * The product grid layout component.
3
- * @param {Object} props The component props.
4
- * @returns {JSX}
5
- */var Layout=function Layout(_ref2){var children=_ref2.children,columns=_ref2.columns,className=_ref2.className;var _useStyles=useStyles({columns:columns}),classes=_useStyles.classes,cx=_useStyles.cx;return React.createElement(Grid,{wrap:true,className:cx(classes.root,className,'theme__product-grid'),"data-test-id":"productGrid"},children);};Layout.defaultProps={className:null,children:null};export default Layout;
@@ -1,22 +0,0 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useContext}from'react';import PropTypes from'prop-types';import{ViewContext,InfiniteContainer,LoadingIndicator}from'@shopgate/engage/components';import{ProductListTypeProvider}from'@shopgate/engage/product';import{ITEMS_PER_LOAD}from'@shopgate/engage/core/constants';import{useResponsiveValue}from'@shopgate/engage/styles';import Iterator from"./components/Iterator";import Layout from"./components/Layout";export var WIDGET_ID='@shopgate/engage/product/ProductGrid';/**
2
- * The Product Grid component.
3
- * @param {Object} props The component props.
4
- * @param {Array} props.products The list of products to display.
5
- * @param {string} props.scope Optional scope of the component. Will be used as subType property of
6
- * the ProductListTypeContext and is intended as a description in which "context" the component is
7
- * used.
8
- * @param {Object} props.meta Optional metadata for the product list type context.
9
- * @param {Object} props.flags The flags object.
10
- * @param {boolean} props.flags.name Whether to display product names.
11
- * @param {boolean} props.flags.price Whether to display product prices.
12
- * @param {boolean} props.flags.reviews Whether to display rating stars.
13
- * @param {boolean} props.infiniteLoad Whether the grid should support infinite loading.
14
- * @param {Function} props.handleGetProducts Callback function that's invoked to load more products
15
- * when infinite loading is enabled.
16
- * @param {number} props.totalProductCount The total number of products. Needed when infinite
17
- * loading is enabled.
18
- * @param {string} props.requestHash The hash for the current request. Needed when infinite loading
19
- * is enabled
20
- * @param {string} props.className Optional class name for the grid container
21
- * @returns {JSX.Element}
22
- */var ProductGrid=function ProductGrid(_ref){var flags=_ref.flags,infiniteLoad=_ref.infiniteLoad,handleGetProducts=_ref.handleGetProducts,products=_ref.products,totalProductCount=_ref.totalProductCount,requestHash=_ref.requestHash,scope=_ref.scope,meta=_ref.meta,className=_ref.className;var _useContext=useContext(ViewContext),getContentRef=_useContext.getContentRef;var columns=useResponsiveValue({xs:2,md:4});if(!infiniteLoad){return React.createElement(Layout,{columns:columns,className:className},React.createElement(ProductListTypeProvider,{type:"productGrid",subType:scope,meta:meta},products.map(function(product){return React.createElement(Iterator,_extends({display:flags,id:product.id,key:product.id},product));})));}return React.createElement(ProductListTypeProvider,{type:"productGrid",subType:scope,meta:meta},React.createElement(InfiniteContainer,{containerRef:getContentRef(),wrapper:function wrapper(props){return React.createElement(Layout,_extends({columns:columns,className:className},props));},iterator:Iterator,loader:handleGetProducts,items:products,columns:columns,loadingIndicator:React.createElement(LoadingIndicator,null),totalItems:totalProductCount,initialLimit:ITEMS_PER_LOAD,limit:ITEMS_PER_LOAD,requestHash:requestHash,enablePromiseBasedLoading:true}));};ProductGrid.defaultProps={flags:null,handleGetProducts:function handleGetProducts(){},infiniteLoad:true,products:null,requestHash:null,totalProductCount:null,scope:null,meta:null,className:null};export default ProductGrid;
@@ -1 +0,0 @@
1
- import React from'react';import{mount}from'enzyme';import ProductGrid from'.';global.console.error=jest.fn();jest.mock('@shopgate/engage/core',function(){return{hasWebBridge:jest.fn(function(){return false;}),isIOSTheme:jest.fn(function(){return false;}),withForwardedRef:jest.fn(),withCurrentProduct:jest.fn(),useWidgetSettings:jest.fn().mockReturnValue({})};});jest.mock('@shopgate/engage/components',function(){var _jest$requireActual=jest.requireActual('@shopgate/engage/components/View/context'),ViewContext=_jest$requireActual.ViewContext;return{ViewContext:ViewContext,InfiniteContainer:function InfiniteContainer(){return null;},Grid:function Grid(){return null;}};});jest.mock("./components/Iterator",function(){return function Iterator(){return null;};});jest.mock('@shopgate/engage/product',function(){return{ProductListTypeProvider:function ProductListTypeProvider(_ref){var children=_ref.children;return children;},ProductListEntryProvider:function ProductListEntryProvider(_ref2){var children=_ref2.children;return children;}};});describe('<ProductGrid />',function(){it('should render with the InfiniteContainer',function(){var wrapper=mount(React.createElement(ProductGrid,{products:[]}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('InfiniteContainer').exists()).toBe(true);expect(wrapper.find('Layout').exists()).toBe(false);});it('should render the original layout',function(){var wrapper=mount(React.createElement(ProductGrid,{infiniteLoad:false,products:[]}));expect(wrapper).toMatchSnapshot();expect(wrapper.find('InfiniteContainer').exists()).toBe(false);expect(wrapper.find('Layout').exists()).toBe(true);});});
@@ -1,23 +0,0 @@
1
- // Import the Color constructor from the color.js package
2
- import Color from'color';/**
3
- * Converts any valid input color to an RGBA CSS string.
4
- * If the input color already contains an alpha channel (< 1), that alpha is preserved.
5
- * Otherwise, the provided `opacity` is applied.
6
- *
7
- * @param {string} inputColor any CSS‐valid color string (hex, rgb(), hsl(), etc.)
8
- * @param {number} [opacity=1] fallback alpha (0–1) to use if `inputColor` has no alpha
9
- * @returns {string} "rgba(r, g, b, a)" string
10
- *
11
- * @example
12
- * toRgba('#ff0000') // → "rgba(255, 0, 0, 1)"
13
- * toRgba('#ff0000', 0.5) // → "rgba(255, 0, 0, 0.5)"
14
- * toRgba('rgba(10,20,30,0.2)', 0.9) // → "rgba(10, 20, 30, 0.2)"
15
- * toRgba('hsl(120, 100%, 50%)') // → "rgba(0, 255, 0, 1)"
16
- * toRgba('blue', 0.3) // → "rgba(0, 0, 255, 0.3)"
17
- */export function colorToRgba(inputColor){var opacity=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;// Parse the input into a Color instance
18
- var parsed=Color(inputColor);// Extract the alpha channel from the parsed color (default is 1 if none was provided)
19
- var inputAlpha=parsed.alpha();// Determine which alpha to use:
20
- // - If the parsed color already had alpha < 1, keep that.
21
- // - Otherwise, use the provided opacity value.
22
- var finalAlpha=inputAlpha<1?inputAlpha:opacity;// Set the computed alpha and return as "rgba(r, g, b, a)" string
23
- return parsed.alpha(finalAlpha).rgb().string();}
package/styles/index.d.ts DELETED
@@ -1,17 +0,0 @@
1
- export * from './helpers';
2
- export {
3
- ThemeProvider,
4
- createTheme,
5
- useActiveBreakpoint,
6
- useMediaQuery,
7
- useResponsiveValue,
8
- useTheme,
9
- Theme,
10
- } from './theme';
11
- export {
12
- makeStyles,
13
- withStyles,
14
- tss,
15
- GlobalStyles,
16
- keyframes,
17
- } from './tss';
@@ -1,114 +0,0 @@
1
- export type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
2
- export const keys: Breakpoint[];
3
-
4
- export interface Breakpoints {
5
- keys: Breakpoint[];
6
- /**
7
- * Each breakpoint (a key) matches with a fixed screen width (a value).
8
- * @default
9
- * {
10
- * // extra-small
11
- * xs: 0,
12
- * // small
13
- * sm: 600,
14
- * // medium
15
- * md: 900,
16
- * // large
17
- * lg: 1200,
18
- * // extra-large
19
- * xl: 1536,
20
- * }
21
- */
22
- values: { [key in Breakpoint]: number };
23
- /**
24
- * @param key - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
25
- * @returns A media query string which matches screen widths greater than the screen size given by the breakpoint key (inclusive).
26
- * @example
27
- * ```js
28
- * const styles = (theme) => ({
29
- * root: {
30
- * backgroundColor: 'blue',
31
- * // Matches "md" and above
32
- * [theme.breakpoints.up('md')]: {
33
- * backgroundColor: 'red',
34
- * }
35
- * }
36
- * })
37
- * ```
38
- */
39
- up: (key: Breakpoint | number) => string;
40
- /**
41
- * @param key - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
42
- * @returns A media query string which matches screen widths less than the screen size given by the breakpoint key (exclusive).
43
- * @example
44
- * ```js
45
- * const styles = (theme) => ({
46
- * root: {
47
- * backgroundColor: 'blue',
48
- * // Matches "xs" and "sm"
49
- * [theme.breakpoints.down('md')]: {
50
- * backgroundColor: 'red',
51
- * }
52
- * }
53
- * })
54
- * ```
55
- */
56
- down: (key: Breakpoint | number) => string;
57
- /**
58
- * @param start - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
59
- * @param end - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
60
- * @returns A media query string which matches screen widths greater than
61
- * the screen size given by the breakpoint key in the first argument (inclusive) and less than the screen size given by the breakpoint key in the second argument (exclusive).
62
- * @example
63
- * ```js
64
- * const styles = (theme) => ({
65
- * root: {
66
- * backgroundColor: 'blue',
67
- * // Matches "sm" and "md"
68
- * [theme.breakpoints.between('sm', 'lg')]: {
69
- * backgroundColor: 'red',
70
- * }
71
- * }
72
- * })
73
- * ```
74
- */
75
- between: (start: Breakpoint | number, end: Breakpoint | number) => string;
76
- /**
77
- * @param key - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
78
- * @returns A media query string which matches screen widths starting from
79
- * the screen size given by the breakpoint key (inclusive) and stopping at the screen size given by the next breakpoint key (exclusive).
80
- * @example
81
- * ```js
82
- * const styles = (theme) => ({
83
- * root: {
84
- * backgroundColor: 'blue',
85
- * // Matches "sm"
86
- * [theme.breakpoints.only('sm')]: {
87
- * backgroundColor: 'red',
88
- * }
89
- * }
90
- * })
91
- * ```
92
- */
93
- only: (key: Breakpoint) => string;
94
- /**
95
- * @param key - A breakpoint key (`xs`, `sm`, etc.).
96
- * @returns A media query string which matches screen widths stopping at
97
- * the screen size given by the breakpoint key (exclusive) and starting at the screen size given by the next breakpoint key (inclusive).
98
- * @example
99
- * ```js
100
- * const styles = (theme) => ({
101
- * root: {
102
- * backgroundColor: 'blue',
103
- * // Matches "xs", "md", "lg", and "xl"
104
- * [theme.breakpoints.not('sm')]: {
105
- * backgroundColor: 'red',
106
- * }
107
- * }
108
- * })
109
- * ```
110
- */
111
- not: (key: Breakpoint) => string;
112
- }
113
-
114
- export default function createBreakpoints(): Breakpoints;
@@ -1,41 +0,0 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}/* eslint-disable valid-jsdoc */ // Possible breakpoints for responsive design
2
- /** @type {import('./createBreakpoints').Breakpoint[]} */export var breakpointKeys=['xs','sm','md','lg','xl'];/**
3
- * Sorts an object of breakpoints by their numeric values in ascending order.
4
- *
5
- * This is useful in responsive design systems to ensure breakpoints
6
- * are applied in the correct order.
7
- *
8
- * @param {Object.<string, number>} values - An object where keys are breakpoint names
9
- * (e.g., 'xs', 'sm', 'md') and values are numeric pixel values.
10
- * @returns {Object.<string, number>} A new object with the same key-value pairs, sorted by
11
- * ascending numeric values.
12
- *
13
- * @example
14
- * const breakpoints = { md: 960, xs: 0, sm: 600 };
15
- * const sorted = sortBreakpointsValues(breakpoints);
16
- * console.log(sorted); // { xs: 0, sm: 600, md: 960 }
17
- */var sortBreakpointsValues=function sortBreakpointsValues(values){var breakpointsAsArray=Object.keys(values).map(function(key){return{key:key,val:values[key]};})||[];breakpointsAsArray.sort(function(breakpoint1,breakpoint2){return breakpoint1.val-breakpoint2.val;});return breakpointsAsArray.reduce(function(acc,obj){return _extends({},acc,_defineProperty({},obj.key,obj.val));},{});};var unit='px';var step=5;/**
18
- * Creates a set of media query functions based on the provided breakpoints.
19
- */var createBreakpoints=function createBreakpoints(){/** @type {import('./createBreakpoints').Breakpoints['values]} */var values={// Extra small – all mobile phones
20
- xs:0,// Small – large phones in landscape
21
- sm:480,// Medium – tablets
22
- md:768,// Large – small laptops
23
- lg:1024,// Extra large – desktops
24
- xl:1280};var sortedValues=sortBreakpointsValues(values);var keys=Object.keys(sortedValues);/**
25
- * @param {import('./createBreakpoints').Breakpoint | number} key Breakpoint key or pixel value
26
- * @returns {string} A media query string for the specified breakpoint
27
- */function up(key){var value=typeof values[key]==='number'?values[key]:key;return"@media (min-width:".concat(value).concat(unit,")");}/**
28
- * @param {import('./createBreakpoints').Breakpoint | number} key Breakpoint key or pixel value
29
- * @returns {string} A media query string for the specified breakpoint
30
- */function down(key){/** @type {number} */var value=typeof values[key]==='number'?values[key]:key;return"@media (max-width:".concat(value-step/100).concat(unit,")");}/**
31
- * @param {import('./createBreakpoints').Breakpoint | number} start Breakpoint key or pixel value
32
- * @param {import('./createBreakpoints').Breakpoint | number} end Breakpoint key or pixel value
33
- * @returns {string} A media query string for the specified breakpoint
34
- */function between(start,end){var endIndex=keys.indexOf(end);return"@media (min-width:".concat(typeof values[start]==='number'?values[start]:start).concat(unit,") and ")+"(max-width:".concat((endIndex!==-1&&typeof values[keys[endIndex]]==='number'?values[keys[endIndex]]:end)-step/100).concat(unit,")");}/**
35
- * @param {import('./createBreakpoints').Breakpoint} key Breakpoint key or pixel value
36
- * @returns {string} A media query string for the specified breakpoint
37
- */function only(key){if(keys.indexOf(key)+1<keys.length){return between(key,keys[keys.indexOf(key)+1]);}return up(key);}/**
38
- * @param {import('./createBreakpoints').Breakpoint} key Breakpoint key or pixel value
39
- * @returns {string} A media query string for the specified breakpoint
40
- */function not(key){// handle first and last key separately, for better readability
41
- var keyIndex=keys.indexOf(key);if(keyIndex===0){return up(keys[1]);}if(keyIndex===keys.length-1){return down(keys[keyIndex]);}return between(key,keys[keys.indexOf(key)+1]).replace('@media','@media not all and');}return{keys:keys,values:sortedValues,up:up,down:down,between:between,only:only,not:not};};export default createBreakpoints;/* eslint-enable valid-jsdoc */
@@ -1,23 +0,0 @@
1
- /* tslint:disable:unified-signatures */
2
-
3
- export type SpacingArgument = number | string;
4
-
5
- export interface Spacing {
6
- /**
7
- * The spacing helper can be used to create consistent spacing between UI element.
8
- *
9
- * It accepts 0 to 4 spacing arguments, which can be numbers or strings like `auto`,
10
- */
11
- (): number;
12
- (value: number): number;
13
- (topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
14
- (top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
15
- (
16
- top: SpacingArgument,
17
- right: SpacingArgument,
18
- bottom: SpacingArgument,
19
- left: SpacingArgument
20
- ): string;
21
- }
22
-
23
- export default function createSpacing(): Spacing;
@@ -1,14 +0,0 @@
1
- import{isDev}from'@shopgate/engage/core/helpers';var spacingUnit=8;/**
2
- * Create the spacing function of the theme
3
- * @returns {function(...(number | string)): string} A function that takes one or more spacing
4
- * arguments
5
- */var createSpacing=function createSpacing(){/**
6
- *
7
- * @param {number|string} input The input
8
- * @returns {string|number} The result
9
- */var transform=function transform(input){if(typeof input==='number'){return input*spacingUnit;}return input;};/**
10
- * @param {...(number | string)} args - 0 to 4 spacing arguments, which can be numbers
11
- * or strings like 'auto',
12
- * @returns {string} A space-separated string of pixel values or other transformed values
13
- */var spacing=function spacing(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}if(isDev){if(!(args.length<=4)){// eslint-disable-next-line no-console
14
- console.error("Too many arguments passed. Expected between 0 and 4 arguments, got ".concat(args.length,"."));}}if(args.length===0){return transform(1);}if(args.length===1){return transform(args[0]);}return args.slice(0,4).map(function(argument){var output=transform(argument);return typeof output==='number'?"".concat(output,"px"):output;}).join(' ');};return spacing;};export default createSpacing;
@@ -1,19 +0,0 @@
1
- import { type Breakpoints } from './createBreakpoints';
2
- import { type Spacing } from './createSpacing';
3
- import { Transitions } from './transitions';
4
- import { type ZIndex } from './zIndex';
5
-
6
- export { type Breakpoint } from './createBreakpoints'
7
-
8
- export interface ThemeOptions {
9
-
10
- }
11
-
12
- export interface Theme {
13
- breakpoints: Breakpoints;
14
- spacing: Spacing;
15
- transitions: Transitions;
16
- zIndex: ZIndex;
17
- }
18
-
19
- export function createTheme(): Theme;
@@ -1,5 +0,0 @@
1
- import createBreakpoints from"./createBreakpoints";import createSpacing from"./createSpacing";import transitions from"./transitions";import zIndex from"./zIndex";// eslint-disable-next-line valid-jsdoc
2
- /**
3
- * Creates a theme object for the ThemeProvider.
4
- * @returns The theme object
5
- */export var createTheme=function createTheme(){var breakpoints=createBreakpoints();var spacing=createSpacing();return{breakpoints:breakpoints,spacing:spacing,transitions:transitions,zIndex:zIndex};};
@@ -1,100 +0,0 @@
1
- export interface Easing {
2
- /**
3
- * This is the most common easing curve.
4
- */
5
- easeInOut: string;
6
- /**
7
- * Objects enter the screen at full velocity from off-screen and slowly decelerate to a resting
8
- * point.
9
- */
10
- easeOut: string;
11
- /**
12
- * Objects leave the screen at full velocity. They do not decelerate when off-screen.
13
- */
14
- easeIn: string;
15
- /**
16
- * The sharp curve is used by objects that may return to the screen at any time.
17
- */
18
- sharp: string;
19
- }
20
- export const easing: Easing;
21
-
22
- export interface Duration {
23
- shortest: number;
24
- shorter: number;
25
- short: number;
26
- /**
27
- * Most basic recommended timing
28
- */
29
- standard: number;
30
- /**
31
- * This is to be used in complex animations
32
- */
33
- complex: number;
34
- /**
35
- * Recommended when something is entering screen
36
- */
37
- enteringScreen: number;
38
- /**
39
- * Recommended when something is leaving screen
40
- */
41
- leavingScreen: number;
42
- }
43
-
44
- export const duration: Duration;
45
-
46
- export function formatMs(milliseconds: number): string;
47
-
48
- export interface Transitions {
49
- /**
50
- * Easing functions for transitions.
51
- */
52
- easing: Easing;
53
- /**
54
- * Presets for transition durations.
55
- */
56
- duration: Duration;
57
- /**
58
- * Creates a CSS transition string based on the provided properties and options.
59
- */
60
- create(
61
- /**
62
- * The CSS properties to apply the transition to.
63
- * Can be a single property or an array of properties.
64
- */
65
- props: string | string[],
66
- options?: Partial<{
67
- /**
68
- * Duration of the transition as a number in milliseconds or a string with a
69
- * CSS time unit (e.g., '500ms', '0.5s').
70
- */
71
- duration: number | string;
72
- /**
73
- * Easing function to use for the transition.
74
- */
75
- easing: string;
76
- /**
77
- * Delay before the transition starts, as a number in milliseconds or a string with a
78
- * CSS time unit (e.g., '500ms', '0.5s').
79
- */
80
- delay: number | string
81
- }>
82
- ): string;
83
- /**
84
- * Calculates an appropriate animation duration (in milliseconds) for a height-based
85
- * transition effect. The duration increases with height but in a sub-linear fashion,
86
- * providing a smooth and visually pleasing animation speed for expanding/collapsing UI elements.
87
- *
88
- * @param {number} height - The height (in pixels) of the element being animated.
89
- * @returns {number} The calculated duration in milliseconds. Returns 0 if height is 0 or falsy.
90
- *
91
- * @example
92
- * getAutoHeightDuration(72); // returns ~222
93
- */
94
- getAutoHeightDuration(height: number): number;
95
- }
96
-
97
- // export type TransitionsOptions = DeepPartial<Transitions>;
98
-
99
- declare const transitions: Transitions;
100
- export default transitions;
@@ -1,26 +0,0 @@
1
- var _excluded=["duration","easing","delay"];function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import{isDev}from'@shopgate/engage/core/helpers';// Follow https://material.google.com/motion/duration-easing.html#duration-easing-natural-easing-curves
2
- // to learn the context in which each easing should be used.
3
- export var easing={// This is the most common easing curve.
4
- easeInOut:'cubic-bezier(0.4, 0, 0.2, 1)',// Objects enter the screen at full velocity from off-screen and
5
- // slowly decelerate to a resting point.
6
- easeOut:'cubic-bezier(0.0, 0, 0.2, 1)',// Objects leave the screen at full velocity. They do not decelerate when off-screen.
7
- easeIn:'cubic-bezier(0.4, 0, 1, 1)',// The sharp curve is used by objects that may return to the screen at any time.
8
- sharp:'cubic-bezier(0.4, 0, 0.6, 1)'};// Follow https://material.io/guidelines/motion/duration-easing.html#duration-easing-common-durations
9
- // to learn when use what timing
10
- export var duration={shortest:150,shorter:200,"short":250,// most basic recommended timing
11
- standard:300,// this is to be used in complex animations
12
- complex:375,// recommended when something is entering screen
13
- enteringScreen:225,// recommended when something is leaving screen
14
- leavingScreen:195};/**
15
- * Converts milliseconds to a string representation.
16
- * @param {number} milliseconds Input in milliseconds.
17
- * @returns {string}
18
- */function formatMs(milliseconds){return"".concat(Math.round(milliseconds),"ms");}/**
19
- * @param {string|Array} props
20
- * @param {object} param
21
- * @param {string} param.prop
22
- * @param {number} param.duration
23
- * @param {string} param.easing
24
- * @param {number} param.delay
25
- */export default{easing:easing,duration:duration,create:function create(){var props=arguments.length>0&&arguments[0]!==undefined?arguments[0]:['all'];var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var _options$duration=options.duration,durationOption=_options$duration===void 0?duration.standard:_options$duration,_options$easing=options.easing,easingOption=_options$easing===void 0?easing.easeInOut:_options$easing,_options$delay=options.delay,delay=_options$delay===void 0?0:_options$delay,other=_objectWithoutProperties(options,_excluded);if(isDev){/* eslint-disable require-jsdoc */var isString=function isString(value){return typeof value==='string';};var isNumber=function isNumber(value){return!Number.isNaN(parseFloat(value));};/* eslint-enable require-jsdoc */if(!isString(props)&&!Array.isArray(props)){console.error('Shopgate Theme: Argument "props" must be a string or Array.');}if(!isNumber(durationOption)&&!isString(durationOption)){console.error("Shopgate Theme: Argument \"duration\" must be a number or a string but found ".concat(durationOption,"."));}if(!isString(easingOption)){console.error('Shopgate Theme: Argument "easing" must be a string.');}if(!isNumber(delay)&&!isString(delay)){console.error('Shopgate Theme: Argument "delay" must be a number or a string.');}if(Object.keys(other).length!==0){console.error("Shopgate Theme: Unrecognized argument(s) [".concat(Object.keys(other).join(','),"]."));}}return(Array.isArray(props)?props:[props]).map(function(animatedProp){return"".concat(animatedProp," ").concat(typeof durationOption==='string'?durationOption:formatMs(durationOption)," ").concat(easingOption," ").concat(typeof delay==='string'?delay:formatMs(delay));}).join(',');},getAutoHeightDuration:function getAutoHeightDuration(height){if(!height){return 0;}var constant=height/36;// https://www.wolframalpha.com/input/?i=(4+%2B+15+*+(x+%2F+36+)+**+0.25+%2B+(x+%2F+36)+%2F+5)+*+10
26
- return Math.round((4+15*Math.pow(constant,0.25)+constant/5)*10);}};
@@ -1,12 +0,0 @@
1
- export interface ZIndex {
2
- tabBar: number;
3
- drawer: number;
4
- snackbar: number;
5
- modal: number;
6
- }
7
-
8
- export type ZIndexOptions = Partial<ZIndex>;
9
-
10
- declare const zIndex: ZIndex;
11
-
12
- export default zIndex;
@@ -1,3 +0,0 @@
1
- // We need to centralize the zIndex definitions as they work
2
- // like global values in the browser.
3
- var zIndex={tabBar:10,drawer:1200,snackbar:1400,modal:2000};export default zIndex;
@@ -1,4 +0,0 @@
1
- export { default as useActiveBreakpoint } from './useActiveBreakpoint';
2
- export { default as useMediaQuery } from './useMediaQuery';
3
- export { default as useResponsiveValue } from './useResponsiveValue';
4
- export { default as useTheme } from './useTheme';
@@ -1 +0,0 @@
1
- export{default as useActiveBreakpoint}from"./useActiveBreakpoint";export{default as useMediaQuery}from"./useMediaQuery";export{default as useResponsiveValue}from"./useResponsiveValue";export{default as useTheme}from"./useTheme";
@@ -1,18 +0,0 @@
1
- import { Breakpoint } from '..';
2
-
3
- /**
4
- * Returns the active breakpoint for the current window size.
5
- *
6
- * @example
7
- * ```js
8
- * import React from 'react';
9
- * import { useActiveBreakpoint } from '@shopgate/engage/styles';
10
- *
11
- * export default function MyComponent() {
12
- * const activeBreakpoint = useActiveBreakpoint();
13
- *
14
- * return (<span>{`active breakpoint: ${activeBreakpoint}`}</span>)
15
- * }
16
- * ```
17
- */
18
- export default function useActiveBreakpoint(): Breakpoint;
@@ -1,4 +0,0 @@
1
- import{useContext}from'react';import{ActiveBreakpointContext}from"../providers/ActiveBreakpointProvider";// eslint-disable-next-line valid-jsdoc
2
- /**
3
- * Returns the active breakpoint for the current window size.
4
- */var useActiveBreakpoint=function useActiveBreakpoint(){return useContext(ActiveBreakpointContext);};export default useActiveBreakpoint;
@@ -1,33 +0,0 @@
1
- import { Theme } from '..';
2
-
3
- /**
4
- * Creates a media query hook that can be used to check if a media query matches the current
5
- * viewport.
6
- * @param {string|ThemeFn} queryInput The media query string or a function that receives the theme
7
- * and returns a media query string.
8
- * @returns {boolean} Returns true if the media query matches, false otherwise.
9
- *
10
- * @example Use the useTheme hook to get access to the breakpoint helper functions:
11
- * ```js
12
- * import React from 'react';
13
- * import { useTheme, useMediaQuery } from '@shopgate/engage/styles';
14
- *
15
- * export default function MyComponent() {
16
- * const theme = useTheme();
17
- * const matches = useMediaQuery(theme.breakpoints.up('sm'));
18
- *
19
- * return (<span>{`theme.breakpoints.up('sm') matches: ${matches}`}</span>)
20
- * }
21
- *```
22
- * @example Alternatively, you can use a callback function, accepting the theme as a first argument:
23
- * ```js
24
- * import React from 'react';
25
- * import { useMediaQuery } from '@shopgate/engage/styles';
26
- *
27
- * export default function MyComponent() {
28
- * const matches = useMediaQuery((theme) => theme.breakpoints.up('sm'));
29
- *
30
- * return (<span>{`theme.breakpoints.up('sm') matches: ${matches}`}</span>)
31
- * }
32
- */
33
- export default function useMediaQuery(queryInput: string | ((theme: Theme) => string)): boolean;
@@ -1,20 +0,0 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{useState,useEffect}from'react';import useTheme from"./useTheme";/**
2
- * React hook to check if a media query matches the current viewport.
3
- * Doesn't accept media query strings that start with '@media'.
4
- * @param {string} query A media query string, e.g. '(min-width: 600px)'
5
- * @returns {boolean} Returns true if the media query matches, false otherwise.
6
- */var useMediaQueryInternal=function useMediaQueryInternal(query){var _useState=useState(function(){return window.matchMedia(query).matches;}),_useState2=_slicedToArray(_useState,2),match=_useState2[0],setMatch=_useState2[1];useEffect(function(){var queryList=window.matchMedia(query);/**
7
- * Update the match state when the media query changes.
8
- */var updateMatch=function updateMatch(){setMatch(queryList.matches);};queryList.addEventListener('change',updateMatch);return function(){queryList.removeEventListener('change',updateMatch);};},[query]);return match;};/**
9
- * @typedef {import('./useTheme').Theme} Theme
10
- */ /**
11
- * @callback ThemeFn
12
- * @param {Theme} theme The current theme object.
13
- */ /**
14
- * Creates a media query hook that can be used to check if a media query matches the current
15
- * viewport.
16
- * @param {string|ThemeFn} queryInput The media query string or a function that receives the theme
17
- * and returns a media query string.
18
- * @returns {boolean} Returns true if the media query matches, false otherwise.
19
- */var useMediaQuery=function useMediaQuery(queryInput){var theme=useTheme();var query=typeof queryInput==='function'?queryInput(theme):queryInput;// Remove the '@media' prefix if it exists, as useMediaQueryInternal expects a plain media query.
20
- query=query.replace(/^@media( ?)/m,'');var match=useMediaQueryInternal(query);return match;};export default useMediaQuery;
@@ -1,27 +0,0 @@
1
- import { Breakpoint } from '..';
2
-
3
- type BreakpointValueMap<T> = Partial<Record<Breakpoint, T>>;
4
-
5
- /**
6
- * Returns the value for the current breakpoint based on the provided responsive values object.
7
- * It is also responsive to window resizing and returning the appropriate value according to the
8
- * new window size.
9
- * @param values The responsive values object
10
- * @example
11
- * ```js
12
- * import React from 'react';
13
- * import { useResponsiveValue } from '@shopgate/engage/styles';
14
- *
15
- * export default function MyComponent() {
16
- * const flexDir = useResponsiveValue({
17
- * xs: "column",
18
- * lg: "row"
19
- * });
20
- *
21
- * return (<span style={{ display: 'flex', flexDirection: flexDir }} />)
22
- * }
23
- * ```
24
- */
25
- export default function useResponsiveValue<const T extends BreakpointValueMap<any>>(
26
- values: T
27
- ): T[keyof T];
@@ -1,4 +0,0 @@
1
- import useTheme from"./useTheme";import useActiveBreakpoint from"./useActiveBreakpoint";// eslint-disable-next-line require-jsdoc
2
- var useResponsiveValue=function useResponsiveValue(values){var theme=useTheme();var active=useActiveBreakpoint();if(!active)return undefined;// Get the keys of the breakpoints in the theme
3
- var breakpoints=[].concat(theme.breakpoints.keys);var activeIndex=breakpoints.indexOf(active);// Walk from the active breakpoint down to smallest
4
- for(var i=activeIndex;i>=0;i-=1){var bp=breakpoints[i];if(values[bp]!==undefined){return values[bp];}}return undefined;};export default useResponsiveValue;