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

react-router-prompt

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-router-prompt - npm Package Compare versions

Comparing version 0.7.2-beta-1 to 0.7.2-beta-2

2

dist/index.d.ts

@@ -33,3 +33,3 @@ import { default as React } from 'react';

declare function ReactRouterPrompt({ when, children, beforeCancel, beforeConfirm, }: ReactRouterPromptProps): import("react/jsx-runtime").JSX.Element | null;
export { useConfirm, usePrompt };
export default ReactRouterPrompt;
export { useConfirm, usePrompt };

@@ -1,492 +0,52 @@

import je, { useEffect as Ae, useCallback as B } from "react";
import { useBlocker as we, useBeforeUnload as Oe } from "react-router-dom";
var O = { exports: {} }, j = {};
/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var fe;
function Se() {
if (fe) return j;
fe = 1;
var a = Symbol.for("react.transitional.element"), s = Symbol.for("react.fragment");
function c(d, f, v) {
var E = null;
if (v !== void 0 && (E = "" + v), f.key !== void 0 && (E = "" + f.key), "key" in f) {
v = {};
for (var g in f)
g !== "key" && (v[g] = f[g]);
} else v = f;
return f = v.ref, {
$$typeof: a,
type: d,
key: E,
ref: f !== void 0 ? f : null,
props: v
};
}
return j.Fragment = s, j.jsx = c, j.jsxs = c, j;
}
var A = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ve;
function he() {
return ve || (ve = 1, process.env.NODE_ENV !== "production" && function() {
function a(e) {
if (e == null) return null;
if (typeof e == "function")
return e.$$typeof === xe ? null : e.displayName || e.name || null;
if (typeof e == "string") return e;
switch (e) {
case P:
return "Fragment";
case pe:
return "Portal";
case L:
return "Profiler";
case F:
return "StrictMode";
case M:
return "Suspense";
case $:
return "SuspenseList";
}
if (typeof e == "object")
switch (typeof e.tag == "number" && console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
), e.$$typeof) {
case I:
return (e.displayName || "Context") + ".Provider";
case Z:
return (e._context.displayName || "Context") + ".Consumer";
case Y:
var r = e.render;
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
case W:
return r = e.displayName || null, r !== null ? r : a(e.type) || "Memo";
case U:
r = e._payload, e = e._init;
try {
return a(e(r));
} catch {
}
}
return null;
}
function s(e) {
return "" + e;
}
function c(e) {
try {
s(e);
var r = !1;
} catch {
r = !0;
}
if (r) {
r = console;
var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
return t.call(
r,
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
n
), s(e);
}
}
function d() {
}
function f() {
if (k === 0) {
D = console.log, ee = console.info, re = console.warn, te = console.error, oe = console.group, ne = console.groupCollapsed, ae = console.groupEnd;
var e = {
configurable: !0,
enumerable: !0,
value: d,
writable: !0
};
Object.defineProperties(console, {
info: e,
log: e,
warn: e,
error: e,
group: e,
groupCollapsed: e,
groupEnd: e
});
}
k++;
}
function v() {
if (k--, k === 0) {
var e = { configurable: !0, enumerable: !0, writable: !0 };
Object.defineProperties(console, {
log: y({}, e, { value: D }),
info: y({}, e, { value: ee }),
warn: y({}, e, { value: re }),
error: y({}, e, { value: te }),
group: y({}, e, { value: oe }),
groupCollapsed: y({}, e, { value: ne }),
groupEnd: y({}, e, { value: ae })
});
}
0 > k && console.error(
"disabledDepth fell below zero. This is a bug in React. Please file an issue."
);
}
function E(e) {
if (J === void 0)
try {
throw Error();
} catch (t) {
var r = t.stack.trim().match(/\n( *(at )?)/);
J = r && r[1] || "", ue = -1 < t.stack.indexOf(`
at`) ? " (<anonymous>)" : -1 < t.stack.indexOf("@") ? "@unknown:0:0" : "";
}
return `
` + J + e + ue;
}
function g(e, r) {
if (!e || V) return "";
var t = z.get(e);
if (t !== void 0) return t;
V = !0, t = Error.prepareStackTrace, Error.prepareStackTrace = void 0;
var n = null;
n = T.H, T.H = null, f();
try {
var i = {
DetermineComponentFrameRoot: function() {
try {
if (r) {
var _ = function() {
throw Error();
};
if (Object.defineProperty(_.prototype, "props", {
set: function() {
throw Error();
}
}), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(_, []);
} catch (m) {
var w = m;
}
Reflect.construct(e, [], _);
} else {
try {
_.call();
} catch (m) {
w = m;
}
e.call(_.prototype);
}
} else {
try {
throw Error();
} catch (m) {
w = m;
}
(_ = e()) && typeof _.catch == "function" && _.catch(function() {
});
}
} catch (m) {
if (m && w && typeof m.stack == "string")
return [m.stack, w.stack];
}
return [null, null];
}
};
i.DetermineComponentFrameRoot.displayName = "DetermineComponentFrameRoot";
var u = Object.getOwnPropertyDescriptor(
i.DetermineComponentFrameRoot,
"name"
);
u && u.configurable && Object.defineProperty(
i.DetermineComponentFrameRoot,
"name",
{ value: "DetermineComponentFrameRoot" }
);
var o = i.DetermineComponentFrameRoot(), b = o[0], R = o[1];
if (b && R) {
var l = b.split(`
`), p = R.split(`
`);
for (o = u = 0; u < l.length && !l[u].includes(
"DetermineComponentFrameRoot"
); )
u++;
for (; o < p.length && !p[o].includes(
"DetermineComponentFrameRoot"
); )
o++;
if (u === l.length || o === p.length)
for (u = l.length - 1, o = p.length - 1; 1 <= u && 0 <= o && l[u] !== p[o]; )
o--;
for (; 1 <= u && 0 <= o; u--, o--)
if (l[u] !== p[o]) {
if (u !== 1 || o !== 1)
do
if (u--, o--, 0 > o || l[u] !== p[o]) {
var C = `
` + l[u].replace(
" at new ",
" at "
);
return e.displayName && C.includes("<anonymous>") && (C = C.replace("<anonymous>", e.displayName)), typeof e == "function" && z.set(e, C), C;
}
while (1 <= u && 0 <= o);
break;
}
}
} finally {
V = !1, T.H = n, v(), Error.prepareStackTrace = t;
}
return l = (l = e ? e.displayName || e.name : "") ? E(l) : "", typeof e == "function" && z.set(e, l), l;
}
function x(e) {
if (e == null) return "";
if (typeof e == "function") {
var r = e.prototype;
return g(
e,
!(!r || !r.isReactComponent)
);
}
if (typeof e == "string") return E(e);
switch (e) {
case M:
return E("Suspense");
case $:
return E("SuspenseList");
}
if (typeof e == "object")
switch (e.$$typeof) {
case Y:
return e = g(e.render, !1), e;
case W:
return x(e.type);
case U:
r = e._payload, e = e._init;
try {
return x(e(r));
} catch {
}
}
return "";
}
function S() {
var e = T.A;
return e === null ? null : e.getOwner();
}
function be(e) {
if (K.call(e, "key")) {
var r = Object.getOwnPropertyDescriptor(e, "key").get;
if (r && r.isReactWarning) return !1;
}
return e.key !== void 0;
}
function me(e, r) {
function t() {
se || (se = !0, console.error(
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
r
));
}
t.isReactWarning = !0, Object.defineProperty(e, "key", {
get: t,
configurable: !0
});
}
function ge() {
var e = a(this.type);
return ie[e] || (ie[e] = !0, console.error(
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
)), e = this.props.ref, e !== void 0 ? e : null;
}
function _e(e, r, t, n, i, u) {
return t = u.ref, e = {
$$typeof: N,
type: e,
key: r,
props: u,
_owner: i
}, (t !== void 0 ? t : null) !== null ? Object.defineProperty(e, "ref", {
enumerable: !1,
get: ge
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: 0
}), Object.defineProperty(e, "_debugInfo", {
configurable: !1,
enumerable: !1,
writable: !0,
value: null
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
}
function G(e, r, t, n, i, u) {
if (typeof e == "string" || typeof e == "function" || e === P || e === L || e === F || e === M || e === $ || e === Re || typeof e == "object" && e !== null && (e.$$typeof === U || e.$$typeof === W || e.$$typeof === I || e.$$typeof === Z || e.$$typeof === Y || e.$$typeof === ke || e.getModuleId !== void 0)) {
var o = r.children;
if (o !== void 0)
if (n)
if (q(o)) {
for (n = 0; n < o.length; n++)
H(o[n], e);
Object.freeze && Object.freeze(o);
} else
console.error(
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
);
else H(o, e);
} else
o = "", (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (o += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."), e === null ? n = "null" : q(e) ? n = "array" : e !== void 0 && e.$$typeof === N ? (n = "<" + (a(e.type) || "Unknown") + " />", o = " Did you accidentally export a JSX literal instead of a component?") : n = typeof e, console.error(
"React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",
n,
o
);
if (K.call(r, "key")) {
o = a(e);
var b = Object.keys(r).filter(function(l) {
return l !== "key";
});
n = 0 < b.length ? "{key: someKey, " + b.join(": ..., ") + ": ...}" : "{key: someKey}", le[o + n] || (b = 0 < b.length ? "{" + b.join(": ..., ") + ": ...}" : "{}", console.error(
`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,
n,
o,
b,
o
), le[o + n] = !0);
}
if (o = null, t !== void 0 && (c(t), o = "" + t), be(r) && (c(r.key), o = "" + r.key), "key" in r) {
t = {};
for (var R in r)
R !== "key" && (t[R] = r[R]);
} else t = r;
return o && me(
t,
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
), _e(e, o, u, i, S(), t);
}
function H(e, r) {
if (typeof e == "object" && e && e.$$typeof !== Ce) {
if (q(e))
for (var t = 0; t < e.length; t++) {
var n = e[t];
h(n) && X(n, r);
}
else if (h(e))
e._store && (e._store.validated = 1);
else if (e === null || typeof e != "object" ? t = null : (t = Q && e[Q] || e["@@iterator"], t = typeof t == "function" ? t : null), typeof t == "function" && t !== e.entries && (t = t.call(e), t !== e))
for (; !(e = t.next()).done; )
h(e.value) && X(e.value, r);
}
}
function h(e) {
return typeof e == "object" && e !== null && e.$$typeof === N;
}
function X(e, r) {
if (e._store && !e._store.validated && e.key == null && (e._store.validated = 1, r = Te(r), !ce[r])) {
ce[r] = !0;
var t = "";
e && e._owner != null && e._owner !== S() && (t = null, typeof e._owner.tag == "number" ? t = a(e._owner.type) : typeof e._owner.name == "string" && (t = e._owner.name), t = " It was passed a child from " + t + ".");
var n = T.getCurrentStack;
T.getCurrentStack = function() {
var i = x(e.type);
return n && (i += n() || ""), i;
}, console.error(
'Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',
r,
t
), T.getCurrentStack = n;
}
}
function Te(e) {
var r = "", t = S();
return t && (t = a(t.type)) && (r = `
Check the render method of \`` + t + "`."), r || (e = a(e)) && (r = `
Check the top-level render call using <` + e + ">."), r;
}
var ye = je, N = Symbol.for("react.transitional.element"), pe = Symbol.for("react.portal"), P = Symbol.for("react.fragment"), F = Symbol.for("react.strict_mode"), L = Symbol.for("react.profiler"), Z = Symbol.for("react.consumer"), I = Symbol.for("react.context"), Y = Symbol.for("react.forward_ref"), M = Symbol.for("react.suspense"), $ = Symbol.for("react.suspense_list"), W = Symbol.for("react.memo"), U = Symbol.for("react.lazy"), Re = Symbol.for("react.offscreen"), Q = Symbol.iterator, xe = Symbol.for("react.client.reference"), T = ye.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = Object.prototype.hasOwnProperty, y = Object.assign, ke = Symbol.for("react.client.reference"), q = Array.isArray, k = 0, D, ee, re, te, oe, ne, ae;
d.__reactDisabledLog = !0;
var J, ue, V = !1, z = new (typeof WeakMap == "function" ? WeakMap : Map)(), Ce = Symbol.for("react.client.reference"), se, ie = {}, le = {}, ce = {};
A.Fragment = P, A.jsx = function(e, r, t, n, i) {
return G(e, r, t, !1, n, i);
}, A.jsxs = function(e, r, t, n, i) {
return G(e, r, t, !0, n, i);
};
}()), A;
}
var Ee;
function Ne() {
return Ee || (Ee = 1, process.env.NODE_ENV === "production" ? O.exports = Se() : O.exports = he()), O.exports;
}
var de = Ne();
function Pe(a) {
const s = we(a);
return Ae(() => {
s.state === "blocked" && !a && s.reset();
}, [s, a]), Oe(
B(
(c) => {
(typeof a == "boolean" && a === !0 || // @ts-ignore Reload case -- No location present
typeof a == "function" && a()) && (c.preventDefault(), c.returnValue = "Changes that you made may not be saved.");
import { jsx as f, Fragment as m } from "react/jsx-runtime";
import { useEffect as l, useCallback as n } from "react";
import { useBlocker as p, useBeforeUnload as d } from "react-router-dom";
function k(t) {
const o = p(t);
return l(() => {
o.state === "blocked" && !t && o.reset();
}, [o, t]), d(
n(
(e) => {
(typeof t == "boolean" && t === !0 || // @ts-expect-error Reload case -- No location present
typeof t == "function" && t()) && (e.preventDefault(), e.returnValue = "Changes that you made may not be saved.");
},
[a]
[t]
),
{ capture: !0 }
), s;
), o;
}
const Ye = (a) => {
const s = Pe(a), c = () => {
s.state === "blocked" && s.reset();
}, d = () => {
s.state === "blocked" && setTimeout(s.proceed, 0);
const y = (t) => {
const o = k(t), e = () => {
o.state === "blocked" && o.reset();
}, r = () => {
o.state === "blocked" && setTimeout(o.proceed, 0);
};
return {
isActive: s.state === "blocked",
onConfirm: d,
resetConfirmation: c
isActive: o.state === "blocked",
onConfirm: r,
resetConfirmation: e
};
};
function We({
when: a,
children: s,
beforeCancel: c,
beforeConfirm: d
function v({
when: t,
children: o,
beforeCancel: e,
beforeConfirm: r
}) {
const { isActive: f, onConfirm: v, resetConfirmation: E } = Ye(a), g = B(async () => {
d && await d(), v();
}, [d, v]), x = B(async () => {
c && await c(), E();
}, [c, E]);
return f ? /* @__PURE__ */ de.jsx(de.Fragment, { children: s({
const { isActive: c, onConfirm: s, resetConfirmation: i } = y(t), a = n(async () => {
r && await r(), s();
}, [r, s]), u = n(async () => {
e && await e(), i();
}, [e, i]);
return c ? /* @__PURE__ */ f(m, { children: o({
isActive: !0,
onConfirm: g,
onCancel: x
onConfirm: a,
onCancel: u
}) }) : null;
}
export {
We as default,
Ye as useConfirm,
Pe as usePrompt
v as default,
y as useConfirm,
k as usePrompt
};
{
"version": "0.7.2-beta-1",
"version": "0.7.2-beta-2",
"name": "react-router-prompt",

@@ -15,4 +15,3 @@ "description": "React Router Navigation Prompt for v6",

"import": "./dist/react-router-prompt.js",
"require": "./dist/react-router-prompt.umd.cjs",
"types": "./dist/index.d.ts"
"require": "./dist/react-router-prompt.umd.cjs"
}

@@ -35,25 +34,18 @@ },

],
"husky": {
"hooks": {
"pre-commit": "pnpm lint"
}
},
"devDependencies": {
"@size-limit/preset-small-lib": "^11.1.6",
"@types/react": "^19.0.1",
"@size-limit/preset-small-lib": "^11.0.2",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@vitejs/plugin-react-swc": "^3.7.2",
"eslint": "^8.57.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"history": "^5.3.0",
"husky": "^9.1.7",
"husky": "^9.0.11",
"path": "^0.12.7",

@@ -63,7 +55,7 @@ "prettier": "^3.4.2",

"react-dom": "^19.0.0",
"react-router-dom": "^7.0.2",
"size-limit": "^11.1.6",
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-plugin-dts": "^4.3.0",
"react-router-dom": "^6.22.1",
"size-limit": "^11.0.2",
"typescript": "^5.3.3",
"vite": "^6.0.5",
"vite-plugin-dts": "^4.4.0",
"vite-tsconfig-paths": "^5.1.4"

@@ -70,0 +62,0 @@ },

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