foxact 0.2.54 → 0.3.0

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.
@@ -0,0 +1 @@
1
+ "use strict";const r=18>=Number.parseFloat(require("react").version)?function(){for(var r=arguments.length,e=Array(r),t=0;t<r;t++)e[t]=arguments[t];return r=>{e.forEach(e=>{"function"==typeof e?e(r):e&&(e.current=r)})}}:function(){for(var r=arguments.length,e=Array(r),t=0;t<r;t++)e[t]=arguments[t];return r=>{const t=new Set,n=new Set;return e.forEach(e=>{if("function"==typeof e){const o=e(r);"function"==typeof o?t.add(o):n.add(e)}else e&&(e.current=r)}),()=>{t.forEach(r=>r()),n.forEach(r=>r(null))}}};exports.mergeRefs=r;
@@ -0,0 +1,4 @@
1
+ declare function react18AndBelowMergeRefs<T>(...refs: Array<React.Ref<T> | undefined>): React.RefCallback<T>;
2
+ declare const mergeRefs: typeof react18AndBelowMergeRefs;
3
+
4
+ export { mergeRefs };
@@ -0,0 +1 @@
1
+ import{version as r}from"react";const t=18>=Number.parseFloat(r)?function(){for(var r=arguments.length,t=Array(r),e=0;e<r;e++)t[e]=arguments[e];return r=>{t.forEach(t=>{"function"==typeof t?t(r):t&&(t.current=r)})}}:function(){for(var r=arguments.length,t=Array(r),e=0;e<r;e++)t[e]=arguments[e];return r=>{const e=new Set,n=new Set;return t.forEach(t=>{if("function"==typeof t){const o=t(r);"function"==typeof o?e.add(o):n.add(t)}else t&&(t.current=r)}),()=>{e.forEach(r=>r()),n.forEach(r=>r(null))}}};export{t as mergeRefs};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxact",
3
- "version": "0.2.54",
3
+ "version": "0.3.0",
4
4
  "description": "React Hooks/Utils done right. For browser, SSR, and React Server Components.",
5
5
  "homepage": "https://foxact.skk.moe",
6
6
  "repository": {
@@ -61,6 +61,15 @@
61
61
  "require": "./compose-context-provider/index.cjs",
62
62
  "default": "./compose-context-provider/index.cjs"
63
63
  },
64
+ "./context-reducer": {
65
+ "types": "./context-reducer/index.d.ts",
66
+ "import": {
67
+ "types": "./context-reducer/index.d.ts",
68
+ "default": "./context-reducer/index.mjs"
69
+ },
70
+ "require": "./context-reducer/index.cjs",
71
+ "default": "./context-reducer/index.cjs"
72
+ },
64
73
  "./context-state": {
65
74
  "types": "./context-state/index.d.ts",
66
75
  "import": {
@@ -79,15 +88,6 @@
79
88
  "require": "./create-context-reducer/index.cjs",
80
89
  "default": "./create-context-reducer/index.cjs"
81
90
  },
82
- "./context-reducer": {
83
- "types": "./context-reducer/index.d.ts",
84
- "import": {
85
- "types": "./context-reducer/index.d.ts",
86
- "default": "./context-reducer/index.mjs"
87
- },
88
- "require": "./context-reducer/index.cjs",
89
- "default": "./context-reducer/index.cjs"
90
- },
91
91
  "./create-context-state": {
92
92
  "types": "./create-context-state/index.d.ts",
93
93
  "import": {
@@ -187,6 +187,15 @@
187
187
  "require": "./invariant/index.cjs",
188
188
  "default": "./invariant/index.cjs"
189
189
  },
190
+ "./is-safari": {
191
+ "types": "./is-safari/index.d.ts",
192
+ "import": {
193
+ "types": "./is-safari/index.d.ts",
194
+ "default": "./is-safari/index.mjs"
195
+ },
196
+ "require": "./is-safari/index.cjs",
197
+ "default": "./is-safari/index.cjs"
198
+ },
190
199
  "./magic-portal": {
191
200
  "types": "./magic-portal/index.d.ts",
192
201
  "import": {
@@ -196,6 +205,15 @@
196
205
  "require": "./magic-portal/index.cjs",
197
206
  "default": "./magic-portal/index.cjs"
198
207
  },
208
+ "./merge-refs": {
209
+ "types": "./merge-refs/index.d.ts",
210
+ "import": {
211
+ "types": "./merge-refs/index.d.ts",
212
+ "default": "./merge-refs/index.mjs"
213
+ },
214
+ "require": "./merge-refs/index.cjs",
215
+ "default": "./merge-refs/index.cjs"
216
+ },
199
217
  "./no-ssr": {
200
218
  "types": "./no-ssr/index.d.ts",
201
219
  "import": {
@@ -205,15 +223,6 @@
205
223
  "require": "./no-ssr/index.cjs",
206
224
  "default": "./no-ssr/index.cjs"
207
225
  },
208
- "./is-safari": {
209
- "types": "./is-safari/index.d.ts",
210
- "import": {
211
- "types": "./is-safari/index.d.ts",
212
- "default": "./is-safari/index.mjs"
213
- },
214
- "require": "./is-safari/index.cjs",
215
- "default": "./is-safari/index.cjs"
216
- },
217
226
  "./noop": {
218
227
  "types": "./noop/index.d.ts",
219
228
  "import": {
@@ -241,15 +250,6 @@
241
250
  "require": "./open-new-tab/index.cjs",
242
251
  "default": "./open-new-tab/index.cjs"
243
252
  },
244
- "./request-idle-callback": {
245
- "types": "./request-idle-callback/index.d.ts",
246
- "import": {
247
- "types": "./request-idle-callback/index.d.ts",
248
- "default": "./request-idle-callback/index.mjs"
249
- },
250
- "require": "./request-idle-callback/index.cjs",
251
- "default": "./request-idle-callback/index.cjs"
252
- },
253
253
  "./rem": {
254
254
  "types": "./rem/index.d.ts",
255
255
  "import": {
@@ -259,6 +259,15 @@
259
259
  "require": "./rem/index.cjs",
260
260
  "default": "./rem/index.cjs"
261
261
  },
262
+ "./request-idle-callback": {
263
+ "types": "./request-idle-callback/index.d.ts",
264
+ "import": {
265
+ "types": "./request-idle-callback/index.d.ts",
266
+ "default": "./request-idle-callback/index.mjs"
267
+ },
268
+ "require": "./request-idle-callback/index.cjs",
269
+ "default": "./request-idle-callback/index.cjs"
270
+ },
262
271
  "./types": {
263
272
  "types": "./types/index.d.ts",
264
273
  "import": {
@@ -430,24 +439,6 @@
430
439
  "require": "./use-media-query/index.cjs",
431
440
  "default": "./use-media-query/index.cjs"
432
441
  },
433
- "./use-next-link": {
434
- "types": "./use-next-link/index.d.ts",
435
- "import": {
436
- "types": "./use-next-link/index.d.ts",
437
- "default": "./use-next-link/index.mjs"
438
- },
439
- "require": "./use-next-link/index.cjs",
440
- "default": "./use-next-link/index.cjs"
441
- },
442
- "./use-next-pathname": {
443
- "types": "./use-next-pathname/index.d.ts",
444
- "import": {
445
- "types": "./use-next-pathname/index.d.ts",
446
- "default": "./use-next-pathname/index.mjs"
447
- },
448
- "require": "./use-next-pathname/index.cjs",
449
- "default": "./use-next-pathname/index.cjs"
450
- },
451
442
  "./use-page-visibility": {
452
443
  "types": "./use-page-visibility/index.d.ts",
453
444
  "import": {
@@ -457,24 +448,6 @@
457
448
  "require": "./use-page-visibility/index.cjs",
458
449
  "default": "./use-page-visibility/index.cjs"
459
450
  },
460
- "./use-react-router-enable-concurrent-navigation": {
461
- "types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
462
- "import": {
463
- "types": "./use-react-router-enable-concurrent-navigation/index.d.ts",
464
- "default": "./use-react-router-enable-concurrent-navigation/index.mjs"
465
- },
466
- "require": "./use-react-router-enable-concurrent-navigation/index.cjs",
467
- "default": "./use-react-router-enable-concurrent-navigation/index.cjs"
468
- },
469
- "./use-react-router-is-match": {
470
- "types": "./use-react-router-is-match/index.d.ts",
471
- "import": {
472
- "types": "./use-react-router-is-match/index.d.ts",
473
- "default": "./use-react-router-is-match/index.mjs"
474
- },
475
- "require": "./use-react-router-is-match/index.cjs",
476
- "default": "./use-react-router-is-match/index.cjs"
477
- },
478
451
  "./use-readonly-search-params": {
479
452
  "types": "./use-readonly-search-params/index.d.ts",
480
453
  "import": {
package/sizes.json CHANGED
@@ -1 +1 @@
1
- {"total":{"raw":27628,"gzip":16819,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-context-state":{"raw":145,"gzip":116,"br":96},"context-reducer":{"raw":557,"gzip":332,"br":319},"context-state":{"raw":402,"gzip":259,"br":218},"create-magic-portal":{"raw":224,"gzip":136,"br":112},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"create-local-storage-state":{"raw":402,"gzip":216,"br":189},"create-storage-state-factory":{"raw":592,"gzip":338,"br":304},"create-session-storage-state":{"raw":406,"gzip":215,"br":188},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"current-year":{"raw":524,"gzip":355,"br":293},"invariant":{"raw":178,"gzip":156,"br":118},"create-storage-hook":{"raw":2087,"gzip":897,"br":789},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"is-safari":{"raw":233,"gzip":164,"br":119},"noop":{"raw":33,"gzip":53,"br":37},"email-protection":{"raw":426,"gzip":321,"br":272},"open-new-tab":{"raw":335,"gzip":255,"br":187},"magic-portal":{"raw":1039,"gzip":521,"br":463},"nullthrow":{"raw":187,"gzip":163,"br":121},"types":{"raw":0,"gzip":20,"br":1},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"use":{"raw":298,"gzip":197,"br":160},"no-ssr":{"raw":465,"gzip":313,"br":260},"rem":{"raw":823,"gzip":395,"br":350},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-array":{"raw":322,"gzip":236,"br":202},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-fast-click":{"raw":578,"gzip":377,"br":304},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-is-online":{"raw":370,"gzip":258,"br":220},"use-local-storage":{"raw":384,"gzip":215,"br":201},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-media-query":{"raw":604,"gzip":380,"br":315},"use-map":{"raw":339,"gzip":243,"br":208},"use-next-pathname":{"raw":314,"gzip":235,"br":203},"use-page-visibility":{"raw":359,"gzip":263,"br":210},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-react-router-is-match":{"raw":594,"gzip":395,"br":337},"use-react-router-enable-concurrent-navigation":{"raw":966,"gzip":470,"br":397},"use-readonly-search-params":{"raw":1120,"gzip":573,"br":477},"use-session-storage":{"raw":390,"gzip":210,"br":201},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-set":{"raw":340,"gzip":238,"br":203},"use-next-link":{"raw":1647,"gzip":875,"br":742},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"use-state-with-deps":{"raw":464,"gzip":321,"br":295},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":450,"gzip":318,"br":249},"use-url-hash-state":{"raw":1077,"gzip":611,"br":536}}}
1
+ {"total":{"raw":24632,"gzip":15124,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"context-reducer":{"raw":557,"gzip":332,"br":319},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"create-context-state":{"raw":145,"gzip":116,"br":96},"create-local-storage-state":{"raw":402,"gzip":216,"br":189},"create-magic-portal":{"raw":224,"gzip":136,"br":112},"context-state":{"raw":402,"gzip":259,"br":218},"create-storage-state-factory":{"raw":592,"gzip":338,"br":304},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-session-storage-state":{"raw":406,"gzip":215,"br":188},"create-storage-hook":{"raw":2087,"gzip":897,"br":789},"email-protection":{"raw":426,"gzip":321,"br":272},"is-safari":{"raw":233,"gzip":164,"br":119},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"current-year":{"raw":524,"gzip":355,"br":293},"invariant":{"raw":178,"gzip":156,"br":118},"noop":{"raw":33,"gzip":53,"br":37},"no-ssr":{"raw":465,"gzip":313,"br":260},"merge-refs":{"raw":525,"gzip":280,"br":235},"nullthrow":{"raw":187,"gzip":163,"br":121},"magic-portal":{"raw":1039,"gzip":521,"br":463},"types":{"raw":0,"gzip":20,"br":1},"open-new-tab":{"raw":335,"gzip":255,"br":187},"use":{"raw":298,"gzip":197,"br":160},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-composition-input":{"raw":470,"gzip":286,"br":241},"rem":{"raw":823,"gzip":395,"br":350},"use-debounced-value":{"raw":524,"gzip":342,"br":286},"use-array":{"raw":322,"gzip":236,"br":202},"use-clipboard":{"raw":1177,"gzip":650,"br":552},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-is-online":{"raw":370,"gzip":258,"br":220},"use-fast-click":{"raw":578,"gzip":377,"br":304},"use-map":{"raw":339,"gzip":243,"br":208},"use-local-storage":{"raw":384,"gzip":215,"br":201},"use-intersection":{"raw":1230,"gzip":649,"br":597},"use-page-visibility":{"raw":359,"gzip":263,"br":210},"use-retimer":{"raw":199,"gzip":166,"br":127},"use-media-query":{"raw":604,"gzip":380,"br":315},"use-session-storage":{"raw":390,"gzip":210,"br":201},"use-set":{"raw":340,"gzip":238,"br":203},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-readonly-search-params":{"raw":1120,"gzip":573,"br":477},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"use-state-with-deps":{"raw":464,"gzip":321,"br":295},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":450,"gzip":318,"br":249},"use-uncontrolled":{"raw":388,"gzip":273,"br":230},"use-url-hash-state":{"raw":1077,"gzip":611,"br":536}}}
@@ -1 +0,0 @@
1
- "use strict";require("client-only");var e=require("react"),t=require("next/navigation"),r=require("next/dist/shared/lib/router/utils/format-url"),n=require("../use-intersection/index.cjs"),o=require("../use-component-will-receive-update/index.cjs");function u(e,t,r){"u">typeof window&&Promise.resolve(e.prefetch(t,r)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}require("../request-idle-callback/index.cjs");const i={rootMargin:"200px"};exports.unstable_useNextLink=function(c,s){let{prefetch:l,ref:a,onClick:f,onMouseEnter:p,onTouchStart:d,scroll:v=!0,replace:y=!1,...E}=s;const h=null==l?"auto":"full",k=!1!==l,m=t.useRouter(),[N,b]=e.useTransition(),[q,x,g]=n.useIntersection(i),C=e.useMemo(()=>"string"==typeof c?c:r.formatUrl(c),[c]);return o.useComponentWillReceiveUpdate(g,[C]),e.useEffect(()=>{"production"!==process.env.NODE_ENV||x&&k&&u(m,C,{kind:h})},[h,x,k,C,m]),[N,{ref:e.useCallback(e=>{q(e),"function"==typeof a?a(e):a&&e&&(a.current=e)},[a,q]),onClick:e.useCallback(e=>{if("function"==typeof f&&f(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;"A"===t.toUpperCase()&&function(e){var t;const r=e.currentTarget,n=r.getAttribute("target");return n&&"_self"!==n||r.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(null==(t=e.nativeEvent)?void 0:t.which)===2}(e)||(e.preventDefault(),b(()=>{m[y?"replace":"push"](C,{scroll:v})}))},[f,y,C,m,v]),onMouseEnter:e.useCallback(e=>{"function"==typeof p&&p(e),"development"===process.env.NODE_ENV||k&&u(m,C,{kind:h})},[h,p,k,C,m]),onTouchStart:e.useCallback(e=>{"function"==typeof d&&d(e),"development"===process.env.NODE_ENV||k&&u(m,C,{kind:h})},[h,d,k,C,m]),...E}]};
@@ -1,31 +0,0 @@
1
- import { LinkProps } from 'next/link';
2
-
3
- interface UrlObject {
4
- auth?: string | null | undefined;
5
- hash?: string | null | undefined;
6
- host?: string | null | undefined;
7
- hostname?: string | null | undefined;
8
- href?: string | null | undefined;
9
- pathname?: string | null | undefined;
10
- protocol?: string | null | undefined;
11
- search?: string | null | undefined;
12
- slashes?: boolean | null | undefined;
13
- port?: string | number | null | undefined;
14
- query?: any;
15
- }
16
- interface UseNextLinkOptions extends Omit<LinkProps, 'as' | 'href' | 'legacyBehavior' | 'shallow' | 'passHref' | 'locale'> {
17
- ref?: React.RefObject<HTMLAnchorElement> | React.RefCallback<HTMLAnchorElement> | null;
18
- }
19
- interface UseNextLinkReturnProps extends Partial<React.JSX.IntrinsicElements['a']> {
20
- ref: React.RefCallback<HTMLAnchorElement>;
21
- onTouchStart: React.TouchEventHandler<HTMLAnchorElement>;
22
- onMouseEnter: React.MouseEventHandler<HTMLAnchorElement>;
23
- onClick: React.MouseEventHandler<HTMLAnchorElement>;
24
- href?: string;
25
- }
26
- /** @see https://foxact.skk.moe/use-next-link */
27
- declare function useNextLink(hrefProp: string | UrlObject, { prefetch: prefetchProp, ref, onClick, onMouseEnter, onTouchStart, scroll: routerScroll, replace, ...restProps }: UseNextLinkOptions): [isPending: boolean, linkProps: UseNextLinkReturnProps];
28
- declare const unstable_useNextLink: typeof useNextLink;
29
-
30
- export { unstable_useNextLink };
31
- export type { UseNextLinkOptions, UseNextLinkReturnProps };
@@ -1 +0,0 @@
1
- import"client-only";import{useTransition as e,useMemo as t,useEffect as o,useCallback as n}from"react";import{useRouter as r}from"next/navigation";import{formatUrl as i}from"next/dist/shared/lib/router/utils/format-url";import{useIntersection as c}from"../use-intersection/index.mjs";import{useComponentWillReceiveUpdate as u}from"../use-component-will-receive-update/index.mjs";import"../request-idle-callback/index.mjs";function s(e,t,o){"u">typeof window&&Promise.resolve(e.prefetch(t,o)).catch(e=>{if("production"!==process.env.NODE_ENV)throw e})}const l={rootMargin:"200px"},p=function(p,f){let{prefetch:a,ref:m,onClick:d,onMouseEnter:v,onTouchStart:y,scroll:h=!0,replace:E=!1,...N}=f;const x=null==a?"auto":"full",g=!1!==a,k=r(),[w,_]=e(),[D,b,K]=c(l),O=t(()=>"string"==typeof p?p:i(p),[p]);return u(K,[O]),o(()=>{"production"!==process.env.NODE_ENV||b&&g&&s(k,O,{kind:x})},[x,b,g,O,k]),[w,{ref:n(e=>{D(e),"function"==typeof m?m(e):m&&e&&(m.current=e)},[m,D]),onClick:n(e=>{if("function"==typeof d&&d(e),e.defaultPrevented)return;const{nodeName:t}=e.currentTarget;"A"===t.toUpperCase()&&function(e){var t;const o=e.currentTarget,n=o.getAttribute("target");return n&&"_self"!==n||o.download||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(null==(t=e.nativeEvent)?void 0:t.which)===2}(e)||(e.preventDefault(),_(()=>{k[E?"replace":"push"](O,{scroll:h})}))},[d,E,O,k,h]),onMouseEnter:n(e=>{"function"==typeof v&&v(e),"development"===process.env.NODE_ENV||g&&s(k,O,{kind:x})},[x,v,g,O,k]),onTouchStart:n(e=>{"function"==typeof y&&y(e),"development"===process.env.NODE_ENV||g&&s(k,O,{kind:x})},[x,y,g,O,k]),...N}]};export{p as unstable_useNextLink};
@@ -1 +0,0 @@
1
- "use strict";require("client-only");var e=require("next/router.js"),t=require("react");exports.useNextPathname=function(){let r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{asPath:n}=e.useRouter();return t.useMemo(()=>{const e=n.split(/[#?]/)[0];return r?e.endsWith("/")?e:"".concat(e,"/"):e},[r,n])};
@@ -1,4 +0,0 @@
1
- /** @see https://foxact.skk.moe/use-next-pathname */
2
- declare function useNextPathname(ensureTrailingSlash?: boolean): string;
3
-
4
- export { useNextPathname };
@@ -1 +0,0 @@
1
- import"client-only";import{useRouter as t}from"next/router.js";import{useMemo as e}from"react";function n(){let n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{asPath:o}=t();return e(()=>{const t=o.split(/[#?]/)[0];return n?t.endsWith("/")?t:"".concat(t,"/"):t},[n,o])}export{n as useNextPathname};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- "use strict";require("client-only");var r=require("react"),e=require("react-router-dom");function t(){const{navigator:t}=r.useContext(e.UNSAFE_NavigationContext);if(!t)throw TypeError("[foxact/use-react-router-enable-concurrent-navigation] must be used under <RouterProvider /> or a Router component (e.g. <BrowserRouter />)");r.useEffect(()=>{const e=t.go.bind(t),n=t.push.bind(t),o=t.replace.bind(t);return t.go=function(){for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];return r.startTransition(()=>e.apply(t,o))},t.push=function(){for(var e=arguments.length,o=Array(e),a=0;a<e;a++)o[a]=arguments[a];return r.startTransition(()=>n.apply(t,o))},t.replace=function(){for(var e=arguments.length,n=Array(e),a=0;a<e;a++)n[a]=arguments[a];return r.startTransition(()=>o.apply(t,n))},()=>{t.go=e,t.push=n,t.replace=o}},[t])}exports.ReactRouterConcurrentNavigationProvider=function(r){let{children:e}=r;return t(),e},exports.useReactRouterEnableConcurrentNavigation=t;
@@ -1,8 +0,0 @@
1
- import * as react from 'react';
2
- import { Foxact } from '../types/index.js';
3
-
4
- /** @see https://foxact.skk.moe/use-react-router-enable-concurrent-navigation */
5
- declare function useReactRouterEnableConcurrentNavigation(): void;
6
- declare function ReactRouterConcurrentNavigationProvider({ children }: Foxact.PropsWithChildren): react.ReactNode;
7
-
8
- export { ReactRouterConcurrentNavigationProvider, useReactRouterEnableConcurrentNavigation };
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import"client-only";import{useContext as r,useEffect as e,startTransition as o}from"react";import{UNSAFE_NavigationContext as t}from"react-router-dom";function n(){const{navigator:n}=r(t);if(!n)throw TypeError("[foxact/use-react-router-enable-concurrent-navigation] must be used under <RouterProvider /> or a Router component (e.g. <BrowserRouter />)");e(()=>{const r=n.go.bind(n),e=n.push.bind(n),t=n.replace.bind(n);return n.go=function(){for(var e=arguments.length,t=Array(e),u=0;u<e;u++)t[u]=arguments[u];return o(()=>r.apply(n,t))},n.push=function(){for(var r=arguments.length,t=Array(r),u=0;u<r;u++)t[u]=arguments[u];return o(()=>e.apply(n,t))},n.replace=function(){for(var r=arguments.length,e=Array(r),u=0;u<r;u++)e[u]=arguments[u];return o(()=>t.apply(n,e))},()=>{n.go=r,n.push=e,n.replace=t}},[n])}function u(r){let{children:e}=r;return n(),e}export{u as ReactRouterConcurrentNavigationProvider,n as useReactRouterEnableConcurrentNavigation};
@@ -1 +0,0 @@
1
- "use strict";require("client-only");var e=require("../chunks/index.b9dLwVor.cjs"),t=require("react"),r=require("react-router-dom");exports.useReactRouterIsMatch=function(o){let{relative:a,caseSensitive:n=!1,end:s=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{pathname:u}=r.useLocation(),{navigator:{encodeLocation:i=e.t}}=t.useContext(r.UNSAFE_NavigationContext),c=r.useResolvedPath(o,{relative:a});return t.useMemo(()=>{let e=u,t=i(c).pathname;return n||(e=e.toLowerCase(),t=t.toLowerCase()),e===t||!s&&e.startsWith(t)&&"/"===e.charAt(t.length)},[i,c,u,n,s])};
@@ -1,11 +0,0 @@
1
- import { To, RelativeRoutingType } from 'react-router-dom';
2
-
3
- interface UseReactRouterIsMatchOption {
4
- relative?: RelativeRoutingType;
5
- caseSensitive?: boolean;
6
- end?: boolean;
7
- }
8
- /** @see https://foxact.skk.moe/use-react-router-is-match */
9
- declare function useReactRouterIsMatch(to: To, { relative, caseSensitive, end }?: UseReactRouterIsMatchOption): any;
10
-
11
- export { useReactRouterIsMatch };
@@ -1 +0,0 @@
1
- import"client-only";import{t}from"../chunks/index.D0KaUCcV.mjs";import{useContext as r,useMemo as e}from"react";import{useLocation as o,UNSAFE_NavigationContext as a,useResolvedPath as n}from"react-router-dom";function m(m){let{relative:i,caseSensitive:c=!1,end:s=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{pathname:h}=o(),{navigator:{encodeLocation:p=t}}=r(a),u=n(m,{relative:i});return e(()=>{let t=h,r=p(u).pathname;return c||(t=t.toLowerCase(),r=r.toLowerCase()),t===r||!s&&t.startsWith(r)&&"/"===t.charAt(r.length)},[p,u,h,c,s])}export{m as useReactRouterIsMatch};