foxact 0.3.6 → 0.3.8

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.
Files changed (48) hide show
  1. package/breadcrumbs/index.cjs +1 -1
  2. package/breadcrumbs/index.d.ts +2 -2
  3. package/breadcrumbs/index.mjs +1 -1
  4. package/create-breadcrumbs/index.cjs +1 -1
  5. package/create-breadcrumbs/index.mjs +1 -1
  6. package/create-context-reducer/index.cjs +1 -1
  7. package/create-context-reducer/index.mjs +1 -1
  8. package/create-context-state/index.cjs +1 -1
  9. package/create-context-state/index.mjs +1 -1
  10. package/create-local-storage-state/index.cjs +1 -1
  11. package/create-local-storage-state/index.mjs +1 -1
  12. package/create-magic-portal/index.cjs +1 -1
  13. package/create-magic-portal/index.mjs +1 -1
  14. package/create-session-storage-state/index.cjs +1 -1
  15. package/create-session-storage-state/index.mjs +1 -1
  16. package/create-storage-hook/index.cjs +1 -1
  17. package/create-storage-hook/index.mjs +1 -1
  18. package/create-storage-state-factory/index.cjs +1 -1
  19. package/create-storage-state-factory/index.mjs +1 -1
  20. package/current-year/index.cjs +1 -1
  21. package/current-year/index.mjs +1 -1
  22. package/magic-portal/index.cjs +1 -1
  23. package/magic-portal/index.mjs +1 -1
  24. package/merge-props/index.cjs +1 -0
  25. package/merge-props/index.d.ts +7 -0
  26. package/merge-props/index.mjs +1 -0
  27. package/package.json +121 -94
  28. package/polymorphic/index.cjs +1 -0
  29. package/polymorphic/index.d.ts +19 -0
  30. package/polymorphic/index.mjs +1 -0
  31. package/sizes.json +1 -1
  32. package/use-fast-click/index.cjs +1 -1
  33. package/use-fast-click/index.mjs +1 -1
  34. package/use-local-storage/index.cjs +1 -1
  35. package/use-local-storage/index.mjs +1 -1
  36. package/use-media-query/index.cjs +1 -1
  37. package/use-media-query/index.mjs +1 -1
  38. package/use-readonly-search-params/index.cjs +1 -1
  39. package/use-readonly-search-params/index.mjs +1 -1
  40. package/use-resizing/index.cjs +1 -0
  41. package/use-resizing/index.d.ts +9 -0
  42. package/use-resizing/index.mjs +1 -0
  43. package/use-session-storage/index.cjs +1 -1
  44. package/use-session-storage/index.mjs +1 -1
  45. package/use-state-with-deps/index.cjs +1 -1
  46. package/use-state-with-deps/index.mjs +1 -1
  47. package/use-url-hash-state/index.cjs +1 -1
  48. package/use-url-hash-state/index.mjs +1 -1
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime");require("client-only");var r=require("react"),t=require("../magic-portal/index.cjs");require("react-dom"),require("../context-state/index.cjs"),require("../noop/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),exports.createBreadcrumbs=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anonymous)";const i=r.createContext([]),[c,s,o]=t.createMagicPortal(n);return[c,s,function(t){let{title:n,href:c,meta:s,children:o}=t;const u=r.useContext(i),a=r.useMemo(()=>[...u,{title:n,href:c,meta:s}],[u,n,c,s]);return e.jsx(i.Provider,{value:a,children:o})},function(t){const{title:n,meta:c}=t,s=r.useContext(i),u=r.useMemo(()=>[...s,{title:n,meta:c}],[s,n,c]),{children:a}=t,l=r.isValidElement(a)?a:a(u);return e.jsx(i.Provider,{value:u,children:e.jsx(o,{children:l})})},function(){return r.useContext(i)}]};
1
+ "use strict";var e=require("react/jsx-runtime");require("client-only");var r=require("react"),t=require("../magic-portal/index.cjs");exports.createBreadcrumbs=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anonymous)";const o=r.createContext([]),[u,c,i]=t.createMagicPortal(n);function s(t){let{title:n,href:u,meta:c,children:i}=t;const s=r.useContext(o),a=r.useMemo(()=>[...s,{title:n,href:u,meta:c}],[s,n,u,c]);return e.jsx(o.Provider,{value:a,children:i})}function a(t){const{title:n,meta:u}=t,c=r.useContext(o),s=r.useMemo(()=>[...c,{title:n,meta:u}],[c,n,u]),{children:a}=t,l=r.isValidElement(a)?a:a(s);return e.jsx(o.Provider,{value:s,children:e.jsx(i,{children:l})})}return"production"!==process.env.NODE_ENV&&(s.displayName=n+".BreadcrumbSegment"),"production"!==process.env.NODE_ENV&&(a.displayName=n+".BreadcrumbCurrent"),[u,c,s,a,function(){return r.useContext(o)}]};
@@ -22,8 +22,8 @@ type BreadcrumbPortalTargetProps<E extends React.ElementType = 'div'> = Omit<Rea
22
22
  declare function createBreadcrumbs<T = unknown>(name?: string): [
23
23
  BreadcrumbProvider: React.ComponentType<React.PropsWithChildren>,
24
24
  BreadcrumbPortalTarget: <E extends React.ElementType = 'div'>(props: BreadcrumbPortalTargetProps<E>) => React.ReactNode,
25
- BreadcrumbItem: (props: BreadcrumbItemProps<T>) => React.ReactNode,
26
- BreadcrumbPage: (props: BreadcrumbPageProps<T>) => React.ReactNode | null,
25
+ BreadcrumbSegment: (props: BreadcrumbItemProps<T>) => React.ReactNode,
26
+ BreadcrumbCurrent: (props: BreadcrumbPageProps<T>) => React.ReactNode | null,
27
27
  useBreadcrumbs: () => Array<BreadcrumbItemData<T>>
28
28
  ];
29
29
 
@@ -1 +1 @@
1
- import{jsx as r}from"react/jsx-runtime";import"client-only";import{useContext as t,useMemo as e,isValidElement as o,createContext as n}from"react";import{createMagicPortal as i}from"../magic-portal/index.mjs";import"react-dom";import"../context-state/index.mjs";import"../noop/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";function m(){let m=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anonymous)";const c=n([]),[s,d,u]=i(m);return[s,d,function(o){let{title:n,href:i,meta:m,children:s}=o;const d=t(c),u=e(()=>[...d,{title:n,href:i,meta:m}],[d,n,i,m]);return r(c.Provider,{value:u,children:s})},function(n){const{title:i,meta:m}=n,s=t(c),d=e(()=>[...s,{title:i,meta:m}],[s,i,m]),{children:a}=n,l=o(a)?a:a(d);return r(c.Provider,{value:d,children:r(u,{children:l})})},function(){return t(c)}]}export{m as createBreadcrumbs};
1
+ import{jsx as r}from"react/jsx-runtime";import"client-only";import{useContext as e,useMemo as n,isValidElement as t,createContext as o}from"react";import{createMagicPortal as c}from"../magic-portal/index.mjs";function i(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anonymous)";const u=o([]),[m,a,d]=c(i);function l(t){let{title:o,href:c,meta:i,children:m}=t;const a=e(u),d=n(()=>[...a,{title:o,href:c,meta:i}],[a,o,c,i]);return r(u.Provider,{value:d,children:m})}function s(o){const{title:c,meta:i}=o,m=e(u),a=n(()=>[...m,{title:c,meta:i}],[m,c,i]),{children:l}=o,s=t(l)?l:l(a);return r(u.Provider,{value:a,children:r(d,{children:s})})}return"production"!==process.env.NODE_ENV&&(l.displayName=i+".BreadcrumbSegment"),"production"!==process.env.NODE_ENV&&(s.displayName=i+".BreadcrumbCurrent"),[m,a,l,s,function(){return e(u)}]}export{i as createBreadcrumbs};
@@ -1 +1 @@
1
- "use strict";var e=require("../breadcrumbs/index.cjs");require("react/jsx-runtime"),require("client-only"),require("react"),require("../magic-portal/index.cjs"),require("react-dom"),require("../context-state/index.cjs"),require("../noop/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),exports.createBreadcrumbs=e.createBreadcrumbs;
1
+ "use strict";var r=require("../breadcrumbs/index.cjs");exports.createBreadcrumbs=r.createBreadcrumbs;
@@ -1 +1 @@
1
- export{createBreadcrumbs}from"../breadcrumbs/index.mjs";import"react/jsx-runtime";import"client-only";import"react";import"../magic-portal/index.mjs";import"react-dom";import"../context-state/index.mjs";import"../noop/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";
1
+ export{createBreadcrumbs}from"../breadcrumbs/index.mjs";
@@ -1 +1 @@
1
- "use strict";var e=require("../context-reducer/index.cjs");require("react/jsx-runtime"),require("client-only"),require("react"),require("../noop/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs"),exports.createContextReducer=e.createContextReducer;
1
+ "use strict";var e=require("../context-reducer/index.cjs");exports.createContextReducer=e.createContextReducer;
@@ -1 +1 @@
1
- export{createContextReducer}from"../context-reducer/index.mjs";import"react/jsx-runtime";import"client-only";import"react";import"../noop/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";
1
+ export{createContextReducer}from"../context-reducer/index.mjs";
@@ -1 +1 @@
1
- "use strict";var e=require("../context-state/index.cjs");require("react/jsx-runtime"),require("client-only"),require("react"),require("../noop/index.cjs"),exports.createContextState=e.createContextState;
1
+ "use strict";var t=require("../context-state/index.cjs");exports.createContextState=t.createContextState;
@@ -1 +1 @@
1
- export{createContextState}from"../context-state/index.mjs";import"react/jsx-runtime";import"client-only";import"react";import"../noop/index.mjs";
1
+ export{createContextState}from"../context-state/index.mjs";
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const r=e.createStorageStateFactory("localStorage");exports.createLocalStorageState=r;
1
+ "use strict";require("client-only");const e=require("../create-storage-state-factory/index.cjs").createStorageStateFactory("localStorage");exports.createLocalStorageState=e;
@@ -1 +1 @@
1
- import"client-only";import{createStorageStateFactory as e}from"../create-storage-state-factory/index.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const o=e("localStorage");export{o as createLocalStorageState};
1
+ import"client-only";import{createStorageStateFactory as t}from"../create-storage-state-factory/index.mjs";const e=t("localStorage");export{e as createLocalStorageState};
@@ -1 +1 @@
1
- "use strict";var e=require("../magic-portal/index.cjs");require("react/jsx-runtime"),require("client-only"),require("react-dom"),require("../context-state/index.cjs"),require("react"),require("../noop/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),exports.createMagicPortal=e.createMagicPortal;
1
+ "use strict";var r=require("../magic-portal/index.cjs");exports.createMagicPortal=r.createMagicPortal;
@@ -1 +1 @@
1
- export{createMagicPortal}from"../magic-portal/index.mjs";import"react/jsx-runtime";import"client-only";import"react-dom";import"../context-state/index.mjs";import"react";import"../noop/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";
1
+ export{createMagicPortal}from"../magic-portal/index.mjs";
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-state-factory/index.cjs");require("../create-storage-hook/index.cjs"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const r=e.createStorageStateFactory("sessionStorage");exports.createSessionStorageState=r;
1
+ "use strict";require("client-only");const e=require("../create-storage-state-factory/index.cjs").createStorageStateFactory("sessionStorage");exports.createSessionStorageState=e;
@@ -1 +1 @@
1
- import"client-only";import{createStorageStateFactory as e}from"../create-storage-state-factory/index.mjs";import"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const o=e("sessionStorage");export{o as createSessionStorageState};
1
+ import"client-only";import{createStorageStateFactory as t}from"../create-storage-state-factory/index.mjs";const e=t("sessionStorage");export{e as createSessionStorageState};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),t=require("../noop/index.cjs"),r=require("../use-isomorphic-layout-effect/index.cjs"),n=require("../no-ssr/index.cjs"),o=require("../chunks/index.b9dLwVor.cjs"),i=require("../chunks/index.BtiK5_Nn.cjs");require("../create-stackless-error/index.cjs"),exports.createStorage=function(a){const s="localStorage"===a?"foxact-use-local-storage":"foxact-use-session-storage",l="localStorage"===a?"foxact/use-local-storage":"foxact/use-session-storage";function c(){throw n.noSSRError("[".concat(l,"] cannot be used on the server without a serverValue"))}const u="u"<typeof window?t.noop:e=>{window.dispatchEvent(new CustomEvent(s,{detail:e}))},d="u"<typeof window?t.noop:(e,t)=>{try{window[a].setItem(e,t)}catch(e){console.warn("[".concat(l,"] Failed to set value to ").concat(a,", it might be blocked"))}finally{u(e)}},w="u"<typeof window?t.noop:e=>{try{window[a].removeItem(e)}catch(e){console.warn("[".concat(l,"] Failed to remove value from ").concat(a,", it might be blocked"))}finally{u(e)}},f=e=>{if("u"<typeof window)return null;try{return window[a].getItem(e)}catch(e){return console.warn("[".concat(l,"] Failed to get value from ").concat(a,", it might be blocked")),null}},v=function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const n=r.raw?o.t:r.serializer,a=r.raw?o.t:r.deserializer;return e.useCallback(e=>{try{let r;if(i.n(e)){const n=f(t),o=null===n?null:a(n);r=e(o)}else r=e;null===r?w(t):d(t,n(r))}catch(e){console.warn(e)}},[t,n,a])};function g(n,i){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const l=e.useCallback(e=>{if("u"<typeof window)return t.noop;const r=t=>{"key"in t&&t.key!==n||e()},o=t=>{t.detail===n&&e()};return window.addEventListener("storage",r),window.addEventListener(s,o),()=>{window.removeEventListener("storage",r),window.removeEventListener(s,o)}},[n]),u=a.raw?o.t:a.serializer,w=a.raw?o.t:a.deserializer,v=void 0===i?c:()=>u(i),g=e.useSyncExternalStore(l,()=>f(n),v),y=e.useMemo(()=>null===g?null:w(g),[g,w]);return r.useLayoutEffect(()=>{null===f(n)&&void 0!==i&&d(n,u(i))},[n,u,i]),null===y?void 0===i?null:i:y}return{useStorageValue:g,useSetStorage:v,useStorage:function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};return[g(e,t,r),v(e,r)]}}};
1
+ "use strict";require("client-only");var e=require("react"),t=require("../noop/index.cjs"),n=require("../use-isomorphic-layout-effect/index.cjs"),r=require("../no-ssr/index.cjs"),o=require("../chunks/index.b9dLwVor.cjs"),i=require("../chunks/index.BtiK5_Nn.cjs");exports.createStorage=function(a){const s="localStorage"===a?"foxact-use-local-storage":"foxact-use-session-storage",l="localStorage"===a?"foxact/use-local-storage":"foxact/use-session-storage";function c(){throw r.noSSRError("[".concat(l,"] cannot be used on the server without a serverValue"))}const u="u"<typeof window?t.noop:e=>{window.dispatchEvent(new CustomEvent(s,{detail:e}))},d="u"<typeof window?t.noop:(e,t)=>{try{window[a].setItem(e,t)}catch(e){console.warn("[".concat(l,"] Failed to set value to ").concat(a,", it might be blocked"))}finally{u(e)}},w="u"<typeof window?t.noop:e=>{try{window[a].removeItem(e)}catch(e){console.warn("[".concat(l,"] Failed to remove value from ").concat(a,", it might be blocked"))}finally{u(e)}},f=e=>{if("u"<typeof window)return null;try{return window[a].getItem(e)}catch(e){return console.warn("[".concat(l,"] Failed to get value from ").concat(a,", it might be blocked")),null}},v=function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const r=n.raw?o.t:n.serializer,a=n.raw?o.t:n.deserializer;return e.useCallback(e=>{try{let n;if(i.n(e)){const r=f(t),o=null===r?null:a(r);n=e(o)}else n=e;null===n?w(t):d(t,r(n))}catch(e){console.warn(e)}},[t,r,a])};function g(r,i){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const l=e.useCallback(e=>{if("u"<typeof window)return t.noop;const n=t=>{"key"in t&&t.key!==r||e()},o=t=>{t.detail===r&&e()};return window.addEventListener("storage",n),window.addEventListener(s,o),()=>{window.removeEventListener("storage",n),window.removeEventListener(s,o)}},[r]),u=a.raw?o.t:a.serializer,w=a.raw?o.t:a.deserializer,v=void 0===i?c:()=>u(i),g=e.useSyncExternalStore(l,()=>f(r),v),y=e.useMemo(()=>null===g?null:w(g),[g,w]);return n.useLayoutEffect(()=>{null===f(r)&&void 0!==i&&d(r,u(i))},[r,u,i]),null===y?void 0===i?null:i:y}return{useStorageValue:g,useSetStorage:v,useStorage:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};return[g(e,t,n),v(e,n)]}}};
@@ -1 +1 @@
1
- import"client-only";import{useCallback as e,useSyncExternalStore as t,useMemo as o}from"react";import{noop as r}from"../noop/index.mjs";import{useLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as i}from"../no-ssr/index.mjs";import{t as a}from"../chunks/index.D0KaUCcV.mjs";import{n as s}from"../chunks/index.C9-3oDdv.mjs";import"../create-stackless-error/index.mjs";function l(l){const c="localStorage"===l?"foxact-use-local-storage":"foxact-use-session-storage",u="localStorage"===l?"foxact/use-local-storage":"foxact/use-session-storage";function d(){throw i("[".concat(u,"] cannot be used on the server without a serverValue"))}const w="u"<typeof window?r:e=>{window.dispatchEvent(new CustomEvent(c,{detail:e}))},m="u"<typeof window?r:(e,t)=>{try{window[l].setItem(e,t)}catch(e){console.warn("[".concat(u,"] Failed to set value to ").concat(l,", it might be blocked"))}finally{w(e)}},f="u"<typeof window?r:e=>{try{window[l].removeItem(e)}catch(e){console.warn("[".concat(u,"] Failed to remove value from ").concat(l,", it might be blocked"))}finally{w(e)}},g=e=>{if("u"<typeof window)return null;try{return window[l].getItem(e)}catch(e){return console.warn("[".concat(u,"] Failed to get value from ").concat(l,", it might be blocked")),null}},v=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const r=o.raw?a:o.serializer,n=o.raw?a:o.deserializer;return e(e=>{try{let o;if(s(e)){const r=g(t),i=null===r?null:n(r);o=e(i)}else o=e;null===o?f(t):m(t,r(o))}catch(e){console.warn(e)}},[t,r,n])};function p(i,s){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const u=e(e=>{if("u"<typeof window)return r;const t=t=>{"key"in t&&t.key!==i||e()},o=t=>{t.detail===i&&e()};return window.addEventListener("storage",t),window.addEventListener(c,o),()=>{window.removeEventListener("storage",t),window.removeEventListener(c,o)}},[i]),w=l.raw?a:l.serializer,f=l.raw?a:l.deserializer,v=t(u,()=>g(i),void 0===s?d:()=>w(s)),p=o(()=>null===v?null:f(v),[v,f]);return n(()=>{null===g(i)&&void 0!==s&&m(i,w(s))},[i,w,s]),null===p?void 0===s?null:s:p}return{useStorageValue:p,useSetStorage:v,useStorage:function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};return[p(e,t,o),v(e,o)]}}}export{l as createStorage};
1
+ import"client-only";import{useCallback as e,useSyncExternalStore as t,useMemo as o}from"react";import{noop as n}from"../noop/index.mjs";import{useLayoutEffect as r}from"../use-isomorphic-layout-effect/index.mjs";import{noSSRError as i}from"../no-ssr/index.mjs";import{t as a}from"../chunks/index.D0KaUCcV.mjs";import{n as l}from"../chunks/index.C9-3oDdv.mjs";function s(s){const c="localStorage"===s?"foxact-use-local-storage":"foxact-use-session-storage",u="localStorage"===s?"foxact/use-local-storage":"foxact/use-session-storage";function d(){throw i("[".concat(u,"] cannot be used on the server without a serverValue"))}const w="u"<typeof window?n:e=>{window.dispatchEvent(new CustomEvent(c,{detail:e}))},f="u"<typeof window?n:(e,t)=>{try{window[s].setItem(e,t)}catch(e){console.warn("[".concat(u,"] Failed to set value to ").concat(s,", it might be blocked"))}finally{w(e)}},m="u"<typeof window?n:e=>{try{window[s].removeItem(e)}catch(e){console.warn("[".concat(u,"] Failed to remove value from ").concat(s,", it might be blocked"))}finally{w(e)}},g=e=>{if("u"<typeof window)return null;try{return window[s].getItem(e)}catch(e){return console.warn("[".concat(u,"] Failed to get value from ").concat(s,", it might be blocked")),null}},v=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const n=o.raw?a:o.serializer,r=o.raw?a:o.deserializer;return e(e=>{try{let o;if(l(e)){const n=g(t),i=null===n?null:r(n);o=e(i)}else o=e;null===o?m(t):f(t,n(o))}catch(e){console.warn(e)}},[t,n,r])};function p(i,l){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const u=e(e=>{if("u"<typeof window)return n;const t=t=>{"key"in t&&t.key!==i||e()},o=t=>{t.detail===i&&e()};return window.addEventListener("storage",t),window.addEventListener(c,o),()=>{window.removeEventListener("storage",t),window.removeEventListener(c,o)}},[i]),w=s.raw?a:s.serializer,m=s.raw?a:s.deserializer,v=t(u,()=>g(i),void 0===l?d:()=>w(l)),p=o(()=>null===v?null:m(v),[v,m]);return r(()=>{null===g(i)&&void 0!==l&&f(i,w(l))},[i,w,l]),null===p?void 0===l?null:l:p}return{useStorageValue:p,useSetStorage:v,useStorage:function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};return[p(e,t,o),v(e,o)]}}}export{s as createStorage};
@@ -1 +1 @@
1
- "use strict";var e=require("../create-storage-hook/index.cjs");require("client-only"),require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs"),exports.createStorageStateFactory=function(r){return function(t,i){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:c,useStorageValue:n,useSetStorage:o}=e.createStorage(r);return[()=>c(t,i,s),()=>n(t,i,s),()=>o(t,s)]}};
1
+ "use strict";var e=require("../create-storage-hook/index.cjs");exports.createStorageStateFactory=function(r){return function(t,a){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:s,useStorageValue:i,useSetStorage:n}=e.createStorage(r);return[()=>s(t,a,o),()=>i(t,a,o),()=>n(t,o)]}};
@@ -1 +1 @@
1
- import{createStorage as e}from"../create-storage-hook/index.mjs";import"client-only";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";function r(r){return function(t,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:s,useStorageValue:n,useSetStorage:a}=e(r);return[()=>s(t,o,i),()=>n(t,o,i),()=>a(t,i)]}}export{r as createStorageStateFactory};
1
+ import{createStorage as e}from"../create-storage-hook/index.mjs";function r(r){return function(t,o){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:JSON.stringify,deserializer:JSON.parse};const{useStorage:i,useStorageValue:n,useSetStorage:s}=e(r);return[()=>i(t,o,a),()=>n(t,o,a),()=>s(t,a)]}}export{r as createStorageStateFactory};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");require("client-only");const n=r.memo(function(n){let{defaultYear:u,...i}=n;"u"<typeof window&&void 0===u&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[o,s]=r.useState(()=>u||new Date().getFullYear());return t.useIsomorphicLayoutEffect(()=>{s(new Date().getFullYear())},[]),e.jsx("span",{...i,children:o})});exports.CurrentYear=n;
2
+ "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");const u=r.memo(function(u){let{defaultYear:n,...i}=u;"u"<typeof window&&void 0===n&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[s,a]=r.useState(()=>n||new Date().getFullYear());return t.useIsomorphicLayoutEffect(()=>{a(new Date().getFullYear())},[]),e.jsx("span",{...i,children:s})});exports.CurrentYear=u;
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";const o=r(function(r){let{defaultYear:o,...i}=r;"u"<typeof window&&void 0===o&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[a,u]=t(()=>o||new Date().getFullYear());return n(()=>{u(new Date().getFullYear())},[]),e("span",{...i,children:a})});export{o as CurrentYear};
2
+ import{jsx as e}from"react/jsx-runtime";import{memo as r,useState as t}from"react";import{useIsomorphicLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";const o=r(function(r){let{defaultYear:o,...i}=r;"u"<typeof window&&void 0===o&&console.warn('[foxact/current-year] "defaultYear" is required during the server-side rendering.');const[a,u]=t(()=>o||new Date().getFullYear());return n(()=>{u(new Date().getFullYear())},[]),e("span",{...i,children:a})});export{o as CurrentYear};
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime");require("client-only");var r=require("react-dom"),t=require("../context-state/index.cjs"),n=require("../no-ssr/index.cjs"),o=require("react");require("../noop/index.cjs"),require("../create-stackless-error/index.cjs"),exports.createMagicPortal=function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[s,i,a]=t.createContextState(null);function l(r){let{as:t,ssrFallback:o=null,...s}=r;null!=o&&n.noSSR();const i=a();return e.jsx(t||"div",{...c?{"data-foxact-magic-portal-target":c}:{},ref:i,...s})}function u(r){const{ssrFallback:t=null}=r;return null!=t?e.jsx(o.Suspense,{fallback:t,children:e.jsx(l,{...r})}):e.jsx(l,{...r})}function d(e){let{children:t}=e;const n=i();return"u"<typeof window||!n?null:r.createPortal(t,n)}function p(r){let{children:t}=r;return e.jsx(s,{children:t})}return"production"!==process.env.NODE_ENV&&(u.displayName=c+".PortalTarget"),"production"!==process.env.NODE_ENV&&(d.displayName=c+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=c+".PortalProvider"),[p,u,d]};
1
+ "use strict";var e=require("react/jsx-runtime");require("client-only");var t=require("react-dom"),r=require("../context-state/index.cjs"),n=require("../no-ssr/index.cjs"),o=require("react");exports.createMagicPortal=function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[l,a,i]=r.createContextState(null);function s(t){let{as:r,ssrFallback:o=null,...l}=t;null!=o&&n.noSSR();const a=i();return e.jsx(r||"div",{...c?{"data-foxact-magic-portal-target":c}:{},ref:a,...l})}function u(t){const{ssrFallback:r=null}=t;return null!=r?e.jsx(o.Suspense,{fallback:r,children:e.jsx(s,{...t})}):e.jsx(s,{...t})}function d(e){let{children:r}=e;const n=a();return"u"<typeof window||!n?null:t.createPortal(r,n)}function p(t){let{children:r}=t;return e.jsx(l,{children:r})}return"production"!==process.env.NODE_ENV&&(u.displayName=c+".PortalTarget"),"production"!==process.env.NODE_ENV&&(d.displayName=c+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=c+".PortalProvider"),[p,u,d]};
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import"client-only";import{createPortal as o}from"react-dom";import{createContextState as r}from"../context-state/index.mjs";import{noSSR as n}from"../no-ssr/index.mjs";import{Suspense as e}from"react";import"../noop/index.mjs";import"../create-stackless-error/index.mjs";function i(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[l,c,a]=r(null);function s(o){let{as:r,ssrFallback:e=null,...l}=o;null!=e&&n();const c=a();return t(r||"div",{...i?{"data-foxact-magic-portal-target":i}:{},ref:c,...l})}function m(o){const{ssrFallback:r=null}=o;return null!=r?t(e,{fallback:r,children:t(s,{...o})}):t(s,{...o})}function u(t){let{children:r}=t;const n=c();return"u"<typeof window||!n?null:o(r,n)}function p(o){let{children:r}=o;return t(l,{children:r})}return"production"!==process.env.NODE_ENV&&(m.displayName=i+".PortalTarget"),"production"!==process.env.NODE_ENV&&(u.displayName=i+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=i+".PortalProvider"),[p,m,u]}export{i as createMagicPortal};
1
+ import{jsx as t}from"react/jsx-runtime";import"client-only";import{createPortal as o}from"react-dom";import{createContextState as r}from"../context-state/index.mjs";import{noSSR as n}from"../no-ssr/index.mjs";import{Suspense as e}from"react";function l(){let l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"(Anoymous)";const[i,c,a]=r(null);function u(o){let{as:r,ssrFallback:e=null,...i}=o;null!=e&&n();const c=a();return t(r||"div",{...l?{"data-foxact-magic-portal-target":l}:{},ref:c,...i})}function m(o){const{ssrFallback:r=null}=o;return null!=r?t(e,{fallback:r,children:t(u,{...o})}):t(u,{...o})}function s(t){let{children:r}=t;const n=c();return"u"<typeof window||!n?null:o(r,n)}function p(o){let{children:r}=o;return t(i,{children:r})}return"production"!==process.env.NODE_ENV&&(m.displayName=l+".PortalTarget"),"production"!==process.env.NODE_ENV&&(s.displayName=l+".PortalContent"),"production"!==process.env.NODE_ENV&&(p.displayName=l+".PortalProvider"),[p,m,s]}export{l as createMagicPortal};
@@ -0,0 +1 @@
1
+ "use strict";const t={};function r(t){return"function"==typeof t}function n(n,e){return r(n)?n(e):null!=n?n:t}exports.mergeProps=function(){for(var e,o,c,s=arguments.length,u=Array(s),a=0;a<s;a++)u[a]=arguments[a];const f=1===u.length&&Array.isArray(u[0])?u[0]:u;if(0===f.length)return t;let l=r(e=f[0])?{...n(e,t)}:{...e};if(1===f.length)return l;for(let t=1,e=f.length;t<e;t+=1){f[t]&&(o=l,l=r(c=f[t])?n(c,o):function(t,r){if(!r)return t;const n=Object.keys(r);for(let c=0;c<n.length;c++){const s=n[c],u=r[s];switch(s){case"style":{const r=t.style;r&&!u?t[s]=r:!r&&u?t[s]=u:(r||u)&&(t[s]={...r,...u});break}case"className":var e,o;t[s]=(e=t.className,(o=u)?e?o+" "+e:o:e);break;default:!function(t,r){const n=t.charCodeAt(0),e=t.charCodeAt(1),o=t.charCodeAt(2);return 111===n&&110===e&&o>=65&&o<=90&&("function"==typeof r||void 0===r)}(s,u)?t[s]=u:t[s]=function(t,r){return r?t?function(){for(var n=arguments.length,e=Array(n),o=0;o<n;o++)e[o]=arguments[o];const c=r(...e);return t(...e),c}:r:t}(t[s],u)}}return t}(o,c))}return l};
@@ -0,0 +1,7 @@
1
+ type PropsOf<T extends React.ElementType> = React.ComponentPropsWithRef<T>;
2
+ type InputProps<T extends React.ElementType> = PropsOf<T> | ((otherProps: PropsOf<T>) => PropsOf<T>) | undefined;
3
+ /** @see https://foxact.skk.moe/merge-props */
4
+ declare function mergeProps<T extends React.ElementType>(propsArray: Array<InputProps<T>>): PropsOf<T>;
5
+ declare function mergeProps<T extends React.ElementType>(...props: Array<InputProps<T>>): PropsOf<T>;
6
+
7
+ export { mergeProps };
@@ -0,0 +1 @@
1
+ const t={};function n(){for(var n,o,c,u=arguments.length,a=Array(u),f=0;f<u;f++)a[f]=arguments[f];const s=1===a.length&&Array.isArray(a[0])?a[0]:a;if(0===s.length)return t;let l=r(n=s[0])?{...e(n,t)}:{...n};if(1===s.length)return l;for(let t=1,n=s.length;t<n;t+=1){s[t]&&(o=l,l=r(c=s[t])?e(c,o):function(t,n){if(!n)return t;const r=Object.keys(n);for(let c=0;c<r.length;c++){const u=r[c],a=n[u];switch(u){case"style":{const n=t.style;n&&!a?t[u]=n:!n&&a?t[u]=a:(n||a)&&(t[u]={...n,...a});break}case"className":var e,o;t[u]=(e=t.className,(o=a)?e?o+" "+e:o:e);break;default:!function(t,n){const r=t.charCodeAt(0),e=t.charCodeAt(1),o=t.charCodeAt(2);return 111===r&&110===e&&o>=65&&o<=90&&("function"==typeof n||void 0===n)}(u,a)?t[u]=a:t[u]=function(t,n){return n?t?function(){for(var r=arguments.length,e=Array(r),o=0;o<r;o++)e[o]=arguments[o];const c=n(...e);return t(...e),c}:n:t}(t[u],a)}}return t}(o,c))}return l}function r(t){return"function"==typeof t}function e(n,e){return r(n)?n(e):null!=n?n:t}export{n as mergeProps};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxact",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
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": {
@@ -70,15 +70,6 @@
70
70
  "require": "./compose-context-provider/index.cjs",
71
71
  "default": "./compose-context-provider/index.cjs"
72
72
  },
73
- "./create-breadcrumbs": {
74
- "types": "./create-breadcrumbs/index.d.ts",
75
- "import": {
76
- "types": "./create-breadcrumbs/index.d.ts",
77
- "default": "./create-breadcrumbs/index.mjs"
78
- },
79
- "require": "./create-breadcrumbs/index.cjs",
80
- "default": "./create-breadcrumbs/index.cjs"
81
- },
82
73
  "./create-context-reducer": {
83
74
  "types": "./create-context-reducer/index.d.ts",
84
75
  "import": {
@@ -88,6 +79,15 @@
88
79
  "require": "./create-context-reducer/index.cjs",
89
80
  "default": "./create-context-reducer/index.cjs"
90
81
  },
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": {
@@ -115,6 +115,15 @@
115
115
  "require": "./create-fixed-array/index.cjs",
116
116
  "default": "./create-fixed-array/index.cjs"
117
117
  },
118
+ "./create-local-storage-state": {
119
+ "types": "./create-local-storage-state/index.d.ts",
120
+ "import": {
121
+ "types": "./create-local-storage-state/index.d.ts",
122
+ "default": "./create-local-storage-state/index.mjs"
123
+ },
124
+ "require": "./create-local-storage-state/index.cjs",
125
+ "default": "./create-local-storage-state/index.cjs"
126
+ },
118
127
  "./create-magic-portal": {
119
128
  "types": "./create-magic-portal/index.d.ts",
120
129
  "import": {
@@ -124,6 +133,15 @@
124
133
  "require": "./create-magic-portal/index.cjs",
125
134
  "default": "./create-magic-portal/index.cjs"
126
135
  },
136
+ "./create-breadcrumbs": {
137
+ "types": "./create-breadcrumbs/index.d.ts",
138
+ "import": {
139
+ "types": "./create-breadcrumbs/index.d.ts",
140
+ "default": "./create-breadcrumbs/index.mjs"
141
+ },
142
+ "require": "./create-breadcrumbs/index.cjs",
143
+ "default": "./create-breadcrumbs/index.cjs"
144
+ },
127
145
  "./create-session-storage-state": {
128
146
  "types": "./create-session-storage-state/index.d.ts",
129
147
  "import": {
@@ -178,15 +196,6 @@
178
196
  "require": "./fetch-jsonp/index.cjs",
179
197
  "default": "./fetch-jsonp/index.cjs"
180
198
  },
181
- "./context-reducer": {
182
- "types": "./context-reducer/index.d.ts",
183
- "import": {
184
- "types": "./context-reducer/index.d.ts",
185
- "default": "./context-reducer/index.mjs"
186
- },
187
- "require": "./context-reducer/index.cjs",
188
- "default": "./context-reducer/index.cjs"
189
- },
190
199
  "./invariant": {
191
200
  "types": "./invariant/index.d.ts",
192
201
  "import": {
@@ -196,6 +205,15 @@
196
205
  "require": "./invariant/index.cjs",
197
206
  "default": "./invariant/index.cjs"
198
207
  },
208
+ "./magic-portal": {
209
+ "types": "./magic-portal/index.d.ts",
210
+ "import": {
211
+ "types": "./magic-portal/index.d.ts",
212
+ "default": "./magic-portal/index.mjs"
213
+ },
214
+ "require": "./magic-portal/index.cjs",
215
+ "default": "./magic-portal/index.cjs"
216
+ },
199
217
  "./is-safari": {
200
218
  "types": "./is-safari/index.d.ts",
201
219
  "import": {
@@ -205,6 +223,15 @@
205
223
  "require": "./is-safari/index.cjs",
206
224
  "default": "./is-safari/index.cjs"
207
225
  },
226
+ "./merge-props": {
227
+ "types": "./merge-props/index.d.ts",
228
+ "import": {
229
+ "types": "./merge-props/index.d.ts",
230
+ "default": "./merge-props/index.mjs"
231
+ },
232
+ "require": "./merge-props/index.cjs",
233
+ "default": "./merge-props/index.cjs"
234
+ },
208
235
  "./merge-refs": {
209
236
  "types": "./merge-refs/index.d.ts",
210
237
  "import": {
@@ -214,14 +241,14 @@
214
241
  "require": "./merge-refs/index.cjs",
215
242
  "default": "./merge-refs/index.cjs"
216
243
  },
217
- "./magic-portal": {
218
- "types": "./magic-portal/index.d.ts",
244
+ "./noop": {
245
+ "types": "./noop/index.d.ts",
219
246
  "import": {
220
- "types": "./magic-portal/index.d.ts",
221
- "default": "./magic-portal/index.mjs"
247
+ "types": "./noop/index.d.ts",
248
+ "default": "./noop/index.mjs"
222
249
  },
223
- "require": "./magic-portal/index.cjs",
224
- "default": "./magic-portal/index.cjs"
250
+ "require": "./noop/index.cjs",
251
+ "default": "./noop/index.cjs"
225
252
  },
226
253
  "./no-ssr": {
227
254
  "types": "./no-ssr/index.d.ts",
@@ -232,15 +259,6 @@
232
259
  "require": "./no-ssr/index.cjs",
233
260
  "default": "./no-ssr/index.cjs"
234
261
  },
235
- "./noop": {
236
- "types": "./noop/index.d.ts",
237
- "import": {
238
- "types": "./noop/index.d.ts",
239
- "default": "./noop/index.mjs"
240
- },
241
- "require": "./noop/index.cjs",
242
- "default": "./noop/index.cjs"
243
- },
244
262
  "./nullthrow": {
245
263
  "types": "./nullthrow/index.d.ts",
246
264
  "import": {
@@ -268,6 +286,15 @@
268
286
  "require": "./open-new-tab/index.cjs",
269
287
  "default": "./open-new-tab/index.cjs"
270
288
  },
289
+ "./polymorphic": {
290
+ "types": "./polymorphic/index.d.ts",
291
+ "import": {
292
+ "types": "./polymorphic/index.d.ts",
293
+ "default": "./polymorphic/index.mjs"
294
+ },
295
+ "require": "./polymorphic/index.cjs",
296
+ "default": "./polymorphic/index.cjs"
297
+ },
271
298
  "./rem": {
272
299
  "types": "./rem/index.d.ts",
273
300
  "import": {
@@ -295,24 +322,6 @@
295
322
  "require": "./types/index.cjs",
296
323
  "default": "./types/index.cjs"
297
324
  },
298
- "./typescript-happy-forward-ref": {
299
- "types": "./typescript-happy-forward-ref/index.d.ts",
300
- "import": {
301
- "types": "./typescript-happy-forward-ref/index.d.ts",
302
- "default": "./typescript-happy-forward-ref/index.mjs"
303
- },
304
- "require": "./typescript-happy-forward-ref/index.cjs",
305
- "default": "./typescript-happy-forward-ref/index.cjs"
306
- },
307
- "./create-local-storage-state": {
308
- "types": "./create-local-storage-state/index.d.ts",
309
- "import": {
310
- "types": "./create-local-storage-state/index.d.ts",
311
- "default": "./create-local-storage-state/index.mjs"
312
- },
313
- "require": "./create-local-storage-state/index.cjs",
314
- "default": "./create-local-storage-state/index.cjs"
315
- },
316
325
  "./use": {
317
326
  "types": "./use/index.d.ts",
318
327
  "import": {
@@ -322,6 +331,15 @@
322
331
  "require": "./use/index.cjs",
323
332
  "default": "./use/index.cjs"
324
333
  },
334
+ "./typescript-happy-forward-ref": {
335
+ "types": "./typescript-happy-forward-ref/index.d.ts",
336
+ "import": {
337
+ "types": "./typescript-happy-forward-ref/index.d.ts",
338
+ "default": "./typescript-happy-forward-ref/index.mjs"
339
+ },
340
+ "require": "./typescript-happy-forward-ref/index.cjs",
341
+ "default": "./typescript-happy-forward-ref/index.cjs"
342
+ },
325
343
  "./use-abortable-effect": {
326
344
  "types": "./use-abortable-effect/index.d.ts",
327
345
  "import": {
@@ -331,6 +349,15 @@
331
349
  "require": "./use-abortable-effect/index.cjs",
332
350
  "default": "./use-abortable-effect/index.cjs"
333
351
  },
352
+ "./use-clipboard": {
353
+ "types": "./use-clipboard/index.d.ts",
354
+ "import": {
355
+ "types": "./use-clipboard/index.d.ts",
356
+ "default": "./use-clipboard/index.mjs"
357
+ },
358
+ "require": "./use-clipboard/index.cjs",
359
+ "default": "./use-clipboard/index.cjs"
360
+ },
334
361
  "./use-array": {
335
362
  "types": "./use-array/index.d.ts",
336
363
  "import": {
@@ -358,15 +385,6 @@
358
385
  "require": "./use-composition-input/index.cjs",
359
386
  "default": "./use-composition-input/index.cjs"
360
387
  },
361
- "./use-clipboard": {
362
- "types": "./use-clipboard/index.d.ts",
363
- "import": {
364
- "types": "./use-clipboard/index.d.ts",
365
- "default": "./use-clipboard/index.mjs"
366
- },
367
- "require": "./use-clipboard/index.cjs",
368
- "default": "./use-clipboard/index.cjs"
369
- },
370
388
  "./use-debounced-state": {
371
389
  "types": "./use-debounced-state/index.d.ts",
372
390
  "import": {
@@ -403,15 +421,6 @@
403
421
  "require": "./use-fast-click/index.cjs",
404
422
  "default": "./use-fast-click/index.cjs"
405
423
  },
406
- "./use-intersection": {
407
- "types": "./use-intersection/index.d.ts",
408
- "import": {
409
- "types": "./use-intersection/index.d.ts",
410
- "default": "./use-intersection/index.mjs"
411
- },
412
- "require": "./use-intersection/index.cjs",
413
- "default": "./use-intersection/index.cjs"
414
- },
415
424
  "./use-is-client": {
416
425
  "types": "./use-is-client/index.d.ts",
417
426
  "import": {
@@ -421,6 +430,15 @@
421
430
  "require": "./use-is-client/index.cjs",
422
431
  "default": "./use-is-client/index.cjs"
423
432
  },
433
+ "./use-intersection": {
434
+ "types": "./use-intersection/index.d.ts",
435
+ "import": {
436
+ "types": "./use-intersection/index.d.ts",
437
+ "default": "./use-intersection/index.mjs"
438
+ },
439
+ "require": "./use-intersection/index.cjs",
440
+ "default": "./use-intersection/index.cjs"
441
+ },
424
442
  "./use-is-online": {
425
443
  "types": "./use-is-online/index.d.ts",
426
444
  "import": {
@@ -457,6 +475,15 @@
457
475
  "require": "./use-media-query/index.cjs",
458
476
  "default": "./use-media-query/index.cjs"
459
477
  },
478
+ "./use-map": {
479
+ "types": "./use-map/index.d.ts",
480
+ "import": {
481
+ "types": "./use-map/index.d.ts",
482
+ "default": "./use-map/index.mjs"
483
+ },
484
+ "require": "./use-map/index.cjs",
485
+ "default": "./use-map/index.cjs"
486
+ },
460
487
  "./use-page-visibility": {
461
488
  "types": "./use-page-visibility/index.d.ts",
462
489
  "import": {
@@ -475,6 +502,15 @@
475
502
  "require": "./use-readonly-search-params/index.cjs",
476
503
  "default": "./use-readonly-search-params/index.cjs"
477
504
  },
505
+ "./use-resizing": {
506
+ "types": "./use-resizing/index.d.ts",
507
+ "import": {
508
+ "types": "./use-resizing/index.d.ts",
509
+ "default": "./use-resizing/index.mjs"
510
+ },
511
+ "require": "./use-resizing/index.cjs",
512
+ "default": "./use-resizing/index.cjs"
513
+ },
478
514
  "./use-retimer": {
479
515
  "types": "./use-retimer/index.d.ts",
480
516
  "import": {
@@ -484,15 +520,6 @@
484
520
  "require": "./use-retimer/index.cjs",
485
521
  "default": "./use-retimer/index.cjs"
486
522
  },
487
- "./use-set": {
488
- "types": "./use-set/index.d.ts",
489
- "import": {
490
- "types": "./use-set/index.d.ts",
491
- "default": "./use-set/index.mjs"
492
- },
493
- "require": "./use-set/index.cjs",
494
- "default": "./use-set/index.cjs"
495
- },
496
523
  "./use-session-storage": {
497
524
  "types": "./use-session-storage/index.d.ts",
498
525
  "import": {
@@ -502,14 +529,14 @@
502
529
  "require": "./use-session-storage/index.cjs",
503
530
  "default": "./use-session-storage/index.cjs"
504
531
  },
505
- "./use-map": {
506
- "types": "./use-map/index.d.ts",
532
+ "./use-set": {
533
+ "types": "./use-set/index.d.ts",
507
534
  "import": {
508
- "types": "./use-map/index.d.ts",
509
- "default": "./use-map/index.mjs"
535
+ "types": "./use-set/index.d.ts",
536
+ "default": "./use-set/index.mjs"
510
537
  },
511
- "require": "./use-map/index.cjs",
512
- "default": "./use-map/index.cjs"
538
+ "require": "./use-set/index.cjs",
539
+ "default": "./use-set/index.cjs"
513
540
  },
514
541
  "./use-singleton": {
515
542
  "types": "./use-singleton/index.d.ts",
@@ -547,15 +574,6 @@
547
574
  "require": "./use-typescript-happy-callback/index.cjs",
548
575
  "default": "./use-typescript-happy-callback/index.cjs"
549
576
  },
550
- "./use-url-hash-state": {
551
- "types": "./use-url-hash-state/index.d.ts",
552
- "import": {
553
- "types": "./use-url-hash-state/index.d.ts",
554
- "default": "./use-url-hash-state/index.mjs"
555
- },
556
- "require": "./use-url-hash-state/index.cjs",
557
- "default": "./use-url-hash-state/index.cjs"
558
- },
559
577
  "./use-uncontrolled": {
560
578
  "types": "./use-uncontrolled/index.d.ts",
561
579
  "import": {
@@ -564,6 +582,15 @@
564
582
  },
565
583
  "require": "./use-uncontrolled/index.cjs",
566
584
  "default": "./use-uncontrolled/index.cjs"
585
+ },
586
+ "./use-url-hash-state": {
587
+ "types": "./use-url-hash-state/index.d.ts",
588
+ "import": {
589
+ "types": "./use-url-hash-state/index.d.ts",
590
+ "default": "./use-url-hash-state/index.mjs"
591
+ },
592
+ "require": "./use-url-hash-state/index.cjs",
593
+ "default": "./use-url-hash-state/index.cjs"
567
594
  }
568
595
  }
569
596
  }
@@ -0,0 +1 @@
1
+ "use strict";var e=require("react");exports.createPolymorphic=function(r){return{propName:r,renderPolymorphic:function(n){const{props:t,defaultComponent:l,ref:c}=n,{[r]:o,...i}=t;return(null!=c&&(i.ref=c),e.isValidElement(o))?e.cloneElement(o,i):e.createElement(null!=o?o:l,i)}}};
@@ -0,0 +1,19 @@
1
+ /** @see https://foxact.skk.moe/polymorphic */
2
+ type PolymorphicComponentProps<PropName extends string, Component extends React.ElementType, OwnProps extends Record<string, any> = object> = OwnProps & {
3
+ [K in PropName]?: Component | React.ReactElement;
4
+ } & Omit<React.ComponentPropsWithRef<Component>, keyof OwnProps | PropName>;
5
+ /** @see https://foxact.skk.moe/polymorphic */
6
+ type PolymorphicRef<Component extends React.ElementType> = React.ComponentPropsWithRef<Component>['ref'];
7
+ interface RenderPolymorphicOptions {
8
+ props: Record<string, any>;
9
+ defaultComponent: React.ElementType;
10
+ ref?: React.Ref<any>;
11
+ }
12
+ /** @see https://foxact.skk.moe/polymorphic */
13
+ declare function createPolymorphic<PropName extends string>(propName: PropName): {
14
+ readonly propName: PropName;
15
+ readonly renderPolymorphic: (options: RenderPolymorphicOptions) => React.ReactNode;
16
+ };
17
+
18
+ export { createPolymorphic };
19
+ export type { PolymorphicComponentProps, PolymorphicRef };
@@ -0,0 +1 @@
1
+ import{isValidElement as r,cloneElement as n,createElement as o}from"react";function e(e){return{propName:e,renderPolymorphic:function(t){const{props:c,defaultComponent:l,ref:u}=t,{[e]:i,...f}=c;return(null!=u&&(f.ref=u),r(i))?n(i,f):o(null!=i?i:l,f)}}}export{e as createPolymorphic};
package/sizes.json CHANGED
@@ -1 +1 @@
1
- {"total":{"raw":28610,"gzip":16853,"br":0},"exports":{"compose-context-provider":{"raw":177,"gzip":155,"br":122},"create-context-state":{"raw":145,"gzip":116,"br":96},"create-breadcrumbs":{"raw":301,"gzip":155,"br":131},"breadcrumbs":{"raw":872,"gzip":440,"br":380},"create-magic-portal":{"raw":268,"gzip":148,"br":121},"context-state":{"raw":402,"gzip":259,"br":218},"create-context-reducer":{"raw":223,"gzip":146,"br":117},"create-fixed-array":{"raw":452,"gzip":282,"br":248},"create-stackless-error":{"raw":278,"gzip":198,"br":162},"create-session-storage-state":{"raw":450,"gzip":223,"br":206},"create-storage-state-factory":{"raw":620,"gzip":341,"br":290},"fetch-jsonp":{"raw":890,"gzip":546,"br":429},"context-reducer":{"raw":557,"gzip":332,"br":319},"current-year":{"raw":528,"gzip":356,"br":292},"invariant":{"raw":178,"gzip":156,"br":118},"is-safari":{"raw":233,"gzip":164,"br":119},"merge-refs":{"raw":525,"gzip":280,"br":235},"no-ssr":{"raw":338,"gzip":267,"br":219},"noop":{"raw":33,"gzip":53,"br":37},"create-storage-hook":{"raw":2462,"gzip":972,"br":852},"magic-portal":{"raw":1083,"gzip":536,"br":472},"nullthrow":{"raw":187,"gzip":163,"br":121},"open-new-tab":{"raw":335,"gzip":255,"br":187},"types":{"raw":0,"gzip":20,"br":1},"noop-component":{"raw":142,"gzip":130,"br":111},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80},"request-idle-callback":{"raw":392,"gzip":221,"br":171},"rem":{"raw":823,"gzip":395,"br":350},"use":{"raw":298,"gzip":197,"br":160},"use-abortable-effect":{"raw":215,"gzip":170,"br":144},"create-local-storage-state":{"raw":446,"gzip":222,"br":209},"use-array":{"raw":334,"gzip":243,"br":206},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154},"use-composition-input":{"raw":470,"gzip":286,"br":241},"use-debounced-value":{"raw":553,"gzip":358,"br":320},"use-error-boundary":{"raw":252,"gzip":195,"br":165},"use-debounced-state":{"raw":401,"gzip":280,"br":242},"use-is-client":{"raw":204,"gzip":153,"br":121},"use-fast-click":{"raw":622,"gzip":392,"br":317},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110},"use-intersection":{"raw":1363,"gzip":716,"br":654},"use-is-online":{"raw":370,"gzip":258,"br":220},"use-clipboard":{"raw":2723,"gzip":1332,"br":1140},"use-local-storage":{"raw":428,"gzip":226,"br":198},"use-page-visibility":{"raw":359,"gzip":263,"br":210},"use-media-query":{"raw":648,"gzip":397,"br":332},"use-retimer":{"raw":194,"gzip":166,"br":127},"use-set":{"raw":368,"gzip":247,"br":211},"use-readonly-search-params":{"raw":1164,"gzip":589,"br":496},"use-session-storage":{"raw":434,"gzip":225,"br":210},"use-map":{"raw":384,"gzip":256,"br":220},"use-singleton":{"raw":149,"gzip":135,"br":116},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77},"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-state-with-deps":{"raw":767,"gzip":489,"br":427},"use-url-hash-state":{"raw":1121,"gzip":628,"br":556}}}
1
+ {"total":{"raw":28045,"gzip":17127,"br":14398,"zstd":17172},"exports":{"create-context-reducer":{"raw":63,"gzip":74,"br":64,"zstd":72},"compose-context-provider":{"raw":177,"gzip":155,"br":122,"zstd":144},"breadcrumbs":{"raw":879,"gzip":467,"br":395,"zstd":472},"create-context-state":{"raw":59,"gzip":72,"br":59,"zstd":68},"context-reducer":{"raw":557,"gzip":332,"br":319,"zstd":336},"context-state":{"raw":402,"gzip":259,"br":218,"zstd":259},"create-fixed-array":{"raw":452,"gzip":282,"br":248,"zstd":282},"create-magic-portal":{"raw":57,"gzip":71,"br":53,"zstd":66},"create-breadcrumbs":{"raw":56,"gzip":68,"br":52,"zstd":65},"create-local-storage-state":{"raw":169,"gzip":138,"br":111,"zstd":130},"create-session-storage-state":{"raw":173,"gzip":138,"br":108,"zstd":129},"create-stackless-error":{"raw":278,"gzip":198,"br":162,"zstd":188},"fetch-jsonp":{"raw":890,"gzip":546,"br":429,"zstd":552},"current-year":{"raw":508,"gzip":348,"br":283,"zstd":349},"invariant":{"raw":178,"gzip":156,"br":118,"zstd":149},"magic-portal":{"raw":1013,"gzip":517,"br":445,"zstd":526},"create-storage-state-factory":{"raw":364,"gzip":248,"br":197,"zstd":243},"create-storage-hook":{"raw":2418,"gzip":955,"br":834,"zstd":998},"is-safari":{"raw":233,"gzip":164,"br":119,"zstd":156},"merge-props":{"raw":1026,"gzip":556,"br":497,"zstd":575},"noop":{"raw":33,"gzip":53,"br":37,"zstd":42},"merge-refs":{"raw":525,"gzip":280,"br":235,"zstd":278},"no-ssr":{"raw":338,"gzip":267,"br":219,"zstd":268},"nullthrow":{"raw":187,"gzip":163,"br":121,"zstd":156},"noop-component":{"raw":142,"gzip":130,"br":111,"zstd":119},"polymorphic":{"raw":284,"gzip":212,"br":180,"zstd":199},"open-new-tab":{"raw":335,"gzip":255,"br":187,"zstd":255},"rem":{"raw":823,"gzip":395,"br":350,"zstd":402},"types":{"raw":0,"gzip":20,"br":1,"zstd":9},"request-idle-callback":{"raw":392,"gzip":221,"br":171,"zstd":213},"use":{"raw":298,"gzip":197,"br":160,"zstd":190},"typescript-happy-forward-ref":{"raw":119,"gzip":103,"br":80,"zstd":91},"use-abortable-effect":{"raw":215,"gzip":170,"br":144,"zstd":166},"use-component-will-receive-update":{"raw":216,"gzip":188,"br":154,"zstd":178},"use-array":{"raw":334,"gzip":243,"br":206,"zstd":236},"use-composition-input":{"raw":470,"gzip":286,"br":241,"zstd":296},"use-debounced-state":{"raw":401,"gzip":280,"br":242,"zstd":286},"use-error-boundary":{"raw":252,"gzip":195,"br":165,"zstd":187},"use-debounced-value":{"raw":553,"gzip":358,"br":320,"zstd":360},"use-fast-click":{"raw":499,"gzip":350,"br":284,"zstd":355},"use-is-client":{"raw":204,"gzip":153,"br":121,"zstd":148},"use-is-online":{"raw":370,"gzip":258,"br":220,"zstd":257},"use-isomorphic-layout-effect":{"raw":169,"gzip":137,"br":110,"zstd":127},"use-local-storage":{"raw":192,"gzip":143,"br":114,"zstd":137},"use-clipboard":{"raw":2723,"gzip":1332,"br":1140,"zstd":1397},"use-media-query":{"raw":604,"gzip":380,"br":315,"zstd":382},"use-map":{"raw":384,"gzip":256,"br":220,"zstd":262},"use-page-visibility":{"raw":359,"gzip":263,"br":210,"zstd":266},"use-session-storage":{"raw":198,"gzip":141,"br":118,"zstd":137},"use-resizing":{"raw":511,"gzip":334,"br":294,"zstd":342},"use-intersection":{"raw":1363,"gzip":716,"br":654,"zstd":750},"use-readonly-search-params":{"raw":1120,"gzip":573,"br":477,"zstd":584},"use-singleton":{"raw":149,"gzip":135,"br":116,"zstd":123},"use-retimer":{"raw":194,"gzip":166,"br":127,"zstd":154},"use-set":{"raw":368,"gzip":247,"br":211,"zstd":255},"use-stable-handler-only-when-you-know-what-you-are-doing-or-you-will-be-fired":{"raw":450,"gzip":318,"br":249,"zstd":321},"use-typescript-happy-callback":{"raw":107,"gzip":102,"br":77,"zstd":94},"use-uncontrolled":{"raw":388,"gzip":273,"br":230,"zstd":277},"use-state-with-deps":{"raw":747,"gzip":479,"br":418,"zstd":488},"use-url-hash-state":{"raw":1077,"gzip":611,"br":536,"zstd":626}}}
@@ -1 +1 @@
1
- "use strict";var e=require("react"),r=require("../use-media-query/index.cjs");require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../noop/index.cjs"),require("event-target-bus"),exports.useFastClick=function(n){const s=e.useCallback(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),n(e))},[n]);return r.useMediaQuery("(pointer: coarse)",!1)?{onClick:s}:{onMouseDown:s}};
1
+ "use strict";var e=require("react"),t=require("../use-media-query/index.cjs");exports.useFastClick=function(n){const o=e.useCallback(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),n(e))},[n]);return t.useMediaQuery("(pointer: coarse)",!1)?{onClick:o}:{onMouseDown:o}};
@@ -1 +1 @@
1
- import{useCallback as e}from"react";import{useMediaQuery as o}from"../use-media-query/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../noop/index.mjs";import"event-target-bus";function t(t){const n=e(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),t(e))},[t]);return o("(pointer: coarse)",!1)?{onClick:n}:{onMouseDown:n}}export{t as useFastClick};
1
+ import{useCallback as e}from"react";import{useMediaQuery as o}from"../use-media-query/index.mjs";function t(t){const n=e(e=>{("mousedown"!==e.type||0===e.button)&&("development"!==process.env.NODE_ENV||e.currentTarget instanceof HTMLDivElement||e.currentTarget instanceof HTMLButtonElement||console.warn('[foxact/use-fast-click] You should only use "useFastClick" on <div /> or <button /> elements'),t(e))},[t]);return o("(pointer: coarse)",!1)?{onClick:n}:{onMouseDown:n}}export{t as useFastClick};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const{useStorage:r,useSetStorage:s}=e.createStorage("localStorage");exports.useLocalStorage=r,exports.useSetLocalStorage=s;
1
+ "use strict";require("client-only");const{useStorage:e,useSetStorage:t}=require("../create-storage-hook/index.cjs").createStorage("localStorage");exports.useLocalStorage=e,exports.useSetLocalStorage=t;
@@ -1 +1 @@
1
- import"client-only";import{createStorage as e}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const{useStorage:o,useSetStorage:t}=e("localStorage");export{o as useLocalStorage,t as useSetLocalStorage};
1
+ import"client-only";import{createStorage as e}from"../create-storage-hook/index.mjs";const{useStorage:o,useSetStorage:t}=e("localStorage");export{o as useLocalStorage,t as useSetLocalStorage};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";var e=require("../no-ssr/index.cjs"),r=require("../noop/index.cjs"),t=require("react"),n=require("event-target-bus");require("../create-stackless-error/index.cjs");const o=new Map;function u(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,s){const i=t.useCallback(t=>(function(e,t){if("u"<typeof window)return r.noop;let u=o.get(e);return u||(u=n.createEventTargetBus(window.matchMedia(e),"change"),o.set(e,u)),u.on(t)})(e,t),[e]);return t.useSyncExternalStore(i,()=>"u"<typeof window?null!=s&&s:window.matchMedia(e).matches,void 0===s?u:()=>s)};
2
+ "use strict";var e=require("../no-ssr/index.cjs"),r=require("../noop/index.cjs"),t=require("react"),n=require("event-target-bus");const o=new Map;function u(){throw e.noSSRError("useMediaQuery cannot be used on the server without a serverValue")}exports.useMediaQuery=function(e,i){const a=t.useCallback(t=>(function(e,t){if("u"<typeof window)return r.noop;let u=o.get(e);return u||(u=n.createEventTargetBus(window.matchMedia(e),"change"),o.set(e,u)),u.on(t)})(e,t),[e]);return t.useSyncExternalStore(a,()=>"u"<typeof window?null!=i&&i:window.matchMedia(e).matches,void 0===i?u:()=>i)};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as t}from"../noop/index.mjs";import{useCallback as o,useSyncExternalStore as r}from"react";import{createEventTargetBus as n}from"event-target-bus";import"../create-stackless-error/index.mjs";const i=new Map;function s(){throw e("useMediaQuery cannot be used on the server without a serverValue")}function u(e,u){return r(o(o=>(function(e,o){if("u"<typeof window)return t;let r=i.get(e);return r||(r=n(window.matchMedia(e),"change"),i.set(e,r)),r.on(o)})(e,o),[e]),()=>"u"<typeof window?null!=u&&u:window.matchMedia(e).matches,void 0===u?s:()=>u)}export{u as useMediaQuery};
2
+ import{noSSRError as e}from"../no-ssr/index.mjs";import{noop as t}from"../noop/index.mjs";import{useCallback as o,useSyncExternalStore as n}from"react";import{createEventTargetBus as r}from"event-target-bus";const i=new Map;function u(){throw e("useMediaQuery cannot be used on the server without a serverValue")}function a(e,a){return n(o(o=>(function(e,o){if("u"<typeof window)return t;let n=i.get(e);return n||(n=r(window.matchMedia(e),"change"),i.set(e,n)),n.on(o)})(e,o),[e]),()=>"u"<typeof window?null!=a&&a:window.matchMedia(e).matches,void 0===a?u:()=>a)}export{a as useMediaQuery};
@@ -1 +1 @@
1
- "use strict";var e=require("event-target-bus"),r=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),a=require("react");require("../create-stackless-error/index.cjs");class t extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class o extends URLSearchParams{append(){throw new t}delete(){throw new t}set(){throw new t}sort(){throw new t}}let s=null;function u(r){return"u"<typeof window?n.noop:(null!=s||(s=e.createEventTargetBus(window,"popstate")),s.on(r))}let c=null,l=null;function i(){return"u"<typeof window?new o:window.location.search===c&&null!==l?l:l=new o(c=window.location.search)}function w(){throw r.noSSRError('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}exports.ReadonlyURLSearchParams=o,exports.useReadonlySearchParams=function(e){return a.useSyncExternalStore(u,i,null==e?w:()=>{const r=e();return r instanceof o?r:new o(r)})};
1
+ "use strict";var e=require("event-target-bus"),r=require("../no-ssr/index.cjs"),n=require("../noop/index.cjs"),a=require("react");class t extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class o extends URLSearchParams{append(){throw new t}delete(){throw new t}set(){throw new t}sort(){throw new t}}let s=null;function u(r){return"u"<typeof window?n.noop:(null!=s||(s=e.createEventTargetBus(window,"popstate")),s.on(r))}let l=null,c=null;function i(){return"u"<typeof window?new o:window.location.search===l&&null!==c?c:c=new o(l=window.location.search)}function w(){throw r.noSSRError('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}exports.ReadonlyURLSearchParams=o,exports.useReadonlySearchParams=function(e){return a.useSyncExternalStore(u,i,null==e?w:()=>{const r=e();return r instanceof o?r:new o(r)})};
@@ -1 +1 @@
1
- import{createEventTargetBus as e}from"event-target-bus";import{noSSRError as r}from"../no-ssr/index.mjs";import{noop as n}from"../noop/index.mjs";import{useSyncExternalStore as o}from"react";import"../create-stackless-error/index.mjs";class a extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class t extends URLSearchParams{append(){throw new a}delete(){throw new a}set(){throw new a}sort(){throw new a}}let s=null;function l(r){return"u"<typeof window?n:(null!=s||(s=e(window,"popstate")),s.on(r))}let c=null,u=null;function i(){return"u"<typeof window?new t:window.location.search===c&&null!==u?u:u=new t(c=window.location.search)}function w(){throw r('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}function d(e){return o(l,i,null==e?w:()=>{const r=e();return r instanceof t?r:new t(r)})}export{t as ReadonlyURLSearchParams,d as useReadonlySearchParams};
1
+ import{createEventTargetBus as e}from"event-target-bus";import{noSSRError as r}from"../no-ssr/index.mjs";import{noop as n}from"../noop/index.mjs";import{useSyncExternalStore as o}from"react";class a extends Error{constructor(){var e;super("[foxact/use-readonly-search-params] Method unavailable on `ReadonlyURLSearchParams`"),(e="name")in this?Object.defineProperty(this,e,{value:"ReadonlyURLSearchParamsError",enumerable:!0,configurable:!0,writable:!0}):this[e]="ReadonlyURLSearchParamsError"}}class t extends URLSearchParams{append(){throw new a}delete(){throw new a}set(){throw new a}sort(){throw new a}}let s=null;function l(r){return"u"<typeof window?n:(null!=s||(s=e(window,"popstate")),s.on(r))}let u=null,c=null;function i(){return"u"<typeof window?new t:window.location.search===u&&null!==c?c:c=new t(u=window.location.search)}function w(){throw r('[foxact] useReadonlySearchParams cannot be used on the server without a "getServerDefaultValue" function')}function d(e){return o(l,i,null==e?w:()=>{const r=e();return r instanceof t?r:new t(r)})}export{t as ReadonlyURLSearchParams,d as useReadonlySearchParams};
@@ -0,0 +1 @@
1
+ "use strict";require("client-only");var e=require("react"),r=require("../use-debounced-state/index.cjs");exports.useResizing=function(){let{timeout:n=150,leading:u=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[t,c,s]=r.useDebouncedState(!1,n,!1),i=e.useRef(null),l=e.useRef(!0);return[t,e.useCallback(e=>{i.current&&(i.current.disconnect(),i.current=null),s(!1),l.current=!0,e&&(i.current=new ResizeObserver(()=>{(!l.current||(l.current=!1,u))&&(s(!0),c(!1))}),i.current.observe(e))},[u,s,c])]};
@@ -0,0 +1,9 @@
1
+ interface UseResizingOptions {
2
+ timeout?: number;
3
+ leading?: boolean;
4
+ }
5
+ /** @see https://foxact.skk.moe/use-resizing */
6
+ declare function useResizing({ timeout, leading }?: UseResizingOptions): [isResizing: boolean, refCallback: React.RefCallback<Element>];
7
+
8
+ export { useResizing };
9
+ export type { UseResizingOptions };
@@ -0,0 +1 @@
1
+ import"client-only";import{useRef as e,useCallback as r}from"react";import{useDebouncedState as n}from"../use-debounced-state/index.mjs";function t(){let{timeout:t=150,leading:c=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[u,o,i]=n(!1,t,!1),s=e(null),l=e(!0);return[u,r(e=>{s.current&&(s.current.disconnect(),s.current=null),i(!1),l.current=!0,e&&(s.current=new ResizeObserver(()=>{(!l.current||(l.current=!1,c))&&(i(!0),o(!1))}),s.current.observe(e))},[c,i,o])]}export{t as useResizing};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("../create-storage-hook/index.cjs");require("react"),require("../noop/index.cjs"),require("../use-isomorphic-layout-effect/index.cjs"),require("../no-ssr/index.cjs"),require("../create-stackless-error/index.cjs"),require("../chunks/index.b9dLwVor.cjs"),require("../chunks/index.BtiK5_Nn.cjs");const{useStorage:r,useSetStorage:s}=e.createStorage("sessionStorage");exports.useSessionStorage=r,exports.useSetSessionStorage=s;
1
+ "use strict";require("client-only");const{useStorage:e,useSetStorage:s}=require("../create-storage-hook/index.cjs").createStorage("sessionStorage");exports.useSessionStorage=e,exports.useSetSessionStorage=s;
@@ -1 +1 @@
1
- import"client-only";import{createStorage as e}from"../create-storage-hook/index.mjs";import"react";import"../noop/index.mjs";import"../use-isomorphic-layout-effect/index.mjs";import"../no-ssr/index.mjs";import"../create-stackless-error/index.mjs";import"../chunks/index.D0KaUCcV.mjs";import"../chunks/index.C9-3oDdv.mjs";const{useStorage:o,useSetStorage:s}=e("sessionStorage");export{o as useSessionStorage,s as useSetSessionStorage};
1
+ import"client-only";import{createStorage as e}from"../create-storage-hook/index.mjs";const{useStorage:o,useSetStorage:s}=e("sessionStorage");export{o as useSessionStorage,s as useSetSessionStorage};
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("../use-isomorphic-layout-effect/index.cjs");function s(e,t){Object.defineProperty(e.t,t,{get:()=>(e.d[t]=!0,e.s[t]),enumerable:!0})}function n(e){return{state:e.s,tracked:e.d}}require("client-only");const r=Object.prototype.hasOwnProperty;exports.useStateWithDeps=function(c){const[{inst:u},o]=e.useState(()=>{const e={s:c,d:{},t:{},u:!1};for(const t in c)r.call(c,t)&&s(e,t);return{inst:e}}),i=e.useCallback(e=>{const t="function"==typeof e?e(u.s):e;let n=!1;for(const e in t)r.call(t,e)&&(r.call(u.t,e)||s(u,e),!Object.is(u.s[e],t[e])&&(u.s[e]=t[e],u.d[e]&&(n=!0)));n&&!u.u&&o({inst:u})},[u]);return t.useLayoutEffect(()=>(u.u=!1,()=>{u.u=!0})),"production"!==process.env.NODE_ENV&&e.useDebugValue(u,n),[u.t,i]};
1
+ "use strict";var t=require("react"),e=require("../use-isomorphic-layout-effect/index.cjs");function s(t,e){Object.defineProperty(t.t,e,{get:()=>(t.d[e]=!0,t.s[e]),enumerable:!0})}function c(t){return{state:t.s,tracked:t.d}}const n=Object.prototype.hasOwnProperty;exports.useStateWithDeps=function(r){const[{inst:u},o]=t.useState(()=>{const t={s:r,d:{},t:{},u:!1};for(const e in r)n.call(r,e)&&s(t,e);return{inst:t}}),i=t.useCallback(t=>{const e="function"==typeof t?t(u.s):t;let c=!1;for(const t in e)n.call(e,t)&&(n.call(u.t,t)||s(u,t),!Object.is(u.s[t],e[t])&&(u.s[t]=e[t],u.d[t]&&(c=!0)));c&&!u.u&&o({inst:u})},[u]);return e.useLayoutEffect(()=>(u.u=!1,()=>{u.u=!0})),"production"!==process.env.NODE_ENV&&t.useDebugValue(u,c),[u.t,i]};
@@ -1 +1 @@
1
- import{useState as t,useCallback as e,useDebugValue as o}from"react";import{useLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";import"client-only";function r(t,e){Object.defineProperty(t.t,e,{get:()=>(t.d[e]=!0,t.s[e]),enumerable:!0})}function c(t){return{state:t.s,tracked:t.d}}const s=Object.prototype.hasOwnProperty;function i(i){const[{inst:u},p]=t(()=>{const t={s:i,d:{},t:{},u:!1};for(const e in i)s.call(i,e)&&r(t,e);return{inst:t}}),f=e(t=>{const e="function"==typeof t?t(u.s):t;let o=!1;for(const t in e)s.call(e,t)&&(s.call(u.t,t)||r(u,t),!Object.is(u.s[t],e[t])&&(u.s[t]=e[t],u.d[t]&&(o=!0)));o&&!u.u&&p({inst:u})},[u]);return n(()=>(u.u=!1,()=>{u.u=!0})),"production"!==process.env.NODE_ENV&&o(u,c),[u.t,f]}export{i as useStateWithDeps};
1
+ import{useState as t,useCallback as e,useDebugValue as o}from"react";import{useLayoutEffect as n}from"../use-isomorphic-layout-effect/index.mjs";function r(t,e){Object.defineProperty(t.t,e,{get:()=>(t.d[e]=!0,t.s[e]),enumerable:!0})}function s(t){return{state:t.s,tracked:t.d}}const c=Object.prototype.hasOwnProperty;function i(i){const[{inst:u},f]=t(()=>{const t={s:i,d:{},t:{},u:!1};for(const e in i)c.call(i,e)&&r(t,e);return{inst:t}}),p=e(t=>{const e="function"==typeof t?t(u.s):t;let o=!1;for(const t in e)c.call(e,t)&&(c.call(u.t,t)||r(u,t),!Object.is(u.s[t],e[t])&&(u.s[t]=e[t],u.d[t]&&(o=!0)));o&&!u.u&&f({inst:u})},[u]);return n(()=>(u.u=!1,()=>{u.u=!0})),"production"!==process.env.NODE_ENV&&o(u,s),[u.t,p]}export{i as useStateWithDeps};
@@ -1 +1 @@
1
- "use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),n=require("../no-ssr/index.cjs"),t=require("../chunks/index.b9dLwVor.cjs"),s=require("../chunks/index.BtiK5_Nn.cjs"),l=require("event-target-bus");require("../create-stackless-error/index.cjs");let a=null;const i=e=>"u"<typeof window?r.noop:(null!=a||(a=l.createEventTargetBus(window,"hashchange")),a.on(e));function o(){throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(r,n){var l;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t.t,deserializer:t.t};const u=a.raw?t.t:a.serializer,c=a.raw?t.t:a.deserializer,h=void 0===n?o:()=>u(n),d=e.useSyncExternalStore(i,()=>new URLSearchParams(location.hash.slice(1)).get(r),h),w=e.useMemo(()=>null===d?null!=n?n:null:c(d),[n,c,d]),S=e.useCallback(e=>{const t=location.hash,l=new URLSearchParams(t.slice(1)),a=s.n(e)?e(w):e;a===n||null===a?l.delete(r):l.set(r,u(a));const i=l.toString();t!==i&&(location.hash=i)},[n,w,r,u]);return[null!=(l=null!=w?w:n)?l:null,S]};
1
+ "use strict";require("client-only");var e=require("react"),r=require("../noop/index.cjs"),n=require("../no-ssr/index.cjs"),t=require("../chunks/index.b9dLwVor.cjs"),s=require("../chunks/index.BtiK5_Nn.cjs"),l=require("event-target-bus");let a=null;const i=e=>"u"<typeof window?r.noop:(null!=a||(a=l.createEventTargetBus(window,"hashchange")),a.on(e));function o(){throw n.noSSRError("useUrlHashState cannot be used on the server without a serverValue")}exports.unstable_useUrlHashState=function(r,n){var l;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:t.t,deserializer:t.t};const u=a.raw?t.t:a.serializer,c=a.raw?t.t:a.deserializer,h=void 0===n?o:()=>u(n),d=e.useSyncExternalStore(i,()=>new URLSearchParams(location.hash.slice(1)).get(r),h),w=e.useMemo(()=>null===d?null!=n?n:null:c(d),[n,c,d]),S=e.useCallback(e=>{const t=location.hash,l=new URLSearchParams(t.slice(1)),a=s.n(e)?e(w):e;a===n||null===a?l.delete(r):l.set(r,u(a));const i=l.toString();t!==i&&(location.hash=i)},[n,w,r,u]);return[null!=(l=null!=w?w:n)?l:null,S]};
@@ -1 +1 @@
1
- import"client-only";import{useSyncExternalStore as e,useMemo as r,useCallback as t}from"react";import{noop as n}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";import{t as s}from"../chunks/index.D0KaUCcV.mjs";import{n as l}from"../chunks/index.C9-3oDdv.mjs";import{createEventTargetBus as a}from"event-target-bus";import"../create-stackless-error/index.mjs";let i=null;const u=e=>"u"<typeof window?n:(null!=i||(i=a(window,"hashchange")),i.on(e));function c(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function m(n,o){var a;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:s,deserializer:s};const m=i.raw?s:i.serializer,h=i.raw?s:i.deserializer,d=e(u,()=>new URLSearchParams(location.hash.slice(1)).get(n),void 0===o?c:()=>m(o)),p=r(()=>null===d?null!=o?o:null:h(d),[o,h,d]),w=t(e=>{const r=location.hash,t=new URLSearchParams(r.slice(1)),s=l(e)?e(p):e;s===o||null===s?t.delete(n):t.set(n,m(s));const a=t.toString();r!==a&&(location.hash=a)},[o,p,n,m]);return[null!=(a=null!=p?p:o)?a:null,w]}export{m as unstable_useUrlHashState};
1
+ import"client-only";import{useSyncExternalStore as e,useMemo as n,useCallback as r}from"react";import{noop as t}from"../noop/index.mjs";import{noSSRError as o}from"../no-ssr/index.mjs";import{t as l}from"../chunks/index.D0KaUCcV.mjs";import{n as s}from"../chunks/index.C9-3oDdv.mjs";import{createEventTargetBus as a}from"event-target-bus";let i=null;const u=e=>"u"<typeof window?t:(null!=i||(i=a(window,"hashchange")),i.on(e));function h(){throw o("useUrlHashState cannot be used on the server without a serverValue")}function c(t,o){var a;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{raw:!1,serializer:l,deserializer:l};const c=i.raw?l:i.serializer,m=i.raw?l:i.deserializer,d=e(u,()=>new URLSearchParams(location.hash.slice(1)).get(t),void 0===o?h:()=>c(o)),w=n(()=>null===d?null!=o?o:null:m(d),[o,m,d]),p=r(e=>{const n=location.hash,r=new URLSearchParams(n.slice(1)),l=s(e)?e(w):e;l===o||null===l?r.delete(t):r.set(t,c(l));const a=r.toString();n!==a&&(location.hash=a)},[o,w,t,c]);return[null!=(a=null!=w?w:o)?a:null,p]}export{c as unstable_useUrlHashState};