@qubhq/react-router-prompt 0.7.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Shyam Gupta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # react-router-prompt 🚨
2
+
3
+ > A component for the react-router 6 `Prompt`. Allows to create more flexible dialogs.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/react-router-prompt.svg)](https://www.npmjs.com/package/react-router-prompt)
6
+
7
+ [![npm downloads](https://img.shields.io/npm/dw/react-router-prompt.svg)](https://www.npmjs.com/package/react-router-prompt)
8
+
9
+ [![npm bundle size](https://img.shields.io/bundlephobia/minzip/react-router-prompt)](https://www.npmjs.com/package/react-router-prompt)
10
+
11
+ ## ✨ [Demo](https://codesandbox.io/s/react-router-prompt-example-react-router-6-7-y9ug7z?file=/src/App.js)
12
+
13
+ ## 🏠 [Homepage](https://github.com/sshyam-gupta/react-router-prompt#readme)
14
+
15
+ ## Installation
16
+
17
+ ### Prerequisite
18
+
19
+ **React-router-dom >= 6.19** and can be used only with [**data routers**](https://reactrouter.com/en/6.8.1/routers/picking-a-router#using-v64-data-apis)
20
+
21
+ ```bash
22
+ pnpm add react-router-prompt
23
+ ```
24
+
25
+ or with other package manager like yarn
26
+
27
+ ```bash
28
+ yarn add react-router-prompt
29
+ ```
30
+
31
+ ## Basic Usage
32
+
33
+ ```jsx
34
+ <ReactRouterPrompt when={isDirty}>
35
+ {({ isActive, onConfirm, onCancel }) => (
36
+ <Modal show={isActive}>
37
+ <div>
38
+ <p>Do you really want to leave?</p>
39
+ <button onClick={onCancel}>Cancel</button>
40
+ <button onClick={onConfirm}>Ok</button>
41
+ </div>
42
+ </Modal>
43
+ )}
44
+ </ReactRouterPrompt>
45
+ ```
46
+
47
+ ### Props
48
+
49
+ 1. `when`: `boolean` | `BlockerFunction`
50
+
51
+ ```ts
52
+ BlockerFunction = (args: {
53
+ currentLocation: Location
54
+ nextLocation: Location
55
+ historyAction: HistoryAction
56
+ }) => boolean
57
+ ```
58
+
59
+ 2. `beforeConfirm()` : `Promise<unknown>` _(Optional)_
60
+
61
+ 3. `beforeCancel()` : `Promise<unknown>` _(Optional)_
62
+
63
+ ### Return values
64
+
65
+ 1. `isActive`: `Boolean`
66
+ 2. `onConfirm()`: `void`
67
+ 3. `onCancel()`: `void`
68
+
69
+ #### Note 🗒️
70
+
71
+ This version works with react-router-dom >=v6.19
72
+ Should be used within [data routers](https://reactrouter.com/en/6.8.1/routers/picking-a-router#using-v64-data-apis)
73
+
74
+ For react-router support `(v6 - v6.2.x)` please install v0.3.0
75
+
76
+ For react-router support (v6.7.x - v6.18.x) please install v0.5.4
77
+
78
+ _Skipped support in middle due to breaking changes on react-router apis_
79
+
80
+ ## Contributing
81
+
82
+ Contributions, issues and feature requests are always welcome!
83
+ Feel free to check [issues page](https://github.com/sshyam-gupta/react-router-prompt/issues).
84
+
85
+ ## Acknowledgements
86
+
87
+ - Inspiration from [react-router-navigation-prompt](https://www.npmjs.com/package/react-router-navigation-prompt)
88
+ - Gist: [https://gist.github.com/rmorse/426ffcc579922a82749934826fa9f743](https://gist.github.com/rmorse/426ffcc579922a82749934826fa9f743)
89
+
90
+ ## Support
91
+
92
+ Give a ⭐️ if this project helped you!
93
+
94
+ ## 📝 License
95
+
96
+ Copyright © 2023 [Shyam Gupta (shyamm@outlook.com)](https://github.com/sshyam-gupta)
97
+ This project is [MIT](https://github.com/sshyam-gupta/react-router-prompt/blob/main/LICENSE) licensed.
98
+
99
+ ## About me
100
+
101
+ - Website: [sshyam-gupta.space](https://sshyam-gupta.space/)
102
+ - Twitter: [@shyamm06](https://twitter.com/shyamm06)
103
+ - GitHub: [@sshyam-gupta](https://github.com/sshyam-gupta)
104
+ - LinkedIn: [@shyam-gupta-66463a62](https://linkedin.com/in/https://www.linkedin.com/in/shyam-gupta-66463a62/)
@@ -0,0 +1,9 @@
1
+ import { BlockerFunction } from 'react-router-dom';
2
+ import { DefaultBehaviour } from '../types';
3
+ declare interface InitialStateType {
4
+ isActive: boolean;
5
+ onConfirm(): void;
6
+ resetConfirmation(): void;
7
+ }
8
+ declare const useConfirm: (when: boolean | BlockerFunction, defaultBehaviour: DefaultBehaviour) => InitialStateType;
9
+ export default useConfirm;
@@ -0,0 +1,4 @@
1
+ import { Blocker, BlockerFunction } from 'react-router-dom';
2
+ import { DefaultBehaviour } from '../types';
3
+ declare function usePrompt(when: boolean | BlockerFunction, defaultBehaviour: DefaultBehaviour): Blocker;
4
+ export default usePrompt;
@@ -0,0 +1,36 @@
1
+ import { default as React } from 'react';
2
+ import { BlockerFunction } from 'react-router-dom';
3
+ import { default as useConfirm } from './hooks/use-confirm';
4
+ import { default as usePrompt } from './hooks/use-prompt';
5
+ import { DefaultBehaviour } from './types';
6
+ type ReactRouterPromptProps = {
7
+ when: boolean | BlockerFunction;
8
+ children: (data: {
9
+ isActive: boolean;
10
+ onCancel: () => void;
11
+ onConfirm: () => void;
12
+ }) => React.ReactNode;
13
+ beforeCancel?: () => Promise<unknown>;
14
+ beforeConfirm?: () => Promise<unknown>;
15
+ defaultBehaviour?: DefaultBehaviour;
16
+ };
17
+ /**
18
+ * A replacement component for the react-router `Prompt`.
19
+ * Allows for more flexible dialogs.
20
+ *
21
+ * @example
22
+ * <ReactRouterPrompt when={isDirty}>
23
+ * {({isActive, onConfirm, onCancel}) => (
24
+ * <Modal show={isActive}>
25
+ * <div>
26
+ * <p>Do you really want to leave?</p>
27
+ * <button onClick={onCancel}>Cancel</button>
28
+ * <button onClick={onConfirm}>Ok</button>
29
+ * </div>
30
+ * </Modal>
31
+ * )}
32
+ * </ReactRouterPrompt>
33
+ */
34
+ declare function ReactRouterPrompt({ when, children, beforeCancel, beforeConfirm, defaultBehaviour, }: ReactRouterPromptProps): import("react/jsx-runtime").JSX.Element | null;
35
+ export default ReactRouterPrompt;
36
+ export { useConfirm, usePrompt };
package/dist/main.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,685 @@
1
+ import je, { useEffect as dr, useCallback as Z } from "react";
2
+ import { useBlocker as vr, useBeforeUnload as pr } from "react-router-dom";
3
+ var Q = { exports: {} }, W = {};
4
+ /**
5
+ * @license React
6
+ * react-jsx-runtime.production.min.js
7
+ *
8
+ * Copyright (c) Facebook, Inc. and its affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ var Oe;
14
+ function yr() {
15
+ if (Oe) return W;
16
+ Oe = 1;
17
+ var d = je, m = Symbol.for("react.element"), l = Symbol.for("react.fragment"), p = Object.prototype.hasOwnProperty, T = d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, k = { key: !0, ref: !0, __self: !0, __source: !0 };
18
+ function C(E, c, O) {
19
+ var b, h = {}, S = null, Y = null;
20
+ O !== void 0 && (S = "" + O), c.key !== void 0 && (S = "" + c.key), c.ref !== void 0 && (Y = c.ref);
21
+ for (b in c) p.call(c, b) && !k.hasOwnProperty(b) && (h[b] = c[b]);
22
+ if (E && E.defaultProps) for (b in c = E.defaultProps, c) h[b] === void 0 && (h[b] = c[b]);
23
+ return { $$typeof: m, type: E, key: S, ref: Y, props: h, _owner: T.current };
24
+ }
25
+ return W.Fragment = l, W.jsx = C, W.jsxs = C, W;
26
+ }
27
+ var $ = {};
28
+ /**
29
+ * @license React
30
+ * react-jsx-runtime.development.js
31
+ *
32
+ * Copyright (c) Facebook, Inc. and its affiliates.
33
+ *
34
+ * This source code is licensed under the MIT license found in the
35
+ * LICENSE file in the root directory of this source tree.
36
+ */
37
+ var Se;
38
+ function gr() {
39
+ return Se || (Se = 1, process.env.NODE_ENV !== "production" && function() {
40
+ var d = je, m = Symbol.for("react.element"), l = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), T = Symbol.for("react.strict_mode"), k = Symbol.for("react.profiler"), C = Symbol.for("react.provider"), E = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), b = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), S = Symbol.for("react.lazy"), Y = Symbol.for("react.offscreen"), ee = Symbol.iterator, ke = "@@iterator";
41
+ function we(e) {
42
+ if (e === null || typeof e != "object")
43
+ return null;
44
+ var r = ee && e[ee] || e[ke];
45
+ return typeof r == "function" ? r : null;
46
+ }
47
+ var w = d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
48
+ function v(e) {
49
+ {
50
+ for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
51
+ t[n - 1] = arguments[n];
52
+ xe("error", e, t);
53
+ }
54
+ }
55
+ function xe(e, r, t) {
56
+ {
57
+ var n = w.ReactDebugCurrentFrame, i = n.getStackAddendum();
58
+ i !== "" && (r += "%s", t = t.concat([i]));
59
+ var u = t.map(function(o) {
60
+ return String(o);
61
+ });
62
+ u.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, u);
63
+ }
64
+ }
65
+ var Ae = !1, De = !1, Fe = !1, Ie = !1, We = !1, re;
66
+ re = Symbol.for("react.module.reference");
67
+ function $e(e) {
68
+ return !!(typeof e == "string" || typeof e == "function" || e === p || e === k || We || e === T || e === O || e === b || Ie || e === Y || Ae || De || Fe || typeof e == "object" && e !== null && (e.$$typeof === S || e.$$typeof === h || e.$$typeof === C || e.$$typeof === E || e.$$typeof === c || // This needs to include all possible module reference object
69
+ // types supported by any Flight configuration anywhere since
70
+ // we don't know which Flight build this will end up being used
71
+ // with.
72
+ e.$$typeof === re || e.getModuleId !== void 0));
73
+ }
74
+ function Ye(e, r, t) {
75
+ var n = e.displayName;
76
+ if (n)
77
+ return n;
78
+ var i = r.displayName || r.name || "";
79
+ return i !== "" ? t + "(" + i + ")" : t;
80
+ }
81
+ function te(e) {
82
+ return e.displayName || "Context";
83
+ }
84
+ function _(e) {
85
+ if (e == null)
86
+ return null;
87
+ if (typeof e.tag == "number" && v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
88
+ return e.displayName || e.name || null;
89
+ if (typeof e == "string")
90
+ return e;
91
+ switch (e) {
92
+ case p:
93
+ return "Fragment";
94
+ case l:
95
+ return "Portal";
96
+ case k:
97
+ return "Profiler";
98
+ case T:
99
+ return "StrictMode";
100
+ case O:
101
+ return "Suspense";
102
+ case b:
103
+ return "SuspenseList";
104
+ }
105
+ if (typeof e == "object")
106
+ switch (e.$$typeof) {
107
+ case E:
108
+ var r = e;
109
+ return te(r) + ".Consumer";
110
+ case C:
111
+ var t = e;
112
+ return te(t._context) + ".Provider";
113
+ case c:
114
+ return Ye(e, e.render, "ForwardRef");
115
+ case h:
116
+ var n = e.displayName || null;
117
+ return n !== null ? n : _(e.type) || "Memo";
118
+ case S: {
119
+ var i = e, u = i._payload, o = i._init;
120
+ try {
121
+ return _(o(u));
122
+ } catch {
123
+ return null;
124
+ }
125
+ }
126
+ }
127
+ return null;
128
+ }
129
+ var P = Object.assign, D = 0, ne, ae, oe, ie, ue, se, fe;
130
+ function le() {
131
+ }
132
+ le.__reactDisabledLog = !0;
133
+ function Le() {
134
+ {
135
+ if (D === 0) {
136
+ ne = console.log, ae = console.info, oe = console.warn, ie = console.error, ue = console.group, se = console.groupCollapsed, fe = console.groupEnd;
137
+ var e = {
138
+ configurable: !0,
139
+ enumerable: !0,
140
+ value: le,
141
+ writable: !0
142
+ };
143
+ Object.defineProperties(console, {
144
+ info: e,
145
+ log: e,
146
+ warn: e,
147
+ error: e,
148
+ group: e,
149
+ groupCollapsed: e,
150
+ groupEnd: e
151
+ });
152
+ }
153
+ D++;
154
+ }
155
+ }
156
+ function Ve() {
157
+ {
158
+ if (D--, D === 0) {
159
+ var e = {
160
+ configurable: !0,
161
+ enumerable: !0,
162
+ writable: !0
163
+ };
164
+ Object.defineProperties(console, {
165
+ log: P({}, e, {
166
+ value: ne
167
+ }),
168
+ info: P({}, e, {
169
+ value: ae
170
+ }),
171
+ warn: P({}, e, {
172
+ value: oe
173
+ }),
174
+ error: P({}, e, {
175
+ value: ie
176
+ }),
177
+ group: P({}, e, {
178
+ value: ue
179
+ }),
180
+ groupCollapsed: P({}, e, {
181
+ value: se
182
+ }),
183
+ groupEnd: P({}, e, {
184
+ value: fe
185
+ })
186
+ });
187
+ }
188
+ D < 0 && v("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
189
+ }
190
+ }
191
+ var N = w.ReactCurrentDispatcher, B;
192
+ function L(e, r, t) {
193
+ {
194
+ if (B === void 0)
195
+ try {
196
+ throw Error();
197
+ } catch (i) {
198
+ var n = i.stack.trim().match(/\n( *(at )?)/);
199
+ B = n && n[1] || "";
200
+ }
201
+ return `
202
+ ` + B + e;
203
+ }
204
+ }
205
+ var J = !1, V;
206
+ {
207
+ var Ue = typeof WeakMap == "function" ? WeakMap : Map;
208
+ V = new Ue();
209
+ }
210
+ function ce(e, r) {
211
+ if (!e || J)
212
+ return "";
213
+ {
214
+ var t = V.get(e);
215
+ if (t !== void 0)
216
+ return t;
217
+ }
218
+ var n;
219
+ J = !0;
220
+ var i = Error.prepareStackTrace;
221
+ Error.prepareStackTrace = void 0;
222
+ var u;
223
+ u = N.current, N.current = null, Le();
224
+ try {
225
+ if (r) {
226
+ var o = function() {
227
+ throw Error();
228
+ };
229
+ if (Object.defineProperty(o.prototype, "props", {
230
+ set: function() {
231
+ throw Error();
232
+ }
233
+ }), typeof Reflect == "object" && Reflect.construct) {
234
+ try {
235
+ Reflect.construct(o, []);
236
+ } catch (g) {
237
+ n = g;
238
+ }
239
+ Reflect.construct(e, [], o);
240
+ } else {
241
+ try {
242
+ o.call();
243
+ } catch (g) {
244
+ n = g;
245
+ }
246
+ e.call(o.prototype);
247
+ }
248
+ } else {
249
+ try {
250
+ throw Error();
251
+ } catch (g) {
252
+ n = g;
253
+ }
254
+ e();
255
+ }
256
+ } catch (g) {
257
+ if (g && n && typeof g.stack == "string") {
258
+ for (var a = g.stack.split(`
259
+ `), y = n.stack.split(`
260
+ `), s = a.length - 1, f = y.length - 1; s >= 1 && f >= 0 && a[s] !== y[f]; )
261
+ f--;
262
+ for (; s >= 1 && f >= 0; s--, f--)
263
+ if (a[s] !== y[f]) {
264
+ if (s !== 1 || f !== 1)
265
+ do
266
+ if (s--, f--, f < 0 || a[s] !== y[f]) {
267
+ var R = `
268
+ ` + a[s].replace(" at new ", " at ");
269
+ return e.displayName && R.includes("<anonymous>") && (R = R.replace("<anonymous>", e.displayName)), typeof e == "function" && V.set(e, R), R;
270
+ }
271
+ while (s >= 1 && f >= 0);
272
+ break;
273
+ }
274
+ }
275
+ } finally {
276
+ J = !1, N.current = u, Ve(), Error.prepareStackTrace = i;
277
+ }
278
+ var A = e ? e.displayName || e.name : "", j = A ? L(A) : "";
279
+ return typeof e == "function" && V.set(e, j), j;
280
+ }
281
+ function Me(e, r, t) {
282
+ return ce(e, !1);
283
+ }
284
+ function Ne(e) {
285
+ var r = e.prototype;
286
+ return !!(r && r.isReactComponent);
287
+ }
288
+ function U(e, r, t) {
289
+ if (e == null)
290
+ return "";
291
+ if (typeof e == "function")
292
+ return ce(e, Ne(e));
293
+ if (typeof e == "string")
294
+ return L(e);
295
+ switch (e) {
296
+ case O:
297
+ return L("Suspense");
298
+ case b:
299
+ return L("SuspenseList");
300
+ }
301
+ if (typeof e == "object")
302
+ switch (e.$$typeof) {
303
+ case c:
304
+ return Me(e.render);
305
+ case h:
306
+ return U(e.type, r, t);
307
+ case S: {
308
+ var n = e, i = n._payload, u = n._init;
309
+ try {
310
+ return U(u(i), r, t);
311
+ } catch {
312
+ }
313
+ }
314
+ }
315
+ return "";
316
+ }
317
+ var F = Object.prototype.hasOwnProperty, de = {}, ve = w.ReactDebugCurrentFrame;
318
+ function M(e) {
319
+ if (e) {
320
+ var r = e._owner, t = U(e.type, e._source, r ? r.type : null);
321
+ ve.setExtraStackFrame(t);
322
+ } else
323
+ ve.setExtraStackFrame(null);
324
+ }
325
+ function Be(e, r, t, n, i) {
326
+ {
327
+ var u = Function.call.bind(F);
328
+ for (var o in e)
329
+ if (u(e, o)) {
330
+ var a = void 0;
331
+ try {
332
+ if (typeof e[o] != "function") {
333
+ var y = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
334
+ throw y.name = "Invariant Violation", y;
335
+ }
336
+ a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
337
+ } catch (s) {
338
+ a = s;
339
+ }
340
+ a && !(a instanceof Error) && (M(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), M(null)), a instanceof Error && !(a.message in de) && (de[a.message] = !0, M(i), v("Failed %s type: %s", t, a.message), M(null));
341
+ }
342
+ }
343
+ }
344
+ var Je = Array.isArray;
345
+ function q(e) {
346
+ return Je(e);
347
+ }
348
+ function qe(e) {
349
+ {
350
+ var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
351
+ return t;
352
+ }
353
+ }
354
+ function Ke(e) {
355
+ try {
356
+ return pe(e), !1;
357
+ } catch {
358
+ return !0;
359
+ }
360
+ }
361
+ function pe(e) {
362
+ return "" + e;
363
+ }
364
+ function ye(e) {
365
+ if (Ke(e))
366
+ return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", qe(e)), pe(e);
367
+ }
368
+ var I = w.ReactCurrentOwner, Ge = {
369
+ key: !0,
370
+ ref: !0,
371
+ __self: !0,
372
+ __source: !0
373
+ }, ge, be, K;
374
+ K = {};
375
+ function ze(e) {
376
+ if (F.call(e, "ref")) {
377
+ var r = Object.getOwnPropertyDescriptor(e, "ref").get;
378
+ if (r && r.isReactWarning)
379
+ return !1;
380
+ }
381
+ return e.ref !== void 0;
382
+ }
383
+ function Xe(e) {
384
+ if (F.call(e, "key")) {
385
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
386
+ if (r && r.isReactWarning)
387
+ return !1;
388
+ }
389
+ return e.key !== void 0;
390
+ }
391
+ function He(e, r) {
392
+ if (typeof e.ref == "string" && I.current && r && I.current.stateNode !== r) {
393
+ var t = _(I.current.type);
394
+ K[t] || (v('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', _(I.current.type), e.ref), K[t] = !0);
395
+ }
396
+ }
397
+ function Ze(e, r) {
398
+ {
399
+ var t = function() {
400
+ ge || (ge = !0, v("%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://reactjs.org/link/special-props)", r));
401
+ };
402
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
403
+ get: t,
404
+ configurable: !0
405
+ });
406
+ }
407
+ }
408
+ function Qe(e, r) {
409
+ {
410
+ var t = function() {
411
+ be || (be = !0, v("%s: `ref` 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://reactjs.org/link/special-props)", r));
412
+ };
413
+ t.isReactWarning = !0, Object.defineProperty(e, "ref", {
414
+ get: t,
415
+ configurable: !0
416
+ });
417
+ }
418
+ }
419
+ var er = function(e, r, t, n, i, u, o) {
420
+ var a = {
421
+ // This tag allows us to uniquely identify this as a React Element
422
+ $$typeof: m,
423
+ // Built-in properties that belong on the element
424
+ type: e,
425
+ key: r,
426
+ ref: t,
427
+ props: o,
428
+ // Record the component responsible for creating this element.
429
+ _owner: u
430
+ };
431
+ return a._store = {}, Object.defineProperty(a._store, "validated", {
432
+ configurable: !1,
433
+ enumerable: !1,
434
+ writable: !0,
435
+ value: !1
436
+ }), Object.defineProperty(a, "_self", {
437
+ configurable: !1,
438
+ enumerable: !1,
439
+ writable: !1,
440
+ value: n
441
+ }), Object.defineProperty(a, "_source", {
442
+ configurable: !1,
443
+ enumerable: !1,
444
+ writable: !1,
445
+ value: i
446
+ }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
447
+ };
448
+ function rr(e, r, t, n, i) {
449
+ {
450
+ var u, o = {}, a = null, y = null;
451
+ t !== void 0 && (ye(t), a = "" + t), Xe(r) && (ye(r.key), a = "" + r.key), ze(r) && (y = r.ref, He(r, i));
452
+ for (u in r)
453
+ F.call(r, u) && !Ge.hasOwnProperty(u) && (o[u] = r[u]);
454
+ if (e && e.defaultProps) {
455
+ var s = e.defaultProps;
456
+ for (u in s)
457
+ o[u] === void 0 && (o[u] = s[u]);
458
+ }
459
+ if (a || y) {
460
+ var f = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
461
+ a && Ze(o, f), y && Qe(o, f);
462
+ }
463
+ return er(e, a, y, i, n, I.current, o);
464
+ }
465
+ }
466
+ var G = w.ReactCurrentOwner, me = w.ReactDebugCurrentFrame;
467
+ function x(e) {
468
+ if (e) {
469
+ var r = e._owner, t = U(e.type, e._source, r ? r.type : null);
470
+ me.setExtraStackFrame(t);
471
+ } else
472
+ me.setExtraStackFrame(null);
473
+ }
474
+ var z;
475
+ z = !1;
476
+ function X(e) {
477
+ return typeof e == "object" && e !== null && e.$$typeof === m;
478
+ }
479
+ function Re() {
480
+ {
481
+ if (G.current) {
482
+ var e = _(G.current.type);
483
+ if (e)
484
+ return `
485
+
486
+ Check the render method of \`` + e + "`.";
487
+ }
488
+ return "";
489
+ }
490
+ }
491
+ function tr(e) {
492
+ return "";
493
+ }
494
+ var Ee = {};
495
+ function nr(e) {
496
+ {
497
+ var r = Re();
498
+ if (!r) {
499
+ var t = typeof e == "string" ? e : e.displayName || e.name;
500
+ t && (r = `
501
+
502
+ Check the top-level render call using <` + t + ">.");
503
+ }
504
+ return r;
505
+ }
506
+ }
507
+ function _e(e, r) {
508
+ {
509
+ if (!e._store || e._store.validated || e.key != null)
510
+ return;
511
+ e._store.validated = !0;
512
+ var t = nr(r);
513
+ if (Ee[t])
514
+ return;
515
+ Ee[t] = !0;
516
+ var n = "";
517
+ e && e._owner && e._owner !== G.current && (n = " It was passed a child from " + _(e._owner.type) + "."), x(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), x(null);
518
+ }
519
+ }
520
+ function he(e, r) {
521
+ {
522
+ if (typeof e != "object")
523
+ return;
524
+ if (q(e))
525
+ for (var t = 0; t < e.length; t++) {
526
+ var n = e[t];
527
+ X(n) && _e(n, r);
528
+ }
529
+ else if (X(e))
530
+ e._store && (e._store.validated = !0);
531
+ else if (e) {
532
+ var i = we(e);
533
+ if (typeof i == "function" && i !== e.entries)
534
+ for (var u = i.call(e), o; !(o = u.next()).done; )
535
+ X(o.value) && _e(o.value, r);
536
+ }
537
+ }
538
+ }
539
+ function ar(e) {
540
+ {
541
+ var r = e.type;
542
+ if (r == null || typeof r == "string")
543
+ return;
544
+ var t;
545
+ if (typeof r == "function")
546
+ t = r.propTypes;
547
+ else if (typeof r == "object" && (r.$$typeof === c || // Note: Memo only checks outer props here.
548
+ // Inner props are checked in the reconciler.
549
+ r.$$typeof === h))
550
+ t = r.propTypes;
551
+ else
552
+ return;
553
+ if (t) {
554
+ var n = _(r);
555
+ Be(t, e.props, "prop", n, e);
556
+ } else if (r.PropTypes !== void 0 && !z) {
557
+ z = !0;
558
+ var i = _(r);
559
+ v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown");
560
+ }
561
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
562
+ }
563
+ }
564
+ function or(e) {
565
+ {
566
+ for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
567
+ var n = r[t];
568
+ if (n !== "children" && n !== "key") {
569
+ x(e), v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), x(null);
570
+ break;
571
+ }
572
+ }
573
+ e.ref !== null && (x(e), v("Invalid attribute `ref` supplied to `React.Fragment`."), x(null));
574
+ }
575
+ }
576
+ var Te = {};
577
+ function Ce(e, r, t, n, i, u) {
578
+ {
579
+ var o = $e(e);
580
+ if (!o) {
581
+ var a = "";
582
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
583
+ var y = tr();
584
+ y ? a += y : a += Re();
585
+ var s;
586
+ e === null ? s = "null" : q(e) ? s = "array" : e !== void 0 && e.$$typeof === m ? (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);
587
+ }
588
+ var f = rr(e, r, t, i, u);
589
+ if (f == null)
590
+ return f;
591
+ if (o) {
592
+ var R = r.children;
593
+ if (R !== void 0)
594
+ if (n)
595
+ if (q(R)) {
596
+ for (var A = 0; A < R.length; A++)
597
+ he(R[A], e);
598
+ Object.freeze && Object.freeze(R);
599
+ } else
600
+ 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.");
601
+ else
602
+ he(R, e);
603
+ }
604
+ if (F.call(r, "key")) {
605
+ var j = _(e), g = Object.keys(r).filter(function(cr) {
606
+ return cr !== "key";
607
+ }), H = g.length > 0 ? "{key: someKey, " + g.join(": ..., ") + ": ...}" : "{key: someKey}";
608
+ if (!Te[j + H]) {
609
+ var lr = g.length > 0 ? "{" + g.join(": ..., ") + ": ...}" : "{}";
610
+ v(`A props object containing a "key" prop is being spread into JSX:
611
+ let props = %s;
612
+ <%s {...props} />
613
+ React keys must be passed directly to JSX without using spread:
614
+ let props = %s;
615
+ <%s key={someKey} {...props} />`, H, j, lr, j), Te[j + H] = !0;
616
+ }
617
+ }
618
+ return e === p ? or(f) : ar(f), f;
619
+ }
620
+ }
621
+ function ir(e, r, t) {
622
+ return Ce(e, r, t, !0);
623
+ }
624
+ function ur(e, r, t) {
625
+ return Ce(e, r, t, !1);
626
+ }
627
+ var sr = ur, fr = ir;
628
+ $.Fragment = p, $.jsx = sr, $.jsxs = fr;
629
+ }()), $;
630
+ }
631
+ process.env.NODE_ENV === "production" ? Q.exports = yr() : Q.exports = gr();
632
+ var Pe = Q.exports;
633
+ function br(d, m) {
634
+ const l = vr(d);
635
+ return dr(() => {
636
+ l.state === "blocked" && !d && (m === "proceed" ? l.proceed() : l.reset());
637
+ }, [l, m, d]), pr(
638
+ Z(
639
+ (p) => {
640
+ (typeof d == "boolean" && d === !0 || // @ts-ignore Reload case -- No location present
641
+ typeof d == "function" && d()) && (p.preventDefault(), p.returnValue = "Changes that you made may not be saved.");
642
+ },
643
+ [d]
644
+ ),
645
+ { capture: !0 }
646
+ ), l;
647
+ }
648
+ const mr = (d, m) => {
649
+ const l = br(d, m), p = () => {
650
+ l.state === "blocked" && l.reset();
651
+ }, T = () => {
652
+ l.state === "blocked" && setTimeout(l.proceed, 0);
653
+ };
654
+ return {
655
+ isActive: l.state === "blocked",
656
+ onConfirm: T,
657
+ resetConfirmation: p
658
+ };
659
+ };
660
+ function _r({
661
+ when: d,
662
+ children: m,
663
+ beforeCancel: l,
664
+ beforeConfirm: p,
665
+ defaultBehaviour: T = "reset"
666
+ }) {
667
+ const { isActive: k, onConfirm: C, resetConfirmation: E } = mr(
668
+ d,
669
+ T
670
+ ), c = Z(async () => {
671
+ p && await p(), C();
672
+ }, [p, C]), O = Z(async () => {
673
+ l && await l(), E();
674
+ }, [l, E]);
675
+ return k ? /* @__PURE__ */ Pe.jsx(Pe.Fragment, { children: m({
676
+ isActive: !0,
677
+ onConfirm: c,
678
+ onCancel: O
679
+ }) }) : null;
680
+ }
681
+ export {
682
+ _r as default,
683
+ mr as useConfirm,
684
+ br as usePrompt
685
+ };
@@ -0,0 +1,30 @@
1
+ (function(E,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-router-dom"],_):(E=typeof globalThis<"u"?globalThis:E||self,_(E.ReactRouterPrompt={},E.require$$0,E.reactRouterDom))})(this,function(E,_,re){"use strict";var J={exports:{}},I={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var te;function Ae(){if(te)return I;te=1;var d=_,m=Symbol.for("react.element"),c=Symbol.for("react.fragment"),p=Object.prototype.hasOwnProperty,O=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,x={key:!0,ref:!0,__self:!0,__source:!0};function P(h,l,S){var g,C={},j=null,V=null;S!==void 0&&(j=""+S),l.key!==void 0&&(j=""+l.key),l.ref!==void 0&&(V=l.ref);for(g in l)p.call(l,g)&&!x.hasOwnProperty(g)&&(C[g]=l[g]);if(h&&h.defaultProps)for(g in l=h.defaultProps,l)C[g]===void 0&&(C[g]=l[g]);return{$$typeof:m,type:h,key:j,ref:V,props:C,_owner:O.current}}return I.Fragment=c,I.jsx=P,I.jsxs=P,I}var W={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var ne;function De(){return ne||(ne=1,process.env.NODE_ENV!=="production"&&function(){var d=_,m=Symbol.for("react.element"),c=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),h=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),ue=Symbol.iterator,Ie="@@iterator";function We(e){if(e===null||typeof e!="object")return null;var r=ue&&e[ue]||e[Ie];return typeof r=="function"?r:null}var A=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];Ye("error",e,t)}}function Ye(e,r,t){{var n=A.ReactDebugCurrentFrame,i=n.getStackAddendum();i!==""&&(r+="%s",t=t.concat([i]));var u=t.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var Le=!1,Me=!1,Ve=!1,Ue=!1,$e=!1,se;se=Symbol.for("react.module.reference");function Ne(e){return!!(typeof e=="string"||typeof e=="function"||e===p||e===x||$e||e===O||e===S||e===g||Ue||e===V||Le||Me||Ve||typeof e=="object"&&e!==null&&(e.$$typeof===j||e.$$typeof===C||e.$$typeof===P||e.$$typeof===h||e.$$typeof===l||e.$$typeof===se||e.getModuleId!==void 0))}function Be(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function fe(e){return e.displayName||"Context"}function T(e){if(e==null)return null;if(typeof e.tag=="number"&&v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case p:return"Fragment";case c:return"Portal";case x:return"Profiler";case O:return"StrictMode";case S:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case h:var r=e;return fe(r)+".Consumer";case P:var t=e;return fe(t._context)+".Provider";case l:return Be(e,e.render,"ForwardRef");case C:var n=e.displayName||null;return n!==null?n:T(e.type)||"Memo";case j:{var i=e,u=i._payload,o=i._init;try{return T(o(u))}catch{return null}}}return null}var k=Object.assign,Y=0,ce,le,de,ve,pe,ye,be;function ge(){}ge.__reactDisabledLog=!0;function Je(){{if(Y===0){ce=console.log,le=console.info,de=console.warn,ve=console.error,pe=console.group,ye=console.groupCollapsed,be=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ge,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Y++}}function Ke(){{if(Y--,Y===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},e,{value:ce}),info:k({},e,{value:le}),warn:k({},e,{value:de}),error:k({},e,{value:ve}),group:k({},e,{value:pe}),groupCollapsed:k({},e,{value:ye}),groupEnd:k({},e,{value:be})})}Y<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var K=A.ReactCurrentDispatcher,G;function U(e,r,t){{if(G===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);G=n&&n[1]||""}return`
18
+ `+G+e}}var q=!1,$;{var Ge=typeof WeakMap=="function"?WeakMap:Map;$=new Ge}function me(e,r){if(!e||q)return"";{var t=$.get(e);if(t!==void 0)return t}var n;q=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=K.current,K.current=null,Je();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(b){n=b}Reflect.construct(e,[],o)}else{try{o.call()}catch(b){n=b}e.call(o.prototype)}}else{try{throw Error()}catch(b){n=b}e()}}catch(b){if(b&&n&&typeof b.stack=="string"){for(var a=b.stack.split(`
19
+ `),y=n.stack.split(`
20
+ `),s=a.length-1,f=y.length-1;s>=1&&f>=0&&a[s]!==y[f];)f--;for(;s>=1&&f>=0;s--,f--)if(a[s]!==y[f]){if(s!==1||f!==1)do if(s--,f--,f<0||a[s]!==y[f]){var R=`
21
+ `+a[s].replace(" at new "," at ");return e.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",e.displayName)),typeof e=="function"&&$.set(e,R),R}while(s>=1&&f>=0);break}}}finally{q=!1,K.current=u,Ke(),Error.prepareStackTrace=i}var F=e?e.displayName||e.name:"",w=F?U(F):"";return typeof e=="function"&&$.set(e,w),w}function qe(e,r,t){return me(e,!1)}function ze(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function N(e,r,t){if(e==null)return"";if(typeof e=="function")return me(e,ze(e));if(typeof e=="string")return U(e);switch(e){case S:return U("Suspense");case g:return U("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case l:return qe(e.render);case C:return N(e.type,r,t);case j:{var n=e,i=n._payload,u=n._init;try{return N(u(i),r,t)}catch{}}}return""}var L=Object.prototype.hasOwnProperty,Re={},Ee=A.ReactDebugCurrentFrame;function B(e){if(e){var r=e._owner,t=N(e.type,e._source,r?r.type:null);Ee.setExtraStackFrame(t)}else Ee.setExtraStackFrame(null)}function Xe(e,r,t,n,i){{var u=Function.call.bind(L);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var y=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw y.name="Invariant Violation",y}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(s){a=s}a&&!(a instanceof Error)&&(B(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),B(null)),a instanceof Error&&!(a.message in Re)&&(Re[a.message]=!0,B(i),v("Failed %s type: %s",t,a.message),B(null))}}}var He=Array.isArray;function z(e){return He(e)}function Ze(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Qe(e){try{return _e(e),!1}catch{return!0}}function _e(e){return""+e}function he(e){if(Qe(e))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ze(e)),_e(e)}var M=A.ReactCurrentOwner,er={key:!0,ref:!0,__self:!0,__source:!0},Te,Ce,X;X={};function rr(e){if(L.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function tr(e){if(L.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function nr(e,r){if(typeof e.ref=="string"&&M.current&&r&&M.current.stateNode!==r){var t=T(M.current.type);X[t]||(v('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',T(M.current.type),e.ref),X[t]=!0)}}function ar(e,r){{var t=function(){Te||(Te=!0,v("%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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function or(e,r){{var t=function(){Ce||(Ce=!0,v("%s: `ref` 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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var ir=function(e,r,t,n,i,u,o){var a={$$typeof:m,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function ur(e,r,t,n,i){{var u,o={},a=null,y=null;t!==void 0&&(he(t),a=""+t),tr(r)&&(he(r.key),a=""+r.key),rr(r)&&(y=r.ref,nr(r,i));for(u in r)L.call(r,u)&&!er.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var s=e.defaultProps;for(u in s)o[u]===void 0&&(o[u]=s[u])}if(a||y){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&ar(o,f),y&&or(o,f)}return ir(e,a,y,i,n,M.current,o)}}var H=A.ReactCurrentOwner,Oe=A.ReactDebugCurrentFrame;function D(e){if(e){var r=e._owner,t=N(e.type,e._source,r?r.type:null);Oe.setExtraStackFrame(t)}else Oe.setExtraStackFrame(null)}var Z;Z=!1;function Q(e){return typeof e=="object"&&e!==null&&e.$$typeof===m}function Pe(){{if(H.current){var e=T(H.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function sr(e){return""}var Se={};function fr(e){{var r=Pe();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
24
+
25
+ Check the top-level render call using <`+t+">.")}return r}}function je(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=fr(r);if(Se[t])return;Se[t]=!0;var n="";e&&e._owner&&e._owner!==H.current&&(n=" It was passed a child from "+T(e._owner.type)+"."),D(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),D(null)}}function ke(e,r){{if(typeof e!="object")return;if(z(e))for(var t=0;t<e.length;t++){var n=e[t];Q(n)&&je(n,r)}else if(Q(e))e._store&&(e._store.validated=!0);else if(e){var i=We(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)Q(o.value)&&je(o.value,r)}}}function cr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===l||r.$$typeof===C))t=r.propTypes;else return;if(t){var n=T(r);Xe(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!Z){Z=!0;var i=T(r);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){D(e),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),D(null);break}}e.ref!==null&&(D(e),v("Invalid attribute `ref` supplied to `React.Fragment`."),D(null))}}var we={};function xe(e,r,t,n,i,u){{var o=Ne(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var y=sr();y?a+=y:a+=Pe();var s;e===null?s="null":z(e)?s="array":e!==void 0&&e.$$typeof===m?(s="<"+(T(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=ur(e,r,t,i,u);if(f==null)return f;if(o){var R=r.children;if(R!==void 0)if(n)if(z(R)){for(var F=0;F<R.length;F++)ke(R[F],e);Object.freeze&&Object.freeze(R)}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 ke(R,e)}if(L.call(r,"key")){var w=T(e),b=Object.keys(r).filter(function(gr){return gr!=="key"}),ee=b.length>0?"{key: someKey, "+b.join(": ..., ")+": ...}":"{key: someKey}";if(!we[w+ee]){var br=b.length>0?"{"+b.join(": ..., ")+": ...}":"{}";v(`A props object containing a "key" prop is being spread into JSX:
26
+ let props = %s;
27
+ <%s {...props} />
28
+ React keys must be passed directly to JSX without using spread:
29
+ let props = %s;
30
+ <%s key={someKey} {...props} />`,ee,w,br,w),we[w+ee]=!0}}return e===p?lr(f):cr(f),f}}function dr(e,r,t){return xe(e,r,t,!0)}function vr(e,r,t){return xe(e,r,t,!1)}var pr=vr,yr=dr;W.Fragment=p,W.jsx=pr,W.jsxs=yr}()),W}process.env.NODE_ENV==="production"?J.exports=Ae():J.exports=De();var ae=J.exports;function oe(d,m){const c=re.useBlocker(d);return _.useEffect(()=>{c.state==="blocked"&&!d&&(m==="proceed"?c.proceed():c.reset())},[c,m,d]),re.useBeforeUnload(_.useCallback(p=>{(typeof d=="boolean"&&d===!0||typeof d=="function"&&d())&&(p.preventDefault(),p.returnValue="Changes that you made may not be saved.")},[d]),{capture:!0}),c}const ie=(d,m)=>{const c=oe(d,m),p=()=>{c.state==="blocked"&&c.reset()},O=()=>{c.state==="blocked"&&setTimeout(c.proceed,0)};return{isActive:c.state==="blocked",onConfirm:O,resetConfirmation:p}};function Fe({when:d,children:m,beforeCancel:c,beforeConfirm:p,defaultBehaviour:O="reset"}){const{isActive:x,onConfirm:P,resetConfirmation:h}=ie(d,O),l=_.useCallback(async()=>{p&&await p(),P()},[p,P]),S=_.useCallback(async()=>{c&&await c(),h()},[c,h]);return x?ae.jsx(ae.Fragment,{children:m({isActive:!0,onConfirm:l,onCancel:S})}):null}E.default=Fe,E.useConfirm=ie,E.usePrompt=oe,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1 @@
1
+ export type DefaultBehaviour = "reset" | "proceed";
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "version": "0.7.1",
3
+ "name": "@qubhq/react-router-prompt",
4
+ "description": "React Router Navigation Prompt for v6",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "main": "./dist/react-router-prompt.umd.cjs",
10
+ "module": "./dist/react-router-prompt.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/react-router-prompt.js",
15
+ "require": "./dist/react-router-prompt.umd.cjs",
16
+ "types": "./dist/index.d.ts"
17
+ }
18
+ },
19
+ "author": "Shyam Gupta (shyamm@outlook.com)",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/sshyam-gupta/react-router-prompt.git"
24
+ },
25
+ "homepage": "https://github.com/sshyam-gupta/react-router-prompt#readme",
26
+ "keywords": [
27
+ "confirm",
28
+ "navigation",
29
+ "prompt",
30
+ "react",
31
+ "router"
32
+ ],
33
+ "husky": {
34
+ "hooks": {
35
+ "pre-commit": "pnpm lint"
36
+ }
37
+ },
38
+ "devDependencies": {
39
+ "@size-limit/preset-small-lib": "^11.0.2",
40
+ "@types/react": "^18.2.55",
41
+ "@types/react-dom": "^18.2.19",
42
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
43
+ "@typescript-eslint/parser": "^8.0.0",
44
+ "@vitejs/plugin-react-swc": "^3.6.0",
45
+ "eslint": "^8.56.0",
46
+ "eslint-config-airbnb": "^19.0.4",
47
+ "eslint-config-airbnb-typescript": "^18.0.0",
48
+ "eslint-config-prettier": "^9.1.0",
49
+ "eslint-plugin-import": "^2.29.1",
50
+ "eslint-plugin-jsx-a11y": "^6.8.0",
51
+ "eslint-plugin-prettier": "^5.1.3",
52
+ "eslint-plugin-react": "^7.33.2",
53
+ "eslint-plugin-react-hooks": "^4.6.0",
54
+ "history": "^5.3.0",
55
+ "husky": "^9.0.11",
56
+ "path": "^0.12.7",
57
+ "prettier": "^3.2.5",
58
+ "react": "^18.2.0",
59
+ "react-dom": "^18.2.0",
60
+ "react-router-dom": "^6.22.1",
61
+ "size-limit": "^11.0.2",
62
+ "typescript": "^5.3.3",
63
+ "vite": "^5.1.3",
64
+ "vite-plugin-dts": "^4.0.0",
65
+ "vite-tsconfig-paths": "^5.0.0"
66
+ },
67
+ "peerDependencies": {
68
+ "react": ">=16.8",
69
+ "react-dom": ">=16.8",
70
+ "react-router-dom": ">=6.19"
71
+ },
72
+ "size-limit": [
73
+ {
74
+ "path": "dist/react-router-prompt.js",
75
+ "limit": "1.2 KB"
76
+ },
77
+ {
78
+ "path": "dist/react-router-prompt.umd.cjs",
79
+ "limit": "1.2 KB"
80
+ }
81
+ ],
82
+ "scripts": {
83
+ "dev": "vite",
84
+ "build": "tsc && vite build",
85
+ "lint": "eslint src --ext .js,.jsx,.ts,.tsx",
86
+ "lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
87
+ "format": "prettier \"src/**/*.{js,jsx,ts,tsx,css,scss}\" --write",
88
+ "size": "size-limit"
89
+ }
90
+ }