minimal-shared 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.d.cts +19 -0
- package/dist/hooks/index.js +1 -17
- package/dist/hooks/use-back-to-top/index.cjs +1 -0
- package/dist/hooks/use-back-to-top/index.d.cts +2 -0
- package/dist/hooks/use-back-to-top/index.js +1 -1
- package/dist/hooks/use-back-to-top/use-back-to-top.cjs +1 -0
- package/dist/hooks/use-back-to-top/use-back-to-top.d.cts +33 -0
- package/dist/hooks/use-boolean/index.cjs +1 -0
- package/dist/hooks/use-boolean/index.d.cts +2 -0
- package/dist/hooks/use-boolean/index.js +1 -1
- package/dist/hooks/use-boolean/use-boolean.cjs +1 -0
- package/dist/hooks/use-boolean/use-boolean.d.cts +29 -0
- package/dist/hooks/use-client-rect/index.cjs +1 -0
- package/dist/hooks/use-client-rect/index.d.cts +2 -0
- package/dist/hooks/use-client-rect/index.js +1 -1
- package/dist/hooks/use-client-rect/use-client-rect.cjs +1 -0
- package/dist/hooks/use-client-rect/use-client-rect.d.cts +29 -0
- package/dist/hooks/use-cookies/index.cjs +1 -0
- package/dist/hooks/use-cookies/index.d.cts +2 -0
- package/dist/hooks/use-cookies/index.js +1 -1
- package/dist/hooks/use-cookies/use-cookies.cjs +1 -0
- package/dist/hooks/use-cookies/use-cookies.d.cts +40 -0
- package/dist/hooks/use-copy-to-clipboard/index.cjs +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.d.cts +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.js +1 -1
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.cjs +1 -0
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.d.cts +26 -0
- package/dist/hooks/use-countdown-date/index.cjs +1 -0
- package/dist/hooks/use-countdown-date/index.d.cts +1 -0
- package/dist/hooks/use-countdown-date/index.js +1 -1
- package/dist/hooks/use-countdown-date/use-countdown-date.cjs +1 -0
- package/dist/hooks/use-countdown-date/use-countdown-date.d.cts +29 -0
- package/dist/hooks/use-countdown-seconds/index.cjs +1 -0
- package/dist/hooks/use-countdown-seconds/index.d.cts +2 -0
- package/dist/hooks/use-countdown-seconds/index.js +1 -1
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.cjs +1 -0
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.d.cts +35 -0
- package/dist/hooks/use-debounce/index.cjs +1 -0
- package/dist/hooks/use-debounce/index.d.cts +1 -0
- package/dist/hooks/use-debounce/index.js +1 -1
- package/dist/hooks/use-debounce/use-debounce.cjs +1 -0
- package/dist/hooks/use-debounce/use-debounce.d.cts +21 -0
- package/dist/hooks/use-double-click/index.cjs +1 -0
- package/dist/hooks/use-double-click/index.d.cts +2 -0
- package/dist/hooks/use-double-click/index.js +1 -1
- package/dist/hooks/use-double-click/use-double-click.cjs +1 -0
- package/dist/hooks/use-double-click/use-double-click.d.cts +28 -0
- package/dist/hooks/use-is-client/index.cjs +1 -0
- package/dist/hooks/use-is-client/index.d.cts +1 -0
- package/dist/hooks/use-is-client/index.js +1 -1
- package/dist/hooks/use-is-client/use-is-client.cjs +1 -0
- package/dist/hooks/use-is-client/use-is-client.d.cts +18 -0
- package/dist/hooks/use-local-storage/index.cjs +1 -0
- package/dist/hooks/use-local-storage/index.d.cts +1 -0
- package/dist/hooks/use-local-storage/index.js +1 -1
- package/dist/hooks/use-local-storage/use-local-storage.cjs +1 -0
- package/dist/hooks/use-local-storage/use-local-storage.d.cts +38 -0
- package/dist/hooks/use-multi-select/index.cjs +1 -0
- package/dist/hooks/use-multi-select/index.d.cts +2 -0
- package/dist/hooks/use-multi-select/index.js +1 -1
- package/dist/hooks/use-multi-select/use-multi-select.cjs +1 -0
- package/dist/hooks/use-multi-select/use-multi-select.d.cts +55 -0
- package/dist/hooks/use-popover/index.cjs +1 -0
- package/dist/hooks/use-popover/index.d.cts +2 -0
- package/dist/hooks/use-popover/index.js +1 -1
- package/dist/hooks/use-popover/use-popover.cjs +1 -0
- package/dist/hooks/use-popover/use-popover.d.cts +35 -0
- package/dist/hooks/use-popover-hover/index.cjs +1 -0
- package/dist/hooks/use-popover-hover/index.d.cts +2 -0
- package/dist/hooks/use-popover-hover/index.js +1 -1
- package/dist/hooks/use-popover-hover/use-popover-hover.cjs +1 -0
- package/dist/hooks/use-popover-hover/use-popover-hover.d.cts +41 -0
- package/dist/hooks/use-scroll-offset-top/index.cjs +1 -0
- package/dist/hooks/use-scroll-offset-top/index.d.cts +2 -0
- package/dist/hooks/use-scroll-offset-top/index.js +1 -1
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.cjs +1 -0
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.d.cts +28 -0
- package/dist/hooks/use-set-state/index.cjs +1 -0
- package/dist/hooks/use-set-state/index.d.cts +1 -0
- package/dist/hooks/use-set-state/index.js +1 -1
- package/dist/hooks/use-set-state/use-set-state.cjs +1 -0
- package/dist/hooks/use-set-state/use-set-state.d.cts +32 -0
- package/dist/hooks/use-tabs/index.cjs +1 -0
- package/dist/hooks/use-tabs/index.d.cts +2 -0
- package/dist/hooks/use-tabs/index.js +1 -1
- package/dist/hooks/use-tabs/use-tabs.cjs +1 -0
- package/dist/hooks/use-tabs/use-tabs.d.cts +30 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.js +9 -2
- package/dist/utils/active-link/active-link.cjs +1 -0
- package/dist/utils/active-link/active-link.d.cts +16 -0
- package/dist/utils/active-link/index.cjs +1 -0
- package/dist/utils/active-link/index.d.cts +1 -0
- package/dist/utils/active-link/index.js +1 -1
- package/dist/utils/classes/classes.cjs +1 -0
- package/dist/utils/classes/classes.d.cts +25 -0
- package/dist/utils/classes/index.cjs +1 -0
- package/dist/utils/classes/index.d.cts +1 -0
- package/dist/utils/classes/index.js +1 -1
- package/dist/utils/color/color.cjs +9 -0
- package/dist/utils/color/color.d.cts +67 -0
- package/dist/utils/color/index.cjs +9 -0
- package/dist/utils/color/index.d.cts +1 -0
- package/dist/utils/color/index.js +9 -1
- package/dist/utils/cookies/cookies.cjs +1 -0
- package/dist/utils/cookies/cookies.d.cts +42 -0
- package/dist/utils/cookies/index.cjs +1 -0
- package/dist/utils/cookies/index.d.cts +1 -0
- package/dist/utils/cookies/index.js +1 -1
- package/dist/utils/font/font.cjs +1 -0
- package/dist/utils/font/font.d.cts +37 -0
- package/dist/utils/font/index.cjs +1 -0
- package/dist/utils/font/index.d.cts +1 -0
- package/dist/utils/font/index.js +1 -1
- package/dist/utils/index.cjs +9 -0
- package/dist/utils/index.d.cts +10 -0
- package/dist/utils/index.js +9 -10
- package/dist/utils/local-storage/index.cjs +1 -0
- package/dist/utils/local-storage/index.d.cts +1 -0
- package/dist/utils/local-storage/index.js +1 -1
- package/dist/utils/local-storage/local-storage.cjs +1 -0
- package/dist/utils/local-storage/local-storage.d.cts +43 -0
- package/dist/utils/object/index.cjs +1 -0
- package/dist/utils/object/index.d.cts +1 -0
- package/dist/utils/object/index.js +1 -1
- package/dist/utils/object/object.cjs +1 -0
- package/dist/utils/object/object.d.cts +26 -0
- package/dist/utils/transform-number/index.cjs +1 -0
- package/dist/utils/transform-number/index.d.cts +1 -0
- package/dist/utils/transform-number/index.js +1 -1
- package/dist/utils/transform-number/transform-number.cjs +1 -0
- package/dist/utils/transform-number/transform-number.d.cts +31 -0
- package/dist/utils/url/index.cjs +1 -0
- package/dist/utils/url/index.d.cts +1 -0
- package/dist/utils/url/index.js +1 -1
- package/dist/utils/url/url.cjs +1 -0
- package/dist/utils/url/url.d.cts +54 -0
- package/dist/utils/uuidv4/index.cjs +1 -0
- package/dist/utils/uuidv4/index.d.cts +1 -0
- package/dist/utils/uuidv4/index.js +1 -1
- package/dist/utils/uuidv4/uuidv4.cjs +1 -0
- package/dist/utils/uuidv4/uuidv4.d.cts +12 -0
- package/package.json +1 -1
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var I=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var o in t)I(e,o,{get:t[o],enumerable:!0})},W=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of N(t))!_.call(e,n)&&n!==o&&I(e,n,{get:()=>t[n],enumerable:!(r=B(t,n))||r.enumerable});return e};var J=e=>W(I({},"__esModule",{value:!0}),e);var de={};$(de,{updateSelectedItems:()=>j,useBackToTop:()=>ee,useBoolean:()=>G,useClientRect:()=>oe,useCookies:()=>K,useCopyToClipboard:()=>fe,useCountdownDate:()=>ae,useCountdownSeconds:()=>pe,useDebounce:()=>Q,useDoubleClick:()=>re,useIsClient:()=>Z,useLocalStorage:()=>ie,useMultiSelect:()=>ne,usePopover:()=>q,usePopoverHover:()=>le,useScrollOffsetTop:()=>ue,useSetState:()=>X,useTabs:()=>Y});module.exports=J(de);var w=require("react");function Y(e){let[t,o]=(0,w.useState)(e),r=(0,w.useCallback)((n,i)=>{o(i)},[]);return{value:t,setValue:o,onChange:r}}var C=require("react");function G(e=!1){let[t,o]=(0,C.useState)(e),r=(0,C.useCallback)(()=>{o(!0)},[]),n=(0,C.useCallback)(()=>{o(!1)},[]),i=(0,C.useCallback)(()=>{o(s=>!s)},[]);return{value:t,onTrue:r,onFalse:n,onToggle:i,setValue:o}}var R=require("react");function q(){let[e,t]=(0,R.useState)(null),o=(0,R.useCallback)(n=>{t(n.currentTarget)},[]),r=(0,R.useCallback)(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:o,onClose:r,setAnchorEl:t}}var m=require("react");function A(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,n=decodeURIComponent(document.cookie).split("; ").find(s=>s.startsWith(t));if(!n)return null;let i=n.substring(t.length);try{return JSON.parse(i)}catch{return i}}catch(t){return console.error("Error retrieving cookie:",t),null}}function U(e,t,o){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:r=0,sameSite:n="Strict",secure:i=!1,path:s="/",domain:a}=o??{};try{let l=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),u=[`${e}=${l}`,`path=${s}`,n&&`SameSite=${n}`,i&&"Secure",a&&`domain=${a}`];if(r>0){let p=new Date(Date.now()+r*24*60*60*1e3);u.push(`expires=${p.toUTCString()}`)}document.cookie=u.filter(Boolean).join("; ")}catch(l){console.error("Error setting cookie:",l)}}function P(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:o="/",domain:r}=t??{};try{let n=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${o}`,r&&`domain=${r}`,"Secure"];document.cookie=n.filter(Boolean).join("; ")}catch(n){console.error("Error removing cookie:",n)}}function K(e,t,o){let{initializeWithValue:r=!0,...n}=o??{},i=t&&typeof t=="object",[s,a]=(0,m.useState)(t);(0,m.useEffect)(()=>{let c=A(e);c?a(i?g=>({...g,...c}):c):t&&r&&U(e,t,n)},[]);let l=(0,m.useCallback)(c=>{i?a(g=>{let L={...g,...c};return U(e,L,n),L}):(U(e,c,n),a(c))},[n,i,e]),u=(0,m.useCallback)((c,g)=>{i&&l({[c]:g})},[i,l]),p=(0,m.useCallback)(c=>{a(c??t),P(e)},[t,e]);return(0,m.useMemo)(()=>({state:s,setState:l,setField:u,resetState:p}),[p,u,l,s])}var D=require("react");function Q(e,t=1e3){let[o,r]=(0,D.useState)(e);return(0,D.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),o}var x=require("react");function X(e){let[t,o]=(0,x.useState)(e),r=(0,x.useCallback)(s=>{o(a=>({...a,...s}))},[]),n=(0,x.useCallback)((s,a)=>{r({[s]:a})},[r]),i=(0,x.useCallback)(s=>{o(s??e)},[e]);return{state:t,setState:r,setField:n,resetState:i}}var O=require("react");function Z(){let[e,t]=(0,O.useState)(!1);return(0,O.useEffect)(()=>{t(!0)},[]),e}var S=require("react");function ee(e,t){let[o,r]=(0,S.useState)(!1),n=te(e),i=(0,S.useCallback)(()=>{let l=window.innerHeight,u=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(u/(p-l)*100);if(n.type==="percentage")r(f>=n.value);else{let c=p-l-u;r(n.value>=c)}},[n.type,n.value]),s=(0,S.useMemo)(()=>{let l;return()=>{clearTimeout(l),l=setTimeout(i,100)}},[i]);return(0,S.useEffect)(()=>{let l=t?s:i;return window.addEventListener("scroll",l),()=>{window.removeEventListener("scroll",l)}},[s,i,t]),{isVisible:o,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:r}}function te(e){let t,o;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");o="percentage"}else throw new Error("String input must end with %");else t=e,o="number";return{value:t,type:o}}var d=require("react");function oe(e,t){let o=(0,d.useRef)(null),r=e||o,[n,i]=(0,d.useState)(void 0),[s,a]=(0,d.useState)(void 0),l=typeof window<"u"?d.useLayoutEffect:d.useEffect,u=(0,d.useCallback)(()=>{if(r.current){let c=r.current.getBoundingClientRect();i(c),a({scrollWidth:r.current.scrollWidth,scrollHeight:r.current.scrollHeight})}},[r]);l(()=>{u()},[u]),(0,d.useEffect)(()=>{let c=t||"resize";return window.addEventListener(c,u),()=>{window.removeEventListener(c,u)}},[t,u]);let p=(0,d.useMemo)(()=>n,[n]),f=(0,d.useMemo)(()=>s,[s]);return{elementRef:r,top:p?.top??0,right:p?.right??0,bottom:p?.bottom??0,left:p?.left??0,x:p?.x??0,y:p?.y??0,width:p?.width??0,height:p?.height??0,scrollWidth:f?.scrollWidth??0,scrollHeight:f?.scrollHeight??0}}var h=require("react");function ne(e,t){let[o,r]=(0,h.useState)(t??[]),n=(0,h.useCallback)(l=>{r(u=>j(u,l))},[]),i=(0,h.useCallback)(()=>{r(l=>l.length===e.length?[]:e)},[e]),s=(0,h.useCallback)(()=>{r([])},[]),a=(0,h.useMemo)(()=>o.length===0?"unchecked":o.length===e.length?"checked":"indeterminate",[e.length,o.length]);return{values:o,status:a,setValues:r,onSelectAllItems:i,onDeSelectAllItems:s,onToggleSelectItem:n}}function j(e,t){return e.includes(t)?e.filter(o=>o!==t):[...e,t]}var E=require("react");function re({click:e,doubleClick:t,timeout:o=250}){let r=(0,E.useRef)(null),n=(0,E.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return(0,E.useCallback)(s=>{n(),e&&s.detail===1&&(r.current=setTimeout(()=>{e(s)},o)),s.detail%2===0&&t(s)},[e,t,o,n])}var T=require("react");function F(e,t){if(!se())return t??null;let o=localStorage.getItem(e);if(o!=="undefined"){if(o)try{return JSON.parse(o)}catch{return o??t??null}return t??null}}function V(e,t){try{let o=JSON.stringify(t);window.localStorage.setItem(e,o)}catch(o){console.error("Error while setting storage:",o)}}function z(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function se(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function ie(e,t,o){let{initializeWithValue:r=!0}=o??{},n=t&&typeof t=="object",[i,s]=(0,T.useState)(t);(0,T.useEffect)(()=>{let f=F(e);f?s(n?c=>({...c,...f}):f):t&&r&&V(e,t)},[]);let a=(0,T.useCallback)(f=>{n?s(c=>{let g={...c,...f};return V(e,g),g}):(V(e,f),s(f))},[e,n]),l=(0,T.useCallback)((f,c)=>{n&&a({[f]:c})},[n,a]),u=(0,T.useCallback)(f=>{s(f??t),z(e)},[t,e]);return(0,T.useMemo)(()=>({state:i,setState:a,setField:l,resetState:u}),[u,l,a,i])}var y=require("react");function le(e){let t=(0,y.useRef)(null),o=e||t,[r,n]=(0,y.useState)(!1),i=(0,y.useCallback)(()=>{n(!0)},[]),s=(0,y.useCallback)(()=>{n(!1)},[]);return{elementRef:o,anchorEl:o.current,open:r,onOpen:i,onClose:s,setOpen:n}}var k=require("react");function ae(e,t="- -"){let[o,r]=(0,k.useState)({days:t,hours:t,minutes:t,seconds:t}),n=(0,k.useCallback)(()=>{let i=new Date,{days:s,hours:a,minutes:l,seconds:u}=ce(e,i);r({days:M(s),hours:M(a),minutes:M(l),seconds:M(u)})},[e]);return(0,k.useEffect)(()=>{n();let i=setInterval(n,1e3);return()=>clearInterval(i)},[]),o}function M(e){return String(e).length===1?`0${e}`:`${e}`}function ce(e,t){let o=e.getTime()-t.getTime();return{days:Math.floor(o/(1e3*60*60*24)),hours:Math.floor(o%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(o%(1e3*60*60)/(1e3*60)),seconds:Math.floor(o%(1e3*60)/1e3)}}var b=require("react");function ue(e=0){let t=(0,b.useRef)(null),[o,r]=(0,b.useState)(!1),n=(0,b.useCallback)(()=>{let i=window.scrollY;if(t.current){let s=t.current.offsetTop;r(i>s-e)}else r(i>e)},[e]);return(0,b.useEffect)(()=>(n(),window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[n]),{elementRef:t,offsetTop:o}}var v=require("react");function pe(e){let[t,o]=(0,v.useState)(e),[r,n]=(0,v.useState)(!1),i=(0,v.useCallback)(()=>{n(!0)},[]),s=(0,v.useCallback)(()=>{n(!1),o(e)},[e]);return(0,v.useEffect)(()=>{let a=null;return r&&t>0?a=setInterval(()=>{o(l=>l-1)},1e3):t<=0&&n(!1),()=>{a&&clearInterval(a)}},[r,t]),{value:t,setValue:o,isCounting:r,start:i,reset:s}}var H=require("react");function fe(){let[e,t]=(0,H.useState)(null);return{copy:(0,H.useCallback)(async r=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(r),t(r),!0}catch(n){return console.warn("Copy failed",n),t(null),!1}},[t]),copiedText:e}}0&&(module.exports={updateSelectedItems,useBackToTop,useBoolean,useClientRect,useCookies,useCopyToClipboard,useCountdownDate,useCountdownSeconds,useDebounce,useDoubleClick,useIsClient,useLocalStorage,useMultiSelect,usePopover,usePopoverHover,useScrollOffsetTop,useSetState,useTabs});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export { UseTabsReturn, useTabs } from './use-tabs/use-tabs.cjs';
|
2
|
+
export { UseBooleanReturn, useBoolean } from './use-boolean/use-boolean.cjs';
|
3
|
+
export { UsePopoverReturn, usePopover } from './use-popover/use-popover.cjs';
|
4
|
+
export { UseCookiesOptions, UseCookiesReturn, useCookies } from './use-cookies/use-cookies.cjs';
|
5
|
+
export { UseDebounceReturn, useDebounce } from './use-debounce/use-debounce.cjs';
|
6
|
+
export { UseSetStateReturn, useSetState } from './use-set-state/use-set-state.cjs';
|
7
|
+
export { UseIsClientReturn, useIsClient } from './use-is-client/use-is-client.cjs';
|
8
|
+
export { UseBackToTopReturn, useBackToTop } from './use-back-to-top/use-back-to-top.cjs';
|
9
|
+
export { UseClientRectReturn, useClientRect } from './use-client-rect/use-client-rect.cjs';
|
10
|
+
export { UseMultiSelectReturn, updateSelectedItems, useMultiSelect } from './use-multi-select/use-multi-select.cjs';
|
11
|
+
export { UseDoubleClickReturn, useDoubleClick } from './use-double-click/use-double-click.cjs';
|
12
|
+
export { UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from './use-local-storage/use-local-storage.cjs';
|
13
|
+
export { usePopoverHover } from './use-popover-hover/use-popover-hover.cjs';
|
14
|
+
export { UseCountdownDateReturn, useCountdownDate } from './use-countdown-date/use-countdown-date.cjs';
|
15
|
+
export { UseScrollOffsetTopReturn, useScrollOffsetTop } from './use-scroll-offset-top/use-scroll-offset-top.cjs';
|
16
|
+
export { UseCountdownSecondsReturn, useCountdownSeconds } from './use-countdown-seconds/use-countdown-seconds.cjs';
|
17
|
+
export { CopiedValue, CopyFn, UseCopyToClipboardReturn, useCopyToClipboard } from './use-copy-to-clipboard/use-copy-to-clipboard.cjs';
|
18
|
+
import 'react';
|
19
|
+
import '../utils/cookies/cookies.cjs';
|
package/dist/hooks/index.js
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
2
|
-
export * from './use-boolean';
|
3
|
-
export * from './use-popover';
|
4
|
-
export * from './use-cookies';
|
5
|
-
export * from './use-debounce';
|
6
|
-
export * from './use-set-state';
|
7
|
-
export * from './use-is-client';
|
8
|
-
export * from './use-back-to-top';
|
9
|
-
export * from './use-client-rect';
|
10
|
-
export * from './use-multi-select';
|
11
|
-
export * from './use-double-click';
|
12
|
-
export * from './use-local-storage';
|
13
|
-
export * from './use-popover-hover';
|
14
|
-
export * from './use-countdown-date';
|
15
|
-
export * from './use-scroll-offset-top';
|
16
|
-
export * from './use-countdown-seconds';
|
17
|
-
export * from './use-copy-to-clipboard';
|
1
|
+
import{useState as L,useCallback as A}from"react";function xe(e){let[t,o]=L(e),r=A((n,i)=>{o(i)},[]);return{value:t,setValue:o,onChange:r}}import{useState as P,useCallback as S}from"react";function Ee(e=!1){let[t,o]=P(e),r=S(()=>{o(!0)},[]),n=S(()=>{o(!1)},[]),i=S(()=>{o(s=>!s)},[]);return{value:t,onTrue:r,onFalse:n,onToggle:i,setValue:o}}import{useState as j,useCallback as x}from"react";function De(){let[e,t]=j(null),o=x(n=>{t(n.currentTarget)},[]),r=x(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:o,onClose:r,setAnchorEl:t}}import{useMemo as F,useState as z,useEffect as B,useCallback as h}from"react";function k(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,n=decodeURIComponent(document.cookie).split("; ").find(s=>s.startsWith(t));if(!n)return null;let i=n.substring(t.length);try{return JSON.parse(i)}catch{return i}}catch(t){return console.error("Error retrieving cookie:",t),null}}function m(e,t,o){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:r=0,sameSite:n="Strict",secure:i=!1,path:s="/",domain:a}=o??{};try{let l=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),u=[`${e}=${l}`,`path=${s}`,n&&`SameSite=${n}`,i&&"Secure",a&&`domain=${a}`];if(r>0){let p=new Date(Date.now()+r*24*60*60*1e3);u.push(`expires=${p.toUTCString()}`)}document.cookie=u.filter(Boolean).join("; ")}catch(l){console.error("Error setting cookie:",l)}}function R(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:o="/",domain:r}=t??{};try{let n=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${o}`,r&&`domain=${r}`,"Secure"];document.cookie=n.filter(Boolean).join("; ")}catch(n){console.error("Error removing cookie:",n)}}function Ie(e,t,o){let{initializeWithValue:r=!0,...n}=o??{},i=t&&typeof t=="object",[s,a]=z(t);B(()=>{let c=k(e);c?a(i?d=>({...d,...c}):c):t&&r&&m(e,t,n)},[]);let l=h(c=>{i?a(d=>{let C={...d,...c};return m(e,C,n),C}):(m(e,c,n),a(c))},[n,i,e]),u=h((c,d)=>{i&&l({[c]:d})},[i,l]),p=h(c=>{a(c??t),R(e)},[t,e]);return F(()=>({state:s,setState:l,setField:u,resetState:p}),[p,u,l,s])}import{useState as N,useEffect as _}from"react";function Pe(e,t=1e3){let[o,r]=N(e);return _(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),o}import{useState as $,useCallback as b}from"react";function ze(e){let[t,o]=$(e),r=b(s=>{o(a=>({...a,...s}))},[]),n=b((s,a)=>{r({[s]:a})},[r]),i=b(s=>{o(s??e)},[e]);return{state:t,setState:r,setField:n,resetState:i}}import{useState as W,useEffect as J}from"react";function _e(){let[e,t]=W(!1);return J(()=>{t(!0)},[]),e}import{useMemo as Y,useState as G,useEffect as q,useCallback as K}from"react";function Je(e,t){let[o,r]=G(!1),n=Q(e),i=K(()=>{let l=window.innerHeight,u=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(u/(p-l)*100);if(n.type==="percentage")r(f>=n.value);else{let c=p-l-u;r(n.value>=c)}},[n.type,n.value]),s=Y(()=>{let l;return()=>{clearTimeout(l),l=setTimeout(i,100)}},[i]);return q(()=>{let l=t?s:i;return window.addEventListener("scroll",l),()=>{window.removeEventListener("scroll",l)}},[s,i,t]),{isVisible:o,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:r}}function Q(e){let t,o;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");o="percentage"}else throw new Error("String input must end with %");else t=e,o="number";return{value:t,type:o}}import{useRef as X,useMemo as E,useState as w,useEffect as U,useCallback as Z,useLayoutEffect as ee}from"react";function qe(e,t){let o=X(null),r=e||o,[n,i]=w(void 0),[s,a]=w(void 0),l=typeof window<"u"?ee:U,u=Z(()=>{if(r.current){let c=r.current.getBoundingClientRect();i(c),a({scrollWidth:r.current.scrollWidth,scrollHeight:r.current.scrollHeight})}},[r]);l(()=>{u()},[u]),U(()=>{let c=t||"resize";return window.addEventListener(c,u),()=>{window.removeEventListener(c,u)}},[t,u]);let p=E(()=>n,[n]),f=E(()=>s,[s]);return{elementRef:r,top:p?.top??0,right:p?.right??0,bottom:p?.bottom??0,left:p?.left??0,x:p?.x??0,y:p?.y??0,width:p?.width??0,height:p?.height??0,scrollWidth:f?.scrollWidth??0,scrollHeight:f?.scrollHeight??0}}import{useMemo as te,useState as oe,useCallback as v}from"react";function Xe(e,t){let[o,r]=oe(t??[]),n=v(l=>{r(u=>ne(u,l))},[]),i=v(()=>{r(l=>l.length===e.length?[]:e)},[e]),s=v(()=>{r([])},[]),a=te(()=>o.length===0?"unchecked":o.length===e.length?"checked":"indeterminate",[e.length,o.length]);return{values:o,status:a,setValues:r,onSelectAllItems:i,onDeSelectAllItems:s,onToggleSelectItem:n}}function ne(e,t){return e.includes(t)?e.filter(o=>o!==t):[...e,t]}import{useRef as re,useCallback as D}from"react";function tt({click:e,doubleClick:t,timeout:o=250}){let r=re(null),n=D(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return D(s=>{n(),e&&s.detail===1&&(r.current=setTimeout(()=>{e(s)},o)),s.detail%2===0&&t(s)},[e,t,o,n])}import{useMemo as ie,useState as le,useEffect as ae,useCallback as y}from"react";function O(e,t){if(!se())return t??null;let o=localStorage.getItem(e);if(o!=="undefined"){if(o)try{return JSON.parse(o)}catch{return o??t??null}return t??null}}function T(e,t){try{let o=JSON.stringify(t);window.localStorage.setItem(e,o)}catch(o){console.error("Error while setting storage:",o)}}function V(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function se(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function it(e,t,o){let{initializeWithValue:r=!0}=o??{},n=t&&typeof t=="object",[i,s]=le(t);ae(()=>{let f=O(e);f?s(n?c=>({...c,...f}):f):t&&r&&T(e,t)},[]);let a=y(f=>{n?s(c=>{let d={...c,...f};return T(e,d),d}):(T(e,f),s(f))},[e,n]),l=y((f,c)=>{n&&a({[f]:c})},[n,a]),u=y(f=>{s(f??t),V(e)},[t,e]);return ie(()=>({state:i,setState:a,setField:l,resetState:u}),[u,l,a,i])}import{useRef as ce,useState as ue,useCallback as M}from"react";function ct(e){let t=ce(null),o=e||t,[r,n]=ue(!1),i=M(()=>{n(!0)},[]),s=M(()=>{n(!1)},[]);return{elementRef:o,anchorEl:o.current,open:r,onOpen:i,onClose:s,setOpen:n}}import{useState as pe,useEffect as fe,useCallback as de}from"react";function ft(e,t="- -"){let[o,r]=pe({days:t,hours:t,minutes:t,seconds:t}),n=de(()=>{let i=new Date,{days:s,hours:a,minutes:l,seconds:u}=me(e,i);r({days:g(s),hours:g(a),minutes:g(l),seconds:g(u)})},[e]);return fe(()=>{n();let i=setInterval(n,1e3);return()=>clearInterval(i)},[]),o}function g(e){return String(e).length===1?`0${e}`:`${e}`}function me(e,t){let o=e.getTime()-t.getTime();return{days:Math.floor(o/(1e3*60*60*24)),hours:Math.floor(o%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(o%(1e3*60*60)/(1e3*60)),seconds:Math.floor(o%(1e3*60)/1e3)}}import{useRef as Te,useState as ge,useEffect as Se,useCallback as he}from"react";function Tt(e=0){let t=Te(null),[o,r]=ge(!1),n=he(()=>{let i=window.scrollY;if(t.current){let s=t.current.offsetTop;r(i>s-e)}else r(i>e)},[e]);return Se(()=>(n(),window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[n]),{elementRef:t,offsetTop:o}}import{useState as H,useEffect as be,useCallback as I}from"react";function ht(e){let[t,o]=H(e),[r,n]=H(!1),i=I(()=>{n(!0)},[]),s=I(()=>{n(!1),o(e)},[e]);return be(()=>{let a=null;return r&&t>0?a=setInterval(()=>{o(l=>l-1)},1e3):t<=0&&n(!1),()=>{a&&clearInterval(a)}},[r,t]),{value:t,setValue:o,isCounting:r,start:i,reset:s}}import{useState as ve,useCallback as ye}from"react";function yt(){let[e,t]=ve(null);return{copy:ye(async r=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(r),t(r),!0}catch(n){return console.warn("Copy failed",n),t(null),!1}},[t]),copiedText:e}}export{ne as updateSelectedItems,Je as useBackToTop,Ee as useBoolean,qe as useClientRect,Ie as useCookies,yt as useCopyToClipboard,ft as useCountdownDate,ht as useCountdownSeconds,Pe as useDebounce,tt as useDoubleClick,_e as useIsClient,it as useLocalStorage,Xe as useMultiSelect,De as usePopover,ct as usePopoverHover,Tt as useScrollOffsetTop,ze as useSetState,xe as useTabs};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var c=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var T=(o,e)=>{for(var n in e)c(o,n,{get:e[n],enumerable:!0})},h=(o,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of b(e))!f.call(o,t)&&t!==n&&c(o,t,{get:()=>e[t],enumerable:!(i=w(e,t))||i.enumerable});return o};var g=o=>h(c({},"__esModule",{value:!0}),o);var y={};T(y,{useBackToTop:()=>v});module.exports=g(y);var s=require("react");function v(o,e){let[n,i]=(0,s.useState)(!1),t=S(o),l=(0,s.useCallback)(()=>{let r=window.innerHeight,u=Math.round(window.scrollY),d=document.body.offsetHeight,p=Math.round(u/(d-r)*100);if(t.type==="percentage")i(p>=t.value);else{let m=d-r-u;i(t.value>=m)}},[t.type,t.value]),a=(0,s.useMemo)(()=>{let r;return()=>{clearTimeout(r),r=setTimeout(l,100)}},[l]);return(0,s.useEffect)(()=>{let r=e?a:l;return window.addEventListener("scroll",r),()=>{window.removeEventListener("scroll",r)}},[a,l,e]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:i}}function S(o){let e,n;if(typeof o=="string")if(o.endsWith("%")){if(e=Number(o.slice(0,-1)),isNaN(e))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else e=o,n="number";return{value:e,type:n}}0&&(module.exports={useBackToTop});
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useMemo as p,useState as m,useEffect as w,useCallback as b}from"react";function g(t,o){let[n,i]=m(!1),r=f(t),s=b(()=>{let e=window.innerHeight,c=Math.round(window.scrollY),a=document.body.offsetHeight,u=Math.round(c/(a-e)*100);if(r.type==="percentage")i(u>=r.value);else{let d=a-e-c;i(r.value>=d)}},[r.type,r.value]),l=p(()=>{let e;return()=>{clearTimeout(e),e=setTimeout(s,100)}},[s]);return w(()=>{let e=o?l:s;return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[l,s,o]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:i}}function f(t){let o,n;if(typeof t=="string")if(t.endsWith("%")){if(o=Number(t.slice(0,-1)),isNaN(o))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else o=t,n="number";return{value:o,type:n}}export{g as useBackToTop};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var c=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var T=(o,e)=>{for(var n in e)c(o,n,{get:e[n],enumerable:!0})},h=(o,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of b(e))!f.call(o,t)&&t!==n&&c(o,t,{get:()=>e[t],enumerable:!(i=w(e,t))||i.enumerable});return o};var g=o=>h(c({},"__esModule",{value:!0}),o);var y={};T(y,{useBackToTop:()=>v});module.exports=g(y);var s=require("react");function v(o,e){let[n,i]=(0,s.useState)(!1),t=S(o),l=(0,s.useCallback)(()=>{let r=window.innerHeight,u=Math.round(window.scrollY),d=document.body.offsetHeight,p=Math.round(u/(d-r)*100);if(t.type==="percentage")i(p>=t.value);else{let m=d-r-u;i(t.value>=m)}},[t.type,t.value]),a=(0,s.useMemo)(()=>{let r;return()=>{clearTimeout(r),r=setTimeout(l,100)}},[l]);return(0,s.useEffect)(()=>{let r=e?a:l;return window.addEventListener("scroll",r),()=>{window.removeEventListener("scroll",r)}},[a,l,e]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:i}}function S(o){let e,n;if(typeof o=="string")if(o.endsWith("%")){if(e=Number(o.slice(0,-1)),isNaN(e))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else e=o,n="number";return{value:e,type:n}}0&&(module.exports={useBackToTop});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Custom hook to manage the visibility of a "Back to Top" button based on scroll position.
|
5
|
+
*
|
6
|
+
* @param {string | number} defaultValue - The scroll progress percentage (e.g., '90%') or distance in pixels (e.g., 80) at which the button becomes visible.
|
7
|
+
* - If `defaultValue` is a percentage string (e.g., '90%'), the button becomes visible when the scroll distance is that percentage from the top.
|
8
|
+
* - If `defaultValue` is a number (e.g., 80), the button becomes visible when the scroll distance is that many pixels from the bottom.
|
9
|
+
* @param {boolean} [isDebounce=false] - Whether to debounce the scroll handler to improve performance.
|
10
|
+
*
|
11
|
+
* @returns {UseBackToTopReturn} - An object containing:
|
12
|
+
* - `isVisible`: A boolean indicating whether the "Back to Top" button should be visible.
|
13
|
+
* - `onBackToTop`: A function to scroll the window back to the top smoothly.
|
14
|
+
* - `setIsVisible`: A function to manually set the visibility of the "Back to Top" button.
|
15
|
+
*
|
16
|
+
* @example
|
17
|
+
* const { isVisible, onBackToTop } = useBackToTop('90%');
|
18
|
+
* const { isVisible, onBackToTop } = useBackToTop(80);
|
19
|
+
*
|
20
|
+
* return (
|
21
|
+
* <button onClick={onBackToTop} style={{ display: isVisible ? 'block' : 'none' }}>
|
22
|
+
* Back to Top
|
23
|
+
* </button>
|
24
|
+
* );
|
25
|
+
*/
|
26
|
+
type UseBackToTopReturn = {
|
27
|
+
isVisible: boolean;
|
28
|
+
onBackToTop: () => void;
|
29
|
+
setIsVisible: Dispatch<SetStateAction<boolean>>;
|
30
|
+
};
|
31
|
+
declare function useBackToTop(defaultValue: string | number, isDebounce?: boolean): UseBackToTopReturn;
|
32
|
+
|
33
|
+
export { type UseBackToTopReturn, useBackToTop };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var t in e)s(o,t,{get:e[t],enumerable:!0})},m=(o,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!p.call(o,n)&&n!==t&&s(o,n,{get:()=>e[n],enumerable:!(l=c(e,n))||l.enumerable});return o};var v=o=>m(s({},"__esModule",{value:!0}),o);var b={};f(b,{useBoolean:()=>S});module.exports=v(b);var a=require("react");function S(o=!1){let[e,t]=(0,a.useState)(o),l=(0,a.useCallback)(()=>{t(!0)},[]),n=(0,a.useCallback)(()=>{t(!1)},[]),r=(0,a.useCallback)(()=>{t(u=>!u)},[]);return{value:e,onTrue:l,onFalse:n,onToggle:r,setValue:t}}0&&(module.exports={useBoolean});
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useState as u,useCallback as o}from"react";function i(t=!1){let[n,e]=u(t),a=o(()=>{e(!0)},[]),l=o(()=>{e(!1)},[]),s=o(()=>{e(r=>!r)},[]);return{value:n,onTrue:a,onFalse:l,onToggle:s,setValue:e}}export{i as useBoolean};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var t in e)s(o,t,{get:e[t],enumerable:!0})},v=(o,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!p.call(o,n)&&n!==t&&s(o,n,{get:()=>e[n],enumerable:!(l=c(e,n))||l.enumerable});return o};var S=o=>v(s({},"__esModule",{value:!0}),o);var g={};f(g,{useBoolean:()=>b});module.exports=S(g);var a=require("react");function b(o=!1){let[e,t]=(0,a.useState)(o),l=(0,a.useCallback)(()=>{t(!0)},[]),n=(0,a.useCallback)(()=>{t(!1)},[]),r=(0,a.useCallback)(()=>{t(u=>!u)},[]);return{value:e,onTrue:l,onFalse:n,onToggle:r,setValue:t}}0&&(module.exports={useBoolean});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Custom hook to manage a boolean state with utility functions to set it to true, false, or toggle its value.
|
5
|
+
*
|
6
|
+
* @param {boolean} [defaultValue=false] - The initial value of the boolean state.
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
* const { value, onTrue, onFalse, onToggle } = useBoolean(false);
|
10
|
+
*
|
11
|
+
* return (
|
12
|
+
* <div>
|
13
|
+
* <p>Value: {value.toString()}</p>
|
14
|
+
* <button onClick={onTrue}>Set True</button>
|
15
|
+
* <button onClick={onFalse}>Set False</button>
|
16
|
+
* <button onClick={onToggle}>Toggle</button>
|
17
|
+
* </div>
|
18
|
+
* );
|
19
|
+
*/
|
20
|
+
type UseBooleanReturn = {
|
21
|
+
value: boolean;
|
22
|
+
onTrue: () => void;
|
23
|
+
onFalse: () => void;
|
24
|
+
onToggle: () => void;
|
25
|
+
setValue: Dispatch<SetStateAction<boolean>>;
|
26
|
+
};
|
27
|
+
declare function useBoolean(defaultValue?: boolean): UseBooleanReturn;
|
28
|
+
|
29
|
+
export { type UseBooleanReturn, useBoolean };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var s=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(n,t)=>{for(var c in t)s(n,c,{get:t[c],enumerable:!0})},E=(n,t,c,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of a(t))!g.call(n,r)&&r!==c&&s(n,r,{get:()=>t[r],enumerable:!(l=b(t,r))||l.enumerable});return n};var w=n=>E(s({},"__esModule",{value:!0}),n);var H={};p(H,{useClientRect:()=>y});module.exports=w(H);var e=require("react");function y(n,t){let c=(0,e.useRef)(null),l=n||c,[r,f]=(0,e.useState)(void 0),[m,h]=(0,e.useState)(void 0),R=typeof window<"u"?e.useLayoutEffect:e.useEffect,i=(0,e.useCallback)(()=>{if(l.current){let u=l.current.getBoundingClientRect();f(u),h({scrollWidth:l.current.scrollWidth,scrollHeight:l.current.scrollHeight})}},[l]);R(()=>{i()},[i]),(0,e.useEffect)(()=>{let u=t||"resize";return window.addEventListener(u,i),()=>{window.removeEventListener(u,i)}},[t,i]);let o=(0,e.useMemo)(()=>r,[r]),d=(0,e.useMemo)(()=>m,[m]);return{elementRef:l,top:o?.top??0,right:o?.right??0,bottom:o?.bottom??0,left:o?.left??0,x:o?.x??0,y:o?.y??0,width:o?.width??0,height:o?.height??0,scrollWidth:d?.scrollWidth??0,scrollHeight:d?.scrollHeight??0}}0&&(module.exports={useClientRect});
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useRef as a,useMemo as u,useState as s,useEffect as m,useCallback as g,useLayoutEffect as p}from"react";function w(d,r){let f=a(null),t=d||f,[o,h]=s(void 0),[c,R]=s(void 0),b=typeof window<"u"?p:m,n=g(()=>{if(t.current){let l=t.current.getBoundingClientRect();h(l),R({scrollWidth:t.current.scrollWidth,scrollHeight:t.current.scrollHeight})}},[t]);b(()=>{n()},[n]),m(()=>{let l=r||"resize";return window.addEventListener(l,n),()=>{window.removeEventListener(l,n)}},[r,n]);let e=u(()=>o,[o]),i=u(()=>c,[c]);return{elementRef:t,top:e?.top??0,right:e?.right??0,bottom:e?.bottom??0,left:e?.left??0,x:e?.x??0,y:e?.y??0,width:e?.width??0,height:e?.height??0,scrollWidth:i?.scrollWidth??0,scrollHeight:i?.scrollHeight??0}}export{w as useClientRect};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var s=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(n,t)=>{for(var c in t)s(n,c,{get:t[c],enumerable:!0})},E=(n,t,c,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of a(t))!g.call(n,r)&&r!==c&&s(n,r,{get:()=>t[r],enumerable:!(l=b(t,r))||l.enumerable});return n};var w=n=>E(s({},"__esModule",{value:!0}),n);var H={};p(H,{useClientRect:()=>y});module.exports=w(H);var e=require("react");function y(n,t){let c=(0,e.useRef)(null),l=n||c,[r,f]=(0,e.useState)(void 0),[m,h]=(0,e.useState)(void 0),R=typeof window<"u"?e.useLayoutEffect:e.useEffect,i=(0,e.useCallback)(()=>{if(l.current){let u=l.current.getBoundingClientRect();f(u),h({scrollWidth:l.current.scrollWidth,scrollHeight:l.current.scrollHeight})}},[l]);R(()=>{i()},[i]),(0,e.useEffect)(()=>{let u=t||"resize";return window.addEventListener(u,i),()=>{window.removeEventListener(u,i)}},[t,i]);let o=(0,e.useMemo)(()=>r,[r]),d=(0,e.useMemo)(()=>m,[m]);return{elementRef:l,top:o?.top??0,right:o?.right??0,bottom:o?.bottom??0,left:o?.left??0,x:o?.x??0,y:o?.y??0,width:o?.width??0,height:o?.height??0,scrollWidth:d?.scrollWidth??0,scrollHeight:d?.scrollHeight??0}}0&&(module.exports={useClientRect});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { RefObject } from 'react';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Custom hook to get the bounding client rect and scroll dimensions of a DOM element.
|
5
|
+
*
|
6
|
+
* @param {RefObject<HTMLDivElement>} [inputRef] - Optional ref object to the target element.
|
7
|
+
* @param {string} [eventType] - Optional event type to trigger updates (e.g., 'scroll', 'resize').
|
8
|
+
* @returns {UseClientRectReturn} - Object containing the bounding rect, scroll dimensions, and ref to the element.
|
9
|
+
*/
|
10
|
+
type ScrollElValue = {
|
11
|
+
scrollWidth: number;
|
12
|
+
scrollHeight: number;
|
13
|
+
};
|
14
|
+
type DOMRectValue = {
|
15
|
+
top: number;
|
16
|
+
right: number;
|
17
|
+
bottom: number;
|
18
|
+
left: number;
|
19
|
+
x: number;
|
20
|
+
y: number;
|
21
|
+
width: number;
|
22
|
+
height: number;
|
23
|
+
};
|
24
|
+
type UseClientRectReturn = DOMRectValue & ScrollElValue & {
|
25
|
+
elementRef: RefObject<HTMLDivElement>;
|
26
|
+
};
|
27
|
+
declare function useClientRect(inputRef?: RefObject<HTMLDivElement>, eventType?: string): UseClientRectReturn;
|
28
|
+
|
29
|
+
export { type UseClientRectReturn, useClientRect };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var k=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var S=(e,o)=>{for(var r in o)k(e,r,{get:o[r],enumerable:!0})},v=(e,o,r,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of x(o))!y.call(e,t)&&t!==r&&k(e,t,{get:()=>o[t],enumerable:!(i=h(o,t))||i.enumerable});return e};var O=e=>v(k({},"__esModule",{value:!0}),e);var U={};S(U,{useCookies:()=>$});module.exports=O(U);var a=require("react");function C(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let o=`${e}=`,t=decodeURIComponent(document.cookie).split("; ").find(p=>p.startsWith(o));if(!t)return null;let s=t.substring(o.length);try{return JSON.parse(s)}catch{return s}}catch(o){return console.error("Error retrieving cookie:",o),null}}function f(e,o,r){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:i=0,sameSite:t="Strict",secure:s=!1,path:p="/",domain:c}=r??{};try{let d=encodeURIComponent(typeof o=="string"?o:JSON.stringify(o)),u=[`${e}=${d}`,`path=${p}`,t&&`SameSite=${t}`,s&&"Secure",c&&`domain=${c}`];if(i>0){let T=new Date(Date.now()+i*24*60*60*1e3);u.push(`expires=${T.toUTCString()}`)}document.cookie=u.filter(Boolean).join("; ")}catch(d){console.error("Error setting cookie:",d)}}function g(e,o){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:r="/",domain:i}=o??{};try{let t=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${r}`,i&&`domain=${i}`,"Secure"];document.cookie=t.filter(Boolean).join("; ")}catch(t){console.error("Error removing cookie:",t)}}function $(e,o,r){let{initializeWithValue:i=!0,...t}=r??{},s=o&&typeof o=="object",[p,c]=(0,a.useState)(o);(0,a.useEffect)(()=>{let n=C(e);n?c(s?l=>({...l,...n}):n):o&&i&&f(e,o,t)},[]);let d=(0,a.useCallback)(n=>{s?c(l=>{let m={...l,...n};return f(e,m,t),m}):(f(e,n,t),c(n))},[t,s,e]),u=(0,a.useCallback)((n,l)=>{s&&d({[n]:l})},[s,d]),T=(0,a.useCallback)(n=>{c(n??o),g(e)},[o,e]);return(0,a.useMemo)(()=>({state:p,setState:d,setField:u,resetState:T}),[T,u,d,p])}0&&(module.exports={useCookies});
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useMemo as g,useState as h,useEffect as x,useCallback as f}from"react";function m(o){if(!o||typeof o!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${o}=`,t=decodeURIComponent(document.cookie).split("; ").find(d=>d.startsWith(e));if(!t)return null;let i=t.substring(e.length);try{return JSON.parse(i)}catch{return i}}catch(e){return console.error("Error retrieving cookie:",e),null}}function T(o,e,c){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:n=0,sameSite:t="Strict",secure:i=!1,path:d="/",domain:s}=c??{};try{let a=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),p=[`${o}=${a}`,`path=${d}`,t&&`SameSite=${t}`,i&&"Secure",s&&`domain=${s}`];if(n>0){let l=new Date(Date.now()+n*24*60*60*1e3);p.push(`expires=${l.toUTCString()}`)}document.cookie=p.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}function C(o,e){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{path:c="/",domain:n}=e??{};try{let t=[`${o}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${c}`,n&&`domain=${n}`,"Secure"];document.cookie=t.filter(Boolean).join("; ")}catch(t){console.error("Error removing cookie:",t)}}function $(o,e,c){let{initializeWithValue:n=!0,...t}=c??{},i=e&&typeof e=="object",[d,s]=h(e);x(()=>{let r=m(o);r?s(i?u=>({...u,...r}):r):e&&n&&T(o,e,t)},[]);let a=f(r=>{i?s(u=>{let k={...u,...r};return T(o,k,t),k}):(T(o,r,t),s(r))},[t,i,o]),p=f((r,u)=>{i&&a({[r]:u})},[i,a]),l=f(r=>{s(r??e),C(o)},[e,o]);return g(()=>({state:d,setState:a,setField:p,resetState:l}),[l,p,a,d])}export{$ as useCookies};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var k=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var v=(o,e)=>{for(var i in e)k(o,i,{get:e[i],enumerable:!0})},x=(o,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of y(e))!S.call(o,t)&&t!==i&&k(o,t,{get:()=>e[t],enumerable:!(r=h(e,t))||r.enumerable});return o};var O=o=>x(k({},"__esModule",{value:!0}),o);var U={};v(U,{useCookies:()=>$});module.exports=O(U);var a=require("react");function C(o){if(!o||typeof o!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${o}=`,t=decodeURIComponent(document.cookie).split("; ").find(p=>p.startsWith(e));if(!t)return null;let s=t.substring(e.length);try{return JSON.parse(s)}catch{return s}}catch(e){return console.error("Error retrieving cookie:",e),null}}function f(o,e,i){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:r=0,sameSite:t="Strict",secure:s=!1,path:p="/",domain:c}=i??{};try{let d=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),u=[`${o}=${d}`,`path=${p}`,t&&`SameSite=${t}`,s&&"Secure",c&&`domain=${c}`];if(r>0){let T=new Date(Date.now()+r*24*60*60*1e3);u.push(`expires=${T.toUTCString()}`)}document.cookie=u.filter(Boolean).join("; ")}catch(d){console.error("Error setting cookie:",d)}}function g(o,e){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{path:i="/",domain:r}=e??{};try{let t=[`${o}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${i}`,r&&`domain=${r}`,"Secure"];document.cookie=t.filter(Boolean).join("; ")}catch(t){console.error("Error removing cookie:",t)}}function $(o,e,i){let{initializeWithValue:r=!0,...t}=i??{},s=e&&typeof e=="object",[p,c]=(0,a.useState)(e);(0,a.useEffect)(()=>{let n=C(o);n?c(s?l=>({...l,...n}):n):e&&r&&f(o,e,t)},[]);let d=(0,a.useCallback)(n=>{s?c(l=>{let m={...l,...n};return f(o,m,t),m}):(f(o,n,t),c(n))},[t,s,o]),u=(0,a.useCallback)((n,l)=>{s&&d({[n]:l})},[s,d]),T=(0,a.useCallback)(n=>{c(n??e),g(o)},[e,o]);return(0,a.useMemo)(()=>({state:p,setState:d,setField:u,resetState:T}),[T,u,d,p])}0&&(module.exports={useCookies});
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { CookieOptions } from '../../utils/cookies/cookies.cjs';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Custom hook to manage state with cookies.
|
5
|
+
*
|
6
|
+
* @template T
|
7
|
+
* @param {string} key - The key for the cookie.
|
8
|
+
* @param {T} initialState - The initial state value.
|
9
|
+
* @param {UseCookiesOptions} [options] - Optional settings.
|
10
|
+
*
|
11
|
+
* @returns {UseCookiesReturn<T>} - An object containing:
|
12
|
+
* - `state`: The current state.
|
13
|
+
* - `resetState`: A function to reset the state to the initial value and remove the cookie.
|
14
|
+
* - `setState`: A function to update the state and save it to the cookie.
|
15
|
+
* - `setField`: A function to update a specific field in the state and save it to the cookie.
|
16
|
+
*
|
17
|
+
* @example
|
18
|
+
* const { state, setState, setField, resetState } = useCookies('user', { name: '', age: 0 });
|
19
|
+
*
|
20
|
+
* return (
|
21
|
+
* <div>
|
22
|
+
* <p>Name: {state.name}</p>
|
23
|
+
* <p>Age: {state.age}</p>
|
24
|
+
* <button onClick={() => setField('name', 'John')}>Set Name</button>
|
25
|
+
* <button onClick={resetState}>Reset</button>
|
26
|
+
* </div>
|
27
|
+
* );
|
28
|
+
*/
|
29
|
+
type UseCookiesOptions = CookieOptions & {
|
30
|
+
initializeWithValue?: boolean;
|
31
|
+
};
|
32
|
+
type UseCookiesReturn<T> = {
|
33
|
+
state: T;
|
34
|
+
resetState: (defaultState?: T) => void;
|
35
|
+
setState: (updateState: T | Partial<T>) => void;
|
36
|
+
setField: (name: keyof T, updateValue: T[keyof T]) => void;
|
37
|
+
};
|
38
|
+
declare function useCookies<T>(key: string, initialState?: T, options?: UseCookiesOptions): UseCookiesReturn<T>;
|
39
|
+
|
40
|
+
export { type UseCookiesOptions, type UseCookiesReturn, useCookies };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var s=(e,o)=>{for(var t in o)a(e,t,{get:o[t],enumerable:!0})},c=(e,o,t,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of l(o))!u.call(e,r)&&r!==t&&a(e,r,{get:()=>o[r],enumerable:!(p=i(o,r))||p.enumerable});return e};var C=e=>c(a({},"__esModule",{value:!0}),e);var d={};s(d,{useCopyToClipboard:()=>y});module.exports=C(d);var n=require("react");function y(){let[e,o]=(0,n.useState)(null);return{copy:(0,n.useCallback)(async p=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(p),o(p),!0}catch(r){return console.warn("Copy failed",r),o(null),!1}},[o]),copiedText:e}}0&&(module.exports={useCopyToClipboard});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { CopiedValue, CopyFn, UseCopyToClipboardReturn, useCopyToClipboard } from './use-copy-to-clipboard.cjs';
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useState as p,useCallback as n}from"react";function l(){let[r,o]=p(null);return{copy:n(async e=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(e),o(e),!0}catch(t){return console.warn("Copy failed",t),o(null),!1}},[o]),copiedText:r}}export{l as useCopyToClipboard};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var s=(e,o)=>{for(var t in o)a(e,t,{get:o[t],enumerable:!0})},c=(e,o,t,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of l(o))!u.call(e,r)&&r!==t&&a(e,r,{get:()=>o[r],enumerable:!(p=i(o,r))||p.enumerable});return e};var C=e=>c(a({},"__esModule",{value:!0}),e);var d={};s(d,{useCopyToClipboard:()=>y});module.exports=C(d);var n=require("react");function y(){let[e,o]=(0,n.useState)(null);return{copy:(0,n.useCallback)(async p=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(p),o(p),!0}catch(r){return console.warn("Copy failed",r),o(null),!1}},[o]),copiedText:e}}0&&(module.exports={useCopyToClipboard});
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
* Custom hook to copy text to the clipboard.
|
3
|
+
*
|
4
|
+
* @returns {UseCopyToClipboardReturn} - An object containing:
|
5
|
+
* - `copy`: A function to copy text to the clipboard.
|
6
|
+
* - `copiedText`: The last copied text or null if nothing has been copied.
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
* const { copy, copiedText } = useCopyToClipboard();
|
10
|
+
*
|
11
|
+
* return (
|
12
|
+
* <div>
|
13
|
+
* <button onClick={() => copy('Hello, World!')}>Copy Text</button>
|
14
|
+
* {copiedText && <p>Copied: {copiedText}</p>}
|
15
|
+
* </div>
|
16
|
+
* );
|
17
|
+
*/
|
18
|
+
type UseCopyToClipboardReturn = {
|
19
|
+
copy: CopyFn;
|
20
|
+
copiedText: CopiedValue;
|
21
|
+
};
|
22
|
+
type CopiedValue = string | null;
|
23
|
+
type CopyFn = (text: string) => Promise<boolean>;
|
24
|
+
declare function useCopyToClipboard(): UseCopyToClipboardReturn;
|
25
|
+
|
26
|
+
export { type CopiedValue, type CopyFn, type UseCopyToClipboardReturn, useCopyToClipboard };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var i=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var y=(t,n)=>{for(var e in n)i(t,e,{get:n[e],enumerable:!0})},D=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of g(n))!l.call(t,s)&&s!==e&&i(t,s,{get:()=>n[s],enumerable:!(r=h(n,s))||r.enumerable});return t};var b=t=>D(i({},"__esModule",{value:!0}),t);var M={};y(M,{useCountdownDate:()=>w});module.exports=b(M);var o=require("react");function w(t,n="- -"){let[e,r]=(0,o.useState)({days:n,hours:n,minutes:n,seconds:n}),s=(0,o.useCallback)(()=>{let a=new Date,{days:c,hours:m,minutes:d,seconds:f}=C(t,a);r({days:u(c),hours:u(m),minutes:u(d),seconds:u(f)})},[t]);return(0,o.useEffect)(()=>{s();let a=setInterval(s,1e3);return()=>clearInterval(a)},[]),e}function u(t){return String(t).length===1?`0${t}`:`${t}`}function C(t,n){let e=t.getTime()-n.getTime();return{days:Math.floor(e/(1e3*60*60*24)),hours:Math.floor(e%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(e%(1e3*60*60)/(1e3*60)),seconds:Math.floor(e%(1e3*60)/1e3)}}0&&(module.exports={useCountdownDate});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { UseCountdownDateReturn, useCountdownDate } from './use-countdown-date.cjs';
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useState as d,useEffect as f,useCallback as h}from"react";function y(t,n="- -"){let[e,u]=d({days:n,hours:n,minutes:n,seconds:n}),r=h(()=>{let o=new Date,{days:a,hours:i,minutes:c,seconds:m}=g(t,o);u({days:s(a),hours:s(i),minutes:s(c),seconds:s(m)})},[t]);return f(()=>{r();let o=setInterval(r,1e3);return()=>clearInterval(o)},[]),e}function s(t){return String(t).length===1?`0${t}`:`${t}`}function g(t,n){let e=t.getTime()-n.getTime();return{days:Math.floor(e/(1e3*60*60*24)),hours:Math.floor(e%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(e%(1e3*60*60)/(1e3*60)),seconds:Math.floor(e%(1e3*60)/1e3)}}export{y as useCountdownDate};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var i=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var y=(t,n)=>{for(var e in n)i(t,e,{get:n[e],enumerable:!0})},D=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of g(n))!l.call(t,s)&&s!==e&&i(t,s,{get:()=>n[s],enumerable:!(r=h(n,s))||r.enumerable});return t};var b=t=>D(i({},"__esModule",{value:!0}),t);var M={};y(M,{useCountdownDate:()=>w});module.exports=b(M);var o=require("react");function w(t,n="- -"){let[e,r]=(0,o.useState)({days:n,hours:n,minutes:n,seconds:n}),s=(0,o.useCallback)(()=>{let a=new Date,{days:c,hours:m,minutes:d,seconds:f}=C(t,a);r({days:u(c),hours:u(m),minutes:u(d),seconds:u(f)})},[t]);return(0,o.useEffect)(()=>{s();let a=setInterval(s,1e3);return()=>clearInterval(a)},[]),e}function u(t){return String(t).length===1?`0${t}`:`${t}`}function C(t,n){let e=t.getTime()-n.getTime();return{days:Math.floor(e/(1e3*60*60*24)),hours:Math.floor(e%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(e%(1e3*60*60)/(1e3*60)),seconds:Math.floor(e%(1e3*60)/1e3)}}0&&(module.exports={useCountdownDate});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/**
|
2
|
+
* Custom hook to create a countdown timer to a target date.
|
3
|
+
*
|
4
|
+
* @param {Date} targetDate - The target date to count down to.
|
5
|
+
* @param {string} [placeholder='- -'] - The placeholder value to display before the countdown starts.
|
6
|
+
*
|
7
|
+
* @returns {UseCountdownDateReturn} - An object containing the current countdown values in days, hours, minutes, and seconds.
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
* const { days, hours, minutes, seconds } = useCountdownDate(new Date('2023-12-31T23:59:59'));
|
11
|
+
*
|
12
|
+
* return (
|
13
|
+
* <div>
|
14
|
+
* <p>Days: {days}</p>
|
15
|
+
* <p>Hours: {hours}</p>
|
16
|
+
* <p>Minutes: {minutes}</p>
|
17
|
+
* <p>Seconds: {seconds}</p>
|
18
|
+
* </div>
|
19
|
+
* );
|
20
|
+
*/
|
21
|
+
type UseCountdownDateReturn = {
|
22
|
+
days: string;
|
23
|
+
hours: string;
|
24
|
+
minutes: string;
|
25
|
+
seconds: string;
|
26
|
+
};
|
27
|
+
declare function useCountdownDate(targetDate: Date, placeholder?: string): UseCountdownDateReturn;
|
28
|
+
|
29
|
+
export { type UseCountdownDateReturn, useCountdownDate };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var a=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},p=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of S(e))!d.call(t,n)&&n!==o&&a(t,n,{get:()=>e[n],enumerable:!(r=f(e,n))||r.enumerable});return t};var v=t=>p(a({},"__esModule",{value:!0}),t);var b={};m(b,{useCountdownSeconds:()=>C});module.exports=v(b);var s=require("react");function C(t){let[e,o]=(0,s.useState)(t),[r,n]=(0,s.useState)(!1),i=(0,s.useCallback)(()=>{n(!0)},[]),l=(0,s.useCallback)(()=>{n(!1),o(t)},[t]);return(0,s.useEffect)(()=>{let u=null;return r&&e>0?u=setInterval(()=>{o(c=>c-1)},1e3):e<=0&&n(!1),()=>{u&&clearInterval(u)}},[r,e]),{value:e,setValue:o,isCounting:r,start:i,reset:l}}0&&(module.exports={useCountdownSeconds});
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useState as u,useEffect as f,useCallback as a}from"react";function d(t){let[e,n]=u(t),[o,s]=u(!1),i=a(()=>{s(!0)},[]),l=a(()=>{s(!1),n(t)},[t]);return f(()=>{let r=null;return o&&e>0?r=setInterval(()=>{n(c=>c-1)},1e3):e<=0&&s(!1),()=>{r&&clearInterval(r)}},[o,e]),{value:e,setValue:n,isCounting:o,start:i,reset:l}}export{d as useCountdownSeconds};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var a=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},p=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of d(e))!f.call(t,n)&&n!==o&&a(t,n,{get:()=>e[n],enumerable:!(r=S(e,n))||r.enumerable});return t};var v=t=>p(a({},"__esModule",{value:!0}),t);var b={};m(b,{useCountdownSeconds:()=>C});module.exports=v(b);var s=require("react");function C(t){let[e,o]=(0,s.useState)(t),[r,n]=(0,s.useState)(!1),i=(0,s.useCallback)(()=>{n(!0)},[]),l=(0,s.useCallback)(()=>{n(!1),o(t)},[t]);return(0,s.useEffect)(()=>{let u=null;return r&&e>0?u=setInterval(()=>{o(c=>c-1)},1e3):e<=0&&n(!1),()=>{u&&clearInterval(u)}},[r,e]),{value:e,setValue:o,isCounting:r,start:i,reset:l}}0&&(module.exports={useCountdownSeconds});
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Custom hook to create a countdown timer in seconds.
|
5
|
+
*
|
6
|
+
* @param {number} defaultValue - The initial countdown value in seconds.
|
7
|
+
*
|
8
|
+
* @returns {UseCountdownSecondsReturn} - An object containing:
|
9
|
+
* - `value`: The current countdown value in seconds.
|
10
|
+
* - `start`: A function to start the countdown.
|
11
|
+
* - `reset`: A function to reset the countdown to the initial value.
|
12
|
+
* - `isCounting`: A boolean indicating whether the countdown is currently active.
|
13
|
+
* - `setValue`: A function to manually set the countdown value.
|
14
|
+
*
|
15
|
+
* @example
|
16
|
+
* const { value, start, reset, isCounting } = useCountdownSeconds(30);
|
17
|
+
*
|
18
|
+
* return (
|
19
|
+
* <div>
|
20
|
+
* <p>Countdown: {value} seconds</p>
|
21
|
+
* <button onClick={start} disabled={isCounting}>Start</button>
|
22
|
+
* <button onClick={reset}>Reset</button>
|
23
|
+
* </div>
|
24
|
+
* );
|
25
|
+
*/
|
26
|
+
type UseCountdownSecondsReturn = {
|
27
|
+
value: number;
|
28
|
+
start: () => void;
|
29
|
+
reset: () => void;
|
30
|
+
isCounting: boolean;
|
31
|
+
setValue: Dispatch<SetStateAction<number>>;
|
32
|
+
};
|
33
|
+
declare function useCountdownSeconds(defaultValue: number): UseCountdownSecondsReturn;
|
34
|
+
|
35
|
+
export { type UseCountdownSecondsReturn, useCountdownSeconds };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},f=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of b(e))!i.call(t,n)&&n!==r&&s(t,n,{get:()=>e[n],enumerable:!(o=c(e,n))||o.enumerable});return t};var p=t=>f(s({},"__esModule",{value:!0}),t);var d={};m(d,{useDebounce:()=>D});module.exports=p(d);var u=require("react");function D(t,e=1e3){let[r,o]=(0,u.useState)(t);return(0,u.useEffect)(()=>{let n=setTimeout(()=>{o(t)},e);return()=>{clearTimeout(n)}},[t,e]),r}0&&(module.exports={useDebounce});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { UseDebounceReturn, useDebounce } from './use-debounce.cjs';
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useState as u,useEffect as s}from"react";function b(e,t=1e3){let[n,r]=u(e);return s(()=>{let o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}export{b as useDebounce};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var u in e)s(t,u,{get:e[u],enumerable:!0})},f=(t,e,u,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of b(e))!i.call(t,n)&&n!==u&&s(t,n,{get:()=>e[n],enumerable:!(r=c(e,n))||r.enumerable});return t};var p=t=>f(s({},"__esModule",{value:!0}),t);var d={};m(d,{useDebounce:()=>D});module.exports=p(d);var o=require("react");function D(t,e=1e3){let[u,r]=(0,o.useState)(t);return(0,o.useEffect)(()=>{let n=setTimeout(()=>{r(t)},e);return()=>{clearTimeout(n)}},[t,e]),u}0&&(module.exports={useDebounce});
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/**
|
2
|
+
* Custom hook to debounce a value. The debounced value will only update after the specified delay has passed without any changes.
|
3
|
+
*
|
4
|
+
* @param {string} value - The value to debounce.
|
5
|
+
* @param {number} [delay=1000] - The delay in milliseconds to wait before updating the debounced value.
|
6
|
+
*
|
7
|
+
* @returns {UseDebounceReturn} - The debounced value.
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
* const debouncedSearchTerm = useDebounce(searchTerm, 500);
|
11
|
+
*
|
12
|
+
* useEffect(() => {
|
13
|
+
* if (debouncedSearchTerm) {
|
14
|
+
* // Perform search
|
15
|
+
* }
|
16
|
+
* }, [debouncedSearchTerm]);
|
17
|
+
*/
|
18
|
+
type UseDebounceReturn = string;
|
19
|
+
declare function useDebounce(value: string, delay?: number): UseDebounceReturn;
|
20
|
+
|
21
|
+
export { type UseDebounceReturn, useDebounce };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},p=(t,e,o,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!m.call(t,n)&&n!==o&&i(t,n,{get:()=>e[n],enumerable:!(u=c(e,n))||u.enumerable});return t};var E=t=>p(i({},"__esModule",{value:!0}),t);var d={};v(d,{useDoubleClick:()=>a});module.exports=E(d);var l=require("react");function a({click:t,doubleClick:e,timeout:o=250}){let u=(0,l.useRef)(null),n=(0,l.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]);return(0,l.useCallback)(r=>{n(),t&&r.detail===1&&(u.current=setTimeout(()=>{t(r)},o)),r.detail%2===0&&e(r)},[t,e,o,n])}0&&(module.exports={useDoubleClick});
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useRef as i,useCallback as r}from"react";function m({click:n,doubleClick:o,timeout:u=250}){let e=i(null),l=r(()=>{e.current&&(clearTimeout(e.current),e.current=null)},[]);return r(t=>{l(),n&&t.detail===1&&(e.current=setTimeout(()=>{n(t)},u)),t.detail%2===0&&o(t)},[n,o,u,l])}export{m as useDoubleClick};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var r=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var o in e)r(t,o,{get:e[o],enumerable:!0})},E=(t,e,o,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!m.call(t,n)&&n!==o&&r(t,n,{get:()=>e[n],enumerable:!(u=c(e,n))||u.enumerable});return t};var a=t=>E(r({},"__esModule",{value:!0}),t);var d={};v(d,{useDoubleClick:()=>p});module.exports=a(d);var l=require("react");function p({click:t,doubleClick:e,timeout:o=250}){let u=(0,l.useRef)(null),n=(0,l.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]);return(0,l.useCallback)(i=>{n(),t&&i.detail===1&&(u.current=setTimeout(()=>{t(i)},o)),i.detail%2===0&&e(i)},[t,e,o,n])}0&&(module.exports={useDoubleClick});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { MouseEvent, SyntheticEvent } from 'react';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Custom hook to handle single and double click events on an element.
|
5
|
+
*
|
6
|
+
* @param {UseDoubleClickProps} props - The properties for the hook.
|
7
|
+
* @param {number} [props.timeout=250] - The timeout in milliseconds to differentiate between single and double clicks.
|
8
|
+
* @param {function} [props.click] - The function to call on a single click.
|
9
|
+
* @param {function} props.doubleClick - The function to call on a double click.
|
10
|
+
*
|
11
|
+
* @returns {UseDoubleClickReturn} - A function to handle the click events.
|
12
|
+
*
|
13
|
+
* @example
|
14
|
+
* const handleClick = (event) => console.log('Single Click', event);
|
15
|
+
* const handleDoubleClick = (event) => console.log('Double Click', event);
|
16
|
+
* const handleEvent = useDoubleClick({ click: handleClick, doubleClick: handleDoubleClick });
|
17
|
+
*
|
18
|
+
* return <div onClick={handleEvent}>Click Me</div>;
|
19
|
+
*/
|
20
|
+
type UseDoubleClickReturn = (event: MouseEvent<HTMLElement>) => void;
|
21
|
+
type UseDoubleClickProps = {
|
22
|
+
timeout?: number;
|
23
|
+
click?: (event: SyntheticEvent) => void;
|
24
|
+
doubleClick: (event: SyntheticEvent) => void;
|
25
|
+
};
|
26
|
+
declare function useDoubleClick({ click, doubleClick, timeout, }: UseDoubleClickProps): UseDoubleClickReturn;
|
27
|
+
|
28
|
+
export { type UseDoubleClickReturn, useDoubleClick };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var s in e)o(t,s,{get:e[s],enumerable:!0})},C=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!f.call(t,n)&&n!==s&&o(t,n,{get:()=>e[n],enumerable:!(i=u(e,n))||i.enumerable});return t};var a=t=>C(o({},"__esModule",{value:!0}),t);var m={};p(m,{useIsClient:()=>c});module.exports=a(m);var r=require("react");function c(){let[t,e]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{e(!0)},[]),t}0&&(module.exports={useIsClient});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { UseIsClientReturn, useIsClient } from './use-is-client.cjs';
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useState as n,useEffect as s}from"react";function o(){let[e,t]=n(!1);return s(()=>{t(!0)},[]),e}export{o as useIsClient};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var s in e)i(t,s,{get:e[s],enumerable:!0})},p=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!f.call(t,n)&&n!==s&&i(t,n,{get:()=>e[n],enumerable:!(o=u(e,n))||o.enumerable});return t};var a=t=>p(i({},"__esModule",{value:!0}),t);var I={};C(I,{useIsClient:()=>c});module.exports=a(I);var r=require("react");function c(){let[t,e]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{e(!0)},[]),t}0&&(module.exports={useIsClient});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* Custom hook to determine if the code is running on the client side.
|
3
|
+
*
|
4
|
+
* @returns {boolean} - Returns true if the code is running on the client side, otherwise false.
|
5
|
+
*
|
6
|
+
* @example
|
7
|
+
* const isClient = useIsClient();
|
8
|
+
*
|
9
|
+
* return (
|
10
|
+
* <div>
|
11
|
+
* <p>Is Client: {isClient.toString()}</p>
|
12
|
+
* </div>
|
13
|
+
* );
|
14
|
+
*/
|
15
|
+
type UseIsClientReturn = boolean;
|
16
|
+
declare function useIsClient(): UseIsClientReturn;
|
17
|
+
|
18
|
+
export { type UseIsClientReturn, useIsClient };
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var T=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var o in t)T(e,o,{get:t[o],enumerable:!0})},h=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of v(t))!w.call(e,r)&&r!==o&&T(e,r,{get:()=>t[r],enumerable:!(i=_(t,r))||i.enumerable});return e};var x=e=>h(T({},"__esModule",{value:!0}),e);var z={};y(z,{useLocalStorage:()=>V});module.exports=x(z);var s=require("react");function S(e,t){if(!b())return t??null;let o=localStorage.getItem(e);if(o!=="undefined"){if(o)try{return JSON.parse(o)}catch{return o??t??null}return t??null}}function c(e,t){try{let o=JSON.stringify(t);window.localStorage.setItem(e,o)}catch(o){console.error("Error while setting storage:",o)}}function p(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function b(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function V(e,t,o){let{initializeWithValue:i=!0}=o??{},r=t&&typeof t=="object",[d,n]=(0,s.useState)(t);(0,s.useEffect)(()=>{let a=S(e);a?n(r?l=>({...l,...a}):a):t&&i&&c(e,t)},[]);let u=(0,s.useCallback)(a=>{r?n(l=>{let m={...l,...a};return c(e,m),m}):(c(e,a),n(a))},[e,r]),g=(0,s.useCallback)((a,l)=>{r&&u({[a]:l})},[r,u]),f=(0,s.useCallback)(a=>{n(a??t),p(e)},[t,e]);return(0,s.useMemo)(()=>({state:d,setState:u,setField:g,resetState:f}),[f,g,u,d])}0&&(module.exports={useLocalStorage});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from './use-local-storage.cjs';
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import{useMemo as _,useState as v,useEffect as w,useCallback as u}from"react";function f(e,t){if(!p())return t??null;let r=localStorage.getItem(e);if(r!=="undefined"){if(r)try{return JSON.parse(r)}catch{return r??t??null}return t??null}}function i(e,t){try{let r=JSON.stringify(t);window.localStorage.setItem(e,r)}catch(r){console.error("Error while setting storage:",r)}}function m(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function p(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function V(e,t,r){let{initializeWithValue:S=!0}=r??{},a=t&&typeof t=="object",[c,s]=v(t);w(()=>{let o=f(e);o?s(a?n=>({...n,...o}):o):t&&S&&i(e,t)},[]);let l=u(o=>{a?s(n=>{let g={...n,...o};return i(e,g),g}):(i(e,o),s(o))},[e,a]),T=u((o,n)=>{a&&l({[o]:n})},[a,l]),d=u(o=>{s(o??t),m(e)},[t,e]);return _(()=>({state:c,setState:l,setField:T,resetState:d}),[d,T,l,c])}export{V as useLocalStorage};
|