minimal-shared 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,3 +1,23 @@
1
1
  # minimal-shared
2
2
 
3
3
  Shared hooks and utils used by Mnimal UI and Zone UI.
4
+
5
+ ###### List of hooks
6
+
7
+ - useTabs
8
+ - useBoolean
9
+ - usePopover
10
+ - useCookies
11
+ - useDebounce
12
+ - useSetState
13
+ - useIsClient
14
+ - useBackToTop
15
+ - useClientRect
16
+ - useMultiSelect
17
+ - useDoubleClick
18
+ - useLocalStorage
19
+ - usePopoverHover
20
+ - useCountdownDate
21
+ - useScrollOffsetTop
22
+ - useCountdownSeconds
23
+ - useCopyToClipboard
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var M=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var ee=(e,t)=>{for(var n in t)M(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&&M(e,o,{get:()=>t[o],enumerable:!(r=Q(t,o))||r.enumerable});return e};var ne=e=>te(M({},"__esModule",{value:!0}),e);var Ie={};ee(Ie,{createPaletteChannel:()=>ae,getCookie:()=>B,getStorage:()=>N,hasKeys:()=>le,hasParams:()=>L,hexToRgbChannel:()=>J,isActiveLink:()=>fe,isEqualPath:()=>oe,isExternalLink:()=>$,localStorageAvailable:()=>Y,mergeClasses:()=>pe,pxToRem:()=>ie,remToPx:()=>se,removeCookie:()=>F,removeLastSlash:()=>v,removeParams:()=>H,removeStorage:()=>j,setCookie:()=>w,setFont:()=>re,setStorage:()=>E,transformNumber:()=>de,transformValue:()=>W,transformValueOnBlur:()=>K,transformValueOnChange:()=>G,updateSelectedItems:()=>q,useBackToTop:()=>ye,useBoolean:()=>ge,useClientRect:()=>Ce,useCookies:()=>he,useCopyToClipboard:()=>Ae,useCountdownDate:()=>Ue,useCountdownSeconds:()=>De,useDebounce:()=>Se,useDoubleClick:()=>ke,useIsClient:()=>xe,useLocalStorage:()=>we,useMultiSelect:()=>Re,usePopover:()=>Te,usePopoverHover:()=>Ee,useScrollOffsetTop:()=>Oe,useSetState:()=>be,useTabs:()=>me,uuidv4:()=>ce,varAlpha:()=>ue});module.exports=ne(Ie);var L=e=>{let t=e.split("?")[1];return t?new URLSearchParams(t).toString().length>0:!1};function v(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function oe(e,t){return v(e)===v(t)}function H(e){try{let t=new URL(e,window.location.origin);return v(t.pathname)}catch{return e}}function $(e){return e.startsWith("http")}var z='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function re(e){return e?`"${e}", ${z}`:z}function se(e){let t=parseFloat(e);return Math.round(t*16)}function ie(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 ae(e){let t={};return Object.entries(e).forEach(([n,r])=>{r&&(t[`${n}Channel`]=J(r))}),{...e,...t}}function ue(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}".
1
+ "use strict";var P=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var ee=(e,t)=>{for(var n in t)P(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&&P(e,o,{get:()=>t[o],enumerable:!(r=Q(t,o))||r.enumerable});return e};var ne=e=>te(P({},"__esModule",{value:!0}),e);var Me={};ee(Me,{createPaletteChannel:()=>ue,getCookie:()=>B,getStorage:()=>N,hasKeys:()=>ce,hasParams:()=>L,hexToRgbChannel:()=>J,isActiveLink:()=>de,isEqualPath:()=>oe,isExternalLink:()=>$,localStorageAvailable:()=>Y,mergeClasses:()=>fe,mergeRefs:()=>re,pxToRem:()=>ae,remToPx:()=>ie,removeCookie:()=>F,removeLastSlash:()=>v,removeParams:()=>H,removeStorage:()=>j,setCookie:()=>w,setFont:()=>se,setStorage:()=>E,transformNumber:()=>me,transformValue:()=>W,transformValueOnBlur:()=>K,transformValueOnChange:()=>G,updateSelectedItems:()=>q,useBackToTop:()=>ve,useBoolean:()=>Te,useClientRect:()=>Re,useCookies:()=>Se,useCopyToClipboard:()=>Ie,useCountdownDate:()=>Ve,useCountdownSeconds:()=>Ae,useDebounce:()=>be,useDoubleClick:()=>we,useIsClient:()=>ye,useLocalStorage:()=>Ee,useMultiSelect:()=>ke,usePopover:()=>he,usePopoverHover:()=>Ue,useScrollOffsetTop:()=>De,useSetState:()=>xe,useTabs:()=>ge,uuidv4:()=>pe,varAlpha:()=>le});module.exports=ne(Me);var L=e=>{let t=e.split("?")[1];return t?new URLSearchParams(t).toString().length>0:!1};function v(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function oe(e,t){return v(e)===v(t)}function H(e){try{let t=new URL(e,window.location.origin);return v(t.pathname)}catch{return e}}function $(e){return e.startsWith("http")}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}".
2
2
  Supported formats are:
3
3
  - RGB channels: "0 184 217".
4
4
  - CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)".
@@ -6,4 +6,4 @@
6
6
  - Hex: "#00B8D9".
7
7
  - RGB: "rgb(0, 184, 217)".
8
8
  - RGBA: "rgba(0, 184, 217, 1)".
9
- `);return`rgba(${e} / ${t})`}function le(e,t){return!e||!t.length||typeof e!="object"?!1:t.every(n=>n in e)}function ce(){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 pe(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 B(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 w(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 F(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 fe(e,t,n=!0){let r=v(e),o=L(t);if(t.startsWith("#")||$(t))return!1;if(n||o){let u=r.includes(t),a=H(t);return u||o&&a===r}return r===t}function N(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 E(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function j(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 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 de={onChange:G,onBlur:K,value:W};var O=require("react");function me(e){let[t,n]=(0,O.useState)(e),r=(0,O.useCallback)((o,s)=>{n(s)},[]);return{value:t,setValue:n,onChange:r}}var C=require("react");function ge(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 Te(){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 he(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=B(e);l?u(s?T=>({...T,...l}):l):t&&r&&w(e,t,o)},[]);let a=(0,m.useCallback)(l=>{s?u(T=>{let _={...T,...l};return w(e,_,o),_}):(w(e,l,o),u(l))},[o,s,e]),c=(0,m.useCallback)((l,T)=>{s&&a({[l]:T})},[s,a]),p=(0,m.useCallback)(l=>{u(l??t),F(e)},[t,e]);return(0,m.useMemo)(()=>({state:i,setState:a,setField:c,resetState:p}),[p,c,a,i])}var D=require("react");function Se(e,t=1e3){let[n,r]=(0,D.useState)(e);return(0,D.useEffect)(()=>{let o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}var R=require("react");function be(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 A=require("react");function xe(){let[e,t]=(0,A.useState)(!1);return(0,A.useEffect)(()=>{t(!0)},[]),e}var h=require("react");function ye(e,t){let[n,r]=(0,h.useState)(!1),o=ve(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 ve(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 Ce(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 S=require("react");function Re(e,t){let[n,r]=(0,S.useState)(t??[]),o=(0,S.useCallback)(a=>{r(c=>q(c,a))},[]),s=(0,S.useCallback)(()=>{r(a=>a.length===e.length?[]:e)},[e]),i=(0,S.useCallback)(()=>{r([])},[]),u=(0,S.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 V=require("react");function ke({click:e,doubleClick:t,timeout:n=250}){let r=(0,V.useRef)(null),o=(0,V.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return(0,V.useCallback)(i=>{o(),e&&i.detail===1&&(r.current=setTimeout(()=>{e(i)},n)),i.detail%2===0&&t(i)},[e,t,n,o])}var g=require("react");function we(e,t,n){let{initializeWithValue:r=!0}=n??{},o=t&&typeof t=="object",[s,i]=(0,g.useState)(t);(0,g.useEffect)(()=>{let f=N(e);f?i(o?l=>({...l,...f}):f):t&&r&&E(e,t)},[]);let u=(0,g.useCallback)(f=>{o?i(l=>{let T={...l,...f};return E(e,T),T}):(E(e,f),i(f))},[e,o]),a=(0,g.useCallback)((f,l)=>{o&&u({[f]:l})},[o,u]),c=(0,g.useCallback)(f=>{i(f??t),j(e)},[t,e]);return(0,g.useMemo)(()=>({state:s,setState:u,setField:a,resetState:c}),[c,a,u,s])}var y=require("react");function Ee(e){let t=(0,y.useRef)(null),n=e||t,[r,o]=(0,y.useState)(!1),s=(0,y.useCallback)(()=>{o(!0)},[]),i=(0,y.useCallback)(()=>{o(!1)},[]);return{elementRef:n,anchorEl:n.current,open:r,onOpen:s,onClose:i,setOpen:o}}var k=require("react");function Ue(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}=Ve(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 Ve(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 b=require("react");function Oe(e=0){let t=(0,b.useRef)(null),[n,r]=(0,b.useState)(!1),o=(0,b.useCallback)(()=>{let s=window.scrollY;if(t.current){let i=t.current.offsetTop;r(s>i-e)}else r(s>e)},[e]);return(0,b.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 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 P=require("react");function Ae(){let[e,t]=(0,P.useState)(null);return{copy:(0,P.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,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});
9
+ `);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 B(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 w(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 F(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){let r=v(e),o=L(t);if(t.startsWith("#")||$(t))return!1;if(n||o){let u=r.includes(t),a=H(t);return u||o&&a===r}return r===t}function N(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 E(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function j(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 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 me={onChange:G,onBlur:K,value:W};var O=require("react");function ge(e){let[t,n]=(0,O.useState)(e),r=(0,O.useCallback)((o,s)=>{n(s)},[]);return{value:t,setValue:n,onChange:r}}var C=require("react");function Te(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 he(){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=B(e);l?u(s?T=>({...T,...l}):l):t&&r&&w(e,t,o)},[]);let a=(0,m.useCallback)(l=>{s?u(T=>{let _={...T,...l};return w(e,_,o),_}):(w(e,l,o),u(l))},[o,s,e]),c=(0,m.useCallback)((l,T)=>{s&&a({[l]:T})},[s,a]),p=(0,m.useCallback)(l=>{u(l??t),F(e)},[t,e]);return(0,m.useMemo)(()=>({state:i,setState:a,setField:c,resetState:p}),[p,c,a,i])}var D=require("react");function be(e,t=1e3){let[n,r]=(0,D.useState)(e);return(0,D.useEffect)(()=>{let o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}var R=require("react");function xe(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 A=require("react");function ye(){let[e,t]=(0,A.useState)(!1);return(0,A.useEffect)(()=>{t(!0)},[]),e}var h=require("react");function ve(e,t){let[n,r]=(0,h.useState)(!1),o=Ce(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 Ce(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 Re(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 S=require("react");function ke(e,t){let[n,r]=(0,S.useState)(t??[]),o=(0,S.useCallback)(a=>{r(c=>q(c,a))},[]),s=(0,S.useCallback)(()=>{r(a=>a.length===e.length?[]:e)},[e]),i=(0,S.useCallback)(()=>{r([])},[]),u=(0,S.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 V=require("react");function we({click:e,doubleClick:t,timeout:n=250}){let r=(0,V.useRef)(null),o=(0,V.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return(0,V.useCallback)(i=>{o(),e&&i.detail===1&&(r.current=setTimeout(()=>{e(i)},n)),i.detail%2===0&&t(i)},[e,t,n,o])}var g=require("react");function Ee(e,t,n){let{initializeWithValue:r=!0}=n??{},o=t&&typeof t=="object",[s,i]=(0,g.useState)(t);(0,g.useEffect)(()=>{let f=N(e);f?i(o?l=>({...l,...f}):f):t&&r&&E(e,t)},[]);let u=(0,g.useCallback)(f=>{o?i(l=>{let T={...l,...f};return E(e,T),T}):(E(e,f),i(f))},[e,o]),a=(0,g.useCallback)((f,l)=>{o&&u({[f]:l})},[o,u]),c=(0,g.useCallback)(f=>{i(f??t),j(e)},[t,e]);return(0,g.useMemo)(()=>({state:s,setState:u,setField:a,resetState:c}),[c,a,u,s])}var y=require("react");function Ue(e){let t=(0,y.useRef)(null),n=e||t,[r,o]=(0,y.useState)(!1),s=(0,y.useCallback)(()=>{o(!0)},[]),i=(0,y.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}=Oe(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 Oe(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 b=require("react");function De(e=0){let t=(0,b.useRef)(null),[n,r]=(0,b.useState)(!1),o=(0,b.useCallback)(()=>{let s=window.scrollY;if(t.current){let i=t.current.offsetTop;r(s>i-e)}else r(s>e)},[e]);return(0,b.useEffect)(()=>(o(),window.addEventListener("scroll",o),()=>{window.removeEventListener("scroll",o)}),[o]),{elementRef:t,offsetTop:n}}var x=require("react");function Ae(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 M=require("react");function Ie(){let[e,t]=(0,M.useState)(null);return{copy:(0,M.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,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,5 @@
1
1
  export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './utils/url/url.cjs';
2
+ export { mergeRefs } from './utils/refs/refs.cjs';
2
3
  export { pxToRem, remToPx, setFont } from './utils/font/font.cjs';
3
4
  export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './utils/color/color.cjs';
4
5
  export { hasKeys } from './utils/object/object.cjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './utils/url/url.js';
2
+ export { mergeRefs } from './utils/refs/refs.js';
2
3
  export { pxToRem, remToPx, setFont } from './utils/font/font.js';
3
4
  export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './utils/color/color.js';
4
5
  export { hasKeys } from './utils/object/object.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var R=e=>{let t=e.split("?")[1];return t?new URLSearchParams(t).toString().length>0:!1};function m(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function De(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 w(e){return e.startsWith("http")}var E='-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}", ${E}`:E}function Pe(e){let t=parseFloat(e);return Math.round(t*16)}function Me(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function N(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 He(e){let t={};return Object.entries(e).forEach(([n,o])=>{o&&(t[`${n}Channel`]=N(o))}),{...e,...t}}function $e(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}".
1
+ var R=e=>{let t=e.split("?")[1];return t?new URLSearchParams(t).toString().length>0:!1};function m(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function De(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 w(e){return e.startsWith("http")}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 E='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function Pe(e){return e?`"${e}", ${E}`:E}function Le(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 N(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 Be(e){let t={};return Object.entries(e).forEach(([n,o])=>{o&&(t[`${n}Channel`]=N(o))}),{...e,...t}}function Fe(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}".
2
2
  Supported formats are:
3
3
  - RGB channels: "0 184 217".
4
4
  - CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)".
@@ -6,4 +6,4 @@ var R=e=>{let t=e.split("?")[1];return t?new URLSearchParams(t).toString().lengt
6
6
  - Hex: "#00B8D9".
7
7
  - RGB: "rgb(0, 184, 217)".
8
8
  - RGBA: "rgba(0, 184, 217, 1)".
9
- `);return`rgba(${e} / ${t})`}function Fe(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 _e(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 g(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 V(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 Ge(e,t,n=!0){let o=m(e),r=R(t);if(t.startsWith("#")||w(t))return!1;if(n||r){let u=o.includes(t),a=k(t);return u||r&&a===o}return o===t}function O(e,t){if(!j())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 T(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function D(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function j(){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 A(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function W(e){let n=A(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 Qe={onChange:W,onBlur:_,value:A};import{useState as z,useCallback as J}from"react";function et(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 S}from"react";function ot(e=!1){let[t,n]=Y(e),o=S(()=>{n(!0)},[]),r=S(()=>{n(!1)},[]),s=S(()=>{n(i=>!i)},[]);return{value:t,onTrue:o,onFalse:r,onToggle:s,setValue:n}}import{useState as G,useCallback as I}from"react";function it(){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 b}from"react";function ct(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&&g(e,t,r)},[]);let a=b(l=>{s?u(d=>{let C={...d,...l};return g(e,C,r),C}):(g(e,l,r),u(l))},[r,s,e]),c=b((l,d)=>{s&&a({[l]:d})},[s,a]),p=b(l=>{u(l??t),V(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 dt(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 Tt(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 bt(){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 vt(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 P,useState as M,useEffect as L,useCallback as le,useLayoutEffect as ce}from"react";function kt(e,t){let n=ue(null),o=e||n,[r,s]=M(void 0),[i,u]=M(void 0),a=typeof window<"u"?ce:L,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]),L(()=>{let l=t||"resize";return window.addEventListener(l,c),()=>{window.removeEventListener(l,c)}},[t,c]);let p=P(()=>r,[r]),f=P(()=>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 Ut(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 Dt({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 ge,useState as Te,useEffect as he,useCallback as v}from"react";function Mt(e,t,n){let{initializeWithValue:o=!0}=n??{},r=t&&typeof t=="object",[s,i]=Te(t);he(()=>{let f=O(e);f?i(r?l=>({...l,...f}):f):t&&o&&T(e,t)},[]);let u=v(f=>{r?i(l=>{let d={...l,...f};return T(e,d),d}):(T(e,f),i(f))},[e,r]),a=v((f,l)=>{r&&u({[f]:l})},[r,u]),c=v(f=>{i(f??t),D(e)},[t,e]);return ge(()=>({state:s,setState:u,setField:a,resetState:c}),[c,a,u,s])}import{useRef as Se,useState as be,useCallback as $}from"react";function $t(e){let t=Se(null),n=e||t,[o,r]=be(!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 Nt(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 we,useCallback as Ee}from"react";function _t(e=0){let t=Re(null),[n,o]=ke(!1),r=Ee(()=>{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 Ue,useCallback as F}from"react";function Yt(e){let[t,n]=B(e),[o,r]=B(!1),s=F(()=>{r(!0)},[]),i=F(()=>{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 Ve,useCallback as Oe}from"react";function qt(){let[e,t]=Ve(null);return{copy:Oe(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{He as createPaletteChannel,U as getCookie,O as getStorage,Fe as hasKeys,R as hasParams,N as hexToRgbChannel,Ge as isActiveLink,De as isEqualPath,w as isExternalLink,j as localStorageAvailable,_e as mergeClasses,Me as pxToRem,Pe as remToPx,V as removeCookie,m as removeLastSlash,k as removeParams,D as removeStorage,g as setCookie,Ie as setFont,T as setStorage,Qe as transformNumber,A as transformValue,_ as transformValueOnBlur,W as transformValueOnChange,de as updateSelectedItems,vt as useBackToTop,ot as useBoolean,kt as useClientRect,ct as useCookies,qt as useCopyToClipboard,Nt as useCountdownDate,Yt as useCountdownSeconds,dt as useDebounce,Dt as useDoubleClick,bt as useIsClient,Mt as useLocalStorage,Ut as useMultiSelect,it as usePopover,$t as usePopoverHover,_t as useScrollOffsetTop,Tt as useSetState,et as useTabs,je as uuidv4,$e as varAlpha};
9
+ `);return`rgba(${e} / ${t})`}function je(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 g(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 V(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){let o=m(e),r=R(t);if(t.startsWith("#")||w(t))return!1;if(n||r){let u=o.includes(t),a=k(t);return u||r&&a===o}return o===t}function O(e,t){if(!j())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 T(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function D(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function j(){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 A(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function W(e){let n=A(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 Ze={onChange:W,onBlur:_,value:A};import{useState as z,useCallback as J}from"react";function nt(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 S}from"react";function st(e=!1){let[t,n]=Y(e),o=S(()=>{n(!0)},[]),r=S(()=>{n(!1)},[]),s=S(()=>{n(i=>!i)},[]);return{value:t,onTrue:o,onFalse:r,onToggle:s,setValue:n}}import{useState as G,useCallback as I}from"react";function ut(){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 b}from"react";function ft(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&&g(e,t,r)},[]);let a=b(l=>{s?u(d=>{let C={...d,...l};return g(e,C,r),C}):(g(e,l,r),u(l))},[r,s,e]),c=b((l,d)=>{s&&a({[l]:d})},[s,a]),p=b(l=>{u(l??t),V(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 gt(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 St(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 yt(){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 Rt(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 M,useState as P,useEffect as L,useCallback as le,useLayoutEffect as ce}from"react";function Et(e,t){let n=ue(null),o=e||n,[r,s]=P(void 0),[i,u]=P(void 0),a=typeof window<"u"?ce:L,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]),L(()=>{let l=t||"resize";return window.addEventListener(l,c),()=>{window.removeEventListener(l,c)}},[t,c]);let p=M(()=>r,[r]),f=M(()=>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 Ot(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 It({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 ge,useState as Te,useEffect as he,useCallback as v}from"react";function Ht(e,t,n){let{initializeWithValue:o=!0}=n??{},r=t&&typeof t=="object",[s,i]=Te(t);he(()=>{let f=O(e);f?i(r?l=>({...l,...f}):f):t&&o&&T(e,t)},[]);let u=v(f=>{r?i(l=>{let d={...l,...f};return T(e,d),d}):(T(e,f),i(f))},[e,r]),a=v((f,l)=>{r&&u({[f]:l})},[r,u]),c=v(f=>{i(f??t),D(e)},[t,e]);return ge(()=>({state:s,setState:u,setField:a,resetState:c}),[c,a,u,s])}import{useRef as Se,useState as be,useCallback as $}from"react";function Ft(e){let t=Se(null),n=e||t,[o,r]=be(!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 Wt(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 we,useCallback as Ee}from"react";function Jt(e=0){let t=Re(null),[n,o]=ke(!1),r=Ee(()=>{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 Ue,useCallback as F}from"react";function Kt(e){let[t,n]=B(e),[o,r]=B(!1),s=F(()=>{r(!0)},[]),i=F(()=>{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 Ve,useCallback as Oe}from"react";function Xt(){let[e,t]=Ve(null);return{copy:Oe(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{Be as createPaletteChannel,U as getCookie,O as getStorage,je as hasKeys,R as hasParams,N as hexToRgbChannel,qe as isActiveLink,De as isEqualPath,w as isExternalLink,j as localStorageAvailable,Je as mergeClasses,Ie as mergeRefs,He as pxToRem,Le as remToPx,V as removeCookie,m as removeLastSlash,k as removeParams,D as removeStorage,g as setCookie,Pe as setFont,T as setStorage,Ze as transformNumber,A as transformValue,_ as transformValueOnBlur,W as transformValueOnChange,de as updateSelectedItems,Rt as useBackToTop,st as useBoolean,Et as useClientRect,ft as useCookies,Xt as useCopyToClipboard,Wt as useCountdownDate,Kt as useCountdownSeconds,gt as useDebounce,It as useDoubleClick,yt as useIsClient,Ht as useLocalStorage,Ot as useMultiSelect,ut as usePopover,Ft as usePopoverHover,Jt as useScrollOffsetTop,St as useSetState,nt as useTabs,_e as uuidv4,Fe as varAlpha};
@@ -1,4 +1,4 @@
1
- "use strict";var p=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var $=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},C=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of w(e))!I.call(r,n)&&n!==t&&p(r,n,{get:()=>e[n],enumerable:!(o=T(e,n))||o.enumerable});return r};var v=r=>C(p({},"__esModule",{value:!0}),r);var G={};$(G,{createPaletteChannel:()=>V,getCookie:()=>B,getStorage:()=>D,hasKeys:()=>O,hasParams:()=>g,hexToRgbChannel:()=>h,isActiveLink:()=>F,isEqualPath:()=>A,isExternalLink:()=>d,localStorageAvailable:()=>y,mergeClasses:()=>R,pxToRem:()=>N,remToPx:()=>E,removeCookie:()=>j,removeLastSlash:()=>s,removeParams:()=>f,removeStorage:()=>J,setCookie:()=>L,setFont:()=>P,setStorage:()=>W,transformNumber:()=>M,transformValue:()=>x,transformValueOnBlur:()=>S,transformValueOnChange:()=>b,uuidv4:()=>U,varAlpha:()=>_});module.exports=v(G);var g=r=>{let e=r.split("?")[1];return e?new URLSearchParams(e).toString().length>0:!1};function s(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function A(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 d(r){return r.startsWith("http")}var m='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function P(r){return r?`"${r}", ${m}`:m}function E(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 V(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}".
1
+ "use strict";var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var $=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},C=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of w(e))!I.call(r,n)&&n!==t&&p(r,n,{get:()=>e[n],enumerable:!(o=k(e,n))||o.enumerable});return r};var A=r=>C(p({},"__esModule",{value:!0}),r);var H={};$(H,{createPaletteChannel:()=>O,getCookie:()=>L,getStorage:()=>W,hasKeys:()=>_,hasParams:()=>f,hexToRgbChannel:()=>h,isActiveLink:()=>D,isEqualPath:()=>v,isExternalLink:()=>d,localStorageAvailable:()=>y,mergeClasses:()=>B,mergeRefs:()=>P,pxToRem:()=>N,remToPx:()=>R,removeCookie:()=>F,removeLastSlash:()=>s,removeParams:()=>g,removeStorage:()=>J,setCookie:()=>j,setFont:()=>E,setStorage:()=>M,transformNumber:()=>G,transformValue:()=>x,transformValueOnBlur:()=>S,transformValueOnChange:()=>b,uuidv4:()=>U,varAlpha:()=>V});module.exports=A(H);var f=r=>{let e=r.split("?")[1];return e?new URLSearchParams(e).toString().length>0:!1};function s(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function v(r,e){return s(r)===s(e)}function g(r){try{let e=new URL(r,window.location.origin);return s(e.pathname)}catch{return r}}function d(r){return r.startsWith("http")}function P(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 E(r){return r?`"${r}", ${m}`:m}function R(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 V(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}".
2
2
  Supported formats are:
3
3
  - RGB channels: "0 184 217".
4
4
  - CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)".
@@ -6,4 +6,4 @@
6
6
  - Hex: "#00B8D9".
7
7
  - RGB: "rgb(0, 184, 217)".
8
8
  - RGBA: "rgba(0, 184, 217, 1)".
9
- `);return`rgba(${r} / ${e})`}function O(r,e){return!r||!e.length||typeof r!="object"?!1:e.every(t=>t in r)}function U(){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 R(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(c=>c.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 L(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:c="/",domain:u}=t??{};try{let a=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),l=[`${r}=${a}`,`path=${c}`,n&&`SameSite=${n}`,i&&"Secure",u&&`domain=${u}`];if(o>0){let k=new Date(Date.now()+o*24*60*60*1e3);l.push(`expires=${k.toUTCString()}`)}document.cookie=l.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}function j(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 F(r,e,t=!0){let o=s(r),n=g(e);if(e.startsWith("#")||d(e))return!1;if(t||n){let u=o.includes(e),a=f(e);return u||n&&a===o}return o===e}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 W(r,e){try{let t=JSON.stringify(e);window.localStorage.setItem(r,t)}catch(t){console.error("Error while setting storage:",t)}}function J(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 x(r,e=""){return r==null||typeof r=="number"&&Number.isNaN(r)?e:r.toString()}function b(r){let t=x(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 M={onChange:b,onBlur:S,value:x};0&&(module.exports={createPaletteChannel,getCookie,getStorage,hasKeys,hasParams,hexToRgbChannel,isActiveLink,isEqualPath,isExternalLink,localStorageAvailable,mergeClasses,pxToRem,remToPx,removeCookie,removeLastSlash,removeParams,removeStorage,setCookie,setFont,setStorage,transformNumber,transformValue,transformValueOnBlur,transformValueOnChange,uuidv4,varAlpha});
9
+ `);return`rgba(${r} / ${e})`}function _(r,e){return!r||!e.length||typeof r!="object"?!1:e.every(t=>t in r)}function U(){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 B(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 L(r){if(!r||typeof r!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${r}=`,n=decodeURIComponent(document.cookie).split("; ").find(c=>c.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 j(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:c="/",domain:u}=t??{};try{let a=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),l=[`${r}=${a}`,`path=${c}`,n&&`SameSite=${n}`,i&&"Secure",u&&`domain=${u}`];if(o>0){let T=new Date(Date.now()+o*24*60*60*1e3);l.push(`expires=${T.toUTCString()}`)}document.cookie=l.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}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 D(r,e,t=!0){let o=s(r),n=f(e);if(e.startsWith("#")||d(e))return!1;if(t||n){let u=o.includes(e),a=g(e);return u||n&&a===o}return o===e}function W(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 M(r,e){try{let t=JSON.stringify(e);window.localStorage.setItem(r,t)}catch(t){console.error("Error while setting storage:",t)}}function J(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 x(r,e=""){return r==null||typeof r=="number"&&Number.isNaN(r)?e:r.toString()}function b(r){let t=x(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 G={onChange:b,onBlur:S,value:x};0&&(module.exports={createPaletteChannel,getCookie,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,4 +1,5 @@
1
1
  export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url/url.cjs';
2
+ export { mergeRefs } from './refs/refs.cjs';
2
3
  export { pxToRem, remToPx, setFont } from './font/font.cjs';
3
4
  export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './color/color.cjs';
4
5
  export { hasKeys } from './object/object.cjs';
@@ -1,4 +1,5 @@
1
1
  export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './url/url.js';
2
+ export { mergeRefs } from './refs/refs.js';
2
3
  export { pxToRem, remToPx, setFont } from './font/font.js';
3
4
  export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './color/color.js';
4
5
  export { hasKeys } from './object/object.js';
@@ -1,4 +1,4 @@
1
- var p=r=>{let e=r.split("?")[1];return e?new URLSearchParams(e).toString().length>0:!1};function a(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function k(r,e){return a(r)===a(e)}function g(r){try{let e=new URL(r,window.location.origin);return a(e.pathname)}catch{return r}}function f(r){return r.startsWith("http")}var d='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function w(r){return r?`"${r}", ${d}`:d}function I(r){let e=parseFloat(r);return Math.round(e*16)}function $(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 v(r){let e={};return Object.entries(r).forEach(([t,n])=>{n&&(e[`${t}Channel`]=h(n))}),{...r,...e}}function A(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}".
1
+ var p=r=>{let e=r.split("?")[1];return e?new URLSearchParams(e).toString().length>0:!1};function a(r){return r!=="/"&&r.endsWith("/")?r.slice(0,-1):r}function T(r,e){return a(r)===a(e)}function f(r){try{let e=new URL(r,window.location.origin);return a(e.pathname)}catch{return r}}function g(r){return r.startsWith("http")}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 d='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function $(r){return r?`"${r}", ${d}`:d}function C(r){let e=parseFloat(r);return Math.round(e*16)}function A(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 P(r){let e={};return Object.entries(r).forEach(([t,n])=>{n&&(e[`${t}Channel`]=h(n))}),{...r,...e}}function E(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}".
2
2
  Supported formats are:
3
3
  - RGB channels: "0 184 217".
4
4
  - CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)".
@@ -6,4 +6,4 @@ var p=r=>{let e=r.split("?")[1];return e?new URLSearchParams(e).toString().lengt
6
6
  - Hex: "#00B8D9".
7
7
  - RGB: "rgb(0, 184, 217)".
8
8
  - RGBA: "rgba(0, 184, 217, 1)".
9
- `);return`rgba(${r} / ${e})`}function E(r,e){return!r||!e.length||typeof r!="object"?!1:e.every(t=>t in r)}function V(){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 O(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 R(r){if(!r||typeof r!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${r}=`,o=decodeURIComponent(document.cookie).split("; ").find(c=>c.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:c="/",domain:u}=t??{};try{let s=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),l=[`${r}=${s}`,`path=${c}`,o&&`SameSite=${o}`,i&&"Secure",u&&`domain=${u}`];if(n>0){let m=new Date(Date.now()+n*24*60*60*1e3);l.push(`expires=${m.toUTCString()}`)}document.cookie=l.filter(Boolean).join("; ")}catch(s){console.error("Error setting cookie:",s)}}function L(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 D(r,e,t=!0){let n=a(r),o=p(e);if(e.startsWith("#")||f(e))return!1;if(t||o){let u=n.includes(e),s=g(e);return u||o&&s===n}return n===e}function J(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 M(r,e){try{let t=JSON.stringify(e);window.localStorage.setItem(r,t)}catch(t){console.error("Error while setting storage:",t)}}function G(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 x(r,e=""){return r==null||typeof r=="number"&&Number.isNaN(r)?e:r.toString()}function b(r){let t=x(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 K={onChange:b,onBlur:S,value:x};export{v as createPaletteChannel,R as getCookie,J as getStorage,E as hasKeys,p as hasParams,h as hexToRgbChannel,D as isActiveLink,k as isEqualPath,f as isExternalLink,y as localStorageAvailable,O as mergeClasses,$ as pxToRem,I as remToPx,L as removeCookie,a as removeLastSlash,g as removeParams,G as removeStorage,B as setCookie,w as setFont,M as setStorage,K as transformNumber,x as transformValue,S as transformValueOnBlur,b as transformValueOnChange,V as uuidv4,A as varAlpha};
9
+ `);return`rgba(${r} / ${e})`}function N(r,e){return!r||!e.length||typeof r!="object"?!1:e.every(t=>t in r)}function V(){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 U(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 L(r){if(!r||typeof r!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${r}=`,o=decodeURIComponent(document.cookie).split("; ").find(c=>c.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 j(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:c="/",domain:u}=t??{};try{let s=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),l=[`${r}=${s}`,`path=${c}`,o&&`SameSite=${o}`,i&&"Secure",u&&`domain=${u}`];if(n>0){let m=new Date(Date.now()+n*24*60*60*1e3);l.push(`expires=${m.toUTCString()}`)}document.cookie=l.filter(Boolean).join("; ")}catch(s){console.error("Error setting cookie:",s)}}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 M(r,e,t=!0){let n=a(r),o=p(e);if(e.startsWith("#")||g(e))return!1;if(t||o){let u=n.includes(e),s=f(e);return u||o&&s===n}return n===e}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 x(r,e=""){return r==null||typeof r=="number"&&Number.isNaN(r)?e:r.toString()}function b(r){let t=x(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 z={onChange:b,onBlur:S,value:x};export{P as createPaletteChannel,L as getCookie,G as getStorage,N as hasKeys,p as hasParams,h as hexToRgbChannel,M as isActiveLink,T as isEqualPath,g as isExternalLink,y as localStorageAvailable,U as mergeClasses,w as mergeRefs,A as pxToRem,C as remToPx,F as removeCookie,a as removeLastSlash,f as removeParams,K as removeStorage,j as setCookie,$ as setFont,H as setStorage,z as transformNumber,x as transformValue,S as transformValueOnBlur,b as transformValueOnChange,V as uuidv4,E as varAlpha};
@@ -0,0 +1 @@
1
+ "use strict";var r=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var i=(n,e)=>{for(var t in e)r(n,t,{get:e[t],enumerable:!0})},R=(n,e,t,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let f of l(e))!o.call(n,f)&&f!==t&&r(n,f,{get:()=>e[f],enumerable:!(c=u(e,f))||c.enumerable});return n};var a=n=>R(r({},"__esModule",{value:!0}),n);var b={};i(b,{mergeRefs:()=>T});module.exports=a(b);function T(n){return e=>{if(n.length!==0)for(let t of n)t&&(typeof t=="function"?t(e):"current"in t&&(t.current=e))}}0&&(module.exports={mergeRefs});
@@ -0,0 +1 @@
1
+ export { mergeRefs } from './refs.cjs';
@@ -0,0 +1 @@
1
+ export { mergeRefs } from './refs.js';
@@ -0,0 +1 @@
1
+ function f(n){return t=>{if(n.length!==0)for(let e of n)e&&(typeof e=="function"?e(t):"current"in e&&(e.current=t))}}export{f as mergeRefs};
@@ -0,0 +1 @@
1
+ "use strict";var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var o=(n,e)=>{for(var t in e)c(n,t,{get:e[t],enumerable:!0})},R=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let f of l(e))!i.call(n,f)&&f!==t&&c(n,f,{get:()=>e[f],enumerable:!(r=u(e,f))||r.enumerable});return n};var a=n=>R(c({},"__esModule",{value:!0}),n);var b={};o(b,{mergeRefs:()=>T});module.exports=a(b);function T(n){return e=>{if(n.length!==0)for(let t of n)t&&(typeof t=="function"?t(e):"current"in t&&(t.current=e))}}0&&(module.exports={mergeRefs});
@@ -0,0 +1,3 @@
1
+ declare function mergeRefs<T>(refs: (React.Ref<T> | undefined | null)[]): React.RefCallback<T>;
2
+
3
+ export { mergeRefs };
@@ -0,0 +1,3 @@
1
+ declare function mergeRefs<T>(refs: (React.Ref<T> | undefined | null)[]): React.RefCallback<T>;
2
+
3
+ export { mergeRefs };
@@ -0,0 +1 @@
1
+ function f(n){return t=>{if(n.length!==0)for(let e of n)e&&(typeof e=="function"?e(t):"current"in e&&(e.current=t))}}export{f as mergeRefs};
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "minimal-shared",
3
3
  "author": "Minimals",
4
- "version": "1.0.1",
5
- "description": "Shared hooks and utils used by Mnimal UI and Zone UI.",
4
+ "version": "1.0.3",
5
+ "description": "Shared hooks and utils used by Minimal UI and Zone UI.",
6
6
  "keywords": [
7
7
  "typescript",
8
8
  "react",
@@ -11,7 +11,8 @@
11
11
  ],
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "https://github.com/minimal-ui-kit/minimal-shared"
14
+ "url": "https://github.com/minimal-ui-kit/minimal-shared",
15
+ "homepage": "https://github.com/minimal-ui-kit/minimal-shared#readme"
15
16
  },
16
17
  "license": "MIT",
17
18
  "sideEffects": false,
@@ -85,7 +86,7 @@
85
86
  "lint:fix": "eslint --fix \"**/*.{js,jsx,ts,tsx}\"",
86
87
  "lint:print": "npx eslint --print-config eslint.config.mjs > eslint-current-config.json",
87
88
  "clean": "rm -rf node_modules .turbo .next out dist build",
88
- "re:build": "pnpm clean && pnpm install && pnpm build",
89
+ "re:build": "pnpm clean && pnpm install && pnpm test && pnpm build",
89
90
  "tsc:print": "npx tsc --showConfig"
90
91
  }
91
92
  }