minimal-shared 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/utils/active-link/active-link.cjs +1 -1
- package/dist/utils/active-link/active-link.d.cts +19 -8
- package/dist/utils/active-link/active-link.d.ts +19 -8
- package/dist/utils/active-link/active-link.js +1 -1
- package/dist/utils/active-link/index.cjs +1 -1
- package/dist/utils/active-link/index.js +1 -1
- package/dist/utils/index.cjs +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/url/index.cjs +1 -1
- package/dist/utils/url/index.js +1 -1
- package/dist/utils/url/url.cjs +1 -1
- package/dist/utils/url/url.d.cts +28 -24
- package/dist/utils/url/url.d.ts +28 -24
- package/dist/utils/url/url.js +1 -1
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var I=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var ee=(e,t)=>{for(var n in t)I(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&&I(e,o,{get:()=>t[o],enumerable:!(r=Q(t,o))||r.enumerable});return e};var ne=e=>te(I({},"__esModule",{value:!0}),e);var
|
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
|
1
|
+
"use strict";var I=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var ee=(e,t)=>{for(var n in t)I(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&&I(e,o,{get:()=>t[o],enumerable:!(r=Q(t,o))||r.enumerable});return e};var ne=e=>te(I({},"__esModule",{value:!0}),e);var Ae={};ee(Ae,{createPaletteChannel:()=>ue,getCookie:()=>j,getStorage:()=>F,hasKeys:()=>ce,hasParams:()=>P,hexToRgbChannel:()=>J,isActiveLink:()=>de,isEqualPath:()=>oe,isExternalLink:()=>$,localStorageAvailable:()=>Y,mergeClasses:()=>fe,mergeRefs:()=>re,pxToRem:()=>ae,remToPx:()=>ie,removeCookie:()=>B,removeLastSlash:()=>y,removeParams:()=>H,removeStorage:()=>N,setCookie:()=>E,setFont:()=>se,setStorage:()=>w,transformNumber:()=>me,transformValue:()=>W,transformValueOnBlur:()=>K,transformValueOnChange:()=>G,updateSelectedItems:()=>q,useBackToTop:()=>ve,useBoolean:()=>ge,useClientRect:()=>Re,useCookies:()=>be,useCopyToClipboard:()=>De,useCountdownDate:()=>Oe,useCountdownSeconds:()=>Le,useDebounce:()=>Se,useDoubleClick:()=>Ee,useIsClient:()=>ye,useLocalStorage:()=>we,useMultiSelect:()=>ke,usePopover:()=>he,usePopoverHover:()=>Ue,useScrollOffsetTop:()=>Me,useSetState:()=>xe,useTabs:()=>Te,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 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 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 F(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 N(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 V=require("react");function Te(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 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 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 be(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),B(e)},[t,e]);return(0,m.useMemo)(()=>({state:i,setState:a,setField:c,resetState:p}),[p,c,a,i])}var M=require("react");function Se(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 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 L=require("react");function ye(){let[e,t]=(0,L.useState)(!1);return(0,L.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 b=require("react");function ke(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 Ee({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 we(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?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),N(e)},[t,e]);return(0,T.useMemo)(()=>({state:s,setState:u,setField:a,resetState:c}),[c,a,u,s])}var v=require("react");function Ue(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 Oe(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:D(i),hours:D(u),minutes:D(a),seconds:D(c)})},[e]);return(0,k.useEffect)(()=>{o();let s=setInterval(o,1e3);return()=>clearInterval(s)},[]),n}function D(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 S=require("react");function Me(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 Le(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 A=require("react");function De(){let[e,t]=(0,A.useState)(null);return{copy:(0,A.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.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
`));return`rgba(${e} / ${t})`}function Ne(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
|
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 De(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 Ie(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 F(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`]=F(o))}),{...e,...t}}function Be(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 Ne(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(!N())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 N(){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 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 Ze={onChange:W,onBlur:_,value:L};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 b}from"react";function st(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 D}from"react";function ut(){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 Q,useCallback as S}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&&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 Tt(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 bt(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 A,useState as I,useEffect as P,useCallback as le,useLayoutEffect as ce}from"react";function wt(e,t){let n=ue(null),o=e||n,[r,s]=I(void 0),[i,u]=I(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=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 pe,useState as fe,useCallback as y}from"react";function Vt(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 Te,useState as ge,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]=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 Bt(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 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 Ee,useCallback as we}from"react";function Jt(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 B}from"react";function Kt(e){let[t,n]=j(e),[o,r]=j(!1),s=B(()=>{r(!0)},[]),i=B(()=>{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 Xt(){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,V as getStorage,Ne as hasKeys,R as hasParams,F as hexToRgbChannel,qe as isActiveLink,Me as isEqualPath,E as isExternalLink,N as localStorageAvailable,Je as mergeClasses,De as mergeRefs,He as pxToRem,Pe as remToPx,O as removeCookie,m as removeLastSlash,k as removeParams,M as removeStorage,T as setCookie,Ie as setFont,g as setStorage,Ze as transformNumber,L as transformValue,_ as transformValueOnBlur,W as transformValueOnChange,de as updateSelectedItems,Rt as useBackToTop,st as useBoolean,wt as useClientRect,ft as useCookies,Xt as useCopyToClipboard,Wt as useCountdownDate,Kt as useCountdownSeconds,Tt as useDebounce,Dt as useDoubleClick,yt as useIsClient,Ht as useLocalStorage,Vt as useMultiSelect,ut as usePopover,Bt as usePopoverHover,Jt as useScrollOffsetTop,bt as useSetState,nt as useTabs,_e as uuidv4,Be as varAlpha};
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";var o=Object.defineProperty;var
|
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,16 +1,27 @@
|
|
1
1
|
/**
|
2
|
-
* Determines
|
2
|
+
* Determines whether a given target path is considered "active"
|
3
|
+
* based on the current pathname — typically used for highlighting
|
4
|
+
* active navigation links.
|
3
5
|
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
6
|
+
* ✅ Features:
|
7
|
+
* - Removes trailing slashes and query parameters before comparison.
|
8
|
+
* - Ignores external links (e.g. `https://...`) and hash links (e.g. `#section`).
|
9
|
+
* - Supports deep matching to detect nested routes or links with query strings.
|
7
10
|
*
|
8
|
-
* @
|
11
|
+
* @param {string} currentPathname - The current URL pathname (e.g., from `window.location.pathname` or router).
|
12
|
+
* @param {string} targetPath - The target path to check (can include query parameters).
|
13
|
+
* @param {boolean} [deep=true] - If true, performs deep matching (for nested routes or param links).
|
14
|
+
*
|
15
|
+
* @returns {boolean} - Returns `true` if the target path is considered active; otherwise, `false`.
|
9
16
|
*
|
10
17
|
* @example
|
11
|
-
*
|
12
|
-
*
|
18
|
+
* isActiveLink('/dashboard/user/list', '/dashboard/user'); // true (deep match)
|
19
|
+
* isActiveLink('/dashboard/user', '/dashboard/user?id=123'); // true (query param)
|
20
|
+
* isActiveLink('/dashboard/user', '/dashboard/user', false); // true (exact match)
|
21
|
+
* isActiveLink('/dashboard/user', '/dashboard'); // false
|
22
|
+
* isActiveLink('/dashboard/user', '#section'); // false (hash link)
|
23
|
+
* isActiveLink('/dashboard/user', 'https://example.com'); // false (external link)
|
13
24
|
*/
|
14
|
-
declare function isActiveLink(
|
25
|
+
declare function isActiveLink(currentPathname: string, targetPath: string, deep?: boolean): boolean;
|
15
26
|
|
16
27
|
export { isActiveLink };
|
@@ -1,16 +1,27 @@
|
|
1
1
|
/**
|
2
|
-
* Determines
|
2
|
+
* Determines whether a given target path is considered "active"
|
3
|
+
* based on the current pathname — typically used for highlighting
|
4
|
+
* active navigation links.
|
3
5
|
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
6
|
+
* ✅ Features:
|
7
|
+
* - Removes trailing slashes and query parameters before comparison.
|
8
|
+
* - Ignores external links (e.g. `https://...`) and hash links (e.g. `#section`).
|
9
|
+
* - Supports deep matching to detect nested routes or links with query strings.
|
7
10
|
*
|
8
|
-
* @
|
11
|
+
* @param {string} currentPathname - The current URL pathname (e.g., from `window.location.pathname` or router).
|
12
|
+
* @param {string} targetPath - The target path to check (can include query parameters).
|
13
|
+
* @param {boolean} [deep=true] - If true, performs deep matching (for nested routes or param links).
|
14
|
+
*
|
15
|
+
* @returns {boolean} - Returns `true` if the target path is considered active; otherwise, `false`.
|
9
16
|
*
|
10
17
|
* @example
|
11
|
-
*
|
12
|
-
*
|
18
|
+
* isActiveLink('/dashboard/user/list', '/dashboard/user'); // true (deep match)
|
19
|
+
* isActiveLink('/dashboard/user', '/dashboard/user?id=123'); // true (query param)
|
20
|
+
* isActiveLink('/dashboard/user', '/dashboard/user', false); // true (exact match)
|
21
|
+
* isActiveLink('/dashboard/user', '/dashboard'); // false
|
22
|
+
* isActiveLink('/dashboard/user', '#section'); // false (hash link)
|
23
|
+
* isActiveLink('/dashboard/user', 'https://example.com'); // false (external link)
|
13
24
|
*/
|
14
|
-
declare function isActiveLink(
|
25
|
+
declare function isActiveLink(currentPathname: string, targetPath: string, deep?: boolean): boolean;
|
15
26
|
|
16
27
|
export { isActiveLink };
|
@@ -1 +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 +1 @@
|
|
1
|
-
"use strict";var o=Object.defineProperty;var
|
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 +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};
|
package/dist/utils/index.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var
|
2
|
-
`));return`rgba(${
|
1
|
+
"use strict";var u=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var I=(e,r)=>{for(var t in r)u(e,t,{get:r[t],enumerable:!0})},C=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of w(r))!$.call(e,n)&&n!==t&&u(e,n,{get:()=>r[n],enumerable:!(o=k(r,n))||o.enumerable});return e};var A=e=>C(u({},"__esModule",{value:!0}),e);var H={};I(H,{createPaletteChannel:()=>O,getCookie:()=>j,getStorage:()=>D,hasKeys:()=>_,hasParams:()=>l,hexToRgbChannel:()=>h,isActiveLink:()=>W,isEqualPath:()=>E,isExternalLink:()=>f,localStorageAvailable:()=>y,mergeClasses:()=>L,mergeRefs:()=>R,pxToRem:()=>N,remToPx:()=>P,removeCookie:()=>F,removeLastSlash:()=>s,removeParams:()=>p,removeStorage:()=>M,setCookie:()=>B,setFont:()=>v,setStorage:()=>J,transformNumber:()=>G,transformValue:()=>g,transformValueOnBlur:()=>S,transformValueOnChange:()=>b,uuidv4:()=>U,varAlpha:()=>V});module.exports=A(H);function l(e){try{let r=new URL(e,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function s(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function E(e,r){return s(e)===s(r)}function p(e){try{let r=new URL(e,window.location.origin);return s(r.pathname)}catch{return e}}function f(e){return/^https?:\/\//i.test(e)}function R(e){return r=>{if(e.length!==0)for(let t of e)t&&(typeof t=="function"?t(r):"current"in t&&(t.current=r))}}var x='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function v(e){return e?`"${e}", ${x}`:x}function P(e){let r=parseFloat(e);return Math.round(r*16)}function N(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function h(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 r=parseInt(e.substring(1,3),16),t=parseInt(e.substring(3,5),16),o=parseInt(e.substring(5,7),16);return`${r} ${t} ${o}`}function O(e){let r={};return Object.entries(e).forEach(([t,o])=>{o&&(r[`${t}Channel`]=h(o))}),{...e,...r}}function V(e,r=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} / ${r})`}function _(e,r){return!e||!r.length||typeof e!="object"?!1:r.every(t=>t in e)}function U(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}function L(e,r){let t=e?Array.isArray(e)?e:[e]:[],o=Object.entries(r||{}).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(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let r=`${e}=`,n=decodeURIComponent(document.cookie).split("; ").find(a=>a.startsWith(r));if(!n)return null;let i=n.substring(r.length);try{return JSON.parse(i)}catch{return i}}catch(r){return console.error("Error retrieving cookie:",r),null}}function B(e,r,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:o=0,sameSite:n="Strict",secure:i=!1,path:a="/",domain:d}=t??{};try{let c=encodeURIComponent(typeof r=="string"?r:JSON.stringify(r)),m=[`${e}=${c}`,`path=${a}`,n&&`SameSite=${n}`,i&&"Secure",d&&`domain=${d}`];if(o>0){let T=new Date(Date.now()+o*24*60*60*1e3);m.push(`expires=${T.toUTCString()}`)}document.cookie=m.filter(Boolean).join("; ")}catch(c){console.error("Error setting cookie:",c)}}function F(e,r){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:t="/",domain:o}=r??{};try{let n=[`${e}=`,"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(e,r,t=!0){if(!e||!r)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(r.startsWith("#")||f(r))return!1;let o=s(e),n=s(p(r));return t||l(r)?o===n||o.startsWith(`${n}/`)||o.startsWith(`${n}?`):o===n}function D(e,r){if(!y())return r??null;let t=localStorage.getItem(e);if(t!=="undefined"){if(t)try{return JSON.parse(t)}catch{return t??r??null}return r??null}}function J(e,r){try{let t=JSON.stringify(r);window.localStorage.setItem(e,t)}catch(t){console.error("Error while setting storage:",t)}}function M(e){try{window.localStorage.removeItem(e)}catch(r){console.error("Error while removing from storage:",r)}}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 g(e,r=""){return e==null||typeof e=="number"&&Number.isNaN(e)?r:e.toString()}function b(e){let t=g(e).replace(/[^0-9.]/g,""),[o,...n]=t.split(".");return n.length>0?`${o}.${n.join("")}`:o}function S(e,r=""){if(e==null||typeof e=="number"&&Number.isNaN(e))return r;let t=parseFloat(e.toString());return Number.isNaN(t)?r:t}var G={onChange:b,onBlur:S,value:g};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});
|
package/dist/utils/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
`));return`rgba(${
|
1
|
+
function p(e){try{let r=new URL(e,window.location.origin);return Array.from(r.searchParams.keys()).length>0}catch{return!1}}function s(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function T(e,r){return s(e)===s(r)}function f(e){try{let r=new URL(e,window.location.origin);return s(r.pathname)}catch{return e}}function g(e){return/^https?:\/\//i.test(e)}function w(e){return r=>{if(e.length!==0)for(let t of e)t&&(typeof t=="function"?t(r):"current"in t&&(t.current=r))}}var d='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function I(e){return e?`"${e}", ${d}`:d}function C(e){let r=parseFloat(e);return Math.round(r*16)}function A(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function h(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 r=parseInt(e.substring(1,3),16),t=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return`${r} ${t} ${n}`}function R(e){let r={};return Object.entries(e).forEach(([t,n])=>{n&&(r[`${t}Channel`]=h(n))}),{...e,...r}}function v(e,r=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} / ${r})`}function N(e,r){return!e||!r.length||typeof e!="object"?!1:r.every(t=>t in e)}function V(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}function U(e,r){let t=e?Array.isArray(e)?e:[e]:[],n=Object.entries(r||{}).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(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let r=`${e}=`,o=decodeURIComponent(document.cookie).split("; ").find(a=>a.startsWith(r));if(!o)return null;let i=o.substring(r.length);try{return JSON.parse(i)}catch{return i}}catch(r){return console.error("Error retrieving cookie:",r),null}}function B(e,r,t){if(!e||typeof e!="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 r=="string"?r:JSON.stringify(r)),l=[`${e}=${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(e,r){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:t="/",domain:n}=r??{};try{let o=[`${e}=`,"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(e,r,t=!0){if(!e||!r)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(r.startsWith("#")||g(r))return!1;let n=s(e),o=s(f(r));return t||p(r)?n===o||n.startsWith(`${o}/`)||n.startsWith(`${o}?`):n===o}function G(e,r){if(!y())return r??null;let t=localStorage.getItem(e);if(t!=="undefined"){if(t)try{return JSON.parse(t)}catch{return t??r??null}return r??null}}function H(e,r){try{let t=JSON.stringify(r);window.localStorage.setItem(e,t)}catch(t){console.error("Error while setting storage:",t)}}function K(e){try{window.localStorage.removeItem(e)}catch(r){console.error("Error while removing from storage:",r)}}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 m(e,r=""){return e==null||typeof e=="number"&&Number.isNaN(e)?r:e.toString()}function b(e){let t=m(e).replace(/[^0-9.]/g,""),[n,...o]=t.split(".");return o.length>0?`${n}.${o.join("")}`:n}function S(e,r=""){if(e==null||typeof e=="number"&&Number.isNaN(e))return r;let t=parseFloat(e.toString());return Number.isNaN(t)?r:t}var q={onChange:b,onBlur:S,value:m};export{R as createPaletteChannel,j as getCookie,G as getStorage,N as hasKeys,p as hasParams,h as hexToRgbChannel,J 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,s as removeLastSlash,f as removeParams,K as removeStorage,B as setCookie,I as setFont,H as setStorage,q as transformNumber,m as transformValue,S as transformValueOnBlur,b as transformValueOnChange,V as uuidv4,v as varAlpha};
|
package/dist/utils/url/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
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});
|
package/dist/utils/url/index.js
CHANGED
@@ -1 +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};
|
package/dist/utils/url/url.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
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});
|
package/dist/utils/url/url.d.cts
CHANGED
@@ -1,53 +1,57 @@
|
|
1
1
|
/**
|
2
2
|
* Checks if a URL has query parameters.
|
3
3
|
*
|
4
|
-
* @param
|
5
|
-
* @returns
|
4
|
+
* @param url - The URL to check.
|
5
|
+
* @returns True if the URL has query parameters, false otherwise.
|
6
6
|
*
|
7
7
|
* @example
|
8
|
-
*
|
9
|
-
*
|
8
|
+
* hasParams('https://example.com?page=1'); // true
|
9
|
+
* hasParams('https://example.com'); // false
|
10
10
|
*/
|
11
|
-
declare
|
11
|
+
declare function hasParams(url: string): boolean;
|
12
12
|
/**
|
13
|
-
* Removes the trailing slash from a pathname if
|
13
|
+
* Removes the trailing slash from a pathname if present.
|
14
14
|
*
|
15
|
-
* @param
|
16
|
-
* @returns
|
15
|
+
* @param pathname - The pathname to process.
|
16
|
+
* @returns The pathname without the trailing slash.
|
17
17
|
*
|
18
18
|
* @example
|
19
|
-
*
|
20
|
-
*
|
19
|
+
* removeLastSlash('/dashboard/'); // '/dashboard'
|
20
|
+
* removeLastSlash('/dashboard'); // '/dashboard'
|
21
21
|
*/
|
22
22
|
declare function removeLastSlash(pathname: string): string;
|
23
23
|
/**
|
24
|
-
* Checks if two
|
24
|
+
* Checks if two paths are equal after removing trailing slashes.
|
25
25
|
*
|
26
|
-
* @param
|
27
|
-
* @param
|
28
|
-
* @returns
|
26
|
+
* @param targetUrl - The target URL to compare.
|
27
|
+
* @param pathname - The pathname to compare.
|
28
|
+
* @returns True if the paths are equal, false otherwise.
|
29
|
+
*
|
30
|
+
* @example
|
31
|
+
* isEqualPath('/dashboard/', '/dashboard'); // true
|
32
|
+
* isEqualPath('/home', '/dashboard'); // false
|
29
33
|
*/
|
30
34
|
declare function isEqualPath(targetUrl: string, pathname: string): boolean;
|
31
35
|
/**
|
32
|
-
* Removes query parameters from a URL.
|
36
|
+
* Removes query parameters from a URL and returns only the cleaned pathname.
|
33
37
|
*
|
34
|
-
* @param
|
35
|
-
* @returns
|
38
|
+
* @param url - The URL to process.
|
39
|
+
* @returns The pathname without query parameters.
|
36
40
|
*
|
37
41
|
* @example
|
38
|
-
*
|
39
|
-
*
|
42
|
+
* removeParams('https://example.com/dashboard/user?id=123'); // '/dashboard/user'
|
43
|
+
* removeParams('/dashboard/user?id=123'); // '/dashboard/user'
|
40
44
|
*/
|
41
45
|
declare function removeParams(url: string): string;
|
42
46
|
/**
|
43
|
-
*
|
47
|
+
* Determines whether a given URL is external (i.e., starts with "http").
|
44
48
|
*
|
45
|
-
* @param
|
46
|
-
* @returns
|
49
|
+
* @param url - The URL to check.
|
50
|
+
* @returns True if the URL is external, false otherwise.
|
47
51
|
*
|
48
52
|
* @example
|
49
|
-
*
|
50
|
-
*
|
53
|
+
* isExternalLink('https://example.com'); // true
|
54
|
+
* isExternalLink('/internal'); // false
|
51
55
|
*/
|
52
56
|
declare function isExternalLink(url: string): boolean;
|
53
57
|
|
package/dist/utils/url/url.d.ts
CHANGED
@@ -1,53 +1,57 @@
|
|
1
1
|
/**
|
2
2
|
* Checks if a URL has query parameters.
|
3
3
|
*
|
4
|
-
* @param
|
5
|
-
* @returns
|
4
|
+
* @param url - The URL to check.
|
5
|
+
* @returns True if the URL has query parameters, false otherwise.
|
6
6
|
*
|
7
7
|
* @example
|
8
|
-
*
|
9
|
-
*
|
8
|
+
* hasParams('https://example.com?page=1'); // true
|
9
|
+
* hasParams('https://example.com'); // false
|
10
10
|
*/
|
11
|
-
declare
|
11
|
+
declare function hasParams(url: string): boolean;
|
12
12
|
/**
|
13
|
-
* Removes the trailing slash from a pathname if
|
13
|
+
* Removes the trailing slash from a pathname if present.
|
14
14
|
*
|
15
|
-
* @param
|
16
|
-
* @returns
|
15
|
+
* @param pathname - The pathname to process.
|
16
|
+
* @returns The pathname without the trailing slash.
|
17
17
|
*
|
18
18
|
* @example
|
19
|
-
*
|
20
|
-
*
|
19
|
+
* removeLastSlash('/dashboard/'); // '/dashboard'
|
20
|
+
* removeLastSlash('/dashboard'); // '/dashboard'
|
21
21
|
*/
|
22
22
|
declare function removeLastSlash(pathname: string): string;
|
23
23
|
/**
|
24
|
-
* Checks if two
|
24
|
+
* Checks if two paths are equal after removing trailing slashes.
|
25
25
|
*
|
26
|
-
* @param
|
27
|
-
* @param
|
28
|
-
* @returns
|
26
|
+
* @param targetUrl - The target URL to compare.
|
27
|
+
* @param pathname - The pathname to compare.
|
28
|
+
* @returns True if the paths are equal, false otherwise.
|
29
|
+
*
|
30
|
+
* @example
|
31
|
+
* isEqualPath('/dashboard/', '/dashboard'); // true
|
32
|
+
* isEqualPath('/home', '/dashboard'); // false
|
29
33
|
*/
|
30
34
|
declare function isEqualPath(targetUrl: string, pathname: string): boolean;
|
31
35
|
/**
|
32
|
-
* Removes query parameters from a URL.
|
36
|
+
* Removes query parameters from a URL and returns only the cleaned pathname.
|
33
37
|
*
|
34
|
-
* @param
|
35
|
-
* @returns
|
38
|
+
* @param url - The URL to process.
|
39
|
+
* @returns The pathname without query parameters.
|
36
40
|
*
|
37
41
|
* @example
|
38
|
-
*
|
39
|
-
*
|
42
|
+
* removeParams('https://example.com/dashboard/user?id=123'); // '/dashboard/user'
|
43
|
+
* removeParams('/dashboard/user?id=123'); // '/dashboard/user'
|
40
44
|
*/
|
41
45
|
declare function removeParams(url: string): string;
|
42
46
|
/**
|
43
|
-
*
|
47
|
+
* Determines whether a given URL is external (i.e., starts with "http").
|
44
48
|
*
|
45
|
-
* @param
|
46
|
-
* @returns
|
49
|
+
* @param url - The URL to check.
|
50
|
+
* @returns True if the URL is external, false otherwise.
|
47
51
|
*
|
48
52
|
* @example
|
49
|
-
*
|
50
|
-
*
|
53
|
+
* isExternalLink('https://example.com'); // true
|
54
|
+
* isExternalLink('/internal'); // false
|
51
55
|
*/
|
52
56
|
declare function isExternalLink(url: string): boolean;
|
53
57
|
|
package/dist/utils/url/url.js
CHANGED
@@ -1 +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};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "minimal-shared",
|
3
3
|
"author": "Minimals",
|
4
|
-
"version": "1.0.
|
4
|
+
"version": "1.0.8",
|
5
5
|
"description": "Shared hooks and utils used by Minimal UI and Zone UI.",
|
6
6
|
"keywords": [
|
7
7
|
"typescript",
|
@@ -61,7 +61,6 @@
|
|
61
61
|
"@testing-library/react": "^16.2.0",
|
62
62
|
"@types/node": "^22.13.5",
|
63
63
|
"@types/react": "19.0.10",
|
64
|
-
"chalk": "^5.4.1",
|
65
64
|
"jsdom": "^26.0.0",
|
66
65
|
"react": "^19.0.0",
|
67
66
|
"tsup": "^8.3.6",
|