react-router-prompt
Advanced tools
Comparing version
import React from "react"; | ||
import { unstable_BlockerFunction as BlockerFunction } from "react-router-dom"; | ||
import useConfirm from "./hooks/use-confirm"; | ||
import usePrompt from "./hooks/use-prompt"; | ||
type ReactRouterPromptProps = { | ||
@@ -32,1 +34,2 @@ when: boolean | BlockerFunction; | ||
export default ReactRouterPrompt; | ||
export { useConfirm, usePrompt }; |
@@ -7,4 +7,4 @@ import Oe, { useEffect as ur, useCallback as H } from "react"; | ||
}, | ||
set exports(l) { | ||
X = l; | ||
set exports(s) { | ||
X = s; | ||
} | ||
@@ -26,4 +26,4 @@ }, F = {}; | ||
Te = 1; | ||
var l = Oe, c = Symbol.for("react.element"), b = Symbol.for("react.fragment"), g = Object.prototype.hasOwnProperty, S = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, C = { key: !0, ref: !0, __self: !0, __source: !0 }; | ||
function T(y, d, w) { | ||
var s = Oe, c = Symbol.for("react.element"), b = Symbol.for("react.fragment"), g = Object.prototype.hasOwnProperty, S = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, C = { key: !0, ref: !0, __self: !0, __source: !0 }; | ||
function T(E, d, w) { | ||
var m, R = {}, O = null, $ = null; | ||
@@ -33,6 +33,6 @@ w !== void 0 && (O = "" + w), d.key !== void 0 && (O = "" + d.key), d.ref !== void 0 && ($ = d.ref); | ||
g.call(d, m) && !C.hasOwnProperty(m) && (R[m] = d[m]); | ||
if (y && y.defaultProps) | ||
for (m in d = y.defaultProps, d) | ||
if (E && E.defaultProps) | ||
for (m in d = E.defaultProps, d) | ||
R[m] === void 0 && (R[m] = d[m]); | ||
return { $$typeof: c, type: y, key: O, ref: $, props: R, _owner: S.current }; | ||
return { $$typeof: c, type: E, key: O, ref: $, props: R, _owner: S.current }; | ||
} | ||
@@ -54,3 +54,3 @@ return F.Fragment = b, F.jsx = T, F.jsxs = T, F; | ||
return Ce || (Ce = 1, process.env.NODE_ENV !== "production" && function() { | ||
var l = Oe, c = Symbol.for("react.element"), b = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), C = Symbol.for("react.profiler"), T = Symbol.for("react.provider"), y = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), m = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), $ = Symbol.for("react.offscreen"), Z = Symbol.iterator, Pe = "@@iterator"; | ||
var s = Oe, c = Symbol.for("react.element"), b = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), S = Symbol.for("react.strict_mode"), C = Symbol.for("react.profiler"), T = Symbol.for("react.provider"), E = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), m = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), $ = Symbol.for("react.offscreen"), Z = Symbol.iterator, Pe = "@@iterator"; | ||
function Se(e) { | ||
@@ -62,3 +62,3 @@ if (e === null || typeof e != "object") | ||
} | ||
var x = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
var x = s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
function v(e) { | ||
@@ -84,3 +84,3 @@ { | ||
function Fe(e) { | ||
return !!(typeof e == "string" || typeof e == "function" || e === g || e === C || De || e === S || e === w || e === m || Ae || e === $ || xe || je || ke || typeof e == "object" && e !== null && (e.$$typeof === O || e.$$typeof === R || e.$$typeof === T || e.$$typeof === y || e.$$typeof === d || // This needs to include all possible module reference object | ||
return !!(typeof e == "string" || typeof e == "function" || e === g || e === C || De || e === S || e === w || e === m || Ae || e === $ || xe || je || ke || typeof e == "object" && e !== null && (e.$$typeof === O || e.$$typeof === R || e.$$typeof === T || e.$$typeof === E || e.$$typeof === d || // This needs to include all possible module reference object | ||
// types supported by any Flight configuration anywhere since | ||
@@ -124,3 +124,3 @@ // we don't know which Flight build this will end up being used | ||
switch (e.$$typeof) { | ||
case y: | ||
case E: | ||
var r = e; | ||
@@ -278,14 +278,14 @@ return ee(r) + ".Consumer"; | ||
`), p = n.stack.split(` | ||
`), s = a.length - 1, f = p.length - 1; s >= 1 && f >= 0 && a[s] !== p[f]; ) | ||
f--; | ||
for (; s >= 1 && f >= 0; s--, f--) | ||
if (a[s] !== p[f]) { | ||
if (s !== 1 || f !== 1) | ||
`), f = a.length - 1, l = p.length - 1; f >= 1 && l >= 0 && a[f] !== p[l]; ) | ||
l--; | ||
for (; f >= 1 && l >= 0; f--, l--) | ||
if (a[f] !== p[l]) { | ||
if (f !== 1 || l !== 1) | ||
do | ||
if (s--, f--, f < 0 || a[s] !== p[f]) { | ||
var E = ` | ||
` + a[s].replace(" at new ", " at "); | ||
return e.displayName && E.includes("<anonymous>") && (E = E.replace("<anonymous>", e.displayName)), typeof e == "function" && Y.set(e, E), E; | ||
if (f--, l--, l < 0 || a[f] !== p[l]) { | ||
var y = ` | ||
` + a[f].replace(" at new ", " at "); | ||
return e.displayName && y.includes("<anonymous>") && (y = y.replace("<anonymous>", e.displayName)), typeof e == "function" && Y.set(e, y), y; | ||
} | ||
while (s >= 1 && f >= 0); | ||
while (f >= 1 && l >= 0); | ||
break; | ||
@@ -356,4 +356,4 @@ } | ||
a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); | ||
} catch (s) { | ||
a = s; | ||
} catch (f) { | ||
a = f; | ||
} | ||
@@ -475,9 +475,9 @@ a && !(a instanceof Error) && (V(i), v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), V(null)), a instanceof Error && !(a.message in le) && (le[a.message] = !0, V(i), v("Failed %s type: %s", t, a.message), V(null)); | ||
if (e && e.defaultProps) { | ||
var s = e.defaultProps; | ||
for (u in s) | ||
o[u] === void 0 && (o[u] = s[u]); | ||
var f = e.defaultProps; | ||
for (u in f) | ||
o[u] === void 0 && (o[u] = f[u]); | ||
} | ||
if (a || p) { | ||
var f = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; | ||
a && Ke(o, f), p && He(o, f); | ||
var l = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; | ||
a && Ke(o, l), p && He(o, l); | ||
} | ||
@@ -523,3 +523,3 @@ return Xe(e, a, p, i, n, D.current, o); | ||
} | ||
var Ee = {}; | ||
var ye = {}; | ||
function er(e) { | ||
@@ -537,3 +537,3 @@ { | ||
} | ||
function ye(e, r) { | ||
function Ee(e, r) { | ||
{ | ||
@@ -544,5 +544,5 @@ if (!e._store || e._store.validated || e.key != null) | ||
var t = er(r); | ||
if (Ee[t]) | ||
if (ye[t]) | ||
return; | ||
Ee[t] = !0; | ||
ye[t] = !0; | ||
var n = ""; | ||
@@ -559,3 +559,3 @@ e && e._owner && e._owner !== G.current && (n = " It was passed a child from " + _(e._owner.type) + "."), j(e), v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), j(null); | ||
var n = e[t]; | ||
K(n) && ye(n, r); | ||
K(n) && Ee(n, r); | ||
} | ||
@@ -568,3 +568,3 @@ else if (K(e)) | ||
for (var u = i.call(e), o; !(o = u.next()).done; ) | ||
K(o.value) && ye(o.value, r); | ||
K(o.value) && Ee(o.value, r); | ||
} | ||
@@ -618,22 +618,22 @@ } | ||
p ? a += p : a += ge(); | ||
var s; | ||
e === null ? s = "null" : q(e) ? s = "array" : e !== void 0 && e.$$typeof === c ? (s = "<" + (_(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : s = typeof e, v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", s, a); | ||
var f; | ||
e === null ? f = "null" : q(e) ? f = "array" : e !== void 0 && e.$$typeof === c ? (f = "<" + (_(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : f = typeof e, v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", f, a); | ||
} | ||
var f = Ze(e, r, t, i, u); | ||
if (f == null) | ||
return f; | ||
var l = Ze(e, r, t, i, u); | ||
if (l == null) | ||
return l; | ||
if (o) { | ||
var E = r.children; | ||
if (E !== void 0) | ||
var y = r.children; | ||
if (y !== void 0) | ||
if (n) | ||
if (q(E)) { | ||
for (var k = 0; k < E.length; k++) | ||
Re(E[k], e); | ||
Object.freeze && Object.freeze(E); | ||
if (q(y)) { | ||
for (var k = 0; k < y.length; k++) | ||
Re(y[k], e); | ||
Object.freeze && Object.freeze(y); | ||
} else | ||
v("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 | ||
Re(E, e); | ||
Re(y, e); | ||
} | ||
return e === g ? tr(f) : rr(f), f; | ||
return e === g ? tr(l) : rr(l), l; | ||
} | ||
@@ -651,15 +651,16 @@ } | ||
} | ||
(function(l) { | ||
process.env.NODE_ENV === "production" ? l.exports = cr() : l.exports = dr(); | ||
(function(s) { | ||
process.env.NODE_ENV === "production" ? s.exports = cr() : s.exports = dr(); | ||
})(lr); | ||
function vr(l) { | ||
const c = sr(l); | ||
function vr(s) { | ||
const c = sr(s); | ||
return ur(() => { | ||
c.state === "blocked" && !l && c.reset(); | ||
}, [c, l]), fr( | ||
c.state === "blocked" && !s && c.reset(); | ||
}, [c, s]), fr( | ||
H( | ||
(b) => { | ||
l && (b.preventDefault(), b.returnValue = "Changes that you made may not be saved."); | ||
(typeof s == "boolean" && s === !0 || // @ts-ignore Reload case -- No location present | ||
typeof s == "function" && s()) && (b.preventDefault(), b.returnValue = "Changes that you made may not be saved."); | ||
}, | ||
[l] | ||
[s] | ||
), | ||
@@ -669,4 +670,4 @@ { capture: !0 } | ||
} | ||
const pr = (l) => { | ||
const c = vr(l), b = () => { | ||
const pr = (s) => { | ||
const c = vr(s), b = () => { | ||
c.state === "blocked" && c.reset(); | ||
@@ -683,3 +684,3 @@ }, g = () => { | ||
function gr({ | ||
when: l, | ||
when: s, | ||
children: c, | ||
@@ -689,3 +690,3 @@ beforeCancel: b, | ||
}) { | ||
const { isActive: S, onConfirm: C, resetConfirmation: T } = pr(l), y = H(async () => { | ||
const { isActive: S, onConfirm: C, resetConfirmation: T } = pr(s), E = H(async () => { | ||
g && await g(), C(); | ||
@@ -697,3 +698,3 @@ }, [g, C]), d = H(async () => { | ||
isActive: !0, | ||
onConfirm: y, | ||
onConfirm: E, | ||
onCancel: d | ||
@@ -703,3 +704,5 @@ }) }) : null; | ||
export { | ||
gr as default | ||
gr as default, | ||
pr as useConfirm, | ||
vr as usePrompt | ||
}; |
{ | ||
"name": "react-router-prompt", | ||
"version": "0.5.3", | ||
"version": "0.5.4-beta.1", | ||
"description": "React Router Navigation Prompt for v6", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62082
1.09%877
0.69%