@shopgate/engage
Version:
Shopgate's ENGAGE library.
11 lines • 1.2 kB
JavaScript
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{useWidgetStyles}from"../hooks/useWidgetStyles";/**
* Retrieves the styles for a specific widget by its ID.
* @param {Function} WrappedComponent The react component to wrap.
* @param {string} widgetId The id of the widget to look for, which must exist in the config.
* @param {number|undefined} [index] The optional index of the widget.
* @returns {Object}
*/export function withWidgetStyles(WrappedComponent,widgetId,index){/**
* The actual HOC.
* @param {Object} props The component props.
* @returns {JSX}
*/var WithWidgetStyles=function WithWidgetStyles(props){var styles=useWidgetStyles(widgetId,index);return React.createElement(WrappedComponent,_extends({widgetStyles:styles},props));};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithWidgetStyles.displayName="WithWidgetStyles(".concat(displayName,")");return WithWidgetStyles;}