@qubhq/react-router-prompt 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { useBlocker as x, useBeforeUnload as b } from "react-router";
4
4
  function y(o, c, n) {
5
5
  const t = x(o);
6
6
  return p(() => {
7
- t.state === "blocked" && t.location && c && c(t.location), t.state === "blocked" && !o && (n === "proceed" ? t.proceed() : t.reset());
7
+ t.state === "blocked" && t.location && c && c(t.location), t.state === "blocked" && !o && (n === "proceed" ? setTimeout(t.proceed, 0) : t.reset());
8
8
  }, [t, n, o, c]), b(
9
9
  a(
10
10
  (e) => {
@@ -19,11 +19,11 @@ function y(o, c, n) {
19
19
  const C = (o, c) => {
20
20
  const [n, t] = k(null), e = y(
21
21
  o,
22
- (r) => {
23
- t(r);
22
+ (s) => {
23
+ t(s);
24
24
  },
25
25
  c
26
- ), s = () => {
26
+ ), r = () => {
27
27
  e.state === "blocked" && e.reset();
28
28
  }, i = () => {
29
29
  e.state === "blocked" && setTimeout(e.proceed, 0);
@@ -31,7 +31,7 @@ const C = (o, c) => {
31
31
  return {
32
32
  isActive: e.state === "blocked",
33
33
  onConfirm: i,
34
- resetConfirmation: s,
34
+ resetConfirmation: r,
35
35
  nextLocation: n || void 0
36
36
  };
37
37
  };
@@ -42,15 +42,15 @@ function R({
42
42
  beforeConfirm: t,
43
43
  defaultBehaviour: e = "reset"
44
44
  }) {
45
- const { isActive: s, onConfirm: i, resetConfirmation: r, nextLocation: u } = C(
45
+ const { isActive: r, onConfirm: i, resetConfirmation: s, nextLocation: u } = C(
46
46
  o,
47
47
  e
48
48
  ), f = a(async () => {
49
49
  t && await t(), i();
50
50
  }, [t, i]), l = a(async () => {
51
- n && await n(), r();
52
- }, [n, r]);
53
- return s ? /* @__PURE__ */ m(d, { children: c({
51
+ n && await n(), s();
52
+ }, [n, s]);
53
+ return r ? /* @__PURE__ */ m(d, { children: c({
54
54
  isActive: !0,
55
55
  onConfirm: f,
56
56
  onCancel: l,
@@ -1 +1 @@
1
- (function(o,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react/jsx-runtime"),require("react"),require("react-router")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-router"],c):(o=typeof globalThis<"u"?globalThis:o||self,c(o.ReactRouterPrompt={},o["react/jsx-runtime"],o.react,o.reactRouter))})(this,function(o,c,s,d){"use strict";function l(t,r,i){const e=d.useBlocker(t);return s.useEffect(()=>{e.state==="blocked"&&e.location&&r&&r(e.location),e.state==="blocked"&&!t&&(i==="proceed"?e.proceed():e.reset())},[e,i,t,r]),d.useBeforeUnload(s.useCallback(n=>{(typeof t=="boolean"&&t===!0||typeof t=="function"&&t())&&(n.preventDefault(),n.returnValue="Changes that you made may not be saved.")},[t]),{capture:!0}),e}const m=(t,r)=>{const[i,e]=s.useState(null),n=l(t,a=>{e(a)},r),f=()=>{n.state==="blocked"&&n.reset()},u=()=>{n.state==="blocked"&&setTimeout(n.proceed,0)};return{isActive:n.state==="blocked",onConfirm:u,resetConfirmation:f,nextLocation:i||void 0}};function p({when:t,children:r,beforeCancel:i,beforeConfirm:e,defaultBehaviour:n="reset"}){const{isActive:f,onConfirm:u,resetConfirmation:a,nextLocation:k}=m(t,n),y=s.useCallback(async()=>{e&&await e(),u()},[e,u]),C=s.useCallback(async()=>{i&&await i(),a()},[i,a]);return f?c.jsx(c.Fragment,{children:r({isActive:!0,onConfirm:y,onCancel:C,nextLocation:k||void 0})}):null}o.default=p,o.useConfirm=m,o.usePrompt=l,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("react-router")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-router"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.ReactRouterPrompt={},o["react/jsx-runtime"],o.react,o.reactRouter))})(this,function(o,s,c,d){"use strict";function l(t,r,i){const e=d.useBlocker(t);return c.useEffect(()=>{e.state==="blocked"&&e.location&&r&&r(e.location),e.state==="blocked"&&!t&&(i==="proceed"?setTimeout(e.proceed,0):e.reset())},[e,i,t,r]),d.useBeforeUnload(c.useCallback(n=>{(typeof t=="boolean"&&t===!0||typeof t=="function"&&t())&&(n.preventDefault(),n.returnValue="Changes that you made may not be saved.")},[t]),{capture:!0}),e}const m=(t,r)=>{const[i,e]=c.useState(null),n=l(t,a=>{e(a)},r),f=()=>{n.state==="blocked"&&n.reset()},u=()=>{n.state==="blocked"&&setTimeout(n.proceed,0)};return{isActive:n.state==="blocked",onConfirm:u,resetConfirmation:f,nextLocation:i||void 0}};function p({when:t,children:r,beforeCancel:i,beforeConfirm:e,defaultBehaviour:n="reset"}){const{isActive:f,onConfirm:u,resetConfirmation:a,nextLocation:k}=m(t,n),y=c.useCallback(async()=>{e&&await e(),u()},[e,u]),C=c.useCallback(async()=>{i&&await i(),a()},[i,a]);return f?s.jsx(s.Fragment,{children:r({isActive:!0,onConfirm:y,onCancel:C,nextLocation:k||void 0})}):null}o.default=p,o.useConfirm=m,o.usePrompt=l,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.8.1",
2
+ "version": "0.8.2",
3
3
  "name": "@qubhq/react-router-prompt",
4
4
  "description": "React Router Navigation Prompt for v6",
5
5
  "type": "module",