@ikas/bp-storefront 0.92.0 → 0.94.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.
@@ -1 +1 @@
1
- import{IkasStorefrontConfig as e}from"../packages/storefront-config/src/index.js";import{getCheckoutUrlFromCartStore as t}from"../functions/stores/cart/index.js";import{cartStore as a}from"../stores/cart/index.js";var n=function(){function n(){}return n.initialize=function(e,t){var a=this;this.window=t||window,this.currentPath=void 0!==this.window?this.window.location.pathname:"/",void 0!==this.window&&(n.pageParams=e,this.window.addEventListener("popstate",n.handlePopState),n.interceptAnchorClicks(),this.window.addEventListener("pageshow",function(e){return a.isFromBFCache=e.persisted}))},n.navigate=function(t,a,r){if(void 0===a&&(a=!1),void 0===r&&(r=!1),void 0!==this.window){var o=n.ensurePathPrefix(t);e.getIsPreview()||(a?this.window.history.replaceState({},"",o):r?this.window.open(o,"_blank"):this.window.location.href=o),n.handleRouteChange(o)}},n.navigateToPage=function(e,r,c,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1);var u=Object.entries(c||{}).map(function(e){var t=e[0],a=e[1];return"".concat(t,"=").concat(encodeURIComponent(a))}).join("&"),d="";switch(e){case"INDEX":d="/";break;case"ACCOUNT":d="/account";break;case"ACTIVATE_CUSTOMER":d="/account/activate";break;case"ADDRESSES":d="/account/addresses";break;case"FAVORITE_PRODUCTS":d="/account/favorite-products";break;case"FORGOT_PASSWORD":d="/account/forgot-password";break;case"LOGIN":d="/account/login";break;case"RAFFLE_ACCOUNT":d="/account/raffles";break;case"RECOVER_PASSWORD":d="/account/recover-password";break;case"REGISTER":d="/account/register";break;case"ORDERS":d="/account/orders";break;case"ORDER_DETAIL":d="/account/orders/".concat(r);break;case"BLOG_INDEX":d="/blog";break;case"BLOG":case"BLOG_CATEGORY":d="/blog/".concat(r);break;case"CART":d="/cart";break;case"CHECKOUT":d=t(a);break;case"CUSTOM":d="/pages/".concat(r);break;case"RAFFLE":d="/raffle";break;case"RAFFLE_DETAIL":d="/raffle/".concat(r);break;case"SEARCH":d="/search";break;case"NOT_FOUND":d="/404"}u&&(d+="?".concat(u)),n.navigate(o(d),i,s)},n.addObserver=function(e){n.observers.push(e)},n.removeObserver=function(e){n.observers=n.observers.filter(function(t){return t!==e})},n.goBack=function(){this.window.history.back()},n.getCurrentPath=function(){return n.currentPath},n.getPageParams=function(){return n.pageParams},n.handleRouteChange=function(e){n.currentPath=e,n.notifyObservers()},n.handlePopState=function(){void 0!==this.window&&n.handleRouteChange(this.window.location.pathname)},n.interceptAnchorClicks=function(){void 0!==this.window&&this.window.addEventListener("click",function(e){var t=e.target.closest("a");if(t&&"A"===t.tagName&&t.getAttribute("href")){if(e.metaKey||e.ctrlKey)return;e.preventDefault();var a=t.getAttribute("href"),r="_blank"===t.getAttribute("target");n.navigate(a,!1,r)}})},n.notifyObservers=function(){n.observers.forEach(function(e){return e(n.currentPath)})},n.ensurePathPrefix=function(e){return e.startsWith("http")||e.startsWith("/")?e:"/".concat(e)},n.currentPath="undefined"!=typeof window?window.location.pathname:"/",n.observers=[],n.pageParams={},n.isFromBFCache=!1,n}(),r=n;function o(t){var a=e.getCurrentPath(),n=t.split("/").filter(function(e){return""!==e})[0];return n&&e.getSupportedPaths().includes(n)?t:"".concat(a?"/".concat(a):"").concat(t).replace("//","/")}export{n as Router,r as router,o as withRoutePrefix};
1
+ import{IkasStorefrontConfig as e}from"../packages/storefront-config/src/index.js";import{getCheckoutUrlFromCartStore as t}from"../functions/stores/cart/index.js";import{cartStore as a}from"../stores/cart/index.js";var r=function(){function r(){}return r.initialize=function(e,t){var a=this;this.window=t||window,this.currentPath=void 0!==this.window?this.window.location.pathname:"/",void 0!==this.window&&(r.pageParams=e,this.window.addEventListener("popstate",r.handlePopState),r.interceptAnchorClicks(),this.window.addEventListener("pageshow",function(e){return a.isFromBFCache=e.persisted}))},r.navigate=function(t,a,n){if(void 0===a&&(a=!1),void 0===n&&(n=!1),void 0!==this.window){var o=r.ensurePathPrefix(t);e.getIsPreview()||(a?this.window.history.replaceState({},"",o):n?this.window.open(o,"_blank"):this.window.location.href=o),r.handleRouteChange(o)}},r.navigateToPage=function(e,n,c,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1);var u=Object.entries(c||{}).map(function(e){var t=e[0],a=e[1];return"".concat(t,"=").concat(encodeURIComponent(a))}).join("&"),d="";switch(e){case"INDEX":d="/";break;case"ACCOUNT":d="/account";break;case"ACTIVATE_CUSTOMER":d="/account/activate";break;case"ADDRESSES":d="/account/addresses";break;case"FAVORITE_PRODUCTS":d="/account/favorite-products";break;case"FORGOT_PASSWORD":d="/account/forgot-password";break;case"LOGIN":d="/account/login";break;case"RAFFLE_ACCOUNT":d="/account/raffles";break;case"RECOVER_PASSWORD":d="/account/recover-password";break;case"REGISTER":d="/account/register";break;case"ORDERS":d="/account/orders";break;case"ORDER_DETAIL":d="/account/orders/".concat(n);break;case"BLOG_INDEX":d="/blog";break;case"BLOG":case"BLOG_CATEGORY":d="/blog/".concat(n);break;case"CART":d="/cart";break;case"CHECKOUT":d=t(a);break;case"CUSTOM":d="/pages/".concat(n);break;case"RAFFLE":d="/raffle";break;case"RAFFLE_DETAIL":d="/raffle/".concat(n);break;case"SEARCH":d="/search";break;case"NOT_FOUND":d="/404"}u&&(d+="?".concat(u)),r.navigate(o(d),i,s)},r.addObserver=function(e){r.observers.push(e)},r.removeObserver=function(e){r.observers=r.observers.filter(function(t){return t!==e})},r.goBack=function(){this.window.history.back()},r.getCurrentPath=function(){return r.currentPath},r.getPageParams=function(){return r.pageParams},r.handleRouteChange=function(e){r.currentPath=e,r.notifyObservers()},r.handlePopState=function(){void 0!==this.window&&r.handleRouteChange(this.window.location.pathname)},r.interceptAnchorClicks=function(){void 0!==this.window&&this.window.addEventListener("click",function(e){var t=e.target.closest("a");if(t&&"A"===t.tagName&&t.getAttribute("href")){var a=t.getAttribute("href");if(e.metaKey||e.ctrlKey)return;if(/^(mailto|tel|sms|javascript):/i.test(a))return;e.preventDefault();var n="_blank"===t.getAttribute("target");r.navigate(a,!1,n)}})},r.notifyObservers=function(){r.observers.forEach(function(e){return e(r.currentPath)})},r.ensurePathPrefix=function(e){return e.startsWith("http")||e.startsWith("/")?e:"/".concat(e)},r.currentPath="undefined"!=typeof window?window.location.pathname:"/",r.observers=[],r.pageParams={},r.isFromBFCache=!1,r}(),n=r;function o(t){var a=e.getCurrentPath(),r=t.split("/").filter(function(e){return""!==e})[0];return r&&e.getSupportedPaths().includes(r)?t:"".concat(a?"/".concat(a):"").concat(t).replace("//","/")}export{r as Router,n as router,o as withRoutePrefix};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/bp-storefront",
3
- "version": "0.92.0",
3
+ "version": "0.94.0",
4
4
  "description": "A framework for the ikas blueprint storefronts.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",