UNPKG

@react-motion-router/core

Version:

Declarative routing library for ReactJS ⚛ with animations baked in ⏮

1 lines 4.3 kB
import*as e from"react";var n={810:(n,o,t)=>{n.exports=(e=>{var n={};return t.d(n,e),n})({Children:()=>e.Children,isValidElement:()=>e.isValidElement,lazy:()=>e.lazy})}},o={};function t(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return n[e](a,a.exports,t),a.exports}t.d=(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);var r={};(()=>{t.d(r,{Nu:()=>c,PV:()=>l,Po:()=>p,QN:()=>i,V_:()=>h,Vo:()=>f,cT:()=>o,dw:()=>g,e1:()=>s,fJ:()=>d,hR:()=>n,kI:()=>v,r2:()=>m,rL:()=>u,uZ:()=>a});var e=t(810);function n(e,n=[],o=!0){let t="";const r={};let a=0;for(let i in e)if(!n.includes(i)){if(a<e.length){const n=e[i];let o=e.getPropertyValue(n);if("visibility"===n)o="visible";t+=`${n}:${o};`}else{if(!o)break;let n=i,t=e[n];if("string"==typeof t&&"cssText"!==n&&!n.includes("webkit")&&!n.includes("grid")){switch(n){case"offset":n="cssOffset";break;case"float":n="cssFloat";break;case"visibility":t="visible"}r[n]=t}}a++}return[t,r]}function o(e,n=[]){const o={};for(const t in e)if(e[t]&&e[t].length&&"function"!=typeof e[t]){if(/^\d+$/.test(t))continue;if("offset"===t)continue;if(n.includes(t))continue;o[t]=e[t]}return o}function a(e,n,o){return e<n?n:o&&e>o?o:e}function i(e,n,o=window.location.origin){if(void 0===e||void 0===n)return e===n?{exact:!0,matchedPathname:n}:null;const t=new URLPattern(e,o),r=new URL(n,o),a=t.exec(r);let i="",s="";for(let e=0;e<t.pathname.length;e++){if(t.pathname[e]!==r.pathname[e]){s=r.pathname.substring(e);break}i+=t.pathname[e]}return a?{exact:e===n,matchedPathname:i,rest:s}:null}function s(e,n,o=window.location.origin){return n.some((n=>i(n,e,o)))}function c(e,n=window){return new Promise((o=>{queueMicrotask((()=>o(n.dispatchEvent(e))))}))}function l(e,n){return"string"==typeof n&&(n=new URL(n)),"string"!=typeof e&&(e=e.pathname),e=e.replace(/^\//,""),n.pathname.endsWith("/")||(n=new URL(n.href+"/")),new URL(e,n)}function u(e){const n=new URLSearchParams(decodeURI(e)).entries(),o={};for(const[e,t]of n){let n="";try{n=JSON.parse(t)}catch(e){console.warn("Non JSON serialisable value was passed as URL route param."),n=t}o[e]=n}return Object.keys(o).length?o:void 0}function d(e,n){return(n||u)(e)||{}}function p(e,n){try{return(n||function(e){return new URLSearchParams(e).toString()})(e)}catch(e){console.error(e),console.warn("Non JSON serialisable value was passed as route param to Anchor.")}return""}function f(n){const o=(0,e.lazy)(n);return o.preload=()=>{const e=n();return e.then((e=>o.preloaded=e.default)).catch(console.error),e},o}function v(n,o){let t=o;return new Promise(((r,a)=>{let s=!1;for(;t;){const c=t.routes;if(e.Children.forEach(c,(o=>{if(s)return;if(!(0,e.isValidElement)(o))return;i(o.props.path,n)&&(s=!0,queueMicrotask((async()=>{var e,n,t,i,c,l,u,d,p,f,v,h;const m=[];"preload"in o.props.component&&m.push(o.props.component.preload()),(null===(n=null===(e=o.props.config)||void 0===e?void 0:e.header)||void 0===n?void 0:n.component)&&"preload"in(null===(i=null===(t=o.props.config)||void 0===t?void 0:t.header)||void 0===i?void 0:i.component)&&m.push(null===(l=null===(c=o.props.config)||void 0===c?void 0:c.header)||void 0===l?void 0:l.component.preload()),(null===(d=null===(u=o.props.config)||void 0===u?void 0:u.footer)||void 0===d?void 0:d.component)&&"preload"in(null===(f=null===(p=o.props.config)||void 0===p?void 0:p.footer)||void 0===f?void 0:f.component)&&m.push(null===(h=null===(v=o.props.config)||void 0===v?void 0:v.footer)||void 0===h?void 0:h.component.preload());try{await Promise.all(m),r(s)}catch(e){a(e)}})))})),s)break;t=o.parentRouterData}s||r(!1)}))}function h(e,n=0){var o;const t=null===(o=null==e?void 0:e.effect)||void 0===o?void 0:o.getTiming().duration;return Number(t)||n}const m={in:{type:"none",duration:0},out:{type:"none",duration:0}},g=2147483647})();var a=r.r2,i=r.dw,s=r.uZ,c=r.PV,l=r.rL,u=r.Nu,d=r.V_,p=r.hR,f=r.cT,v=r.e1,h=r.Vo,m=r.QN,g=r.kI,w=r.Po,b=r.fJ;export{a as DEFAULT_ANIMATION,i as MAX_Z_INDEX,s as clamp,c as concatenateURL,l as defaultSearchParamsToObject,u as dispatchEvent,d as getAnimationDuration,p as getCSSData,f as getStyleObject,v as includesRoute,h as lazy,m as matchRoute,g as prefetchRoute,w as searchParamsFromObject,b as searchParamsToObject};