Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boring-router-react

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boring-router-react - npm Package Compare versions

Comparing version 0.3.3 to 0.3.7

2

bld/library/link.d.ts

@@ -12,4 +12,4 @@ import { RouteBuilder, RouteMatch, RouteMatchSharedToParamDict } from 'boring-router';

}
export declare const Link: (<T extends RouteMatch<import("boring-router").GeneralParamDict, import("boring-router").NextRouteMatch<import("boring-router").GeneralParamDict, string | undefined, string>, string | undefined, string, object> | RouteBuilder<string>>({ className, to, params, replace, toggle, leave, onClick, ...props }: LinkProps<T>) => JSX.Element) & {
export declare const Link: (<T extends RouteMatch<import("boring-router").GeneralParamDict, import("boring-router").NextRouteMatch<import("boring-router").GeneralParamDict, string | undefined, string>, string | undefined, string, object> | RouteBuilder<string>>(props: LinkProps<T>) => JSX.Element) & {
displayName: string;
};

@@ -7,8 +7,10 @@ "use strict";

const mobx_react_lite_1 = require("mobx-react-lite");
const react_1 = tslib_1.__importStar(require("react"));
const react_1 = tslib_1.__importDefault(require("react"));
const _utils_1 = require("./@utils");
exports.Link = mobx_react_lite_1.observer(({ className, to, params, replace = false, toggle = false, leave, onClick, ...props }) => {
let store = mobx_react_lite_1.useLocalStore(() => {
exports.Link = mobx_react_lite_1.observer((props) => {
let { to, params, replace, toggle = false, leave = false, onClick, ...restProps } = props;
let store = mobx_react_lite_1.useLocalStore(props => {
return {
get href() {
let { to, params } = props;
try {

@@ -27,34 +29,39 @@ if (to instanceof boring_router_1.RouteMatch) {

},
// eslint-disable-next-line @magicspace/empty-line-around-blocks
get composedOnClick() {
let { to, params, leave, toggle, replace, onClick } = props;
return _utils_1.composeEventHandler([
onClick,
(event) => {
if (event.ctrlKey ||
event.metaKey ||
event.button === 1 /* middle button */) {
return;
}
event.preventDefault();
if (to instanceof boring_router_1.RouteMatch) {
let leaveOption = leave === undefined ? toggle && to.$matched : leave;
if (replace) {
to.$replace(params, { leave: leaveOption });
}
else {
to.$push(params, { leave: leaveOption });
}
}
else {
if (replace) {
to.$replace();
}
else {
to.$push();
}
}
},
], true);
// eslint-disable-next-line @magicspace/empty-line-around-blocks
},
};
});
let composedOnClick = react_1.useCallback(_utils_1.composeEventHandler([
onClick,
(event) => {
if (event.ctrlKey ||
event.metaKey ||
event.button === 1 /* middle button */) {
return;
}
event.preventDefault();
if (to instanceof boring_router_1.RouteMatch) {
let leaveOption = leave === undefined ? toggle && to.$matched : leave;
if (replace) {
to.$replace(params, { leave: leaveOption });
}
else {
to.$push(params, { leave: leaveOption });
}
}
else {
if (replace) {
to.$replace();
}
else {
to.$push();
}
}
},
], true), [onClick]);
return (react_1.default.createElement("a", Object.assign({ className: className, href: store.href, onClick: composedOnClick }, props)));
}, { to, params, leave, toggle, replace, onClick });
return (react_1.default.createElement("a", Object.assign({}, restProps, { href: store.href, onClick: store.composedOnClick })));
});
//# sourceMappingURL=link.js.map

@@ -8,4 +8,4 @@ /// <reference types="react" />

}
export declare const NavLink: (<T extends RouteMatch<import("boring-router").GeneralParamDict, import("boring-router").NextRouteMatch<import("boring-router").GeneralParamDict, string | undefined, string>, string | undefined, string, object> | RouteBuilder<string>>({ className, activeClassName, exact, ...props }: NavLinkProps<T>) => JSX.Element) & {
export declare const NavLink: (<T extends RouteMatch<import("boring-router").GeneralParamDict, import("boring-router").NextRouteMatch<import("boring-router").GeneralParamDict, string | undefined, string>, string | undefined, string, object> | RouteBuilder<string>>(props: NavLinkProps<T>) => JSX.Element) & {
displayName: string;
};

@@ -8,21 +8,34 @@ "use strict";

const mobx_react_lite_1 = require("mobx-react-lite");
const react_1 = tslib_1.__importStar(require("react"));
const react_1 = tslib_1.__importDefault(require("react"));
const link_1 = require("./link");
exports.NavLink = mobx_react_lite_1.observer(({ className, activeClassName = 'active', exact, ...props }) => {
let { to } = props;
let route = react_1.useMemo(() => {
if (to instanceof boring_router_1.RouteBuilder) {
let builderRoute = to.$route;
if (!(builderRoute instanceof boring_router_1.RouteMatch)) {
throw new Error('`RouteBuilder` for `NavLink` component must have first building part as a `Route`');
}
return builderRoute;
}
else {
return to;
}
}, [to]);
let matched = exact ? route.$exact : route.$matched;
return (react_1.default.createElement(link_1.Link, Object.assign({ className: classnames_1.default(className, matched && activeClassName) }, props)));
exports.NavLink = mobx_react_lite_1.observer((props) => {
let { to, exact = false } = props;
let store = mobx_react_lite_1.useLocalStore(props => {
return {
get route() {
let { to } = props;
if (to instanceof boring_router_1.RouteBuilder) {
let builderRoute = to.$route;
if (!(builderRoute instanceof boring_router_1.RouteMatch)) {
throw new Error('`RouteBuilder` for `NavLink` component must have first building part as a `Route`');
}
return builderRoute;
}
else {
return to;
}
// eslint-disable-next-line @magicspace/empty-line-around-blocks
},
// eslint-disable-next-line @magicspace/empty-line-around-blocks
get matched() {
let { exact = false } = props;
let route = this.route;
return exact ? route.$exact : route.$matched;
// eslint-disable-next-line @magicspace/empty-line-around-blocks
},
};
}, { to, exact });
let { className, activeClassName = 'active', exact: _exact, ...restProps } = props;
return (react_1.default.createElement(link_1.Link, Object.assign({ className: classnames_1.default(className, store.matched && activeClassName) }, restProps)));
});
//# sourceMappingURL=nav-link.js.map
{
"name": "boring-router-react",
"version": "0.3.3",
"version": "0.3.7",
"description": "A type-safe MobX router with parallel routing support.",

@@ -36,3 +36,3 @@ "repository": {

},
"gitHead": "ca1048def542e1f8eb46bfaac8205a3f403cb16a"
"gitHead": "cc47f16ea2602ec9984c93b2385a0b1f3f59c169"
}

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc