@automattic/shopping-cart
Version:
A library to use the WordPress.com shopping cart.
18 lines • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const use_manager_client_1 = tslib_1.__importDefault(require("./use-manager-client"));
const use_shopping_cart_1 = tslib_1.__importDefault(require("./use-shopping-cart"));
function withShoppingCart(Component, mapPropsToCartKey) {
return function ShoppingCartWrapper(props) {
const cartKey = mapPropsToCartKey ? mapPropsToCartKey(props) : props.cartKey;
// Even though managerClient isn't used here this guard will provide a
// better error message than waiting for the one in useShoppingCart.
(0, use_manager_client_1.default)('withShoppingCart');
const shoppingCartManager = (0, use_shopping_cart_1.default)(cartKey);
return ((0, jsx_runtime_1.jsx)(Component, { ...props, shoppingCartManager: shoppingCartManager, cart: shoppingCartManager.responseCart }));
};
}
exports.default = withShoppingCart;
//# sourceMappingURL=with-shopping-cart.js.map