minimal-shared 1.0.9 → 1.0.11

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 (37) hide show
  1. package/dist/hooks/index.cjs +1 -1
  2. package/dist/hooks/index.js +1 -1
  3. package/dist/hooks/use-tabs/index.cjs +1 -1
  4. package/dist/hooks/use-tabs/index.js +1 -1
  5. package/dist/hooks/use-tabs/use-tabs.cjs +1 -1
  6. package/dist/hooks/use-tabs/use-tabs.d.cts +40 -12
  7. package/dist/hooks/use-tabs/use-tabs.d.ts +40 -12
  8. package/dist/hooks/use-tabs/use-tabs.js +1 -1
  9. package/dist/index.cjs +2 -2
  10. package/dist/index.d.cts +2 -2
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +2 -2
  13. package/dist/utils/active-link/active-link.cjs +1 -1
  14. package/dist/utils/active-link/active-link.js +1 -1
  15. package/dist/utils/active-link/index.cjs +1 -1
  16. package/dist/utils/active-link/index.js +1 -1
  17. package/dist/utils/css-variables/css-variables.cjs +1 -1
  18. package/dist/utils/css-variables/css-variables.d.cts +5 -5
  19. package/dist/utils/css-variables/css-variables.d.ts +5 -5
  20. package/dist/utils/css-variables/css-variables.js +1 -1
  21. package/dist/utils/css-variables/index.cjs +1 -1
  22. package/dist/utils/css-variables/index.d.cts +1 -1
  23. package/dist/utils/css-variables/index.d.ts +1 -1
  24. package/dist/utils/css-variables/index.js +1 -1
  25. package/dist/utils/index.cjs +2 -2
  26. package/dist/utils/index.d.cts +2 -2
  27. package/dist/utils/index.d.ts +2 -2
  28. package/dist/utils/index.js +2 -2
  29. package/dist/utils/url/index.cjs +1 -1
  30. package/dist/utils/url/index.d.cts +1 -1
  31. package/dist/utils/url/index.d.ts +1 -1
  32. package/dist/utils/url/index.js +1 -1
  33. package/dist/utils/url/url.cjs +1 -1
  34. package/dist/utils/url/url.d.cts +7 -3
  35. package/dist/utils/url/url.d.ts +7 -3
  36. package/dist/utils/url/url.js +1 -1
  37. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var o in t)L(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&&L(e,n,{get:()=>t[n],enumerable:!(r=B(t,n))||r.enumerable});return e};var J=e=>W(L({},"__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 x=require("react");function G(e=!1){let[t,o]=(0,x.useState)(e),r=(0,x.useCallback)(()=>{o(!0)},[]),n=(0,x.useCallback)(()=>{o(!1)},[]),i=(0,x.useCallback)(()=>{o(s=>!s)},[]);return{value:t,onTrue:r,onFalse:n,onToggle:i,setValue:o}}var k=require("react");function q(){let[e,t]=(0,k.useState)(null),o=(0,k.useCallback)(n=>{t(n.currentTarget)},[]),r=(0,k.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 I={...g,...c};return U(e,I,n),I}):(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 M=require("react");function Q(e,t=1e3){let[o,r]=(0,M.useState)(e);return(0,M.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),o}var C=require("react");function X(e){let[t,o]=(0,C.useState)(e),r=(0,C.useCallback)(s=>{o(a=>({...a,...s}))},[]),n=(0,C.useCallback)((s,a)=>{r({[s]:a})},[r]),i=(0,C.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 R=require("react");function ae(e,t="- -"){let[o,r]=(0,R.useState)({days:t,hours:t,minutes:t,seconds:t}),n=(0,R.useCallback)(()=>{let i=new Date,{days:s,hours:a,minutes:l,seconds:u}=ce(e,i);r({days:D(s),hours:D(a),minutes:D(l),seconds:D(u)})},[e]);return(0,R.useEffect)(()=>{n();let i=setInterval(n,1e3);return()=>clearInterval(i)},[]),o}function D(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});
1
+ "use strict";var L=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var $=(e,t)=>{for(var o in t)L(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&&L(e,n,{get:()=>t[n],enumerable:!(r=B(t,n))||r.enumerable});return e};var J=e=>W(L({},"__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 k=require("react");function Y(e=!1){let[t,o]=(0,k.useState)(e),r=(0,k.useCallback)((i,s)=>{o(s)},[]),n=(0,k.useCallback)(()=>{o(e)},[e]);return{value:t,setValue:o,onChange:r,reset:n}}var x=require("react");function G(e=!1){let[t,o]=(0,x.useState)(e),r=(0,x.useCallback)(()=>{o(!0)},[]),n=(0,x.useCallback)(()=>{o(!1)},[]),i=(0,x.useCallback)(()=>{o(s=>!s)},[]);return{value:t,onTrue:r,onFalse:n,onToggle:i,setValue:o}}var E=require("react");function q(){let[e,t]=(0,E.useState)(null),o=(0,E.useCallback)(n=>{t(n.currentTarget)},[]),r=(0,E.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?S=>({...S,...c}):c):t&&r&&U(e,t,n)},[]);let l=(0,m.useCallback)(c=>{i?a(S=>{let I={...S,...c};return U(e,I,n),I}):(U(e,c,n),a(c))},[n,i,e]),u=(0,m.useCallback)((c,S)=>{i&&l({[c]:S})},[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 M=require("react");function Q(e,t=1e3){let[o,r]=(0,M.useState)(e);return(0,M.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),o}var C=require("react");function X(e){let[t,o]=(0,C.useState)(e),r=(0,C.useCallback)(s=>{o(a=>({...a,...s}))},[]),n=(0,C.useCallback)((s,a)=>{r({[s]:a})},[r]),i=(0,C.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 g=require("react");function ee(e,t){let[o,r]=(0,g.useState)(!1),n=te(e),i=(0,g.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,g.useMemo)(()=>{let l;return()=>{clearTimeout(l),l=setTimeout(i,100)}},[i]);return(0,g.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 w=require("react");function re({click:e,doubleClick:t,timeout:o=250}){let r=(0,w.useRef)(null),n=(0,w.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return(0,w.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 D(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&&D(e,t)},[]);let a=(0,T.useCallback)(f=>{n?s(c=>{let S={...c,...f};return D(e,S),S}):(D(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 R=require("react");function ae(e,t="- -"){let[o,r]=(0,R.useState)({days:t,hours:t,minutes:t,seconds:t}),n=(0,R.useCallback)(()=>{let i=new Date,{days:s,hours:a,minutes:l,seconds:u}=ce(e,i);r({days:V(s),hours:V(a),minutes:V(l),seconds:V(u)})},[e]);return(0,R.useEffect)(()=>{n();let i=setInterval(n,1e3);return()=>clearInterval(i)},[]),o}function V(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});
@@ -1 +1 @@
1
- import{useState as I,useCallback as A}from"react";function Ce(e){let[t,o]=I(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 C}from"react";function Me(){let[e,t]=j(null),o=C(n=>{t(n.currentTarget)},[]),r=C(()=>{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 R(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 k(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 Le(e,t,o){let{initializeWithValue:r=!0,...n}=o??{},i=t&&typeof t=="object",[s,a]=z(t);B(()=>{let c=R(e);c?a(i?d=>({...d,...c}):c):t&&r&&m(e,t,n)},[]);let l=h(c=>{i?a(d=>{let x={...d,...c};return m(e,x,n),x}):(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),k(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 M}from"react";function tt({click:e,doubleClick:t,timeout:o=250}){let r=re(null),n=M(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return M(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 D}from"react";function ct(e){let t=ce(null),o=e||t,[r,n]=ue(!1),i=D(()=>{n(!0)},[]),s=D(()=>{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 L}from"react";function ht(e){let[t,o]=H(e),[r,n]=H(!1),i=L(()=>{n(!0)},[]),s=L(()=>{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,Le 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,Me as usePopover,ct as usePopoverHover,Tt as useScrollOffsetTop,ze as useSetState,Ce as useTabs};
1
+ import{useState as A,useCallback as C}from"react";function Ce(e=!1){let[t,o]=A(e),r=C((i,s)=>{o(s)},[]),n=C(()=>{o(e)},[e]);return{value:t,setValue:o,onChange:r,reset:n}}import{useState as P,useCallback as g}from"react";function Ee(e=!1){let[t,o]=P(e),r=g(()=>{o(!0)},[]),n=g(()=>{o(!1)},[]),i=g(()=>{o(s=>!s)},[]);return{value:t,onTrue:r,onFalse:n,onToggle:i,setValue:o}}import{useState as j,useCallback as R}from"react";function Me(){let[e,t]=j(null),o=R(n=>{t(n.currentTarget)},[]),r=R(()=>{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 E(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 Le(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 x={...d,...c};return m(e,x,n),x}):(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),E(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 w,useState as U,useEffect as M,useCallback as Z,useLayoutEffect as ee}from"react";function qe(e,t){let o=X(null),r=e||o,[n,i]=U(void 0),[s,a]=U(void 0),l=typeof window<"u"?ee:M,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]),M(()=>{let c=t||"resize";return window.addEventListener(c,u),()=>{window.removeEventListener(c,u)}},[t,u]);let p=w(()=>n,[n]),f=w(()=>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 O}from"react";function tt({click:e,doubleClick:t,timeout:o=250}){let r=re(null),n=O(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return O(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 D(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=D(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 H}from"react";function ct(e){let t=ce(null),o=e||t,[r,n]=ue(!1),i=H(()=>{n(!0)},[]),s=H(()=>{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:S(s),hours:S(a),minutes:S(l),seconds:S(u)})},[e]);return fe(()=>{n();let i=setInterval(n,1e3);return()=>clearInterval(i)},[]),o}function S(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 Se,useEffect as ge,useCallback as he}from"react";function Tt(e=0){let t=Te(null),[o,r]=Se(!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 ge(()=>(n(),window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[n]),{elementRef:t,offsetTop:o}}import{useState as L,useEffect as be,useCallback as I}from"react";function ht(e){let[t,o]=L(e),[r,n]=L(!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,Le 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,Me as usePopover,ct as usePopoverHover,Tt as useScrollOffsetTop,ze as useSetState,Ce as useTabs};
@@ -1 +1 @@
1
- "use strict";var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},S=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!p.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(a=c(t,s))||a.enumerable});return e};var g=e=>S(i({},"__esModule",{value:!0}),e);var l={};v(l,{useTabs:()=>h});module.exports=g(l);var r=require("react");function h(e){let[t,n]=(0,r.useState)(e),a=(0,r.useCallback)((s,o)=>{n(o)},[]);return{value:t,setValue:n,onChange:a}}0&&(module.exports={useTabs});
1
+ "use strict";var r=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var f=(e,t)=>{for(var s in t)r(e,s,{get:t[s],enumerable:!0})},p=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!l.call(e,n)&&n!==s&&r(e,n,{get:()=>t[n],enumerable:!(o=i(t,n))||o.enumerable});return e};var v=e=>p(r({},"__esModule",{value:!0}),e);var S={};f(S,{useTabs:()=>u});module.exports=v(S);var a=require("react");function u(e=!1){let[t,s]=(0,a.useState)(e),o=(0,a.useCallback)((h,c)=>{s(c)},[]),n=(0,a.useCallback)(()=>{s(e)},[e]);return{value:t,setValue:s,onChange:o,reset:n}}0&&(module.exports={useTabs});
@@ -1 +1 @@
1
- import{useState as r,useCallback as i}from"react";function u(e){let[n,t]=r(e),s=i((o,a)=>{t(a)},[]);return{value:n,setValue:t,onChange:s}}export{u as useTabs};
1
+ import{useState as c,useCallback as s}from"react";function l(e=!1){let[n,t]=c(e),a=s((i,r)=>{t(r)},[]),o=s(()=>{t(e)},[e]);return{value:n,setValue:t,onChange:a,reset:o}}export{l as useTabs};
@@ -1 +1 @@
1
- "use strict";var r=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},S=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!p.call(e,s)&&s!==n&&r(e,s,{get:()=>t[s],enumerable:!(a=c(t,s))||a.enumerable});return e};var g=e=>S(r({},"__esModule",{value:!0}),e);var l={};v(l,{useTabs:()=>h});module.exports=g(l);var i=require("react");function h(e){let[t,n]=(0,i.useState)(e),a=(0,i.useCallback)((s,o)=>{n(o)},[]);return{value:t,setValue:n,onChange:a}}0&&(module.exports={useTabs});
1
+ "use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var s in t)c(e,s,{get:t[s],enumerable:!0})},f=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!l.call(e,n)&&n!==s&&c(e,n,{get:()=>t[n],enumerable:!(o=i(t,n))||o.enumerable});return e};var p=e=>f(c({},"__esModule",{value:!0}),e);var S={};v(S,{useTabs:()=>u});module.exports=p(S);var a=require("react");function u(e=!1){let[t,s]=(0,a.useState)(e),o=(0,a.useCallback)((h,r)=>{s(r)},[]),n=(0,a.useCallback)(()=>{s(e)},[e]);return{value:t,setValue:s,onChange:o,reset:n}}0&&(module.exports={useTabs});
@@ -1,17 +1,21 @@
1
1
  import { Dispatch, SetStateAction, SyntheticEvent } from 'react';
2
2
 
3
3
  /**
4
- * Custom hook to manage the state of tabs.
4
+ * A custom React hook to manage the state of a tab component.
5
5
  *
6
- * @param {string} defaultValue - The initial value of the tab.
6
+ * @template T - The type of the tab value (e.g., string, number, or custom type).
7
+ * @param defaultValue - The initial tab value or `false` to indicate no tab is selected. Defaults to `false`.
8
+ * @returns An object containing the current tab state and methods to manipulate it.
7
9
  *
8
- * @returns {UseTabsReturn} - An object containing:
9
- * - `value`: The current value of the tab.
10
- * - `setValue`: A function to manually set the value of the tab.
11
- * - `onChange`: A function to handle the change event when a new tab is selected.
10
+ * @remarks
11
+ * - Use `false` as the tab value to deselect all tabs.
12
+ * - The `onChange` handler is designed to work with tab components like Material-UI's `Tabs`.
13
+ * - The hook is memoized for performance and supports dynamic default values.
12
14
  *
13
15
  * @example
14
- * const { value, onChange } = useTabs('tab1');
16
+ * ```tsx
17
+ * // Example: Using string tab values
18
+ * const { value, onChange, setValue, reset } = useTabs<'tab1' | 'tab2'>('tab1');
15
19
  *
16
20
  * return (
17
21
  * <Tabs value={value} onChange={onChange}>
@@ -19,12 +23,36 @@ import { Dispatch, SetStateAction, SyntheticEvent } from 'react';
19
23
  * <Tab label="Tab 2" value="tab2" />
20
24
  * </Tabs>
21
25
  * );
26
+ *
27
+ * // Manually select a tab
28
+ * setValue('tab2');
29
+ *
30
+ * // Deselect all tabs
31
+ * setValue(false);
32
+ *
33
+ * // Reset to default value
34
+ * reset();
35
+ * ```
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * // Example: Using number tab values with no initial selection
40
+ * const { value, onChange } = useTabs<1 | 2>(false);
41
+ *
42
+ * return (
43
+ * <Tabs value={value} onChange={onChange}>
44
+ * <Tab label="Tab 1" value={1} />
45
+ * <Tab label="Tab 2" value={2} />
46
+ * </Tabs>
47
+ * );
48
+ * ```
22
49
  */
23
- type UseTabsReturn = {
24
- value: string;
25
- setValue: Dispatch<SetStateAction<string>>;
26
- onChange: (event: SyntheticEvent, newValue: string) => void;
50
+ type UseTabsReturn<T> = {
51
+ value: T | false;
52
+ setValue: Dispatch<SetStateAction<T | false>>;
53
+ onChange: (event: SyntheticEvent, newValue: T | false) => void;
54
+ reset: () => void;
27
55
  };
28
- declare function useTabs(defaultValue: string): UseTabsReturn;
56
+ declare function useTabs<T>(defaultValue?: T | false): UseTabsReturn<T>;
29
57
 
30
58
  export { type UseTabsReturn, useTabs };
@@ -1,17 +1,21 @@
1
1
  import { Dispatch, SetStateAction, SyntheticEvent } from 'react';
2
2
 
3
3
  /**
4
- * Custom hook to manage the state of tabs.
4
+ * A custom React hook to manage the state of a tab component.
5
5
  *
6
- * @param {string} defaultValue - The initial value of the tab.
6
+ * @template T - The type of the tab value (e.g., string, number, or custom type).
7
+ * @param defaultValue - The initial tab value or `false` to indicate no tab is selected. Defaults to `false`.
8
+ * @returns An object containing the current tab state and methods to manipulate it.
7
9
  *
8
- * @returns {UseTabsReturn} - An object containing:
9
- * - `value`: The current value of the tab.
10
- * - `setValue`: A function to manually set the value of the tab.
11
- * - `onChange`: A function to handle the change event when a new tab is selected.
10
+ * @remarks
11
+ * - Use `false` as the tab value to deselect all tabs.
12
+ * - The `onChange` handler is designed to work with tab components like Material-UI's `Tabs`.
13
+ * - The hook is memoized for performance and supports dynamic default values.
12
14
  *
13
15
  * @example
14
- * const { value, onChange } = useTabs('tab1');
16
+ * ```tsx
17
+ * // Example: Using string tab values
18
+ * const { value, onChange, setValue, reset } = useTabs<'tab1' | 'tab2'>('tab1');
15
19
  *
16
20
  * return (
17
21
  * <Tabs value={value} onChange={onChange}>
@@ -19,12 +23,36 @@ import { Dispatch, SetStateAction, SyntheticEvent } from 'react';
19
23
  * <Tab label="Tab 2" value="tab2" />
20
24
  * </Tabs>
21
25
  * );
26
+ *
27
+ * // Manually select a tab
28
+ * setValue('tab2');
29
+ *
30
+ * // Deselect all tabs
31
+ * setValue(false);
32
+ *
33
+ * // Reset to default value
34
+ * reset();
35
+ * ```
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * // Example: Using number tab values with no initial selection
40
+ * const { value, onChange } = useTabs<1 | 2>(false);
41
+ *
42
+ * return (
43
+ * <Tabs value={value} onChange={onChange}>
44
+ * <Tab label="Tab 1" value={1} />
45
+ * <Tab label="Tab 2" value={2} />
46
+ * </Tabs>
47
+ * );
48
+ * ```
22
49
  */
23
- type UseTabsReturn = {
24
- value: string;
25
- setValue: Dispatch<SetStateAction<string>>;
26
- onChange: (event: SyntheticEvent, newValue: string) => void;
50
+ type UseTabsReturn<T> = {
51
+ value: T | false;
52
+ setValue: Dispatch<SetStateAction<T | false>>;
53
+ onChange: (event: SyntheticEvent, newValue: T | false) => void;
54
+ reset: () => void;
27
55
  };
28
- declare function useTabs(defaultValue: string): UseTabsReturn;
56
+ declare function useTabs<T>(defaultValue?: T | false): UseTabsReturn<T>;
29
57
 
30
58
  export { type UseTabsReturn, useTabs };
@@ -1 +1 @@
1
- import{useState as i,useCallback as r}from"react";function u(e){let[n,t]=i(e),s=r((o,a)=>{t(a)},[]);return{value:n,setValue:t,onChange:s}}export{u as useTabs};
1
+ import{useState as r,useCallback as s}from"react";function l(e=!1){let[n,t]=r(e),a=s((i,c)=>{t(c)},[]),o=s(()=>{t(e)},[e]);return{value:n,setValue:t,onChange:a,reset:o}}export{l as useTabs};
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var A=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var ee=(e,t)=>{for(var n in t)A(e,n,{get:t[n],enumerable:!0})},te=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of X(t))!Z.call(e,o)&&o!==n&&A(e,o,{get:()=>t[o],enumerable:!(r=Q(t,o))||r.enumerable});return e};var ne=e=>te(A({},"__esModule",{value:!0}),e);var Ae={};ee(Ae,{createPaletteChannel:()=>ue,getCookie:()=>j,getCssVarName:()=>me,getStorage:()=>B,hasKeys:()=>ce,hasParams:()=>P,hexToRgbChannel:()=>J,isActiveLink:()=>de,isEqualPath:()=>oe,isExternalLink:()=>$,localStorageAvailable:()=>Y,mergeClasses:()=>fe,mergeRefs:()=>re,pxToRem:()=>ae,remToPx:()=>ie,removeCookie:()=>N,removeLastSlash:()=>y,removeParams:()=>H,removeStorage:()=>F,setCookie:()=>E,setFont:()=>se,setStorage:()=>w,transformNumber:()=>Te,transformValue:()=>W,transformValueOnBlur:()=>K,transformValueOnChange:()=>G,updateSelectedItems:()=>q,useBackToTop:()=>Ce,useBoolean:()=>he,useClientRect:()=>ke,useCookies:()=>Se,useCopyToClipboard:()=>De,useCountdownDate:()=>Ve,useCountdownSeconds:()=>Ie,useDebounce:()=>xe,useDoubleClick:()=>we,useIsClient:()=>ve,useLocalStorage:()=>Ue,useMultiSelect:()=>Ee,usePopover:()=>be,usePopoverHover:()=>Oe,useScrollOffsetTop:()=>Le,useSetState:()=>ye,useTabs:()=>ge,uuidv4:()=>pe,varAlpha:()=>le});module.exports=ne(Ae);function P(e){try{let t=new URL(e,window.location.origin);return Array.from(t.searchParams.keys()).length>0}catch{return!1}}function y(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function oe(e,t){return y(e)===y(t)}function H(e){try{let t=new URL(e,window.location.origin);return y(t.pathname)}catch{return e}}function $(e){return/^https?:\/\//i.test(e)}function re(e){return t=>{if(e.length!==0)for(let n of e)n&&(typeof n=="function"?n(t):"current"in n&&(n.current=t))}}var z='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function se(e){return e?`"${e}", ${z}`:z}function ie(e){let t=parseFloat(e);return Math.round(t*16)}function ae(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function J(e){if(!e)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(e))throw new Error(`Invalid hex color: ${e}`);let t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),r=parseInt(e.substring(5,7),16);return`${t} ${n} ${r}`}function ue(e){let t={};return Object.entries(e).forEach(([n,r])=>{r&&(t[`${n}Channel`]=J(r))}),{...e,...t}}function le(e,t=1){if(!e)throw new Error("[Alpha]: Color is undefined!");if(e.startsWith("#")||e.startsWith("rgb")||e.startsWith("rgba")||!e.includes("var")&&e.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${e}"`,"Supported formats are:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"Unsupported formats are:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
2
- `));return`rgba(${e} / ${t})`}function ce(e,t){return!e||!t.length||typeof e!="object"?!1:t.every(n=>n in e)}function pe(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function fe(e,t){let n=e?Array.isArray(e)?e:[e]:[],r=Object.entries(t||{}).filter(([o,s])=>s!==void 0&&s!==!1).map(([o,s])=>Array.isArray(s)?s[0]?s[1]:"":s?o:"").filter(Boolean);return[...n.filter(Boolean),...r].join(" ")}function j(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,o=decodeURIComponent(document.cookie).split("; ").find(i=>i.startsWith(t));if(!o)return null;let s=o.substring(t.length);try{return JSON.parse(s)}catch{return s}}catch(t){return console.error("Error retrieving cookie:",t),null}}function E(e,t,n){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:r=0,sameSite:o="Strict",secure:s=!1,path:i="/",domain:u}=n??{};try{let a=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),c=[`${e}=${a}`,`path=${i}`,o&&`SameSite=${o}`,s&&"Secure",u&&`domain=${u}`];if(r>0){let p=new Date(Date.now()+r*24*60*60*1e3);c.push(`expires=${p.toUTCString()}`)}document.cookie=c.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}function N(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:n="/",domain:r}=t??{};try{let o=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${n}`,r&&`domain=${r}`,"Secure"];document.cookie=o.filter(Boolean).join("; ")}catch(o){console.error("Error removing cookie:",o)}}function de(e,t,n=!0){if(!e||!t)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(t.startsWith("#")||$(t))return!1;let r=y(e),o=y(H(t));return n||P(t)?r===o||r.startsWith(`${o}/`)||r.startsWith(`${o}?`):r===o}function B(e,t){if(!Y())return t??null;let n=localStorage.getItem(e);if(n!=="undefined"){if(n)try{return JSON.parse(n)}catch{return n??t??null}return t??null}}function w(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function F(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function Y(){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 me(e){if(typeof e!="string"||!e.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let t=e.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return t?t[1]:(console.error(`Invalid CSS variable format: "${e}". Expected format: var(--variable-name)`),"")}function W(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function G(e){let n=W(e).replace(/[^0-9.]/g,""),[r,...o]=n.split(".");return o.length>0?`${r}.${o.join("")}`:r}function K(e,t=""){if(e==null||typeof e=="number"&&Number.isNaN(e))return t;let n=parseFloat(e.toString());return Number.isNaN(n)?t:n}var Te={onChange:G,onBlur:K,value:W};var V=require("react");function ge(e){let[t,n]=(0,V.useState)(e),r=(0,V.useCallback)((o,s)=>{n(s)},[]);return{value:t,setValue:n,onChange:r}}var C=require("react");function he(e=!1){let[t,n]=(0,C.useState)(e),r=(0,C.useCallback)(()=>{n(!0)},[]),o=(0,C.useCallback)(()=>{n(!1)},[]),s=(0,C.useCallback)(()=>{n(i=>!i)},[]);return{value:t,onTrue:r,onFalse:o,onToggle:s,setValue:n}}var U=require("react");function be(){let[e,t]=(0,U.useState)(null),n=(0,U.useCallback)(o=>{t(o.currentTarget)},[]),r=(0,U.useCallback)(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:n,onClose:r,setAnchorEl:t}}var m=require("react");function Se(e,t,n){let{initializeWithValue:r=!0,...o}=n??{},s=t&&typeof t=="object",[i,u]=(0,m.useState)(t);(0,m.useEffect)(()=>{let l=j(e);l?u(s?g=>({...g,...l}):l):t&&r&&E(e,t,o)},[]);let a=(0,m.useCallback)(l=>{s?u(g=>{let _={...g,...l};return E(e,_,o),_}):(E(e,l,o),u(l))},[o,s,e]),c=(0,m.useCallback)((l,g)=>{s&&a({[l]:g})},[s,a]),p=(0,m.useCallback)(l=>{u(l??t),N(e)},[t,e]);return(0,m.useMemo)(()=>({state:i,setState:a,setField:c,resetState:p}),[p,c,a,i])}var M=require("react");function xe(e,t=1e3){let[n,r]=(0,M.useState)(e);return(0,M.useEffect)(()=>{let o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}var R=require("react");function ye(e){let[t,n]=(0,R.useState)(e),r=(0,R.useCallback)(i=>{n(u=>({...u,...i}))},[]),o=(0,R.useCallback)((i,u)=>{r({[i]:u})},[r]),s=(0,R.useCallback)(i=>{n(i??e)},[e]);return{state:t,setState:r,setField:o,resetState:s}}var L=require("react");function ve(){let[e,t]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{t(!0)},[]),e}var h=require("react");function Ce(e,t){let[n,r]=(0,h.useState)(!1),o=Re(e),s=(0,h.useCallback)(()=>{let a=window.innerHeight,c=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(c/(p-a)*100);if(o.type==="percentage")r(f>=o.value);else{let l=p-a-c;r(o.value>=l)}},[o.type,o.value]),i=(0,h.useMemo)(()=>{let a;return()=>{clearTimeout(a),a=setTimeout(s,100)}},[s]);return(0,h.useEffect)(()=>{let a=t?i:s;return window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a)}},[i,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:r}}function Re(e){let t,n;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else t=e,n="number";return{value:t,type:n}}var d=require("react");function ke(e,t){let n=(0,d.useRef)(null),r=e||n,[o,s]=(0,d.useState)(void 0),[i,u]=(0,d.useState)(void 0),a=typeof window<"u"?d.useLayoutEffect:d.useEffect,c=(0,d.useCallback)(()=>{if(r.current){let l=r.current.getBoundingClientRect();s(l),u({scrollWidth:r.current.scrollWidth,scrollHeight:r.current.scrollHeight})}},[r]);a(()=>{c()},[c]),(0,d.useEffect)(()=>{let l=t||"resize";return window.addEventListener(l,c),()=>{window.removeEventListener(l,c)}},[t,c]);let p=(0,d.useMemo)(()=>o,[o]),f=(0,d.useMemo)(()=>i,[i]);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 b=require("react");function Ee(e,t){let[n,r]=(0,b.useState)(t??[]),o=(0,b.useCallback)(a=>{r(c=>q(c,a))},[]),s=(0,b.useCallback)(()=>{r(a=>a.length===e.length?[]:e)},[e]),i=(0,b.useCallback)(()=>{r([])},[]),u=(0,b.useMemo)(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:u,setValues:r,onSelectAllItems:s,onDeSelectAllItems:i,onToggleSelectItem:o}}function q(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}var O=require("react");function we({click:e,doubleClick:t,timeout:n=250}){let r=(0,O.useRef)(null),o=(0,O.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return(0,O.useCallback)(i=>{o(),e&&i.detail===1&&(r.current=setTimeout(()=>{e(i)},n)),i.detail%2===0&&t(i)},[e,t,n,o])}var T=require("react");function Ue(e,t,n){let{initializeWithValue:r=!0}=n??{},o=t&&typeof t=="object",[s,i]=(0,T.useState)(t);(0,T.useEffect)(()=>{let f=B(e);f?i(o?l=>({...l,...f}):f):t&&r&&w(e,t)},[]);let u=(0,T.useCallback)(f=>{o?i(l=>{let g={...l,...f};return w(e,g),g}):(w(e,f),i(f))},[e,o]),a=(0,T.useCallback)((f,l)=>{o&&u({[f]:l})},[o,u]),c=(0,T.useCallback)(f=>{i(f??t),F(e)},[t,e]);return(0,T.useMemo)(()=>({state:s,setState:u,setField:a,resetState:c}),[c,a,u,s])}var v=require("react");function Oe(e){let t=(0,v.useRef)(null),n=e||t,[r,o]=(0,v.useState)(!1),s=(0,v.useCallback)(()=>{o(!0)},[]),i=(0,v.useCallback)(()=>{o(!1)},[]);return{elementRef:n,anchorEl:n.current,open:r,onOpen:s,onClose:i,setOpen:o}}var k=require("react");function Ve(e,t="- -"){let[n,r]=(0,k.useState)({days:t,hours:t,minutes:t,seconds:t}),o=(0,k.useCallback)(()=>{let s=new Date,{days:i,hours:u,minutes:a,seconds:c}=Me(e,s);r({days:I(i),hours:I(u),minutes:I(a),seconds:I(c)})},[e]);return(0,k.useEffect)(()=>{o();let s=setInterval(o,1e3);return()=>clearInterval(s)},[]),n}function I(e){return String(e).length===1?`0${e}`:`${e}`}function Me(e,t){let n=e.getTime()-t.getTime();return{days:Math.floor(n/(1e3*60*60*24)),hours:Math.floor(n%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(n%(1e3*60*60)/(1e3*60)),seconds:Math.floor(n%(1e3*60)/1e3)}}var S=require("react");function Le(e=0){let t=(0,S.useRef)(null),[n,r]=(0,S.useState)(!1),o=(0,S.useCallback)(()=>{let s=window.scrollY;if(t.current){let i=t.current.offsetTop;r(s>i-e)}else r(s>e)},[e]);return(0,S.useEffect)(()=>(o(),window.addEventListener("scroll",o),()=>{window.removeEventListener("scroll",o)}),[o]),{elementRef:t,offsetTop:n}}var x=require("react");function Ie(e){let[t,n]=(0,x.useState)(e),[r,o]=(0,x.useState)(!1),s=(0,x.useCallback)(()=>{o(!0)},[]),i=(0,x.useCallback)(()=>{o(!1),n(e)},[e]);return(0,x.useEffect)(()=>{let u=null;return r&&t>0?u=setInterval(()=>{n(a=>a-1)},1e3):t<=0&&o(!1),()=>{u&&clearInterval(u)}},[r,t]),{value:t,setValue:n,isCounting:r,start:s,reset:i}}var D=require("react");function De(){let[e,t]=(0,D.useState)(null);return{copy:(0,D.useCallback)(async r=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(r),t(r),!0}catch(o){return console.warn("Copy failed",o),t(null),!1}},[t]),copiedText:e}}0&&(module.exports={createPaletteChannel,getCookie,getCssVarName,getStorage,hasKeys,hasParams,hexToRgbChannel,isActiveLink,isEqualPath,isExternalLink,localStorageAvailable,mergeClasses,mergeRefs,pxToRem,remToPx,removeCookie,removeLastSlash,removeParams,removeStorage,setCookie,setFont,setStorage,transformNumber,transformValue,transformValueOnBlur,transformValueOnChange,updateSelectedItems,useBackToTop,useBoolean,useClientRect,useCookies,useCopyToClipboard,useCountdownDate,useCountdownSeconds,useDebounce,useDoubleClick,useIsClient,useLocalStorage,useMultiSelect,usePopover,usePopoverHover,useScrollOffsetTop,useSetState,useTabs,uuidv4,varAlpha});
1
+ "use strict";var A=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(e,t)=>{for(var n in t)A(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Z(t))!ee.call(e,o)&&o!==n&&A(e,o,{get:()=>t[o],enumerable:!(r=X(t,o))||r.enumerable});return e};var oe=e=>ne(A({},"__esModule",{value:!0}),e);var Pe={};te(Pe,{createPaletteChannel:()=>ue,getCookie:()=>j,getStorage:()=>F,hasKeys:()=>pe,hasParams:()=>P,hexToRgbChannel:()=>Y,isActiveLink:()=>me,isEqualPath:()=>re,isExternalLink:()=>$,localStorageAvailable:()=>q,mergeClasses:()=>de,mergeRefs:()=>se,parseCssVar:()=>Te,pxToRem:()=>le,remToPx:()=>ae,removeCookie:()=>B,removeLastSlash:()=>y,removeParams:()=>H,removeStorage:()=>N,setCookie:()=>k,setFont:()=>ie,setStorage:()=>w,transformNumber:()=>ge,transformValue:()=>W,transformValueOnBlur:()=>K,transformValueOnChange:()=>G,updateSelectedItems:()=>Q,useBackToTop:()=>Re,useBoolean:()=>be,useClientRect:()=>ke,useCookies:()=>xe,useCopyToClipboard:()=>Ae,useCountdownDate:()=>Ve,useCountdownSeconds:()=>De,useDebounce:()=>ye,useDoubleClick:()=>Ue,useIsClient:()=>Ce,useLocalStorage:()=>Oe,useMultiSelect:()=>we,usePopover:()=>Se,usePopoverHover:()=>Me,useScrollOffsetTop:()=>Ie,useSetState:()=>ve,useTabs:()=>he,uuidv4:()=>fe,varAlpha:()=>ce});module.exports=oe(Pe);var z=require("es-toolkit");function P(e){try{let t=new URL(e,window.location.origin);return Array.from(t.searchParams.keys()).length>0}catch{return!1}}function y(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function re(e,t,n={deep:!0}){let r=o=>{try{let{pathname:s,searchParams:i}=new URL(o.trim(),"http://dummy");return n.deep?{pathname:y(s),params:Object.fromEntries(i)}:{pathname:y(s)}}catch{return{pathname:""}}};return(0,z.isEqual)(r(t),r(e))}function H(e){try{let t=new URL(e,window.location.origin);return y(t.pathname)}catch{return e}}function $(e){return/^https?:\/\//i.test(e)}function se(e){return t=>{if(e.length!==0)for(let n of e)n&&(typeof n=="function"?n(t):"current"in n&&(n.current=t))}}var J='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function ie(e){return e?`"${e}", ${J}`:J}function ae(e){let t=parseFloat(e);return Math.round(t*16)}function le(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function Y(e){if(!e)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(e))throw new Error(`Invalid hex color: ${e}`);let t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),r=parseInt(e.substring(5,7),16);return`${t} ${n} ${r}`}function ue(e){let t={};return Object.entries(e).forEach(([n,r])=>{r&&(t[`${n}Channel`]=Y(r))}),{...e,...t}}function ce(e,t=1){if(!e)throw new Error("[Alpha]: Color is undefined!");if(e.startsWith("#")||e.startsWith("rgb")||e.startsWith("rgba")||!e.includes("var")&&e.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${e}"`,"Supported formats are:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"Unsupported formats are:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
2
+ `));return`rgba(${e} / ${t})`}function pe(e,t){return!e||!t.length||typeof e!="object"?!1:t.every(n=>n in e)}function fe(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function de(e,t){let n=e?Array.isArray(e)?e:[e]:[],r=Object.entries(t||{}).filter(([o,s])=>s!==void 0&&s!==!1).map(([o,s])=>Array.isArray(s)?s[0]?s[1]:"":s?o:"").filter(Boolean);return[...n.filter(Boolean),...r].join(" ")}function j(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,o=decodeURIComponent(document.cookie).split("; ").find(i=>i.startsWith(t));if(!o)return null;let s=o.substring(t.length);try{return JSON.parse(s)}catch{return s}}catch(t){return console.error("Error retrieving cookie:",t),null}}function k(e,t,n){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:r=0,sameSite:o="Strict",secure:s=!1,path:i="/",domain:l}=n??{};try{let a=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),c=[`${e}=${a}`,`path=${i}`,o&&`SameSite=${o}`,s&&"Secure",l&&`domain=${l}`];if(r>0){let p=new Date(Date.now()+r*24*60*60*1e3);c.push(`expires=${p.toUTCString()}`)}document.cookie=c.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}function B(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:n="/",domain:r}=t??{};try{let o=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${n}`,r&&`domain=${r}`,"Secure"];document.cookie=o.filter(Boolean).join("; ")}catch(o){console.error("Error removing cookie:",o)}}function me(e,t,n=!0){if(!e||!t)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(t.startsWith("#")||$(t))return!1;let r=y(e),o=y(H(t));return n||P(t)?r===o||r.startsWith(`${o}/`)||r.startsWith(`${o}?`):r===o}function F(e,t){if(!q())return t??null;let n=localStorage.getItem(e);if(n!=="undefined"){if(n)try{return JSON.parse(n)}catch{return n??t??null}return t??null}}function w(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function N(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function q(){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 Te(e){if(typeof e!="string"||!e.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let t=e.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return t?t[1]:(console.error(`Invalid CSS variable format: "${e}". Expected format: var(--variable-name)`),"")}function W(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function G(e){let n=W(e).replace(/[^0-9.]/g,""),[r,...o]=n.split(".");return o.length>0?`${r}.${o.join("")}`:r}function K(e,t=""){if(e==null||typeof e=="number"&&Number.isNaN(e))return t;let n=parseFloat(e.toString());return Number.isNaN(n)?t:n}var ge={onChange:G,onBlur:K,value:W};var U=require("react");function he(e=!1){let[t,n]=(0,U.useState)(e),r=(0,U.useCallback)((s,i)=>{n(i)},[]),o=(0,U.useCallback)(()=>{n(e)},[e]);return{value:t,setValue:n,onChange:r,reset:o}}var C=require("react");function be(e=!1){let[t,n]=(0,C.useState)(e),r=(0,C.useCallback)(()=>{n(!0)},[]),o=(0,C.useCallback)(()=>{n(!1)},[]),s=(0,C.useCallback)(()=>{n(i=>!i)},[]);return{value:t,onTrue:r,onFalse:o,onToggle:s,setValue:n}}var O=require("react");function Se(){let[e,t]=(0,O.useState)(null),n=(0,O.useCallback)(o=>{t(o.currentTarget)},[]),r=(0,O.useCallback)(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:n,onClose:r,setAnchorEl:t}}var m=require("react");function xe(e,t,n){let{initializeWithValue:r=!0,...o}=n??{},s=t&&typeof t=="object",[i,l]=(0,m.useState)(t);(0,m.useEffect)(()=>{let u=j(e);u?l(s?g=>({...g,...u}):u):t&&r&&k(e,t,o)},[]);let a=(0,m.useCallback)(u=>{s?l(g=>{let _={...g,...u};return k(e,_,o),_}):(k(e,u,o),l(u))},[o,s,e]),c=(0,m.useCallback)((u,g)=>{s&&a({[u]:g})},[s,a]),p=(0,m.useCallback)(u=>{l(u??t),B(e)},[t,e]);return(0,m.useMemo)(()=>({state:i,setState:a,setField:c,resetState:p}),[p,c,a,i])}var V=require("react");function ye(e,t=1e3){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}var R=require("react");function ve(e){let[t,n]=(0,R.useState)(e),r=(0,R.useCallback)(i=>{n(l=>({...l,...i}))},[]),o=(0,R.useCallback)((i,l)=>{r({[i]:l})},[r]),s=(0,R.useCallback)(i=>{n(i??e)},[e]);return{state:t,setState:r,setField:o,resetState:s}}var L=require("react");function Ce(){let[e,t]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{t(!0)},[]),e}var h=require("react");function Re(e,t){let[n,r]=(0,h.useState)(!1),o=Ee(e),s=(0,h.useCallback)(()=>{let a=window.innerHeight,c=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(c/(p-a)*100);if(o.type==="percentage")r(f>=o.value);else{let u=p-a-c;r(o.value>=u)}},[o.type,o.value]),i=(0,h.useMemo)(()=>{let a;return()=>{clearTimeout(a),a=setTimeout(s,100)}},[s]);return(0,h.useEffect)(()=>{let a=t?i:s;return window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a)}},[i,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:r}}function Ee(e){let t,n;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else t=e,n="number";return{value:t,type:n}}var d=require("react");function ke(e,t){let n=(0,d.useRef)(null),r=e||n,[o,s]=(0,d.useState)(void 0),[i,l]=(0,d.useState)(void 0),a=typeof window<"u"?d.useLayoutEffect:d.useEffect,c=(0,d.useCallback)(()=>{if(r.current){let u=r.current.getBoundingClientRect();s(u),l({scrollWidth:r.current.scrollWidth,scrollHeight:r.current.scrollHeight})}},[r]);a(()=>{c()},[c]),(0,d.useEffect)(()=>{let u=t||"resize";return window.addEventListener(u,c),()=>{window.removeEventListener(u,c)}},[t,c]);let p=(0,d.useMemo)(()=>o,[o]),f=(0,d.useMemo)(()=>i,[i]);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 b=require("react");function we(e,t){let[n,r]=(0,b.useState)(t??[]),o=(0,b.useCallback)(a=>{r(c=>Q(c,a))},[]),s=(0,b.useCallback)(()=>{r(a=>a.length===e.length?[]:e)},[e]),i=(0,b.useCallback)(()=>{r([])},[]),l=(0,b.useMemo)(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:l,setValues:r,onSelectAllItems:s,onDeSelectAllItems:i,onToggleSelectItem:o}}function Q(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}var M=require("react");function Ue({click:e,doubleClick:t,timeout:n=250}){let r=(0,M.useRef)(null),o=(0,M.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return(0,M.useCallback)(i=>{o(),e&&i.detail===1&&(r.current=setTimeout(()=>{e(i)},n)),i.detail%2===0&&t(i)},[e,t,n,o])}var T=require("react");function Oe(e,t,n){let{initializeWithValue:r=!0}=n??{},o=t&&typeof t=="object",[s,i]=(0,T.useState)(t);(0,T.useEffect)(()=>{let f=F(e);f?i(o?u=>({...u,...f}):f):t&&r&&w(e,t)},[]);let l=(0,T.useCallback)(f=>{o?i(u=>{let g={...u,...f};return w(e,g),g}):(w(e,f),i(f))},[e,o]),a=(0,T.useCallback)((f,u)=>{o&&l({[f]:u})},[o,l]),c=(0,T.useCallback)(f=>{i(f??t),N(e)},[t,e]);return(0,T.useMemo)(()=>({state:s,setState:l,setField:a,resetState:c}),[c,a,l,s])}var v=require("react");function Me(e){let t=(0,v.useRef)(null),n=e||t,[r,o]=(0,v.useState)(!1),s=(0,v.useCallback)(()=>{o(!0)},[]),i=(0,v.useCallback)(()=>{o(!1)},[]);return{elementRef:n,anchorEl:n.current,open:r,onOpen:s,onClose:i,setOpen:o}}var E=require("react");function Ve(e,t="- -"){let[n,r]=(0,E.useState)({days:t,hours:t,minutes:t,seconds:t}),o=(0,E.useCallback)(()=>{let s=new Date,{days:i,hours:l,minutes:a,seconds:c}=Le(e,s);r({days:I(i),hours:I(l),minutes:I(a),seconds:I(c)})},[e]);return(0,E.useEffect)(()=>{o();let s=setInterval(o,1e3);return()=>clearInterval(s)},[]),n}function I(e){return String(e).length===1?`0${e}`:`${e}`}function Le(e,t){let n=e.getTime()-t.getTime();return{days:Math.floor(n/(1e3*60*60*24)),hours:Math.floor(n%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(n%(1e3*60*60)/(1e3*60)),seconds:Math.floor(n%(1e3*60)/1e3)}}var S=require("react");function Ie(e=0){let t=(0,S.useRef)(null),[n,r]=(0,S.useState)(!1),o=(0,S.useCallback)(()=>{let s=window.scrollY;if(t.current){let i=t.current.offsetTop;r(s>i-e)}else r(s>e)},[e]);return(0,S.useEffect)(()=>(o(),window.addEventListener("scroll",o),()=>{window.removeEventListener("scroll",o)}),[o]),{elementRef:t,offsetTop:n}}var x=require("react");function De(e){let[t,n]=(0,x.useState)(e),[r,o]=(0,x.useState)(!1),s=(0,x.useCallback)(()=>{o(!0)},[]),i=(0,x.useCallback)(()=>{o(!1),n(e)},[e]);return(0,x.useEffect)(()=>{let l=null;return r&&t>0?l=setInterval(()=>{n(a=>a-1)},1e3):t<=0&&o(!1),()=>{l&&clearInterval(l)}},[r,t]),{value:t,setValue:n,isCounting:r,start:s,reset:i}}var D=require("react");function Ae(){let[e,t]=(0,D.useState)(null);return{copy:(0,D.useCallback)(async r=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(r),t(r),!0}catch(o){return console.warn("Copy failed",o),t(null),!1}},[t]),copiedText:e}}0&&(module.exports={createPaletteChannel,getCookie,getStorage,hasKeys,hasParams,hexToRgbChannel,isActiveLink,isEqualPath,isExternalLink,localStorageAvailable,mergeClasses,mergeRefs,parseCssVar,pxToRem,remToPx,removeCookie,removeLastSlash,removeParams,removeStorage,setCookie,setFont,setStorage,transformNumber,transformValue,transformValueOnBlur,transformValueOnChange,updateSelectedItems,useBackToTop,useBoolean,useClientRect,useCookies,useCopyToClipboard,useCountdownDate,useCountdownSeconds,useDebounce,useDoubleClick,useIsClient,useLocalStorage,useMultiSelect,usePopover,usePopoverHover,useScrollOffsetTop,useSetState,useTabs,uuidv4,varAlpha});
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './utils/url/url.cjs';
1
+ export { EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './utils/url/url.cjs';
2
2
  export { mergeRefs } from './utils/refs/refs.cjs';
3
3
  export { pxToRem, remToPx, setFont } from './utils/font/font.cjs';
4
4
  export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './utils/color/color.cjs';
@@ -8,7 +8,7 @@ export { StateProps, mergeClasses } from './utils/classes/classes.cjs';
8
8
  export { CookieOptions, getCookie, removeCookie, setCookie } from './utils/cookies/cookies.cjs';
9
9
  export { isActiveLink } from './utils/active-link/active-link.cjs';
10
10
  export { getStorage, localStorageAvailable, removeStorage, setStorage } from './utils/local-storage/local-storage.cjs';
11
- export { getCssVarName } from './utils/css-variables/css-variables.cjs';
11
+ export { parseCssVar } from './utils/css-variables/css-variables.cjs';
12
12
  export { InputValue, transformNumber, transformValue, transformValueOnBlur, transformValueOnChange } from './utils/transform-number/transform-number.cjs';
13
13
  export { UseTabsReturn, useTabs } from './hooks/use-tabs/use-tabs.cjs';
14
14
  export { UseBooleanReturn, useBoolean } from './hooks/use-boolean/use-boolean.cjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './utils/url/url.js';
1
+ export { EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './utils/url/url.js';
2
2
  export { mergeRefs } from './utils/refs/refs.js';
3
3
  export { pxToRem, remToPx, setFont } from './utils/font/font.js';
4
4
  export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './utils/color/color.js';
@@ -8,7 +8,7 @@ export { StateProps, mergeClasses } from './utils/classes/classes.js';
8
8
  export { CookieOptions, getCookie, removeCookie, setCookie } from './utils/cookies/cookies.js';
9
9
  export { isActiveLink } from './utils/active-link/active-link.js';
10
10
  export { getStorage, localStorageAvailable, removeStorage, setStorage } from './utils/local-storage/local-storage.js';
11
- export { getCssVarName } from './utils/css-variables/css-variables.js';
11
+ export { parseCssVar } from './utils/css-variables/css-variables.js';
12
12
  export { InputValue, transformNumber, transformValue, transformValueOnBlur, transformValueOnChange } from './utils/transform-number/transform-number.js';
13
13
  export { UseTabsReturn, useTabs } from './hooks/use-tabs/use-tabs.js';
14
14
  export { UseBooleanReturn, useBoolean } from './hooks/use-boolean/use-boolean.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- function R(e){try{let t=new URL(e,window.location.origin);return Array.from(t.searchParams.keys()).length>0}catch{return!1}}function m(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function Me(e,t){return m(e)===m(t)}function k(e){try{let t=new URL(e,window.location.origin);return m(t.pathname)}catch{return e}}function E(e){return/^https?:\/\//i.test(e)}function Ie(e){return t=>{if(e.length!==0)for(let n of e)n&&(typeof n=="function"?n(t):"current"in n&&(n.current=t))}}var w='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function Ae(e){return e?`"${e}", ${w}`:w}function Pe(e){let t=parseFloat(e);return Math.round(t*16)}function He(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function B(e){if(!e)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(e))throw new Error(`Invalid hex color: ${e}`);let t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),o=parseInt(e.substring(5,7),16);return`${t} ${n} ${o}`}function je(e){let t={};return Object.entries(e).forEach(([n,o])=>{o&&(t[`${n}Channel`]=B(o))}),{...e,...t}}function Ne(e,t=1){if(!e)throw new Error("[Alpha]: Color is undefined!");if(e.startsWith("#")||e.startsWith("rgb")||e.startsWith("rgba")||!e.includes("var")&&e.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${e}"`,"Supported formats are:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"Unsupported formats are:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
2
- `));return`rgba(${e} / ${t})`}function Fe(e,t){return!e||!t.length||typeof e!="object"?!1:t.every(n=>n in e)}function _e(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Je(e,t){let n=e?Array.isArray(e)?e:[e]:[],o=Object.entries(t||{}).filter(([r,s])=>s!==void 0&&s!==!1).map(([r,s])=>Array.isArray(s)?s[0]?s[1]:"":s?r:"").filter(Boolean);return[...n.filter(Boolean),...o].join(" ")}function U(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,r=decodeURIComponent(document.cookie).split("; ").find(i=>i.startsWith(t));if(!r)return null;let s=r.substring(t.length);try{return JSON.parse(s)}catch{return s}}catch(t){return console.error("Error retrieving cookie:",t),null}}function T(e,t,n){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:o=0,sameSite:r="Strict",secure:s=!1,path:i="/",domain:u}=n??{};try{let a=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),c=[`${e}=${a}`,`path=${i}`,r&&`SameSite=${r}`,s&&"Secure",u&&`domain=${u}`];if(o>0){let p=new Date(Date.now()+o*24*60*60*1e3);c.push(`expires=${p.toUTCString()}`)}document.cookie=c.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}function O(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:n="/",domain:o}=t??{};try{let r=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${n}`,o&&`domain=${o}`,"Secure"];document.cookie=r.filter(Boolean).join("; ")}catch(r){console.error("Error removing cookie:",r)}}function qe(e,t,n=!0){if(!e||!t)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(t.startsWith("#")||E(t))return!1;let o=m(e),r=m(k(t));return n||R(t)?o===r||o.startsWith(`${r}/`)||o.startsWith(`${r}?`):o===r}function V(e,t){if(!F())return t??null;let n=localStorage.getItem(e);if(n!=="undefined"){if(n)try{return JSON.parse(n)}catch{return n??t??null}return t??null}}function g(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function M(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function F(){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 Ze(e){if(typeof e!="string"||!e.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let t=e.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return t?t[1]:(console.error(`Invalid CSS variable format: "${e}". Expected format: var(--variable-name)`),"")}function L(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function W(e){let n=L(e).replace(/[^0-9.]/g,""),[o,...r]=n.split(".");return r.length>0?`${o}.${r.join("")}`:o}function _(e,t=""){if(e==null||typeof e=="number"&&Number.isNaN(e))return t;let n=parseFloat(e.toString());return Number.isNaN(n)?t:n}var tt={onChange:W,onBlur:_,value:L};import{useState as z,useCallback as J}from"react";function rt(e){let[t,n]=z(e),o=J((r,s)=>{n(s)},[]);return{value:t,setValue:n,onChange:o}}import{useState as Y,useCallback as b}from"react";function at(e=!1){let[t,n]=Y(e),o=b(()=>{n(!0)},[]),r=b(()=>{n(!1)},[]),s=b(()=>{n(i=>!i)},[]);return{value:t,onTrue:o,onFalse:r,onToggle:s,setValue:n}}import{useState as G,useCallback as I}from"react";function ct(){let[e,t]=G(null),n=I(r=>{t(r.currentTarget)},[]),o=I(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:n,onClose:o,setAnchorEl:t}}import{useMemo as K,useState as q,useEffect as Q,useCallback as S}from"react";function mt(e,t,n){let{initializeWithValue:o=!0,...r}=n??{},s=t&&typeof t=="object",[i,u]=q(t);Q(()=>{let l=U(e);l?u(s?d=>({...d,...l}):l):t&&o&&T(e,t,r)},[]);let a=S(l=>{s?u(d=>{let C={...d,...l};return T(e,C,r),C}):(T(e,l,r),u(l))},[r,s,e]),c=S((l,d)=>{s&&a({[l]:d})},[s,a]),p=S(l=>{u(l??t),O(e)},[t,e]);return K(()=>({state:i,setState:a,setField:c,resetState:p}),[p,c,a,i])}import{useState as X,useEffect as Z}from"react";function ht(e,t=1e3){let[n,o]=X(e);return Z(()=>{let r=setTimeout(()=>{o(e)},t);return()=>{clearTimeout(r)}},[e,t]),n}import{useState as ee,useCallback as x}from"react";function xt(e){let[t,n]=ee(e),o=x(i=>{n(u=>({...u,...i}))},[]),r=x((i,u)=>{o({[i]:u})},[o]),s=x(i=>{n(i??e)},[e]);return{state:t,setState:o,setField:r,resetState:s}}import{useState as te,useEffect as ne}from"react";function Ct(){let[e,t]=te(!1);return ne(()=>{t(!0)},[]),e}import{useMemo as oe,useState as re,useEffect as se,useCallback as ie}from"react";function Et(e,t){let[n,o]=re(!1),r=ae(e),s=ie(()=>{let a=window.innerHeight,c=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(c/(p-a)*100);if(r.type==="percentage")o(f>=r.value);else{let l=p-a-c;o(r.value>=l)}},[r.type,r.value]),i=oe(()=>{let a;return()=>{clearTimeout(a),a=setTimeout(s,100)}},[s]);return se(()=>{let a=t?i:s;return window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a)}},[i,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:o}}function ae(e){let t,n;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else t=e,n="number";return{value:t,type:n}}import{useRef as ue,useMemo as D,useState as A,useEffect as P,useCallback as le,useLayoutEffect as ce}from"react";function Ot(e,t){let n=ue(null),o=e||n,[r,s]=A(void 0),[i,u]=A(void 0),a=typeof window<"u"?ce:P,c=le(()=>{if(o.current){let l=o.current.getBoundingClientRect();s(l),u({scrollWidth:o.current.scrollWidth,scrollHeight:o.current.scrollHeight})}},[o]);a(()=>{c()},[c]),P(()=>{let l=t||"resize";return window.addEventListener(l,c),()=>{window.removeEventListener(l,c)}},[t,c]);let p=D(()=>r,[r]),f=D(()=>i,[i]);return{elementRef:o,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 pe,useState as fe,useCallback as y}from"react";function Lt(e,t){let[n,o]=fe(t??[]),r=y(a=>{o(c=>de(c,a))},[]),s=y(()=>{o(a=>a.length===e.length?[]:e)},[e]),i=y(()=>{o([])},[]),u=pe(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:u,setValues:o,onSelectAllItems:s,onDeSelectAllItems:i,onToggleSelectItem:r}}function de(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}import{useRef as me,useCallback as H}from"react";function At({click:e,doubleClick:t,timeout:n=250}){let o=me(null),r=H(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]);return H(i=>{r(),e&&i.detail===1&&(o.current=setTimeout(()=>{e(i)},n)),i.detail%2===0&&t(i)},[e,t,n,r])}import{useMemo as Te,useState as ge,useEffect as he,useCallback as v}from"react";function jt(e,t,n){let{initializeWithValue:o=!0}=n??{},r=t&&typeof t=="object",[s,i]=ge(t);he(()=>{let f=V(e);f?i(r?l=>({...l,...f}):f):t&&o&&g(e,t)},[]);let u=v(f=>{r?i(l=>{let d={...l,...f};return g(e,d),d}):(g(e,f),i(f))},[e,r]),a=v((f,l)=>{r&&u({[f]:l})},[r,u]),c=v(f=>{i(f??t),M(e)},[t,e]);return Te(()=>({state:s,setState:u,setField:a,resetState:c}),[c,a,u,s])}import{useRef as be,useState as Se,useCallback as $}from"react";function Ft(e){let t=be(null),n=e||t,[o,r]=Se(!1),s=$(()=>{r(!0)},[]),i=$(()=>{r(!1)},[]);return{elementRef:n,anchorEl:n.current,open:o,onOpen:s,onClose:i,setOpen:r}}import{useState as xe,useEffect as ye,useCallback as ve}from"react";function zt(e,t="- -"){let[n,o]=xe({days:t,hours:t,minutes:t,seconds:t}),r=ve(()=>{let s=new Date,{days:i,hours:u,minutes:a,seconds:c}=Ce(e,s);o({days:h(i),hours:h(u),minutes:h(a),seconds:h(c)})},[e]);return ye(()=>{r();let s=setInterval(r,1e3);return()=>clearInterval(s)},[]),n}function h(e){return String(e).length===1?`0${e}`:`${e}`}function Ce(e,t){let n=e.getTime()-t.getTime();return{days:Math.floor(n/(1e3*60*60*24)),hours:Math.floor(n%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(n%(1e3*60*60)/(1e3*60)),seconds:Math.floor(n%(1e3*60)/1e3)}}import{useRef as Re,useState as ke,useEffect as Ee,useCallback as we}from"react";function Gt(e=0){let t=Re(null),[n,o]=ke(!1),r=we(()=>{let s=window.scrollY;if(t.current){let i=t.current.offsetTop;o(s>i-e)}else o(s>e)},[e]);return Ee(()=>(r(),window.addEventListener("scroll",r),()=>{window.removeEventListener("scroll",r)}),[r]),{elementRef:t,offsetTop:n}}import{useState as j,useEffect as Ue,useCallback as N}from"react";function Qt(e){let[t,n]=j(e),[o,r]=j(!1),s=N(()=>{r(!0)},[]),i=N(()=>{r(!1),n(e)},[e]);return Ue(()=>{let u=null;return o&&t>0?u=setInterval(()=>{n(a=>a-1)},1e3):t<=0&&r(!1),()=>{u&&clearInterval(u)}},[o,t]),{value:t,setValue:n,isCounting:o,start:s,reset:i}}import{useState as Oe,useCallback as Ve}from"react";function en(){let[e,t]=Oe(null);return{copy:Ve(async o=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(o),t(o),!0}catch(r){return console.warn("Copy failed",r),t(null),!1}},[t]),copiedText:e}}export{je as createPaletteChannel,U as getCookie,Ze as getCssVarName,V as getStorage,Fe as hasKeys,R as hasParams,B as hexToRgbChannel,qe as isActiveLink,Me as isEqualPath,E as isExternalLink,F as localStorageAvailable,Je as mergeClasses,Ie as mergeRefs,He as pxToRem,Pe as remToPx,O as removeCookie,m as removeLastSlash,k as removeParams,M as removeStorage,T as setCookie,Ae as setFont,g as setStorage,tt as transformNumber,L as transformValue,_ as transformValueOnBlur,W as transformValueOnChange,de as updateSelectedItems,Et as useBackToTop,at as useBoolean,Ot as useClientRect,mt as useCookies,en as useCopyToClipboard,zt as useCountdownDate,Qt as useCountdownSeconds,ht as useDebounce,At as useDoubleClick,Ct as useIsClient,jt as useLocalStorage,Lt as useMultiSelect,ct as usePopover,Ft as usePopoverHover,Gt as useScrollOffsetTop,xt as useSetState,rt as useTabs,_e as uuidv4,Ne as varAlpha};
1
+ import{isEqual as N}from"es-toolkit";function R(e){try{let t=new URL(e,window.location.origin);return Array.from(t.searchParams.keys()).length>0}catch{return!1}}function m(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function Ie(e,t,n={deep:!0}){let o=r=>{try{let{pathname:s,searchParams:i}=new URL(r.trim(),"http://dummy");return n.deep?{pathname:m(s),params:Object.fromEntries(i)}:{pathname:m(s)}}catch{return{pathname:""}}};return N(o(t),o(e))}function E(e){try{let t=new URL(e,window.location.origin);return m(t.pathname)}catch{return e}}function k(e){return/^https?:\/\//i.test(e)}function Ae(e){return t=>{if(e.length!==0)for(let n of e)n&&(typeof n=="function"?n(t):"current"in n&&(n.current=t))}}var w='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function He(e){return e?`"${e}", ${w}`:w}function $e(e){let t=parseFloat(e);return Math.round(t*16)}function je(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function W(e){if(!e)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(e))throw new Error(`Invalid hex color: ${e}`);let t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),o=parseInt(e.substring(5,7),16);return`${t} ${n} ${o}`}function Fe(e){let t={};return Object.entries(e).forEach(([n,o])=>{o&&(t[`${n}Channel`]=W(o))}),{...e,...t}}function Ne(e,t=1){if(!e)throw new Error("[Alpha]: Color is undefined!");if(e.startsWith("#")||e.startsWith("rgb")||e.startsWith("rgba")||!e.includes("var")&&e.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${e}"`,"Supported formats are:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"Unsupported formats are:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
2
+ `));return`rgba(${e} / ${t})`}function _e(e,t){return!e||!t.length||typeof e!="object"?!1:t.every(n=>n in e)}function Je(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function qe(e,t){let n=e?Array.isArray(e)?e:[e]:[],o=Object.entries(t||{}).filter(([r,s])=>s!==void 0&&s!==!1).map(([r,s])=>Array.isArray(s)?s[0]?s[1]:"":s?r:"").filter(Boolean);return[...n.filter(Boolean),...o].join(" ")}function U(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,r=decodeURIComponent(document.cookie).split("; ").find(i=>i.startsWith(t));if(!r)return null;let s=r.substring(t.length);try{return JSON.parse(s)}catch{return s}}catch(t){return console.error("Error retrieving cookie:",t),null}}function T(e,t,n){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:o=0,sameSite:r="Strict",secure:s=!1,path:i="/",domain:l}=n??{};try{let a=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),c=[`${e}=${a}`,`path=${i}`,r&&`SameSite=${r}`,s&&"Secure",l&&`domain=${l}`];if(o>0){let p=new Date(Date.now()+o*24*60*60*1e3);c.push(`expires=${p.toUTCString()}`)}document.cookie=c.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}function O(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:n="/",domain:o}=t??{};try{let r=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${n}`,o&&`domain=${o}`,"Secure"];document.cookie=r.filter(Boolean).join("; ")}catch(r){console.error("Error removing cookie:",r)}}function Xe(e,t,n=!0){if(!e||!t)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(t.startsWith("#")||k(t))return!1;let o=m(e),r=m(E(t));return n||R(t)?o===r||o.startsWith(`${r}/`)||o.startsWith(`${r}?`):o===r}function M(e,t){if(!_())return t??null;let n=localStorage.getItem(e);if(n!=="undefined"){if(n)try{return JSON.parse(n)}catch{return n??t??null}return t??null}}function g(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function V(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function _(){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 tt(e){if(typeof e!="string"||!e.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let t=e.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return t?t[1]:(console.error(`Invalid CSS variable format: "${e}". Expected format: var(--variable-name)`),"")}function L(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function z(e){let n=L(e).replace(/[^0-9.]/g,""),[o,...r]=n.split(".");return r.length>0?`${o}.${r.join("")}`:o}function J(e,t=""){if(e==null||typeof e=="number"&&Number.isNaN(e))return t;let n=parseFloat(e.toString());return Number.isNaN(n)?t:n}var ot={onChange:z,onBlur:J,value:L};import{useState as Y,useCallback as I}from"react";function it(e=!1){let[t,n]=Y(e),o=I((s,i)=>{n(i)},[]),r=I(()=>{n(e)},[e]);return{value:t,setValue:n,onChange:o,reset:r}}import{useState as q,useCallback as b}from"react";function ut(e=!1){let[t,n]=q(e),o=b(()=>{n(!0)},[]),r=b(()=>{n(!1)},[]),s=b(()=>{n(i=>!i)},[]);return{value:t,onTrue:o,onFalse:r,onToggle:s,setValue:n}}import{useState as G,useCallback as D}from"react";function ft(){let[e,t]=G(null),n=D(r=>{t(r.currentTarget)},[]),o=D(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:n,onClose:o,setAnchorEl:t}}import{useMemo as K,useState as Q,useEffect as X,useCallback as S}from"react";function gt(e,t,n){let{initializeWithValue:o=!0,...r}=n??{},s=t&&typeof t=="object",[i,l]=Q(t);X(()=>{let u=U(e);u?l(s?d=>({...d,...u}):u):t&&o&&T(e,t,r)},[]);let a=S(u=>{s?l(d=>{let C={...d,...u};return T(e,C,r),C}):(T(e,u,r),l(u))},[r,s,e]),c=S((u,d)=>{s&&a({[u]:d})},[s,a]),p=S(u=>{l(u??t),O(e)},[t,e]);return K(()=>({state:i,setState:a,setField:c,resetState:p}),[p,c,a,i])}import{useState as Z,useEffect as ee}from"react";function St(e,t=1e3){let[n,o]=Z(e);return ee(()=>{let r=setTimeout(()=>{o(e)},t);return()=>{clearTimeout(r)}},[e,t]),n}import{useState as te,useCallback as x}from"react";function vt(e){let[t,n]=te(e),o=x(i=>{n(l=>({...l,...i}))},[]),r=x((i,l)=>{o({[i]:l})},[o]),s=x(i=>{n(i??e)},[e]);return{state:t,setState:o,setField:r,resetState:s}}import{useState as ne,useEffect as oe}from"react";function Et(){let[e,t]=ne(!1);return oe(()=>{t(!0)},[]),e}import{useMemo as re,useState as se,useEffect as ie,useCallback as ae}from"react";function Ut(e,t){let[n,o]=se(!1),r=le(e),s=ae(()=>{let a=window.innerHeight,c=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(c/(p-a)*100);if(r.type==="percentage")o(f>=r.value);else{let u=p-a-c;o(r.value>=u)}},[r.type,r.value]),i=re(()=>{let a;return()=>{clearTimeout(a),a=setTimeout(s,100)}},[s]);return ie(()=>{let a=t?i:s;return window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a)}},[i,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:o}}function le(e){let t,n;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else t=e,n="number";return{value:t,type:n}}import{useRef as ue,useMemo as A,useState as P,useEffect as H,useCallback as ce,useLayoutEffect as pe}from"react";function Vt(e,t){let n=ue(null),o=e||n,[r,s]=P(void 0),[i,l]=P(void 0),a=typeof window<"u"?pe:H,c=ce(()=>{if(o.current){let u=o.current.getBoundingClientRect();s(u),l({scrollWidth:o.current.scrollWidth,scrollHeight:o.current.scrollHeight})}},[o]);a(()=>{c()},[c]),H(()=>{let u=t||"resize";return window.addEventListener(u,c),()=>{window.removeEventListener(u,c)}},[t,c]);let p=A(()=>r,[r]),f=A(()=>i,[i]);return{elementRef:o,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 fe,useState as de,useCallback as y}from"react";function Dt(e,t){let[n,o]=de(t??[]),r=y(a=>{o(c=>me(c,a))},[]),s=y(()=>{o(a=>a.length===e.length?[]:e)},[e]),i=y(()=>{o([])},[]),l=fe(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:l,setValues:o,onSelectAllItems:s,onDeSelectAllItems:i,onToggleSelectItem:r}}function me(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}import{useRef as Te,useCallback as $}from"react";function Ht({click:e,doubleClick:t,timeout:n=250}){let o=Te(null),r=$(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]);return $(i=>{r(),e&&i.detail===1&&(o.current=setTimeout(()=>{e(i)},n)),i.detail%2===0&&t(i)},[e,t,n,r])}import{useMemo as ge,useState as he,useEffect as be,useCallback as v}from"react";function Ft(e,t,n){let{initializeWithValue:o=!0}=n??{},r=t&&typeof t=="object",[s,i]=he(t);be(()=>{let f=M(e);f?i(r?u=>({...u,...f}):f):t&&o&&g(e,t)},[]);let l=v(f=>{r?i(u=>{let d={...u,...f};return g(e,d),d}):(g(e,f),i(f))},[e,r]),a=v((f,u)=>{r&&l({[f]:u})},[r,l]),c=v(f=>{i(f??t),V(e)},[t,e]);return ge(()=>({state:s,setState:l,setField:a,resetState:c}),[c,a,l,s])}import{useRef as Se,useState as xe,useCallback as j}from"react";function _t(e){let t=Se(null),n=e||t,[o,r]=xe(!1),s=j(()=>{r(!0)},[]),i=j(()=>{r(!1)},[]);return{elementRef:n,anchorEl:n.current,open:o,onOpen:s,onClose:i,setOpen:r}}import{useState as ye,useEffect as ve,useCallback as Ce}from"react";function Yt(e,t="- -"){let[n,o]=ye({days:t,hours:t,minutes:t,seconds:t}),r=Ce(()=>{let s=new Date,{days:i,hours:l,minutes:a,seconds:c}=Re(e,s);o({days:h(i),hours:h(l),minutes:h(a),seconds:h(c)})},[e]);return ve(()=>{r();let s=setInterval(r,1e3);return()=>clearInterval(s)},[]),n}function h(e){return String(e).length===1?`0${e}`:`${e}`}function Re(e,t){let n=e.getTime()-t.getTime();return{days:Math.floor(n/(1e3*60*60*24)),hours:Math.floor(n%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(n%(1e3*60*60)/(1e3*60)),seconds:Math.floor(n%(1e3*60)/1e3)}}import{useRef as Ee,useState as ke,useEffect as we,useCallback as Ue}from"react";function Kt(e=0){let t=Ee(null),[n,o]=ke(!1),r=Ue(()=>{let s=window.scrollY;if(t.current){let i=t.current.offsetTop;o(s>i-e)}else o(s>e)},[e]);return we(()=>(r(),window.addEventListener("scroll",r),()=>{window.removeEventListener("scroll",r)}),[r]),{elementRef:t,offsetTop:n}}import{useState as B,useEffect as Oe,useCallback as F}from"react";function Zt(e){let[t,n]=B(e),[o,r]=B(!1),s=F(()=>{r(!0)},[]),i=F(()=>{r(!1),n(e)},[e]);return Oe(()=>{let l=null;return o&&t>0?l=setInterval(()=>{n(a=>a-1)},1e3):t<=0&&r(!1),()=>{l&&clearInterval(l)}},[o,t]),{value:t,setValue:n,isCounting:o,start:s,reset:i}}import{useState as Me,useCallback as Ve}from"react";function nn(){let[e,t]=Me(null);return{copy:Ve(async o=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(o),t(o),!0}catch(r){return console.warn("Copy failed",r),t(null),!1}},[t]),copiedText:e}}export{Fe as createPaletteChannel,U as getCookie,M as getStorage,_e as hasKeys,R as hasParams,W as hexToRgbChannel,Xe as isActiveLink,Ie as isEqualPath,k as isExternalLink,_ as localStorageAvailable,qe as mergeClasses,Ae as mergeRefs,tt as parseCssVar,je as pxToRem,$e as remToPx,O as removeCookie,m as removeLastSlash,E as removeParams,V as removeStorage,T as setCookie,He as setFont,g as setStorage,ot as transformNumber,L as transformValue,J as transformValueOnBlur,z as transformValueOnChange,me as updateSelectedItems,Ut as useBackToTop,ut as useBoolean,Vt as useClientRect,gt as useCookies,nn as useCopyToClipboard,Yt as useCountdownDate,Zt as useCountdownSeconds,St as useDebounce,Ht as useDoubleClick,Et as useIsClient,Ft as useLocalStorage,Dt as useMultiSelect,ft as usePopover,_t as usePopoverHover,Kt as useScrollOffsetTop,vt as useSetState,it as useTabs,Je as uuidv4,Ne as varAlpha};
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var h=(n,r)=>{for(var s in r)o(n,s,{get:r[s],enumerable:!0})},p=(n,r,s,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of f(r))!m.call(n,t)&&t!==s&&o(n,t,{get:()=>r[t],enumerable:!(i=u(r,t))||i.enumerable});return n};var g=n=>p(o({},"__esModule",{value:!0}),n);var L={};h(L,{isActiveLink:()=>x});module.exports=g(L);function a(n){try{let r=new URL(n,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function e(n){return n!=="/"&&n.endsWith("/")?n.slice(0,-1):n}function c(n){try{let r=new URL(n,window.location.origin);return e(r.pathname)}catch{return n}}function l(n){return/^https?:\/\//i.test(n)}function x(n,r,s=!0){if(!n||!r)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(r.startsWith("#")||l(r))return!1;let i=e(n),t=e(c(r));return s||a(r)?i===t||i.startsWith(`${t}/`)||i.startsWith(`${t}?`):i===t}0&&(module.exports={isActiveLink});
1
+ "use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var h=(t,r)=>{for(var s in r)o(t,s,{get:r[s],enumerable:!0})},f=(t,r,s,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of p(r))!u.call(t,n)&&n!==s&&o(t,n,{get:()=>r[n],enumerable:!(e=m(r,n))||e.enumerable});return t};var d=t=>f(o({},"__esModule",{value:!0}),t);var x={};h(x,{isActiveLink:()=>b});module.exports=d(x);var g=require("es-toolkit");function a(t){try{let r=new URL(t,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function i(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function c(t){try{let r=new URL(t,window.location.origin);return i(r.pathname)}catch{return t}}function l(t){return/^https?:\/\//i.test(t)}function b(t,r,s=!0){if(!t||!r)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(r.startsWith("#")||l(r))return!1;let e=i(t),n=i(c(r));return s||a(r)?e===n||e.startsWith(`${n}/`)||e.startsWith(`${n}?`):e===n}0&&(module.exports={isActiveLink});
@@ -1 +1 @@
1
- function e(n){try{let r=new URL(n,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function s(n){return n!=="/"&&n.endsWith("/")?n.slice(0,-1):n}function o(n){try{let r=new URL(n,window.location.origin);return s(r.pathname)}catch{return n}}function a(n){return/^https?:\/\//i.test(n)}function m(n,r,c=!0){if(!n||!r)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(r.startsWith("#")||a(r))return!1;let t=s(n),i=s(o(r));return c||e(r)?t===i||t.startsWith(`${i}/`)||t.startsWith(`${i}?`):t===i}export{m as isActiveLink};
1
+ import{isEqual as p}from"es-toolkit";function i(t){try{let r=new URL(t,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function s(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function o(t){try{let r=new URL(t,window.location.origin);return s(r.pathname)}catch{return t}}function a(t){return/^https?:\/\//i.test(t)}function f(t,r,c=!0){if(!t||!r)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(r.startsWith("#")||a(r))return!1;let n=s(t),e=s(o(r));return c||i(r)?n===e||n.startsWith(`${e}/`)||n.startsWith(`${e}?`):n===e}export{f as isActiveLink};
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var p=(r,n)=>{for(var s in n)o(r,s,{get:n[s],enumerable:!0})},h=(r,n,s,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of f(n))!m.call(r,t)&&t!==s&&o(r,t,{get:()=>n[t],enumerable:!(i=u(n,t))||i.enumerable});return r};var g=r=>h(o({},"__esModule",{value:!0}),r);var L={};p(L,{isActiveLink:()=>x});module.exports=g(L);function a(r){try{let n=new URL(r,window.location.origin);return Array.from(n.searchParams.keys()).length>0}catch{return!1}}function e(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function c(r){try{let n=new URL(r,window.location.origin);return e(n.pathname)}catch{return r}}function l(r){return/^https?:\/\//i.test(r)}function x(r,n,s=!0){if(!r||!n)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(n.startsWith("#")||l(n))return!1;let i=e(r),t=e(c(n));return s||a(n)?i===t||i.startsWith(`${t}/`)||i.startsWith(`${t}?`):i===t}0&&(module.exports={isActiveLink});
1
+ "use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var h=(t,r)=>{for(var s in r)o(t,s,{get:r[s],enumerable:!0})},f=(t,r,s,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of p(r))!u.call(t,n)&&n!==s&&o(t,n,{get:()=>r[n],enumerable:!(e=m(r,n))||e.enumerable});return t};var d=t=>f(o({},"__esModule",{value:!0}),t);var b={};h(b,{isActiveLink:()=>x});module.exports=d(b);var g=require("es-toolkit");function a(t){try{let r=new URL(t,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function i(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function c(t){try{let r=new URL(t,window.location.origin);return i(r.pathname)}catch{return t}}function l(t){return/^https?:\/\//i.test(t)}function x(t,r,s=!0){if(!t||!r)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(r.startsWith("#")||l(r))return!1;let e=i(t),n=i(c(r));return s||a(r)?e===n||e.startsWith(`${n}/`)||e.startsWith(`${n}?`):e===n}0&&(module.exports={isActiveLink});
@@ -1 +1 @@
1
- function e(r){try{let n=new URL(r,window.location.origin);return Array.from(n.searchParams.keys()).length>0}catch{return!1}}function s(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function o(r){try{let n=new URL(r,window.location.origin);return s(n.pathname)}catch{return r}}function a(r){return/^https?:\/\//i.test(r)}function m(r,n,c=!0){if(!r||!n)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(n.startsWith("#")||a(n))return!1;let t=s(r),i=s(o(n));return c||e(n)?t===i||t.startsWith(`${i}/`)||t.startsWith(`${i}?`):t===i}export{m as isActiveLink};
1
+ import{isEqual as p}from"es-toolkit";function i(t){try{let r=new URL(t,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function s(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function o(t){try{let r=new URL(t,window.location.origin);return s(r.pathname)}catch{return t}}function a(t){return/^https?:\/\//i.test(t)}function f(t,r,c=!0){if(!t||!r)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(r.startsWith("#")||a(r))return!1;let n=s(t),e=s(o(r));return c||i(r)?n===e||n.startsWith(`${e}/`)||n.startsWith(`${e}?`):n===e}export{f as isActiveLink};
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var f=(r,n)=>{for(var e in n)a(r,e,{get:n[e],enumerable:!0})},s=(r,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of m(n))!v.call(r,t)&&t!==e&&a(r,t,{get:()=>n[t],enumerable:!(o=i(n,t))||o.enumerable});return r};var p=r=>s(a({},"__esModule",{value:!0}),r);var c={};f(c,{getCssVarName:()=>u});module.exports=p(c);function u(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let n=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return n?n[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}0&&(module.exports={getCssVarName});
1
+ "use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var v=(r,n)=>{for(var e in n)a(r,e,{get:n[e],enumerable:!0})},f=(r,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of m(n))!s.call(r,t)&&t!==e&&a(r,t,{get:()=>n[t],enumerable:!(o=i(n,t))||o.enumerable});return r};var p=r=>f(a({},"__esModule",{value:!0}),r);var c={};v(c,{parseCssVar:()=>u});module.exports=p(c);function u(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let n=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return n?n[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}0&&(module.exports={parseCssVar});
@@ -5,10 +5,10 @@
5
5
  * @returns The extracted CSS variable name (e.g., '--palette-Tooltip-bg').
6
6
  *
7
7
  * @example
8
- * getCssVarName('var(--palette-Tooltip-bg)'); // → '--palette-Tooltip-bg'
9
- * getCssVarName('var(--palette-Tooltip-bg, rgba(69, 79, 91, 0.92))'); // → '--palette-Tooltip-bg'
10
- * getCssVarName(theme.vars.palette.Tooltip.bg); // → '--palette-Tooltip-bg'
8
+ * parseCssVar('var(--palette-Tooltip-bg)'); // → '--palette-Tooltip-bg'
9
+ * parseCssVar('var(--palette-Tooltip-bg, rgba(69, 79, 91, 0.92))'); // → '--palette-Tooltip-bg'
10
+ * parseCssVar(theme.vars.palette.Tooltip.bg); // → '--palette-Tooltip-bg'
11
11
  */
12
- declare function getCssVarName(cssValue: unknown): string;
12
+ declare function parseCssVar(cssValue: unknown): string;
13
13
 
14
- export { getCssVarName };
14
+ export { parseCssVar };
@@ -5,10 +5,10 @@
5
5
  * @returns The extracted CSS variable name (e.g., '--palette-Tooltip-bg').
6
6
  *
7
7
  * @example
8
- * getCssVarName('var(--palette-Tooltip-bg)'); // → '--palette-Tooltip-bg'
9
- * getCssVarName('var(--palette-Tooltip-bg, rgba(69, 79, 91, 0.92))'); // → '--palette-Tooltip-bg'
10
- * getCssVarName(theme.vars.palette.Tooltip.bg); // → '--palette-Tooltip-bg'
8
+ * parseCssVar('var(--palette-Tooltip-bg)'); // → '--palette-Tooltip-bg'
9
+ * parseCssVar('var(--palette-Tooltip-bg, rgba(69, 79, 91, 0.92))'); // → '--palette-Tooltip-bg'
10
+ * parseCssVar(theme.vars.palette.Tooltip.bg); // → '--palette-Tooltip-bg'
11
11
  */
12
- declare function getCssVarName(cssValue: unknown): string;
12
+ declare function parseCssVar(cssValue: unknown): string;
13
13
 
14
- export { getCssVarName };
14
+ export { parseCssVar };
@@ -1 +1 @@
1
- function t(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let n=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return n?n[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}export{t as getCssVarName};
1
+ function t(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let n=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return n?n[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}export{t as parseCssVar};
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var v=(r,t)=>{for(var e in t)o(r,e,{get:t[e],enumerable:!0})},p=(r,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of m(t))!f.call(r,n)&&n!==e&&o(r,n,{get:()=>t[n],enumerable:!(a=i(t,n))||a.enumerable});return r};var s=r=>p(o({},"__esModule",{value:!0}),r);var c={};v(c,{getCssVarName:()=>u});module.exports=s(c);function u(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let t=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return t?t[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}0&&(module.exports={getCssVarName});
1
+ "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var p=(r,n)=>{for(var e in n)o(r,e,{get:n[e],enumerable:!0})},s=(r,n,e,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of m(n))!f.call(r,t)&&t!==e&&o(r,t,{get:()=>n[t],enumerable:!(a=i(n,t))||a.enumerable});return r};var v=r=>s(o({},"__esModule",{value:!0}),r);var c={};p(c,{parseCssVar:()=>u});module.exports=v(c);function u(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let n=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return n?n[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}0&&(module.exports={parseCssVar});
@@ -1 +1 @@
1
- export { getCssVarName } from './css-variables.cjs';
1
+ export { parseCssVar } from './css-variables.cjs';
@@ -1 +1 @@
1
- export { getCssVarName } from './css-variables.js';
1
+ export { parseCssVar } from './css-variables.js';
@@ -1 +1 @@
1
- function n(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let t=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return t?t[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}export{n as getCssVarName};
1
+ function t(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let n=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return n?n[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}export{t as parseCssVar};
@@ -1,2 +1,2 @@
1
- "use strict";var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var C=(r,e)=>{for(var t in e)u(r,t,{get:e[t],enumerable:!0})},I=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of w(e))!$.call(r,n)&&n!==t&&u(r,n,{get:()=>e[n],enumerable:!(o=T(e,n))||o.enumerable});return r};var v=r=>I(u({},"__esModule",{value:!0}),r);var K={};C(K,{createPaletteChannel:()=>O,getCookie:()=>j,getCssVarName:()=>G,getStorage:()=>D,hasKeys:()=>U,hasParams:()=>l,hexToRgbChannel:()=>h,isActiveLink:()=>W,isEqualPath:()=>A,isExternalLink:()=>f,localStorageAvailable:()=>y,mergeClasses:()=>V,mergeRefs:()=>E,pxToRem:()=>N,remToPx:()=>P,removeCookie:()=>F,removeLastSlash:()=>s,removeParams:()=>p,removeStorage:()=>M,setCookie:()=>B,setFont:()=>R,setStorage:()=>J,transformNumber:()=>H,transformValue:()=>g,transformValueOnBlur:()=>S,transformValueOnChange:()=>b,uuidv4:()=>L,varAlpha:()=>_});module.exports=v(K);function l(r){try{let e=new URL(r,window.location.origin);return Array.from(e.searchParams.keys()).length>0}catch{return!1}}function s(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function A(r,e){return s(r)===s(e)}function p(r){try{let e=new URL(r,window.location.origin);return s(e.pathname)}catch{return r}}function f(r){return/^https?:\/\//i.test(r)}function E(r){return e=>{if(r.length!==0)for(let t of r)t&&(typeof t=="function"?t(e):"current"in t&&(t.current=e))}}var x='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function R(r){return r?`"${r}", ${x}`:x}function P(r){let e=parseFloat(r);return Math.round(e*16)}function N(r){if(typeof r!="number"||isNaN(r))throw new Error(`Invalid pixel value: ${r}`);return`${r/16}rem`}function h(r){if(!r)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(r))throw new Error(`Invalid hex color: ${r}`);let e=parseInt(r.substring(1,3),16),t=parseInt(r.substring(3,5),16),o=parseInt(r.substring(5,7),16);return`${e} ${t} ${o}`}function O(r){let e={};return Object.entries(r).forEach(([t,o])=>{o&&(e[`${t}Channel`]=h(o))}),{...r,...e}}function _(r,e=1){if(!r)throw new Error("[Alpha]: Color is undefined!");if(r.startsWith("#")||r.startsWith("rgb")||r.startsWith("rgba")||!r.includes("var")&&r.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${r}"`,"Supported formats are:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"Unsupported formats are:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
2
- `));return`rgba(${r} / ${e})`}function U(r,e){return!r||!e.length||typeof r!="object"?!1:e.every(t=>t in r)}function L(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function V(r,e){let t=r?Array.isArray(r)?r:[r]:[],o=Object.entries(e||{}).filter(([n,i])=>i!==void 0&&i!==!1).map(([n,i])=>Array.isArray(i)?i[0]?i[1]:"":i?n:"").filter(Boolean);return[...t.filter(Boolean),...o].join(" ")}function j(r){if(!r||typeof r!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${r}=`,n=decodeURIComponent(document.cookie).split("; ").find(a=>a.startsWith(e));if(!n)return null;let i=n.substring(e.length);try{return JSON.parse(i)}catch{return i}}catch(e){return console.error("Error retrieving cookie:",e),null}}function B(r,e,t){if(!r||typeof r!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:o=0,sameSite:n="Strict",secure:i=!1,path:a="/",domain:m}=t??{};try{let c=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),d=[`${r}=${c}`,`path=${a}`,n&&`SameSite=${n}`,i&&"Secure",m&&`domain=${m}`];if(o>0){let k=new Date(Date.now()+o*24*60*60*1e3);d.push(`expires=${k.toUTCString()}`)}document.cookie=d.filter(Boolean).join("; ")}catch(c){console.error("Error setting cookie:",c)}}function F(r,e){if(!r||typeof r!="string"){console.error("Invalid cookie key provided");return}let{path:t="/",domain:o}=e??{};try{let n=[`${r}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${t}`,o&&`domain=${o}`,"Secure"];document.cookie=n.filter(Boolean).join("; ")}catch(n){console.error("Error removing cookie:",n)}}function W(r,e,t=!0){if(!r||!e)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(e.startsWith("#")||f(e))return!1;let o=s(r),n=s(p(e));return t||l(e)?o===n||o.startsWith(`${n}/`)||o.startsWith(`${n}?`):o===n}function D(r,e){if(!y())return e??null;let t=localStorage.getItem(r);if(t!=="undefined"){if(t)try{return JSON.parse(t)}catch{return t??e??null}return e??null}}function J(r,e){try{let t=JSON.stringify(e);window.localStorage.setItem(r,t)}catch(t){console.error("Error while setting storage:",t)}}function M(r){try{window.localStorage.removeItem(r)}catch(e){console.error("Error while removing from storage:",e)}}function y(){try{let r="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(r,r),window.localStorage.removeItem(r),!0}catch{return!1}}function G(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let e=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return e?e[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}function g(r,e=""){return r==null||typeof r=="number"&&Number.isNaN(r)?e:r.toString()}function b(r){let t=g(r).replace(/[^0-9.]/g,""),[o,...n]=t.split(".");return n.length>0?`${o}.${n.join("")}`:o}function S(r,e=""){if(r==null||typeof r=="number"&&Number.isNaN(r))return e;let t=parseFloat(r.toString());return Number.isNaN(t)?e:t}var H={onChange:b,onBlur:S,value:g};0&&(module.exports={createPaletteChannel,getCookie,getCssVarName,getStorage,hasKeys,hasParams,hexToRgbChannel,isActiveLink,isEqualPath,isExternalLink,localStorageAvailable,mergeClasses,mergeRefs,pxToRem,remToPx,removeCookie,removeLastSlash,removeParams,removeStorage,setCookie,setFont,setStorage,transformNumber,transformValue,transformValueOnBlur,transformValueOnChange,uuidv4,varAlpha});
1
+ "use strict";var u=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var I=(r,e)=>{for(var t in e)u(r,t,{get:e[t],enumerable:!0})},v=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $(e))!C.call(r,n)&&n!==t&&u(r,n,{get:()=>e[n],enumerable:!(o=w(e,n))||o.enumerable});return r};var E=r=>v(u({},"__esModule",{value:!0}),r);var K={};I(K,{createPaletteChannel:()=>U,getCookie:()=>B,getStorage:()=>J,hasKeys:()=>L,hasParams:()=>l,hexToRgbChannel:()=>y,isActiveLink:()=>D,isEqualPath:()=>P,isExternalLink:()=>f,localStorageAvailable:()=>b,mergeClasses:()=>V,mergeRefs:()=>A,parseCssVar:()=>G,pxToRem:()=>N,remToPx:()=>O,removeCookie:()=>W,removeLastSlash:()=>s,removeParams:()=>p,removeStorage:()=>q,setCookie:()=>F,setFont:()=>R,setStorage:()=>M,transformNumber:()=>H,transformValue:()=>m,transformValueOnBlur:()=>k,transformValueOnChange:()=>S,uuidv4:()=>j,varAlpha:()=>_});module.exports=E(K);var x=require("es-toolkit");function l(r){try{let e=new URL(r,window.location.origin);return Array.from(e.searchParams.keys()).length>0}catch{return!1}}function s(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function P(r,e,t={deep:!0}){let o=n=>{try{let{pathname:i,searchParams:a}=new URL(n.trim(),"http://dummy");return t.deep?{pathname:s(i),params:Object.fromEntries(a)}:{pathname:s(i)}}catch{return{pathname:""}}};return(0,x.isEqual)(o(e),o(r))}function p(r){try{let e=new URL(r,window.location.origin);return s(e.pathname)}catch{return r}}function f(r){return/^https?:\/\//i.test(r)}function A(r){return e=>{if(r.length!==0)for(let t of r)t&&(typeof t=="function"?t(e):"current"in t&&(t.current=e))}}var h='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function R(r){return r?`"${r}", ${h}`:h}function O(r){let e=parseFloat(r);return Math.round(e*16)}function N(r){if(typeof r!="number"||isNaN(r))throw new Error(`Invalid pixel value: ${r}`);return`${r/16}rem`}function y(r){if(!r)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(r))throw new Error(`Invalid hex color: ${r}`);let e=parseInt(r.substring(1,3),16),t=parseInt(r.substring(3,5),16),o=parseInt(r.substring(5,7),16);return`${e} ${t} ${o}`}function U(r){let e={};return Object.entries(r).forEach(([t,o])=>{o&&(e[`${t}Channel`]=y(o))}),{...r,...e}}function _(r,e=1){if(!r)throw new Error("[Alpha]: Color is undefined!");if(r.startsWith("#")||r.startsWith("rgb")||r.startsWith("rgba")||!r.includes("var")&&r.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${r}"`,"Supported formats are:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"Unsupported formats are:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
2
+ `));return`rgba(${r} / ${e})`}function L(r,e){return!r||!e.length||typeof r!="object"?!1:e.every(t=>t in r)}function j(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function V(r,e){let t=r?Array.isArray(r)?r:[r]:[],o=Object.entries(e||{}).filter(([n,i])=>i!==void 0&&i!==!1).map(([n,i])=>Array.isArray(i)?i[0]?i[1]:"":i?n:"").filter(Boolean);return[...t.filter(Boolean),...o].join(" ")}function B(r){if(!r||typeof r!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${r}=`,n=decodeURIComponent(document.cookie).split("; ").find(a=>a.startsWith(e));if(!n)return null;let i=n.substring(e.length);try{return JSON.parse(i)}catch{return i}}catch(e){return console.error("Error retrieving cookie:",e),null}}function F(r,e,t){if(!r||typeof r!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:o=0,sameSite:n="Strict",secure:i=!1,path:a="/",domain:g}=t??{};try{let c=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),d=[`${r}=${c}`,`path=${a}`,n&&`SameSite=${n}`,i&&"Secure",g&&`domain=${g}`];if(o>0){let T=new Date(Date.now()+o*24*60*60*1e3);d.push(`expires=${T.toUTCString()}`)}document.cookie=d.filter(Boolean).join("; ")}catch(c){console.error("Error setting cookie:",c)}}function W(r,e){if(!r||typeof r!="string"){console.error("Invalid cookie key provided");return}let{path:t="/",domain:o}=e??{};try{let n=[`${r}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${t}`,o&&`domain=${o}`,"Secure"];document.cookie=n.filter(Boolean).join("; ")}catch(n){console.error("Error removing cookie:",n)}}function D(r,e,t=!0){if(!r||!e)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(e.startsWith("#")||f(e))return!1;let o=s(r),n=s(p(e));return t||l(e)?o===n||o.startsWith(`${n}/`)||o.startsWith(`${n}?`):o===n}function J(r,e){if(!b())return e??null;let t=localStorage.getItem(r);if(t!=="undefined"){if(t)try{return JSON.parse(t)}catch{return t??e??null}return e??null}}function M(r,e){try{let t=JSON.stringify(e);window.localStorage.setItem(r,t)}catch(t){console.error("Error while setting storage:",t)}}function q(r){try{window.localStorage.removeItem(r)}catch(e){console.error("Error while removing from storage:",e)}}function b(){try{let r="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(r,r),window.localStorage.removeItem(r),!0}catch{return!1}}function G(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let e=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return e?e[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}function m(r,e=""){return r==null||typeof r=="number"&&Number.isNaN(r)?e:r.toString()}function S(r){let t=m(r).replace(/[^0-9.]/g,""),[o,...n]=t.split(".");return n.length>0?`${o}.${n.join("")}`:o}function k(r,e=""){if(r==null||typeof r=="number"&&Number.isNaN(r))return e;let t=parseFloat(r.toString());return Number.isNaN(t)?e:t}var H={onChange:S,onBlur:k,value:m};0&&(module.exports={createPaletteChannel,getCookie,getStorage,hasKeys,hasParams,hexToRgbChannel,isActiveLink,isEqualPath,isExternalLink,localStorageAvailable,mergeClasses,mergeRefs,parseCssVar,pxToRem,remToPx,removeCookie,removeLastSlash,removeParams,removeStorage,setCookie,setFont,setStorage,transformNumber,transformValue,transformValueOnBlur,transformValueOnChange,uuidv4,varAlpha});
@@ -1,4 +1,4 @@
1
- export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url/url.cjs';
1
+ export { EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url/url.cjs';
2
2
  export { mergeRefs } from './refs/refs.cjs';
3
3
  export { pxToRem, remToPx, setFont } from './font/font.cjs';
4
4
  export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './color/color.cjs';
@@ -8,5 +8,5 @@ export { StateProps, mergeClasses } from './classes/classes.cjs';
8
8
  export { CookieOptions, getCookie, removeCookie, setCookie } from './cookies/cookies.cjs';
9
9
  export { isActiveLink } from './active-link/active-link.cjs';
10
10
  export { getStorage, localStorageAvailable, removeStorage, setStorage } from './local-storage/local-storage.cjs';
11
- export { getCssVarName } from './css-variables/css-variables.cjs';
11
+ export { parseCssVar } from './css-variables/css-variables.cjs';
12
12
  export { InputValue, transformNumber, transformValue, transformValueOnBlur, transformValueOnChange } from './transform-number/transform-number.cjs';
@@ -1,4 +1,4 @@
1
- export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url/url.js';
1
+ export { EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url/url.js';
2
2
  export { mergeRefs } from './refs/refs.js';
3
3
  export { pxToRem, remToPx, setFont } from './font/font.js';
4
4
  export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './color/color.js';
@@ -8,5 +8,5 @@ export { StateProps, mergeClasses } from './classes/classes.js';
8
8
  export { CookieOptions, getCookie, removeCookie, setCookie } from './cookies/cookies.js';
9
9
  export { isActiveLink } from './active-link/active-link.js';
10
10
  export { getStorage, localStorageAvailable, removeStorage, setStorage } from './local-storage/local-storage.js';
11
- export { getCssVarName } from './css-variables/css-variables.js';
11
+ export { parseCssVar } from './css-variables/css-variables.js';
12
12
  export { InputValue, transformNumber, transformValue, transformValueOnBlur, transformValueOnChange } from './transform-number/transform-number.js';
@@ -1,2 +1,2 @@
1
- function p(r){try{let e=new URL(r,window.location.origin);return Array.from(e.searchParams.keys()).length>0}catch{return!1}}function s(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function k(r,e){return s(r)===s(e)}function f(r){try{let e=new URL(r,window.location.origin);return s(e.pathname)}catch{return r}}function g(r){return/^https?:\/\//i.test(r)}function w(r){return e=>{if(r.length!==0)for(let t of r)t&&(typeof t=="function"?t(e):"current"in t&&(t.current=e))}}var m='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function C(r){return r?`"${r}", ${m}`:m}function I(r){let e=parseFloat(r);return Math.round(e*16)}function v(r){if(typeof r!="number"||isNaN(r))throw new Error(`Invalid pixel value: ${r}`);return`${r/16}rem`}function h(r){if(!r)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(r))throw new Error(`Invalid hex color: ${r}`);let e=parseInt(r.substring(1,3),16),t=parseInt(r.substring(3,5),16),n=parseInt(r.substring(5,7),16);return`${e} ${t} ${n}`}function E(r){let e={};return Object.entries(r).forEach(([t,n])=>{n&&(e[`${t}Channel`]=h(n))}),{...r,...e}}function R(r,e=1){if(!r)throw new Error("[Alpha]: Color is undefined!");if(r.startsWith("#")||r.startsWith("rgb")||r.startsWith("rgba")||!r.includes("var")&&r.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${r}"`,"Supported formats are:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"Unsupported formats are:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
2
- `));return`rgba(${r} / ${e})`}function N(r,e){return!r||!e.length||typeof r!="object"?!1:e.every(t=>t in r)}function _(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function L(r,e){let t=r?Array.isArray(r)?r:[r]:[],n=Object.entries(e||{}).filter(([o,i])=>i!==void 0&&i!==!1).map(([o,i])=>Array.isArray(i)?i[0]?i[1]:"":i?o:"").filter(Boolean);return[...t.filter(Boolean),...n].join(" ")}function j(r){if(!r||typeof r!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${r}=`,o=decodeURIComponent(document.cookie).split("; ").find(a=>a.startsWith(e));if(!o)return null;let i=o.substring(e.length);try{return JSON.parse(i)}catch{return i}}catch(e){return console.error("Error retrieving cookie:",e),null}}function B(r,e,t){if(!r||typeof r!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:n=0,sameSite:o="Strict",secure:i=!1,path:a="/",domain:u}=t??{};try{let c=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),l=[`${r}=${c}`,`path=${a}`,o&&`SameSite=${o}`,i&&"Secure",u&&`domain=${u}`];if(n>0){let x=new Date(Date.now()+n*24*60*60*1e3);l.push(`expires=${x.toUTCString()}`)}document.cookie=l.filter(Boolean).join("; ")}catch(c){console.error("Error setting cookie:",c)}}function F(r,e){if(!r||typeof r!="string"){console.error("Invalid cookie key provided");return}let{path:t="/",domain:n}=e??{};try{let o=[`${r}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${t}`,n&&`domain=${n}`,"Secure"];document.cookie=o.filter(Boolean).join("; ")}catch(o){console.error("Error removing cookie:",o)}}function J(r,e,t=!0){if(!r||!e)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(e.startsWith("#")||g(e))return!1;let n=s(r),o=s(f(e));return t||p(e)?n===o||n.startsWith(`${o}/`)||n.startsWith(`${o}?`):n===o}function G(r,e){if(!y())return e??null;let t=localStorage.getItem(r);if(t!=="undefined"){if(t)try{return JSON.parse(t)}catch{return t??e??null}return e??null}}function H(r,e){try{let t=JSON.stringify(e);window.localStorage.setItem(r,t)}catch(t){console.error("Error while setting storage:",t)}}function K(r){try{window.localStorage.removeItem(r)}catch(e){console.error("Error while removing from storage:",e)}}function y(){try{let r="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(r,r),window.localStorage.removeItem(r),!0}catch{return!1}}function q(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let e=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return e?e[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}function d(r,e=""){return r==null||typeof r=="number"&&Number.isNaN(r)?e:r.toString()}function b(r){let t=d(r).replace(/[^0-9.]/g,""),[n,...o]=t.split(".");return o.length>0?`${n}.${o.join("")}`:n}function S(r,e=""){if(r==null||typeof r=="number"&&Number.isNaN(r))return e;let t=parseFloat(r.toString());return Number.isNaN(t)?e:t}var Q={onChange:b,onBlur:S,value:d};export{E as createPaletteChannel,j as getCookie,q as getCssVarName,G as getStorage,N as hasKeys,p as hasParams,h as hexToRgbChannel,J as isActiveLink,k as isEqualPath,g as isExternalLink,y as localStorageAvailable,L as mergeClasses,w as mergeRefs,v as pxToRem,I as remToPx,F as removeCookie,s as removeLastSlash,f as removeParams,K as removeStorage,B as setCookie,C as setFont,H as setStorage,Q as transformNumber,d as transformValue,S as transformValueOnBlur,b as transformValueOnChange,_ as uuidv4,R as varAlpha};
1
+ import{isEqual as h}from"es-toolkit";function p(r){try{let e=new URL(r,window.location.origin);return Array.from(e.searchParams.keys()).length>0}catch{return!1}}function s(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function w(r,e,t={deep:!0}){let n=o=>{try{let{pathname:i,searchParams:a}=new URL(o.trim(),"http://dummy");return t.deep?{pathname:s(i),params:Object.fromEntries(a)}:{pathname:s(i)}}catch{return{pathname:""}}};return h(n(e),n(r))}function f(r){try{let e=new URL(r,window.location.origin);return s(e.pathname)}catch{return r}}function m(r){return/^https?:\/\//i.test(r)}function C(r){return e=>{if(r.length!==0)for(let t of r)t&&(typeof t=="function"?t(e):"current"in t&&(t.current=e))}}var g='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function v(r){return r?`"${r}", ${g}`:g}function E(r){let e=parseFloat(r);return Math.round(e*16)}function P(r){if(typeof r!="number"||isNaN(r))throw new Error(`Invalid pixel value: ${r}`);return`${r/16}rem`}function y(r){if(!r)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(r))throw new Error(`Invalid hex color: ${r}`);let e=parseInt(r.substring(1,3),16),t=parseInt(r.substring(3,5),16),n=parseInt(r.substring(5,7),16);return`${e} ${t} ${n}`}function R(r){let e={};return Object.entries(r).forEach(([t,n])=>{n&&(e[`${t}Channel`]=y(n))}),{...r,...e}}function O(r,e=1){if(!r)throw new Error("[Alpha]: Color is undefined!");if(r.startsWith("#")||r.startsWith("rgb")||r.startsWith("rgba")||!r.includes("var")&&r.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${r}"`,"Supported formats are:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"Unsupported formats are:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
2
+ `));return`rgba(${r} / ${e})`}function U(r,e){return!r||!e.length||typeof r!="object"?!1:e.every(t=>t in r)}function L(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function V(r,e){let t=r?Array.isArray(r)?r:[r]:[],n=Object.entries(e||{}).filter(([o,i])=>i!==void 0&&i!==!1).map(([o,i])=>Array.isArray(i)?i[0]?i[1]:"":i?o:"").filter(Boolean);return[...t.filter(Boolean),...n].join(" ")}function F(r){if(!r||typeof r!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${r}=`,o=decodeURIComponent(document.cookie).split("; ").find(a=>a.startsWith(e));if(!o)return null;let i=o.substring(e.length);try{return JSON.parse(i)}catch{return i}}catch(e){return console.error("Error retrieving cookie:",e),null}}function W(r,e,t){if(!r||typeof r!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:n=0,sameSite:o="Strict",secure:i=!1,path:a="/",domain:u}=t??{};try{let c=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),l=[`${r}=${c}`,`path=${a}`,o&&`SameSite=${o}`,i&&"Secure",u&&`domain=${u}`];if(n>0){let x=new Date(Date.now()+n*24*60*60*1e3);l.push(`expires=${x.toUTCString()}`)}document.cookie=l.filter(Boolean).join("; ")}catch(c){console.error("Error setting cookie:",c)}}function D(r,e){if(!r||typeof r!="string"){console.error("Invalid cookie key provided");return}let{path:t="/",domain:n}=e??{};try{let o=[`${r}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${t}`,n&&`domain=${n}`,"Secure"];document.cookie=o.filter(Boolean).join("; ")}catch(o){console.error("Error removing cookie:",o)}}function q(r,e,t=!0){if(!r||!e)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(e.startsWith("#")||m(e))return!1;let n=s(r),o=s(f(e));return t||p(e)?n===o||n.startsWith(`${o}/`)||n.startsWith(`${o}?`):n===o}function H(r,e){if(!b())return e??null;let t=localStorage.getItem(r);if(t!=="undefined"){if(t)try{return JSON.parse(t)}catch{return t??e??null}return e??null}}function K(r,e){try{let t=JSON.stringify(e);window.localStorage.setItem(r,t)}catch(t){console.error("Error while setting storage:",t)}}function z(r){try{window.localStorage.removeItem(r)}catch(e){console.error("Error while removing from storage:",e)}}function b(){try{let r="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(r,r),window.localStorage.removeItem(r),!0}catch{return!1}}function Q(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let e=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return e?e[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}function d(r,e=""){return r==null||typeof r=="number"&&Number.isNaN(r)?e:r.toString()}function S(r){let t=d(r).replace(/[^0-9.]/g,""),[n,...o]=t.split(".");return o.length>0?`${n}.${o.join("")}`:n}function k(r,e=""){if(r==null||typeof r=="number"&&Number.isNaN(r))return e;let t=parseFloat(r.toString());return Number.isNaN(t)?e:t}var Z={onChange:S,onBlur:k,value:d};export{R as createPaletteChannel,F as getCookie,H as getStorage,U as hasKeys,p as hasParams,y as hexToRgbChannel,q as isActiveLink,w as isEqualPath,m as isExternalLink,b as localStorageAvailable,V as mergeClasses,C as mergeRefs,Q as parseCssVar,P as pxToRem,E as remToPx,D as removeCookie,s as removeLastSlash,f as removeParams,z as removeStorage,W as setCookie,v as setFont,K as setStorage,Z as transformNumber,d as transformValue,k as transformValueOnBlur,S as transformValueOnChange,L as uuidv4,O as varAlpha};
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(r,t)=>{for(var o in t)e(r,o,{get:t[o],enumerable:!0})},g=(r,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c(t))!l.call(r,n)&&n!==o&&e(r,n,{get:()=>t[n],enumerable:!(s=a(t,n))||s.enumerable});return r};var f=r=>g(e({},"__esModule",{value:!0}),r);var d={};u(d,{hasParams:()=>h,isEqualPath:()=>x,isExternalLink:()=>b,removeLastSlash:()=>i,removeParams:()=>w});module.exports=f(d);function h(r){try{let t=new URL(r,window.location.origin);return Array.from(t.searchParams.keys()).length>0}catch{return!1}}function i(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function x(r,t){return i(r)===i(t)}function w(r){try{let t=new URL(r,window.location.origin);return i(t.pathname)}catch{return r}}function b(r){return/^https?:\/\//i.test(r)}0&&(module.exports={hasParams,isEqualPath,isExternalLink,removeLastSlash,removeParams});
1
+ "use strict";var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var h=(t,r)=>{for(var e in r)s(t,e,{get:r[e],enumerable:!0})},g=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of l(r))!m.call(t,n)&&n!==e&&s(t,n,{get:()=>r[n],enumerable:!(o=p(r,n))||o.enumerable});return t};var f=t=>g(s({},"__esModule",{value:!0}),t);var y={};h(y,{hasParams:()=>d,isEqualPath:()=>x,isExternalLink:()=>w,removeLastSlash:()=>a,removeParams:()=>b});module.exports=f(y);var c=require("es-toolkit");function d(t){try{let r=new URL(t,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function a(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function x(t,r,e={deep:!0}){let o=n=>{try{let{pathname:i,searchParams:u}=new URL(n.trim(),"http://dummy");return e.deep?{pathname:a(i),params:Object.fromEntries(u)}:{pathname:a(i)}}catch{return{pathname:""}}};return(0,c.isEqual)(o(r),o(t))}function b(t){try{let r=new URL(t,window.location.origin);return a(r.pathname)}catch{return t}}function w(t){return/^https?:\/\//i.test(t)}0&&(module.exports={hasParams,isEqualPath,isExternalLink,removeLastSlash,removeParams});
@@ -1 +1 @@
1
- export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url.cjs';
1
+ export { EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url.cjs';
@@ -1 +1 @@
1
- export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url.js';
1
+ export { EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url.js';
@@ -1 +1 @@
1
- function o(r){try{let t=new URL(r,window.location.origin);return Array.from(t.searchParams.keys()).length>0}catch{return!1}}function n(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function i(r,t){return n(r)===n(t)}function e(r){try{let t=new URL(r,window.location.origin);return n(t.pathname)}catch{return r}}function s(r){return/^https?:\/\//i.test(r)}export{o as hasParams,i as isEqualPath,s as isExternalLink,n as removeLastSlash,e as removeParams};
1
+ import{isEqual as c}from"es-toolkit";function p(t){try{let r=new URL(t,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function n(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function l(t,r,a={deep:!0}){let e=s=>{try{let{pathname:o,searchParams:i}=new URL(s.trim(),"http://dummy");return a.deep?{pathname:n(o),params:Object.fromEntries(i)}:{pathname:n(o)}}catch{return{pathname:""}}};return c(e(r),e(t))}function m(t){try{let r=new URL(t,window.location.origin);return n(r.pathname)}catch{return t}}function h(t){return/^https?:\/\//i.test(t)}export{p as hasParams,l as isEqualPath,h as isExternalLink,n as removeLastSlash,m as removeParams};
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(r,n)=>{for(var i in n)s(r,i,{get:n[i],enumerable:!0})},g=(r,n,i,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of c(n))!l.call(r,t)&&t!==i&&s(r,t,{get:()=>n[t],enumerable:!(e=a(n,t))||e.enumerable});return r};var f=r=>g(s({},"__esModule",{value:!0}),r);var d={};u(d,{hasParams:()=>h,isEqualPath:()=>w,isExternalLink:()=>b,removeLastSlash:()=>o,removeParams:()=>x});module.exports=f(d);function h(r){try{let n=new URL(r,window.location.origin);return Array.from(n.searchParams.keys()).length>0}catch{return!1}}function o(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function w(r,n){return o(r)===o(n)}function x(r){try{let n=new URL(r,window.location.origin);return o(n.pathname)}catch{return r}}function b(r){return/^https?:\/\//i.test(r)}0&&(module.exports={hasParams,isEqualPath,isExternalLink,removeLastSlash,removeParams});
1
+ "use strict";var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var m=(t,r)=>{for(var e in r)s(t,e,{get:r[e],enumerable:!0})},g=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of p(r))!h.call(t,n)&&n!==e&&s(t,n,{get:()=>r[n],enumerable:!(a=l(r,n))||a.enumerable});return t};var d=t=>g(s({},"__esModule",{value:!0}),t);var y={};m(y,{hasParams:()=>f,isEqualPath:()=>b,isExternalLink:()=>x,removeLastSlash:()=>o,removeParams:()=>w});module.exports=d(y);var c=require("es-toolkit");function f(t){try{let r=new URL(t,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function o(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function b(t,r,e={deep:!0}){let a=n=>{try{let{pathname:i,searchParams:u}=new URL(n.trim(),"http://dummy");return e.deep?{pathname:o(i),params:Object.fromEntries(u)}:{pathname:o(i)}}catch{return{pathname:""}}};return(0,c.isEqual)(a(r),a(t))}function w(t){try{let r=new URL(t,window.location.origin);return o(r.pathname)}catch{return t}}function x(t){return/^https?:\/\//i.test(t)}0&&(module.exports={hasParams,isEqualPath,isExternalLink,removeLastSlash,removeParams});
@@ -24,14 +24,18 @@ declare function removeLastSlash(pathname: string): string;
24
24
  * Checks if two paths are equal after removing trailing slashes.
25
25
  *
26
26
  * @param targetUrl - The target URL to compare.
27
- * @param pathname - The pathname to compare.
27
+ * @param currentUrl - The pathname to compare.
28
+ * @param options.deep - Options for deep comparison.
28
29
  * @returns True if the paths are equal, false otherwise.
29
30
  *
30
31
  * @example
31
32
  * isEqualPath('/dashboard/', '/dashboard'); // true
32
33
  * isEqualPath('/home', '/dashboard'); // false
33
34
  */
34
- declare function isEqualPath(targetUrl: string, pathname: string): boolean;
35
+ type EqualPathOptions = {
36
+ deep?: boolean;
37
+ };
38
+ declare function isEqualPath(targetUrl: string, currentUrl: string, options?: EqualPathOptions): boolean;
35
39
  /**
36
40
  * Removes query parameters from a URL and returns only the cleaned pathname.
37
41
  *
@@ -55,4 +59,4 @@ declare function removeParams(url: string): string;
55
59
  */
56
60
  declare function isExternalLink(url: string): boolean;
57
61
 
58
- export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams };
62
+ export { type EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams };
@@ -24,14 +24,18 @@ declare function removeLastSlash(pathname: string): string;
24
24
  * Checks if two paths are equal after removing trailing slashes.
25
25
  *
26
26
  * @param targetUrl - The target URL to compare.
27
- * @param pathname - The pathname to compare.
27
+ * @param currentUrl - The pathname to compare.
28
+ * @param options.deep - Options for deep comparison.
28
29
  * @returns True if the paths are equal, false otherwise.
29
30
  *
30
31
  * @example
31
32
  * isEqualPath('/dashboard/', '/dashboard'); // true
32
33
  * isEqualPath('/home', '/dashboard'); // false
33
34
  */
34
- declare function isEqualPath(targetUrl: string, pathname: string): boolean;
35
+ type EqualPathOptions = {
36
+ deep?: boolean;
37
+ };
38
+ declare function isEqualPath(targetUrl: string, currentUrl: string, options?: EqualPathOptions): boolean;
35
39
  /**
36
40
  * Removes query parameters from a URL and returns only the cleaned pathname.
37
41
  *
@@ -55,4 +59,4 @@ declare function removeParams(url: string): string;
55
59
  */
56
60
  declare function isExternalLink(url: string): boolean;
57
61
 
58
- export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams };
62
+ export { type EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams };
@@ -1 +1 @@
1
- function i(r){try{let n=new URL(r,window.location.origin);return Array.from(n.searchParams.keys()).length>0}catch{return!1}}function t(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function o(r,n){return t(r)===t(n)}function s(r){try{let n=new URL(r,window.location.origin);return t(n.pathname)}catch{return r}}function e(r){return/^https?:\/\//i.test(r)}export{i as hasParams,o as isEqualPath,e as isExternalLink,t as removeLastSlash,s as removeParams};
1
+ import{isEqual as c}from"es-toolkit";function l(t){try{let r=new URL(t,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function n(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function p(t,r,o={deep:!0}){let e=s=>{try{let{pathname:a,searchParams:i}=new URL(s.trim(),"http://dummy");return o.deep?{pathname:n(a),params:Object.fromEntries(i)}:{pathname:n(a)}}catch{return{pathname:""}}};return c(e(r),e(t))}function h(t){try{let r=new URL(t,window.location.origin);return n(r.pathname)}catch{return t}}function m(t){return/^https?:\/\//i.test(t)}export{l as hasParams,p as isEqualPath,m as isExternalLink,n as removeLastSlash,h as removeParams};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minimal-shared",
3
3
  "author": "Minimals",
4
- "version": "1.0.9",
4
+ "version": "1.0.11",
5
5
  "description": "Shared hooks and utils used by Minimal UI and Zone UI.",
6
6
  "keywords": [
7
7
  "typescript",