react-router-breadcrumbs-hoc
Advanced tools
Comparing version 3.2.10 to 3.3.0
@@ -1,2 +0,2 @@ | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),React__default=_interopDefault(React),reactRouter=require("react-router");function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,o,n={},a=Object.keys(e);for(o=0;o<a.length;o++)r=a[o],0<=t.indexOf(r)||(n[r]=e[r]);return n}function _objectWithoutProperties(e,t){if(null==e)return{};var r,o,n=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)r=a[o],0<=t.indexOf(r)||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}var DEFAULT_MATCH_OPTIONS={exact:!0},NO_BREADCRUMB="NO_BREADCRUMB",humanize=function(e){return e.replace(/^[\s_]+|[\s_]+$/g,"").replace(/[_\s]+/g," ").replace(/^[a-z]/,function(e){return e.toUpperCase()})},render=function(e){var t=e.breadcrumb,r=e.match,o=e.location,n=_objectWithoutProperties(e,["breadcrumb","match","location"]),a=_objectSpread2({match:r,location:o,key:r.url},n);return _objectSpread2({},a,{breadcrumb:"string"==typeof t?React.createElement("span",{key:a.key},t):React__default.createElement(t,a)})},getDefaultBreadcrumb=function(e){var t=e.currentSection,r=e.location,o=e.pathSection,n=reactRouter.matchPath(o,_objectSpread2({},DEFAULT_MATCH_OPTIONS,{path:o}))||{url:"not-found"};return render({breadcrumb:humanize(t),match:n,location:r})},getBreadcrumbMatch=function(e){var c,u=e.currentSection,i=e.disableDefaults,t=e.excludePaths,b=e.location,l=e.pathSection,r=e.routes;return t&&t.some(function(e){return reactRouter.matchPath(l,{path:e,exact:!0,strict:!1})})?NO_BREADCRUMB:(r.some(function(e){var t=e.breadcrumb,r=e.matchOptions,o=e.path,n=_objectWithoutProperties(e,["breadcrumb","matchOptions","path"]);if(!o)throw new Error("withBreadcrumbs: `path` must be provided in every route object");var a=reactRouter.matchPath(l,_objectSpread2({},r||DEFAULT_MATCH_OPTIONS,{path:o}));return a&&null===t||!a&&r?(c=NO_BREADCRUMB,!0):!!a&&(c=!t&&i?NO_BREADCRUMB:render(_objectSpread2({breadcrumb:t||humanize(u),match:a,location:b},n)),!0)}),c||(i?NO_BREADCRUMB:getDefaultBreadcrumb({pathSection:l,currentSection:"/"===l?"Home":u,location:b})))},getBreadcrumbs=function(e){var a=e.routes,c=e.location,t=e.options,u=void 0===t?{}:t,i=[];return c.pathname.split("?")[0].split("/").reduce(function(e,t,r){var o=t?"".concat(e,"/").concat(t):"/";if("/"===o&&0!==r)return"";var n=getBreadcrumbMatch(_objectSpread2({currentSection:t,location:c,pathSection:o,routes:a},u));return n!==NO_BREADCRUMB&&i.push(n),"/"===o?"":o},""),i},flattenRoutes=function r(e){return e.reduce(function(e,t){return t.routes?e.concat([t].concat(_toConsumableArray(r(t.routes)))):e.concat(t)},[])},index=function(e,o){return function(t){var r={options:o,routes:flattenRoutes(e||[])};return reactRouter.useLocation?function(e){return React__default.createElement(t,_objectSpread2({},e,{breadcrumbs:getBreadcrumbs(_objectSpread2({},r,{location:reactRouter.useLocation()}))}))}:reactRouter.withRouter(function(e){return console.warn("[react-router-breadcrumbs-hoc]: react-router v4 support will be deprecated in the next major release. Please consider upgrading react-router and react-router-dom to >= 5.1.0"),React.createElement(t,_objectSpread2({},e,{breadcrumbs:getBreadcrumbs(_objectSpread2({},r,{location:e.location}))}))})}};exports.default=index,exports.getBreadcrumbs=getBreadcrumbs; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),React__default=_interopDefault(React),reactRouter=require("react-router"),__assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function __rest(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,a=Object.getOwnPropertySymbols(e);n<a.length;n++)t.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]]);return r}function __spreadArrays(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var a=Array(e),n=0,t=0;t<r;t++)for(var o=arguments[t],c=0,u=o.length;c<u;c++,n++)a[n]=o[c];return a}var DEFAULT_MATCH_OPTIONS={exact:!0},NO_BREADCRUMB="NO_BREADCRUMB",humanize=function(e){return e.replace(/^[\s_]+|[\s_]+$/g,"").replace(/[_\s]+/g," ").replace(/^[a-z]/,function(e){return e.toUpperCase()})},render=function(e){var t=e.breadcrumb,r=e.match,a=e.location,n=__rest(e,["breadcrumb","match","location"]),o=__assign({match:r,location:a,key:r.url},n);return __assign(__assign({},o),{breadcrumb:"string"==typeof t?React.createElement("span",{key:o.key},t):React__default.createElement(t,__assign({},o))})},getDefaultBreadcrumb=function(e){var t=e.currentSection,r=e.location,a=e.pathSection,n=reactRouter.matchPath(a,__assign(__assign({},DEFAULT_MATCH_OPTIONS),{path:a}))||{url:"not-found"};return render({breadcrumb:humanize(t),match:n,location:r})},getBreadcrumbMatch=function(e){var c,u=e.currentSection,s=e.disableDefaults,t=e.excludePaths,i=e.location,_=e.pathSection,r=e.routes;return t&&t.some(function(e){return reactRouter.matchPath(_,{path:e,exact:!0,strict:!1})})?NO_BREADCRUMB:(r.some(function(e){var t=e.breadcrumb,r=e.matchOptions,a=e.path,n=__rest(e,["breadcrumb","matchOptions","path"]);if(!a)throw new Error("withBreadcrumbs: `path` must be provided in every route object");var o=reactRouter.matchPath(_,__assign(__assign({},r||DEFAULT_MATCH_OPTIONS),{path:a}));return o&&null===t||!o&&r?(c=NO_BREADCRUMB,!0):!!o&&(c=!t&&s?NO_BREADCRUMB:render(__assign({breadcrumb:t||humanize(u),match:o,location:i},n)),!0)}),c||(s?NO_BREADCRUMB:getDefaultBreadcrumb({pathSection:_,currentSection:"/"===_?"Home":u,location:i})))},getBreadcrumbs=function(e){var o=e.routes,c=e.location,t=e.options,u=void 0===t?{}:t,s=[];return c.pathname.split("?")[0].split("/").reduce(function(e,t,r){var a=t?e+"/"+t:"/";if("/"==a&&0!==r)return"";var n=getBreadcrumbMatch(__assign({currentSection:t,location:c,pathSection:a,routes:o},u));return n!==NO_BREADCRUMB&&s.push(n),"/"==a?"":a},""),s},flattenRoutes=function r(e){return e.reduce(function(e,t){return t.routes?e.concat(__spreadArrays([t],r(t.routes))):e.concat(t)},[])},index=function(e,a){return function(t){var r={options:a,routes:flattenRoutes(e||[])};return reactRouter.useLocation?function(e){return React__default.createElement(t,__assign(__assign({},e),{breadcrumbs:getBreadcrumbs(__assign(__assign({},r),{location:reactRouter.useLocation()}))}))}:reactRouter.withRouter(function(e){return console.warn("[react-router-breadcrumbs-hoc]: react-router v4 support will be deprecated in the next major release. Please consider upgrading react-router and react-router-dom to >= 5.1.0"),React.createElement(t,__assign(__assign({},e),{breadcrumbs:getBreadcrumbs(__assign(__assign({},r),{location:e.location}))}))})}};exports.default=index,exports.getBreadcrumbs=getBreadcrumbs; | ||
//# sourceMappingURL=index.js.map |
import React, { createElement } from 'react'; | ||
import { useLocation, withRouter, matchPath } from 'react-router'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
return obj; | ||
} | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
keys.push.apply(keys, symbols); | ||
} | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
return keys; | ||
function __rest(s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
} | ||
return target; | ||
function __spreadArrays() { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
} | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
} | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
} | ||
/** | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* This script exports a HOC that accepts a routes array of objects | ||
* and an options object. | ||
* | ||
* API: | ||
* | ||
* withBreadcrumbs( | ||
* routes?: Array<Route>, | ||
* options? Object<Options>, | ||
* ): HigherOrderComponent | ||
* | ||
* More Info: | ||
* | ||
* https://github.com/icd2k3/react-router-breadcrumbs-hoc | ||
* | ||
*/ | ||
var DEFAULT_MATCH_OPTIONS = { | ||
@@ -130,9 +90,9 @@ exact: true | ||
var render = function render(_ref) { | ||
var Breadcrumb = _ref.breadcrumb, | ||
match = _ref.match, | ||
location = _ref.location, | ||
rest = _objectWithoutProperties(_ref, ["breadcrumb", "match", "location"]); | ||
var render = function render(_a) { | ||
var Breadcrumb = _a.breadcrumb, | ||
match = _a.match, | ||
location = _a.location, | ||
rest = __rest(_a, ["breadcrumb", "match", "location"]); | ||
var componentProps = _objectSpread2({ | ||
var componentProps = __assign({ | ||
match: match, | ||
@@ -143,6 +103,6 @@ location: location, | ||
return _objectSpread2({}, componentProps, { | ||
breadcrumb: typeof Breadcrumb === 'string' ? createElement('span', { | ||
return __assign(__assign({}, componentProps), { | ||
breadcrumb: typeof Breadcrumb === 'string' ? /*#__PURE__*/createElement('span', { | ||
key: componentProps.key | ||
}, Breadcrumb) : React.createElement(Breadcrumb, componentProps) | ||
}, Breadcrumb) : /*#__PURE__*/React.createElement(Breadcrumb, __assign({}, componentProps)) | ||
}); | ||
@@ -155,7 +115,7 @@ }; | ||
var getDefaultBreadcrumb = function getDefaultBreadcrumb(_ref2) { | ||
var currentSection = _ref2.currentSection, | ||
location = _ref2.location, | ||
pathSection = _ref2.pathSection; | ||
var match = matchPath(pathSection, _objectSpread2({}, DEFAULT_MATCH_OPTIONS, { | ||
var getDefaultBreadcrumb = function getDefaultBreadcrumb(_a) { | ||
var currentSection = _a.currentSection, | ||
location = _a.location, | ||
pathSection = _a.pathSection; | ||
var match = matchPath(pathSection, __assign(__assign({}, DEFAULT_MATCH_OPTIONS), { | ||
path: pathSection | ||
@@ -179,9 +139,9 @@ })) | ||
var getBreadcrumbMatch = function getBreadcrumbMatch(_ref3) { | ||
var currentSection = _ref3.currentSection, | ||
disableDefaults = _ref3.disableDefaults, | ||
excludePaths = _ref3.excludePaths, | ||
location = _ref3.location, | ||
pathSection = _ref3.pathSection, | ||
routes = _ref3.routes; | ||
var getBreadcrumbMatch = function getBreadcrumbMatch(_a) { | ||
var currentSection = _a.currentSection, | ||
disableDefaults = _a.disableDefaults, | ||
excludePaths = _a.excludePaths, | ||
location = _a.location, | ||
pathSection = _a.pathSection, | ||
routes = _a.routes; | ||
var breadcrumb; // Check the optional `excludePaths` option in `options` to see if the | ||
@@ -203,7 +163,7 @@ // current path should not include a breadcrumb. | ||
routes.some(function (_ref4) { | ||
var userProvidedBreadcrumb = _ref4.breadcrumb, | ||
matchOptions = _ref4.matchOptions, | ||
path = _ref4.path, | ||
rest = _objectWithoutProperties(_ref4, ["breadcrumb", "matchOptions", "path"]); | ||
routes.some(function (_a) { | ||
var userProvidedBreadcrumb = _a.breadcrumb, | ||
matchOptions = _a.matchOptions, | ||
path = _a.path, | ||
rest = __rest(_a, ["breadcrumb", "matchOptions", "path"]); | ||
@@ -214,3 +174,3 @@ if (!path) { | ||
var match = matchPath(pathSection, _objectSpread2({}, matchOptions || DEFAULT_MATCH_OPTIONS, { | ||
var match = matchPath(pathSection, __assign(__assign({}, matchOptions || DEFAULT_MATCH_OPTIONS), { | ||
path: path | ||
@@ -235,3 +195,3 @@ })); // If user passed breadcrumb: null OR custom match options to suppress a breadcrumb | ||
breadcrumb = render(_objectSpread2({ | ||
breadcrumb = render(__assign({ | ||
// Although we have a match, the user may be passing their react-router config object | ||
@@ -273,7 +233,7 @@ // which we support. The route config object may not have a `breadcrumb` param specified. | ||
var getBreadcrumbs = function getBreadcrumbs(_ref5) { | ||
var routes = _ref5.routes, | ||
location = _ref5.location, | ||
_ref5$options = _ref5.options, | ||
options = _ref5$options === void 0 ? {} : _ref5$options; | ||
var getBreadcrumbs = function getBreadcrumbs(_a) { | ||
var routes = _a.routes, | ||
location = _a.location, | ||
_b = _a.options, | ||
options = _b === void 0 ? {} : _b; | ||
var matches = []; | ||
@@ -287,3 +247,3 @@ var pathname = location.pathname; | ||
// `/1`, `/1/2`, `/1/2/3`. | ||
var pathSection = !currentSection ? '/' : "".concat(previousSection, "/").concat(currentSection); // Ignore trailing slash or double slashes in the URL | ||
var pathSection = !currentSection ? '/' : previousSection + "/" + currentSection; // Ignore trailing slash or double slashes in the URL | ||
@@ -294,3 +254,3 @@ if (pathSection === '/' && index !== 0) { | ||
var breadcrumb = getBreadcrumbMatch(_objectSpread2({ | ||
var breadcrumb = getBreadcrumbMatch(__assign({ | ||
currentSection: currentSection, | ||
@@ -320,3 +280,3 @@ location: location, | ||
if (route.routes) { | ||
return arr.concat([route].concat(_toConsumableArray(flattenRoutes(route.routes)))); | ||
return arr.concat(__spreadArrays([route], flattenRoutes(route.routes))); | ||
} | ||
@@ -344,4 +304,4 @@ | ||
return function (props) { | ||
return React.createElement(Component, _objectSpread2({}, props, { | ||
breadcrumbs: getBreadcrumbs(_objectSpread2({}, sharedBreadcrumbProps, { | ||
return /*#__PURE__*/React.createElement(Component, __assign(__assign({}, props), { | ||
breadcrumbs: getBreadcrumbs(__assign(__assign({}, sharedBreadcrumbProps), { | ||
location: useLocation() | ||
@@ -359,4 +319,4 @@ })) | ||
console.warn('[react-router-breadcrumbs-hoc]: react-router v4 support will be deprecated in the next major release. Please consider upgrading react-router and react-router-dom to >= 5.1.0'); | ||
return createElement(Component, _objectSpread2({}, props, { | ||
breadcrumbs: getBreadcrumbs(_objectSpread2({}, sharedBreadcrumbProps, { | ||
return /*#__PURE__*/createElement(Component, __assign(__assign({}, props), { | ||
breadcrumbs: getBreadcrumbs(__assign(__assign({}, sharedBreadcrumbProps), { | ||
location: props.location | ||
@@ -363,0 +323,0 @@ })) |
@@ -1,2 +0,2 @@ | ||
!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=e||self)["react-router-breadcrumbs-hoc"]={},e.React,e.ReactRouter)}(this,function(e,a,b){"use strict";var u="default"in a?a.default:a;function t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function m(o){for(var e=1;e<arguments.length;e++){var c=null!=arguments[e]?arguments[e]:{};e%2?t(Object(c),!0).forEach(function(e){var t,r,n;t=o,n=c[r=e],r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(c)):t(Object(c)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(c,e))})}return o}function d(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],0<=t.indexOf(r)||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],0<=t.indexOf(r)||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function o(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function h(e){return e.replace(/^[\s_]+|[\s_]+$/g,"").replace(/[_\s]+/g," ").replace(/^[a-z]/,function(e){return e.toUpperCase()})}function y(e){var t=e.breadcrumb,r=e.match,n=e.location,o=d(e,["breadcrumb","match","location"]),c=m({match:r,location:n,key:r.url},o);return m({},c,{breadcrumb:"string"==typeof t?a.createElement("span",{key:c.key},t):u.createElement(t,c)})}function l(e){var a,t,r,n,o,c,u=e.currentSection,i=e.disableDefaults,l=e.excludePaths,s=e.location,f=e.pathSection,p=e.routes;return l&&l.some(function(e){return b.matchPath(f,{path:e,exact:!0,strict:!1})})?v:(p.some(function(e){var t=e.breadcrumb,r=e.matchOptions,n=e.path,o=d(e,["breadcrumb","matchOptions","path"]);if(!n)throw new Error("withBreadcrumbs: `path` must be provided in every route object");var c=b.matchPath(f,m({},r||O,{path:n}));return c&&null===t||!c&&r?(a=v,!0):!!c&&(a=!t&&i?v:y(m({breadcrumb:t||h(u),match:c,location:s},o)),!0)}),a||(i?v:(r=(t={pathSection:f,currentSection:"/"===f?"Home":u,location:s}).currentSection,n=t.location,o=t.pathSection,c=b.matchPath(o,m({},O,{path:o}))||{url:"not-found"},y({breadcrumb:h(r),match:c,location:n}))))}function c(e){var c=e.routes,a=e.location,t=e.options,u=void 0===t?{}:t,i=[];return a.pathname.split("?")[0].split("/").reduce(function(e,t,r){var n=t?"".concat(e,"/").concat(t):"/";if("/"===n&&0!==r)return"";var o=l(m({currentSection:t,location:a,pathSection:n,routes:c},u));return o!==v&&i.push(o),"/"===n?"":n},""),i}var O={exact:!0},v="NO_BREADCRUMB";e.default=function(e,n){return function(t){var r={options:n,routes:function r(e){return e.reduce(function(e,t){return t.routes?e.concat([t].concat(o(r(t.routes)))):e.concat(t)},[])}(e||[])};return b.useLocation?function(e){return u.createElement(t,m({},e,{breadcrumbs:c(m({},r,{location:b.useLocation()}))}))}:b.withRouter(function(e){return console.warn("[react-router-breadcrumbs-hoc]: react-router v4 support will be deprecated in the next major release. Please consider upgrading react-router and react-router-dom to >= 5.1.0"),a.createElement(t,m({},e,{breadcrumbs:c(m({},r,{location:e.location}))}))})}},e.getBreadcrumbs=c,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-router")):"function"==typeof define&&define.amd?define(["exports","react","react-router"],e):e((t=t||self)["react-router-breadcrumbs-hoc"]={},t.React,t.ReactRouter)}(this,function(t,c,d){"use strict";var u="default"in c?c.default:c,h=function(){return(h=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function b(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r}function m(t){return t.replace(/^[\s_]+|[\s_]+$/g,"").replace(/[_\s]+/g," ").replace(/^[a-z]/,function(t){return t.toUpperCase()})}function v(t){var e=t.breadcrumb,r=t.match,n=t.location,o=b(t,["breadcrumb","match","location"]),a=h({match:r,location:n,key:r.url},o);return h(h({},a),{breadcrumb:"string"==typeof e?c.createElement("span",{key:a.key},e):u.createElement(e,h({},a))})}function l(t){var c,e,r,n,o,a,u=t.currentSection,i=t.disableDefaults,l=t.excludePaths,s=t.location,p=t.pathSection,f=t.routes;return l&&l.some(function(t){return d.matchPath(p,{path:t,exact:!0,strict:!1})})?O:(f.some(function(t){var e=t.breadcrumb,r=t.matchOptions,n=t.path,o=b(t,["breadcrumb","matchOptions","path"]);if(!n)throw new Error("withBreadcrumbs: `path` must be provided in every route object");var a=d.matchPath(p,h(h({},r||y),{path:n}));return a&&null===e||!a&&r?(c=O,!0):!!a&&(c=!e&&i?O:v(h({breadcrumb:e||m(u),match:a,location:s},o)),!0)}),c||(i?O:(r=(e={pathSection:p,currentSection:"/"===p?"Home":u,location:s}).currentSection,n=e.location,o=e.pathSection,a=d.matchPath(o,h(h({},y),{path:o}))||{url:"not-found"},v({breadcrumb:m(r),match:a,location:n}))))}function o(t){var a=t.routes,c=t.location,e=t.options,u=void 0===e?{}:e,i=[];return c.pathname.split("?")[0].split("/").reduce(function(t,e,r){var n=e?t+"/"+e:"/";if("/"==n&&0!==r)return"";var o=l(h({currentSection:e,location:c,pathSection:n,routes:a},u));return o!==O&&i.push(o),"/"==n?"":n},""),i}function a(t){return t.reduce(function(t,e){return e.routes?t.concat(function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),o=0,e=0;e<r;e++)for(var a=arguments[e],c=0,u=a.length;c<u;c++,o++)n[o]=a[c];return n}([e],a(e.routes))):t.concat(e)},[])}var y={exact:!0},O="NO_BREADCRUMB";t.default=function(t,n){return function(e){var r={options:n,routes:a(t||[])};return d.useLocation?function(t){return u.createElement(e,h(h({},t),{breadcrumbs:o(h(h({},r),{location:d.useLocation()}))}))}:d.withRouter(function(t){return console.warn("[react-router-breadcrumbs-hoc]: react-router v4 support will be deprecated in the next major release. Please consider upgrading react-router and react-router-dom to >= 5.1.0"),c.createElement(e,h(h({},t),{breadcrumbs:o(h(h({},r),{location:t.location}))}))})}},t.getBreadcrumbs=o,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-router-breadcrumbs-hoc", | ||
"version": "3.2.10", | ||
"version": "3.3.0", | ||
"description": "small, flexible, higher order component for rendering breadcrumbs with react-router 4.x", | ||
@@ -9,3 +9,3 @@ "repository": "icd2k3/react-router-breadcrumbs-hoc", | ||
"umd": "dist/umd/index.js", | ||
"types": "types/react-router-breadcrumbs-hoc/index.d.ts", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
@@ -16,5 +16,3 @@ "prepublishOnly": "npm run build", | ||
"test-build": "sh ./scripts/test-build.sh", | ||
"types": "yarn type-src && yarn type-descriptions", | ||
"type-src": "tsc -p tsconfig.json", | ||
"type-descriptions": "tsc -p types/react-router-breadcrumbs-hoc", | ||
"types": "tsc -p tsconfig.json", | ||
"lint": "eslint ./src/**" | ||
@@ -71,2 +69,3 @@ }, | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"rollup-plugin-uglify": "^6.0.2", | ||
@@ -73,0 +72,0 @@ "typescript": "^3.8.3" |
@@ -20,3 +20,5 @@ { | ||
"strictPropertyInitialization": true, | ||
"target": "es5" | ||
"target": "es5", | ||
"declaration": true, | ||
"declarationDir": "./dist" | ||
}, | ||
@@ -23,0 +25,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
35997
37
13
392
1