use-react-router-breadcrumbs
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -215,3 +215,5 @@ 'use strict'; | ||
breadcrumb: userProvidedBreadcrumb || humanize(currentSection), | ||
match: match, | ||
match: Object.assign(Object.assign({}, match), { | ||
route: route | ||
}), | ||
location: location, | ||
@@ -218,0 +220,0 @@ props: props |
@@ -207,3 +207,5 @@ import React, { createElement } from 'react'; | ||
breadcrumb: userProvidedBreadcrumb || humanize(currentSection), | ||
match: match, | ||
match: Object.assign(Object.assign({}, match), { | ||
route: route | ||
}), | ||
location: location, | ||
@@ -210,0 +212,0 @@ props: props |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-router")):"function"==typeof define&&define.amd?define(["exports","react","react-router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["react-router-breadcrumbs-hoc"]={},e.React,e.ReactRouter)}(this,(function(e,t,r){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(t),o=function(e){return e.join("/").replace(/\/\/+/g,"/")},c=/^:\w+$/,i=function(e){return"*"===e};function u(e,t){var r=e.split("/"),n=r.length;return r.some(i)&&(n+=-2),t&&(n+=2),r.filter((function(e){return!i(e)})).reduce((function(e,t){return c.test(t)?e+3:""===t?e+1:e+10}),n)}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return e.forEach((function(e,a){var c;if("string"!=typeof e.path&&!e.index&&!(null===(c=e.children)||void 0===c?void 0:c.length))throw new Error("useBreadcrumbs: `path` or `index` must be provided in every route object");if(e.path&&e.index)throw new Error("useBreadcrumbs: `path` and `index` cannot be provided at the same time");var i={relativePath:e.path||"",childrenIndex:a,route:e};if("/"===i.relativePath.charAt(0)){if(!i.relativePath.startsWith(n))throw new Error("useBreadcrumbs: The absolute path of the child route must start with the parent path");i.relativePath=i.relativePath.slice(n.length)}var h=o([n,i.relativePath]),l=r.concat(i);if(e.children&&e.children.length>0){if(e.index)throw new Error("useBreadcrumbs: Index route cannot have child routes");s(e.children,t,l,h)}t.push({path:h,score:u(h,e.index),routesMeta:l})})),t}var h=Symbol("NO_BREADCRUMB"),l=function(e){return e.replace(/^[\s_]+|[\s_]+$/g,"").replace(/[_\s]+/g," ").replace(/^[a-z]/,(function(e){return e.toUpperCase()}))},d=function(e){var r=e.breadcrumb,n=e.match,o=e.location,c=e.props,i=Object.assign({match:n,location:o,key:n.pathname},c||{});return Object.assign(Object.assign({},i),{breadcrumb:"string"==typeof r?t.createElement("span",{key:i.key},r):a.default.createElement(r,Object.assign({},i))})},f=function(e){var t,n=e.currentSection,a=e.disableDefaults,o=e.excludePaths,c=e.location,i=e.pathSection,u=e.branches;return o&&o.some((function(e){return null!=r.matchPath({path:e,end:!0},i)}))?h:(u.some((function(e){var o=e.path,u=e.routesMeta,s=u[u.length-1].route,f=s.breadcrumb;if(!f&&s.index){var p=u[u.length-2];p&&p.route.breadcrumb&&(f=p.route.breadcrumb)}var b=s.caseSensitive,m=s.props,v=r.matchPath({path:o,end:!0,caseSensitive:b},i);return v&&null===f?(t=h,!0):!!v&&(!f&&a?(t=h,!0):(t=d({breadcrumb:f||l(n),match:v,location:c,props:m}),!0))})),t||(a?h:function(e){var t=e.currentSection,n=e.location,a=e.pathSection,o=r.matchPath({end:!0,path:a},a);return d({breadcrumb:l(t),match:o,location:n})}({pathSection:i,currentSection:"/"===i?"Home":n,location:c})))},p=function(e){var t=e.routes,r=e.location,n=e.options,a=void 0===n?{}:n,o=r.pathname,c=function(e){return e.sort((function(e,t){return e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every((function(e,r){return e===t[r]}))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((function(e){return e.childrenIndex})),t.routesMeta.map((function(e){return e.childrenIndex})))}))}(s(t)),i=[];return o.split("?")[0].split("/").reduce((function(e,t,n){var o=t?"".concat(e,"/").concat(t):"/";if("/"===o&&0!==n)return"";var u=f(Object.assign({currentSection:t,location:r,pathSection:o,branches:c},a));return u!==h&&i.push(u),"/"===o?"":o}),""),i};e.default=function(e,t){return p({routes:e||[],location:r.useLocation(),options:t})},e.getBreadcrumbs=p,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-router")):"function"==typeof define&&define.amd?define(["exports","react","react-router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["react-router-breadcrumbs-hoc"]={},e.React,e.ReactRouter)}(this,(function(e,t,r){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(t),o=function(e){return e.join("/").replace(/\/\/+/g,"/")},c=/^:\w+$/,i=function(e){return"*"===e};function u(e,t){var r=e.split("/"),n=r.length;return r.some(i)&&(n+=-2),t&&(n+=2),r.filter((function(e){return!i(e)})).reduce((function(e,t){return c.test(t)?e+3:""===t?e+1:e+10}),n)}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return e.forEach((function(e,a){var c;if("string"!=typeof e.path&&!e.index&&!(null===(c=e.children)||void 0===c?void 0:c.length))throw new Error("useBreadcrumbs: `path` or `index` must be provided in every route object");if(e.path&&e.index)throw new Error("useBreadcrumbs: `path` and `index` cannot be provided at the same time");var i={relativePath:e.path||"",childrenIndex:a,route:e};if("/"===i.relativePath.charAt(0)){if(!i.relativePath.startsWith(n))throw new Error("useBreadcrumbs: The absolute path of the child route must start with the parent path");i.relativePath=i.relativePath.slice(n.length)}var h=o([n,i.relativePath]),l=r.concat(i);if(e.children&&e.children.length>0){if(e.index)throw new Error("useBreadcrumbs: Index route cannot have child routes");s(e.children,t,l,h)}t.push({path:h,score:u(h,e.index),routesMeta:l})})),t}var h=Symbol("NO_BREADCRUMB"),l=function(e){return e.replace(/^[\s_]+|[\s_]+$/g,"").replace(/[_\s]+/g," ").replace(/^[a-z]/,(function(e){return e.toUpperCase()}))},d=function(e){var r=e.breadcrumb,n=e.match,o=e.location,c=e.props,i=Object.assign({match:n,location:o,key:n.pathname},c||{});return Object.assign(Object.assign({},i),{breadcrumb:"string"==typeof r?t.createElement("span",{key:i.key},r):a.default.createElement(r,Object.assign({},i))})},f=function(e){var t,n=e.currentSection,a=e.disableDefaults,o=e.excludePaths,c=e.location,i=e.pathSection,u=e.branches;return o&&o.some((function(e){return null!=r.matchPath({path:e,end:!0},i)}))?h:(u.some((function(e){var o=e.path,u=e.routesMeta,s=u[u.length-1].route,f=s.breadcrumb;if(!f&&s.index){var p=u[u.length-2];p&&p.route.breadcrumb&&(f=p.route.breadcrumb)}var b=s.caseSensitive,m=s.props,v=r.matchPath({path:o,end:!0,caseSensitive:b},i);return v&&null===f?(t=h,!0):!!v&&(!f&&a?(t=h,!0):(t=d({breadcrumb:f||l(n),match:Object.assign(Object.assign({},v),{route:s}),location:c,props:m}),!0))})),t||(a?h:function(e){var t=e.currentSection,n=e.location,a=e.pathSection,o=r.matchPath({end:!0,path:a},a);return d({breadcrumb:l(t),match:o,location:n})}({pathSection:i,currentSection:"/"===i?"Home":n,location:c})))},p=function(e){var t=e.routes,r=e.location,n=e.options,a=void 0===n?{}:n,o=r.pathname,c=function(e){return e.sort((function(e,t){return e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every((function(e,r){return e===t[r]}))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((function(e){return e.childrenIndex})),t.routesMeta.map((function(e){return e.childrenIndex})))}))}(s(t)),i=[];return o.split("?")[0].split("/").reduce((function(e,t,n){var o=t?"".concat(e,"/").concat(t):"/";if("/"===o&&0!==n)return"";var u=f(Object.assign({currentSection:t,location:r,pathSection:o,branches:c},a));return u!==h&&i.push(u),"/"===o?"":o}),""),i};e.default=function(e,t){return p({routes:e||[],location:r.useLocation(),options:t})},e.getBreadcrumbs=p,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "use-react-router-breadcrumbs", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "A hook for displaying and setting breadcrumbs for react router", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33872
514