@med_ghoul/forge-shared 1.2.0
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/README.md +158 -0
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.d.cts +19 -0
- package/dist/hooks/index.d.ts +19 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/use-back-to-top/index.cjs +1 -0
- package/dist/hooks/use-back-to-top/index.d.cts +2 -0
- package/dist/hooks/use-back-to-top/index.d.ts +2 -0
- package/dist/hooks/use-back-to-top/index.js +1 -0
- package/dist/hooks/use-back-to-top/use-back-to-top.cjs +1 -0
- package/dist/hooks/use-back-to-top/use-back-to-top.d.cts +33 -0
- package/dist/hooks/use-back-to-top/use-back-to-top.d.ts +33 -0
- package/dist/hooks/use-back-to-top/use-back-to-top.js +1 -0
- package/dist/hooks/use-boolean/index.cjs +1 -0
- package/dist/hooks/use-boolean/index.d.cts +2 -0
- package/dist/hooks/use-boolean/index.d.ts +2 -0
- package/dist/hooks/use-boolean/index.js +1 -0
- package/dist/hooks/use-boolean/use-boolean.cjs +1 -0
- package/dist/hooks/use-boolean/use-boolean.d.cts +29 -0
- package/dist/hooks/use-boolean/use-boolean.d.ts +29 -0
- package/dist/hooks/use-boolean/use-boolean.js +1 -0
- package/dist/hooks/use-client-rect/index.cjs +1 -0
- package/dist/hooks/use-client-rect/index.d.cts +2 -0
- package/dist/hooks/use-client-rect/index.d.ts +2 -0
- package/dist/hooks/use-client-rect/index.js +1 -0
- package/dist/hooks/use-client-rect/use-client-rect.cjs +1 -0
- package/dist/hooks/use-client-rect/use-client-rect.d.cts +29 -0
- package/dist/hooks/use-client-rect/use-client-rect.d.ts +29 -0
- package/dist/hooks/use-client-rect/use-client-rect.js +1 -0
- package/dist/hooks/use-cookies/index.cjs +1 -0
- package/dist/hooks/use-cookies/index.d.cts +2 -0
- package/dist/hooks/use-cookies/index.d.ts +2 -0
- package/dist/hooks/use-cookies/index.js +1 -0
- package/dist/hooks/use-cookies/use-cookies.cjs +1 -0
- package/dist/hooks/use-cookies/use-cookies.d.cts +40 -0
- package/dist/hooks/use-cookies/use-cookies.d.ts +40 -0
- package/dist/hooks/use-cookies/use-cookies.js +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.cjs +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.d.cts +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.d.ts +1 -0
- package/dist/hooks/use-copy-to-clipboard/index.js +1 -0
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.cjs +1 -0
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.d.cts +26 -0
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.d.ts +26 -0
- package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.js +1 -0
- package/dist/hooks/use-countdown-date/index.cjs +1 -0
- package/dist/hooks/use-countdown-date/index.d.cts +1 -0
- package/dist/hooks/use-countdown-date/index.d.ts +1 -0
- package/dist/hooks/use-countdown-date/index.js +1 -0
- package/dist/hooks/use-countdown-date/use-countdown-date.cjs +1 -0
- package/dist/hooks/use-countdown-date/use-countdown-date.d.cts +29 -0
- package/dist/hooks/use-countdown-date/use-countdown-date.d.ts +29 -0
- package/dist/hooks/use-countdown-date/use-countdown-date.js +1 -0
- package/dist/hooks/use-countdown-seconds/index.cjs +1 -0
- package/dist/hooks/use-countdown-seconds/index.d.cts +2 -0
- package/dist/hooks/use-countdown-seconds/index.d.ts +2 -0
- package/dist/hooks/use-countdown-seconds/index.js +1 -0
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.cjs +1 -0
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.d.cts +35 -0
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.d.ts +35 -0
- package/dist/hooks/use-countdown-seconds/use-countdown-seconds.js +1 -0
- package/dist/hooks/use-debounce/index.cjs +1 -0
- package/dist/hooks/use-debounce/index.d.cts +1 -0
- package/dist/hooks/use-debounce/index.d.ts +1 -0
- package/dist/hooks/use-debounce/index.js +1 -0
- package/dist/hooks/use-debounce/use-debounce.cjs +1 -0
- package/dist/hooks/use-debounce/use-debounce.d.cts +21 -0
- package/dist/hooks/use-debounce/use-debounce.d.ts +21 -0
- package/dist/hooks/use-debounce/use-debounce.js +1 -0
- package/dist/hooks/use-double-click/index.cjs +1 -0
- package/dist/hooks/use-double-click/index.d.cts +2 -0
- package/dist/hooks/use-double-click/index.d.ts +2 -0
- package/dist/hooks/use-double-click/index.js +1 -0
- package/dist/hooks/use-double-click/use-double-click.cjs +1 -0
- package/dist/hooks/use-double-click/use-double-click.d.cts +28 -0
- package/dist/hooks/use-double-click/use-double-click.d.ts +28 -0
- package/dist/hooks/use-double-click/use-double-click.js +1 -0
- package/dist/hooks/use-is-client/index.cjs +1 -0
- package/dist/hooks/use-is-client/index.d.cts +1 -0
- package/dist/hooks/use-is-client/index.d.ts +1 -0
- package/dist/hooks/use-is-client/index.js +1 -0
- package/dist/hooks/use-is-client/use-is-client.cjs +1 -0
- package/dist/hooks/use-is-client/use-is-client.d.cts +18 -0
- package/dist/hooks/use-is-client/use-is-client.d.ts +18 -0
- package/dist/hooks/use-is-client/use-is-client.js +1 -0
- package/dist/hooks/use-local-storage/index.cjs +1 -0
- package/dist/hooks/use-local-storage/index.d.cts +1 -0
- package/dist/hooks/use-local-storage/index.d.ts +1 -0
- package/dist/hooks/use-local-storage/index.js +1 -0
- package/dist/hooks/use-local-storage/use-local-storage.cjs +1 -0
- package/dist/hooks/use-local-storage/use-local-storage.d.cts +38 -0
- package/dist/hooks/use-local-storage/use-local-storage.d.ts +38 -0
- package/dist/hooks/use-local-storage/use-local-storage.js +1 -0
- package/dist/hooks/use-multi-select/index.cjs +1 -0
- package/dist/hooks/use-multi-select/index.d.cts +2 -0
- package/dist/hooks/use-multi-select/index.d.ts +2 -0
- package/dist/hooks/use-multi-select/index.js +1 -0
- package/dist/hooks/use-multi-select/use-multi-select.cjs +1 -0
- package/dist/hooks/use-multi-select/use-multi-select.d.cts +55 -0
- package/dist/hooks/use-multi-select/use-multi-select.d.ts +55 -0
- package/dist/hooks/use-multi-select/use-multi-select.js +1 -0
- package/dist/hooks/use-popover/index.cjs +1 -0
- package/dist/hooks/use-popover/index.d.cts +2 -0
- package/dist/hooks/use-popover/index.d.ts +2 -0
- package/dist/hooks/use-popover/index.js +1 -0
- package/dist/hooks/use-popover/use-popover.cjs +1 -0
- package/dist/hooks/use-popover/use-popover.d.cts +35 -0
- package/dist/hooks/use-popover/use-popover.d.ts +35 -0
- package/dist/hooks/use-popover/use-popover.js +1 -0
- package/dist/hooks/use-popover-hover/index.cjs +1 -0
- package/dist/hooks/use-popover-hover/index.d.cts +2 -0
- package/dist/hooks/use-popover-hover/index.d.ts +2 -0
- package/dist/hooks/use-popover-hover/index.js +1 -0
- package/dist/hooks/use-popover-hover/use-popover-hover.cjs +1 -0
- package/dist/hooks/use-popover-hover/use-popover-hover.d.cts +41 -0
- package/dist/hooks/use-popover-hover/use-popover-hover.d.ts +41 -0
- package/dist/hooks/use-popover-hover/use-popover-hover.js +1 -0
- package/dist/hooks/use-scroll-offset-top/index.cjs +1 -0
- package/dist/hooks/use-scroll-offset-top/index.d.cts +2 -0
- package/dist/hooks/use-scroll-offset-top/index.d.ts +2 -0
- package/dist/hooks/use-scroll-offset-top/index.js +1 -0
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.cjs +1 -0
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.d.cts +28 -0
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.d.ts +28 -0
- package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.js +1 -0
- package/dist/hooks/use-set-state/index.cjs +1 -0
- package/dist/hooks/use-set-state/index.d.cts +1 -0
- package/dist/hooks/use-set-state/index.d.ts +1 -0
- package/dist/hooks/use-set-state/index.js +1 -0
- package/dist/hooks/use-set-state/use-set-state.cjs +1 -0
- package/dist/hooks/use-set-state/use-set-state.d.cts +32 -0
- package/dist/hooks/use-set-state/use-set-state.d.ts +32 -0
- package/dist/hooks/use-set-state/use-set-state.js +1 -0
- package/dist/hooks/use-tabs/index.cjs +1 -0
- package/dist/hooks/use-tabs/index.d.cts +2 -0
- package/dist/hooks/use-tabs/index.d.ts +2 -0
- package/dist/hooks/use-tabs/index.js +1 -0
- package/dist/hooks/use-tabs/use-tabs.cjs +1 -0
- package/dist/hooks/use-tabs/use-tabs.d.cts +58 -0
- package/dist/hooks/use-tabs/use-tabs.d.ts +58 -0
- package/dist/hooks/use-tabs/use-tabs.js +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +2 -0
- package/dist/utils/active-link/active-link.cjs +1 -0
- package/dist/utils/active-link/active-link.d.cts +27 -0
- package/dist/utils/active-link/active-link.d.ts +27 -0
- package/dist/utils/active-link/active-link.js +1 -0
- package/dist/utils/active-link/index.cjs +1 -0
- package/dist/utils/active-link/index.d.cts +1 -0
- package/dist/utils/active-link/index.d.ts +1 -0
- package/dist/utils/active-link/index.js +1 -0
- package/dist/utils/classes/classes.cjs +1 -0
- package/dist/utils/classes/classes.d.cts +25 -0
- package/dist/utils/classes/classes.d.ts +25 -0
- package/dist/utils/classes/classes.js +1 -0
- package/dist/utils/classes/index.cjs +1 -0
- package/dist/utils/classes/index.d.cts +1 -0
- package/dist/utils/classes/index.d.ts +1 -0
- package/dist/utils/classes/index.js +1 -0
- package/dist/utils/color/color.cjs +2 -0
- package/dist/utils/color/color.d.cts +52 -0
- package/dist/utils/color/color.d.ts +52 -0
- package/dist/utils/color/color.js +2 -0
- package/dist/utils/color/index.cjs +2 -0
- package/dist/utils/color/index.d.cts +1 -0
- package/dist/utils/color/index.d.ts +1 -0
- package/dist/utils/color/index.js +2 -0
- package/dist/utils/cookies/cookies.cjs +1 -0
- package/dist/utils/cookies/cookies.d.cts +42 -0
- package/dist/utils/cookies/cookies.d.ts +42 -0
- package/dist/utils/cookies/cookies.js +1 -0
- package/dist/utils/cookies/index.cjs +1 -0
- package/dist/utils/cookies/index.d.cts +1 -0
- package/dist/utils/cookies/index.d.ts +1 -0
- package/dist/utils/cookies/index.js +1 -0
- package/dist/utils/css-variables/css-variables.cjs +1 -0
- package/dist/utils/css-variables/css-variables.d.cts +14 -0
- package/dist/utils/css-variables/css-variables.d.ts +14 -0
- package/dist/utils/css-variables/css-variables.js +1 -0
- package/dist/utils/css-variables/index.cjs +1 -0
- package/dist/utils/css-variables/index.d.cts +1 -0
- package/dist/utils/css-variables/index.d.ts +1 -0
- package/dist/utils/css-variables/index.js +1 -0
- package/dist/utils/font/font.cjs +1 -0
- package/dist/utils/font/font.d.cts +37 -0
- package/dist/utils/font/font.d.ts +37 -0
- package/dist/utils/font/font.js +1 -0
- package/dist/utils/font/index.cjs +1 -0
- package/dist/utils/font/index.d.cts +1 -0
- package/dist/utils/font/index.d.ts +1 -0
- package/dist/utils/font/index.js +1 -0
- package/dist/utils/index.cjs +2 -0
- package/dist/utils/index.d.cts +13 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/local-storage/index.cjs +1 -0
- package/dist/utils/local-storage/index.d.cts +1 -0
- package/dist/utils/local-storage/index.d.ts +1 -0
- package/dist/utils/local-storage/index.js +1 -0
- package/dist/utils/local-storage/local-storage.cjs +1 -0
- package/dist/utils/local-storage/local-storage.d.cts +43 -0
- package/dist/utils/local-storage/local-storage.d.ts +43 -0
- package/dist/utils/local-storage/local-storage.js +1 -0
- package/dist/utils/object/index.cjs +1 -0
- package/dist/utils/object/index.d.cts +1 -0
- package/dist/utils/object/index.d.ts +1 -0
- package/dist/utils/object/index.js +1 -0
- package/dist/utils/object/object.cjs +1 -0
- package/dist/utils/object/object.d.cts +26 -0
- package/dist/utils/object/object.d.ts +26 -0
- package/dist/utils/object/object.js +1 -0
- package/dist/utils/refs/index.cjs +1 -0
- package/dist/utils/refs/index.d.cts +1 -0
- package/dist/utils/refs/index.d.ts +1 -0
- package/dist/utils/refs/index.js +1 -0
- package/dist/utils/refs/refs.cjs +1 -0
- package/dist/utils/refs/refs.d.cts +3 -0
- package/dist/utils/refs/refs.d.ts +3 -0
- package/dist/utils/refs/refs.js +1 -0
- package/dist/utils/right-to-left/index.cjs +1 -0
- package/dist/utils/right-to-left/index.d.cts +1 -0
- package/dist/utils/right-to-left/index.d.ts +1 -0
- package/dist/utils/right-to-left/index.js +1 -0
- package/dist/utils/right-to-left/right-to-left.cjs +1 -0
- package/dist/utils/right-to-left/right-to-left.d.cts +13 -0
- package/dist/utils/right-to-left/right-to-left.d.ts +13 -0
- package/dist/utils/right-to-left/right-to-left.js +1 -0
- package/dist/utils/transform-number/index.cjs +1 -0
- package/dist/utils/transform-number/index.d.cts +1 -0
- package/dist/utils/transform-number/index.d.ts +1 -0
- package/dist/utils/transform-number/index.js +1 -0
- package/dist/utils/transform-number/transform-number.cjs +1 -0
- package/dist/utils/transform-number/transform-number.d.cts +31 -0
- package/dist/utils/transform-number/transform-number.d.ts +31 -0
- package/dist/utils/transform-number/transform-number.js +1 -0
- package/dist/utils/url/index.cjs +1 -0
- package/dist/utils/url/index.d.cts +1 -0
- package/dist/utils/url/index.d.ts +1 -0
- package/dist/utils/url/index.js +1 -0
- package/dist/utils/url/url.cjs +1 -0
- package/dist/utils/url/url.d.cts +74 -0
- package/dist/utils/url/url.d.ts +74 -0
- package/dist/utils/url/url.js +1 -0
- package/dist/utils/uuidv4/index.cjs +1 -0
- package/dist/utils/uuidv4/index.d.cts +1 -0
- package/dist/utils/uuidv4/index.d.ts +1 -0
- package/dist/utils/uuidv4/index.js +1 -0
- package/dist/utils/uuidv4/uuidv4.cjs +1 -0
- package/dist/utils/uuidv4/uuidv4.d.cts +12 -0
- package/dist/utils/uuidv4/uuidv4.d.ts +12 -0
- package/dist/utils/uuidv4/uuidv4.js +1 -0
- package/package.json +113 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var P=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Z(t))!ee.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=X(t,r))||o.enumerable});return e};var oe=e=>ne(P({},"__esModule",{value:!0}),e);var je={};te(je,{createPaletteChannel:()=>ce,getCookie:()=>j,getStorage:()=>N,hasKeys:()=>de,hasParams:()=>A,hexToRgbChannel:()=>Y,isActiveLink:()=>ge,isEqualPath:()=>re,isExternalLink:()=>H,localStorageAvailable:()=>q,mergeClasses:()=>Te,mergeRefs:()=>ie,noRtlFlip:()=>be,parseCssVar:()=>he,pxToRem:()=>ue,remToPx:()=>le,removeCookie:()=>F,removeLastSlash:()=>y,removeParams:()=>D,removeStorage:()=>W,safeReturnUrl:()=>se,setCookie:()=>E,setFont:()=>ae,setStorage:()=>k,transformNumber:()=>Se,transformValue:()=>B,transformValueOnBlur:()=>K,transformValueOnChange:()=>G,updateSelectedItems:()=>Q,useBackToTop:()=>ke,useBoolean:()=>ye,useClientRect:()=>Oe,useCookies:()=>Ce,useCopyToClipboard:()=>He,useCountdownDate:()=>Ie,useCountdownSeconds:()=>De,useDebounce:()=>we,useDoubleClick:()=>Le,useIsClient:()=>Ee,useLocalStorage:()=>Ve,useMultiSelect:()=>Me,usePopover:()=>ve,usePopoverHover:()=>$e,useScrollOffsetTop:()=>Ae,useSetState:()=>Re,useTabs:()=>xe,uuidv4:()=>me,varAlpha:()=>fe});module.exports=oe(je);var z=require("es-toolkit");function A(e){try{let t=new URL(e,window.location.origin);return Array.from(t.searchParams.keys()).length>0}catch{return!1}}function y(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function re(e,t,n={deep:!0}){let o=r=>{try{let{pathname:s,searchParams:i}=new URL(r.trim(),"http://dummy");return n.deep?{pathname:y(s),params:Object.fromEntries(i)}:{pathname:y(s)}}catch{return{pathname:""}}};return(0,z.isEqual)(o(t),o(e))}function D(e){try{let t=new URL(e,window.location.origin);return y(t.pathname)}catch{return e}}function H(e){return/^https?:\/\//i.test(e)}function se(e,t){let n=t??"/";if(!e||typeof window>"u"||!window.location?.origin)return n;try{let o=new URL(e,window.location.origin),r=o.origin===window.location.origin,s=o.pathname.startsWith("/")&&!o.pathname.startsWith("//"),i=/^\/:+$/.test(o.pathname),a=o.pathname==="/"&&!o.search&&o.hash;return r&&s&&!i&&!a?`${o.pathname}${o.search}${o.hash}`:n}catch{return e.startsWith("/")&&!e.startsWith("//")?e:n}}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 J='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function ae(e){return e?`"${e}", ${J}`:J}function le(e){let t=parseFloat(e);return Math.round(t*16)}function ue(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function Y(e){if(!e)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(e))throw new Error(`Invalid hex color: ${e}`);let t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),o=parseInt(e.substring(5,7),16);return`${t} ${n} ${o}`}function ce(e){let t={};return Object.entries(e).forEach(([n,o])=>{o&&(t[`${n}Channel`]=Y(o))}),{...e,...t}}function pe(e,t){let n=s=>s.includes("var(--"),o=s=>s.trim().endsWith("%"),r={invalid:`[Alpha]: Invalid opacity "${e}" for ${t}.`,range:"Must be a number between 0 and 1 (e.g., 0.48).",format:'Must be a percentage (e.g., "48%") or CSS variable (e.g., "var(--opacity)").'};if(typeof e=="string"){if(o(e))return e;if(n(e))return`calc(${e} * 100%)`;let s=parseFloat(e.trim());if(!isNaN(s)&&s>=0&&s<=1)return`${Number((s*100).toFixed(2))}%`;throw new Error(`${r.invalid} ${r.format}`)}if(typeof e=="number"){if(e>=0&&e<=1)return`${Number((e*100).toFixed(2))}%`;throw new Error(`${r.invalid} ${r.range}`)}throw new Error(`${r.invalid}`)}function fe(e,t=1){if(!e?.trim())throw new Error("[Alpha]: Color is undefined or empty!");if(e.startsWith("#")||e.startsWith("rgb")||e.startsWith("rgba")||!e.includes("var")&&e.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${e}"`,"\u2705 Supported formats:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"\u274C Unsupported formats:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
|
|
2
|
+
`));let o=pe(t,e);return e.toLowerCase()==="currentcolor"?`color-mix(in srgb, currentColor ${o}, transparent)`:`rgba(${e} / ${o})`}function de(e,t){return!e||!t.length||typeof e!="object"?!1:t.every(n=>n in e)}function me(){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 Te(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 j(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 E(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:a}=n??{};try{let l=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),c=[`${e}=${l}`,`path=${i}`,r&&`SameSite=${r}`,s&&"Secure",a&&`domain=${a}`];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(l){console.error("Error setting cookie:",l)}}function F(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){if(!e||!t)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(t.startsWith("#")||H(t))return!1;let o=y(e),r=y(D(t));return n||A(t)?o===r||o.startsWith(`${r}/`)||o.startsWith(`${r}?`):o===r}function N(e,t){if(!q())return t??null;let n=localStorage.getItem(e);if(n!=="undefined"){if(n)try{return JSON.parse(n)}catch{return n??t??null}return t??null}}function k(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function W(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function q(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function he(e){if(typeof e!="string"||!e.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let t=e.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return t?t[1]:(console.error(`Invalid CSS variable format: "${e}". Expected format: var(--variable-name)`),"")}function be(e){if(typeof e!="string")return console.warn("Invalid CSS value provided"),"";let t=e.trim();return t?t.includes("/* @noflip */")?t:`${t} /* @noflip */`:(console.warn("Empty CSS value provided"),"")}function B(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function G(e){let n=B(e).replace(/[^0-9.]/g,""),[o,...r]=n.split(".");return r.length>0?`${o}.${r.join("")}`:o}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 Se={onChange:G,onBlur:K,value:B};var U=require("react");function xe(e=!1){let[t,n]=(0,U.useState)(e),o=(0,U.useCallback)((s,i)=>{n(i)},[]),r=(0,U.useCallback)(()=>{n(e)},[e]);return{value:t,setValue:n,onChange:o,reset:r}}var C=require("react");function ye(e=!1){let[t,n]=(0,C.useState)(e),o=(0,C.useCallback)(()=>{n(!0)},[]),r=(0,C.useCallback)(()=>{n(!1)},[]),s=(0,C.useCallback)(()=>{n(i=>!i)},[]);return{value:t,onTrue:o,onFalse:r,onToggle:s,setValue:n}}var O=require("react");function ve(){let[e,t]=(0,O.useState)(null),n=(0,O.useCallback)(r=>{t(r.currentTarget)},[]),o=(0,O.useCallback)(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:n,onClose:o,setAnchorEl:t}}var m=require("react");function Ce(e,t,n){let{initializeWithValue:o=!0,...r}=n??{},s=t&&typeof t=="object",[i,a]=(0,m.useState)(t);(0,m.useEffect)(()=>{let u=j(e);u?a(s?g=>({...g,...u}):u):t&&o&&E(e,t,r)},[]);let l=(0,m.useCallback)(u=>{s?a(g=>{let _={...g,...u};return E(e,_,r),_}):(E(e,u,r),a(u))},[r,s,e]),c=(0,m.useCallback)((u,g)=>{s&&l({[u]:g})},[s,l]),p=(0,m.useCallback)(u=>{a(u??t),F(e)},[t,e]);return(0,m.useMemo)(()=>({state:i,setState:l,setField:c,resetState:p}),[p,c,l,i])}var L=require("react");function we(e,t=1e3){let[n,o]=(0,L.useState)(e);return(0,L.useEffect)(()=>{let r=setTimeout(()=>{o(e)},t);return()=>{clearTimeout(r)}},[e,t]),n}var w=require("react");function Re(e){let[t,n]=(0,w.useState)(e),o=(0,w.useCallback)(i=>{n(a=>({...a,...i}))},[]),r=(0,w.useCallback)((i,a)=>{o({[i]:a})},[o]),s=(0,w.useCallback)(i=>{n(i??e)},[e]);return{state:t,setState:o,setField:r,resetState:s}}var V=require("react");function Ee(){let[e,t]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{t(!0)},[]),e}var h=require("react");function ke(e,t){let[n,o]=(0,h.useState)(!1),r=Ue(e),s=(0,h.useCallback)(()=>{let l=window.innerHeight,c=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(c/(p-l)*100);if(r.type==="percentage")o(f>=r.value);else{let u=p-l-c;o(r.value>=u)}},[r.type,r.value]),i=(0,h.useMemo)(()=>{let l;return()=>{clearTimeout(l),l=setTimeout(s,100)}},[s]);return(0,h.useEffect)(()=>{let l=t?i:s;return window.addEventListener("scroll",l),()=>{window.removeEventListener("scroll",l)}},[i,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:o}}function Ue(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 Oe(e,t){let n=(0,d.useRef)(null),o=e||n,[r,s]=(0,d.useState)(void 0),[i,a]=(0,d.useState)(void 0),l=typeof window<"u"?d.useLayoutEffect:d.useEffect,c=(0,d.useCallback)(()=>{if(o.current){let u=o.current.getBoundingClientRect();s(u),a({scrollWidth:o.current.scrollWidth,scrollHeight:o.current.scrollHeight})}},[o]);l(()=>{c()},[c]),(0,d.useEffect)(()=>{let u=t||"resize";return window.addEventListener(u,c),()=>{window.removeEventListener(u,c)}},[t,c]);let p=(0,d.useMemo)(()=>r,[r]),f=(0,d.useMemo)(()=>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}}var b=require("react");function Me(e,t){let[n,o]=(0,b.useState)(t??[]),r=(0,b.useCallback)(l=>{o(c=>Q(c,l))},[]),s=(0,b.useCallback)(()=>{o(l=>l.length===e.length?[]:e)},[e]),i=(0,b.useCallback)(()=>{o([])},[]),a=(0,b.useMemo)(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:a,setValues:o,onSelectAllItems:s,onDeSelectAllItems:i,onToggleSelectItem:r}}function Q(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}var M=require("react");function Le({click:e,doubleClick:t,timeout:n=250}){let o=(0,M.useRef)(null),r=(0,M.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]);return(0,M.useCallback)(i=>{r(),e&&i.detail===1&&(o.current=setTimeout(()=>{e(i)},n)),i.detail%2===0&&t(i)},[e,t,n,r])}var T=require("react");function Ve(e,t,n){let{initializeWithValue:o=!0}=n??{},r=t&&typeof t=="object",[s,i]=(0,T.useState)(t);(0,T.useEffect)(()=>{let f=N(e);f?i(r?u=>({...u,...f}):f):t&&o&&k(e,t)},[]);let a=(0,T.useCallback)(f=>{r?i(u=>{let g={...u,...f};return k(e,g),g}):(k(e,f),i(f))},[e,r]),l=(0,T.useCallback)((f,u)=>{r&&a({[f]:u})},[r,a]),c=(0,T.useCallback)(f=>{i(f??t),W(e)},[t,e]);return(0,T.useMemo)(()=>({state:s,setState:a,setField:l,resetState:c}),[c,l,a,s])}var v=require("react");function $e(e){let t=(0,v.useRef)(null),n=e||t,[o,r]=(0,v.useState)(!1),s=(0,v.useCallback)(()=>{r(!0)},[]),i=(0,v.useCallback)(()=>{r(!1)},[]);return{elementRef:n,anchorEl:n.current,open:o,onOpen:s,onClose:i,setOpen:r}}var R=require("react");function Ie(e,t="- -"){let[n,o]=(0,R.useState)({days:t,hours:t,minutes:t,seconds:t}),r=(0,R.useCallback)(()=>{let s=new Date,{days:i,hours:a,minutes:l,seconds:c}=Pe(e,s);o({days:$(i),hours:$(a),minutes:$(l),seconds:$(c)})},[e]);return(0,R.useEffect)(()=>{r();let s=setInterval(r,1e3);return()=>clearInterval(s)},[]),n}function $(e){return String(e).length===1?`0${e}`:`${e}`}function Pe(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 Ae(e=0){let t=(0,S.useRef)(null),[n,o]=(0,S.useState)(!1),r=(0,S.useCallback)(()=>{let s=window.scrollY;if(t.current){let i=t.current.offsetTop;o(s>i-e)}else o(s>e)},[e]);return(0,S.useEffect)(()=>(r(),window.addEventListener("scroll",r),()=>{window.removeEventListener("scroll",r)}),[r]),{elementRef:t,offsetTop:n}}var x=require("react");function De(e){let[t,n]=(0,x.useState)(e),[o,r]=(0,x.useState)(!1),s=(0,x.useCallback)(()=>{r(!0)},[]),i=(0,x.useCallback)(()=>{r(!1),n(e)},[e]);return(0,x.useEffect)(()=>{let a=null;return o&&t>0?a=setInterval(()=>{n(l=>l-1)},1e3):t<=0&&r(!1),()=>{a&&clearInterval(a)}},[o,t]),{value:t,setValue:n,isCounting:o,start:s,reset:i}}var I=require("react");function He(){let[e,t]=(0,I.useState)(null);return{copy:(0,I.useCallback)(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}}0&&(module.exports={createPaletteChannel,getCookie,getStorage,hasKeys,hasParams,hexToRgbChannel,isActiveLink,isEqualPath,isExternalLink,localStorageAvailable,mergeClasses,mergeRefs,noRtlFlip,parseCssVar,pxToRem,remToPx,removeCookie,removeLastSlash,removeParams,removeStorage,safeReturnUrl,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
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams, safeReturnUrl } from './utils/url/url.cjs';
|
|
2
|
+
export { mergeRefs } from './utils/refs/refs.cjs';
|
|
3
|
+
export { pxToRem, remToPx, setFont } from './utils/font/font.cjs';
|
|
4
|
+
export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './utils/color/color.cjs';
|
|
5
|
+
export { hasKeys } from './utils/object/object.cjs';
|
|
6
|
+
export { uuidv4 } from './utils/uuidv4/uuidv4.cjs';
|
|
7
|
+
export { StateProps, mergeClasses } from './utils/classes/classes.cjs';
|
|
8
|
+
export { CookieOptions, getCookie, removeCookie, setCookie } from './utils/cookies/cookies.cjs';
|
|
9
|
+
export { isActiveLink } from './utils/active-link/active-link.cjs';
|
|
10
|
+
export { getStorage, localStorageAvailable, removeStorage, setStorage } from './utils/local-storage/local-storage.cjs';
|
|
11
|
+
export { parseCssVar } from './utils/css-variables/css-variables.cjs';
|
|
12
|
+
export { noRtlFlip } from './utils/right-to-left/right-to-left.cjs';
|
|
13
|
+
export { InputValue, transformNumber, transformValue, transformValueOnBlur, transformValueOnChange } from './utils/transform-number/transform-number.cjs';
|
|
14
|
+
export { UseTabsReturn, useTabs } from './hooks/use-tabs/use-tabs.cjs';
|
|
15
|
+
export { UseBooleanReturn, useBoolean } from './hooks/use-boolean/use-boolean.cjs';
|
|
16
|
+
export { UsePopoverReturn, usePopover } from './hooks/use-popover/use-popover.cjs';
|
|
17
|
+
export { UseCookiesOptions, UseCookiesReturn, useCookies } from './hooks/use-cookies/use-cookies.cjs';
|
|
18
|
+
export { UseDebounceReturn, useDebounce } from './hooks/use-debounce/use-debounce.cjs';
|
|
19
|
+
export { UseSetStateReturn, useSetState } from './hooks/use-set-state/use-set-state.cjs';
|
|
20
|
+
export { UseIsClientReturn, useIsClient } from './hooks/use-is-client/use-is-client.cjs';
|
|
21
|
+
export { UseBackToTopReturn, useBackToTop } from './hooks/use-back-to-top/use-back-to-top.cjs';
|
|
22
|
+
export { UseClientRectReturn, useClientRect } from './hooks/use-client-rect/use-client-rect.cjs';
|
|
23
|
+
export { UseMultiSelectReturn, updateSelectedItems, useMultiSelect } from './hooks/use-multi-select/use-multi-select.cjs';
|
|
24
|
+
export { UseDoubleClickReturn, useDoubleClick } from './hooks/use-double-click/use-double-click.cjs';
|
|
25
|
+
export { UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from './hooks/use-local-storage/use-local-storage.cjs';
|
|
26
|
+
export { usePopoverHover } from './hooks/use-popover-hover/use-popover-hover.cjs';
|
|
27
|
+
export { UseCountdownDateReturn, useCountdownDate } from './hooks/use-countdown-date/use-countdown-date.cjs';
|
|
28
|
+
export { UseScrollOffsetTopReturn, useScrollOffsetTop } from './hooks/use-scroll-offset-top/use-scroll-offset-top.cjs';
|
|
29
|
+
export { UseCountdownSecondsReturn, useCountdownSeconds } from './hooks/use-countdown-seconds/use-countdown-seconds.cjs';
|
|
30
|
+
export { CopiedValue, CopyFn, UseCopyToClipboardReturn, useCopyToClipboard } from './hooks/use-copy-to-clipboard/use-copy-to-clipboard.cjs';
|
|
31
|
+
import 'react';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { EqualPathOptions, hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams, safeReturnUrl } from './utils/url/url.js';
|
|
2
|
+
export { mergeRefs } from './utils/refs/refs.js';
|
|
3
|
+
export { pxToRem, remToPx, setFont } from './utils/font/font.js';
|
|
4
|
+
export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './utils/color/color.js';
|
|
5
|
+
export { hasKeys } from './utils/object/object.js';
|
|
6
|
+
export { uuidv4 } from './utils/uuidv4/uuidv4.js';
|
|
7
|
+
export { StateProps, mergeClasses } from './utils/classes/classes.js';
|
|
8
|
+
export { CookieOptions, getCookie, removeCookie, setCookie } from './utils/cookies/cookies.js';
|
|
9
|
+
export { isActiveLink } from './utils/active-link/active-link.js';
|
|
10
|
+
export { getStorage, localStorageAvailable, removeStorage, setStorage } from './utils/local-storage/local-storage.js';
|
|
11
|
+
export { parseCssVar } from './utils/css-variables/css-variables.js';
|
|
12
|
+
export { noRtlFlip } from './utils/right-to-left/right-to-left.js';
|
|
13
|
+
export { InputValue, transformNumber, transformValue, transformValueOnBlur, transformValueOnChange } from './utils/transform-number/transform-number.js';
|
|
14
|
+
export { UseTabsReturn, useTabs } from './hooks/use-tabs/use-tabs.js';
|
|
15
|
+
export { UseBooleanReturn, useBoolean } from './hooks/use-boolean/use-boolean.js';
|
|
16
|
+
export { UsePopoverReturn, usePopover } from './hooks/use-popover/use-popover.js';
|
|
17
|
+
export { UseCookiesOptions, UseCookiesReturn, useCookies } from './hooks/use-cookies/use-cookies.js';
|
|
18
|
+
export { UseDebounceReturn, useDebounce } from './hooks/use-debounce/use-debounce.js';
|
|
19
|
+
export { UseSetStateReturn, useSetState } from './hooks/use-set-state/use-set-state.js';
|
|
20
|
+
export { UseIsClientReturn, useIsClient } from './hooks/use-is-client/use-is-client.js';
|
|
21
|
+
export { UseBackToTopReturn, useBackToTop } from './hooks/use-back-to-top/use-back-to-top.js';
|
|
22
|
+
export { UseClientRectReturn, useClientRect } from './hooks/use-client-rect/use-client-rect.js';
|
|
23
|
+
export { UseMultiSelectReturn, updateSelectedItems, useMultiSelect } from './hooks/use-multi-select/use-multi-select.js';
|
|
24
|
+
export { UseDoubleClickReturn, useDoubleClick } from './hooks/use-double-click/use-double-click.js';
|
|
25
|
+
export { UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from './hooks/use-local-storage/use-local-storage.js';
|
|
26
|
+
export { usePopoverHover } from './hooks/use-popover-hover/use-popover-hover.js';
|
|
27
|
+
export { UseCountdownDateReturn, useCountdownDate } from './hooks/use-countdown-date/use-countdown-date.js';
|
|
28
|
+
export { UseScrollOffsetTopReturn, useScrollOffsetTop } from './hooks/use-scroll-offset-top/use-scroll-offset-top.js';
|
|
29
|
+
export { UseCountdownSecondsReturn, useCountdownSeconds } from './hooks/use-countdown-seconds/use-countdown-seconds.js';
|
|
30
|
+
export { CopiedValue, CopyFn, UseCopyToClipboardReturn, useCopyToClipboard } from './hooks/use-copy-to-clipboard/use-copy-to-clipboard.js';
|
|
31
|
+
import 'react';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{isEqual as W}from"es-toolkit";function w(e){try{let t=new URL(e,window.location.origin);return Array.from(t.searchParams.keys()).length>0}catch{return!1}}function m(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function Ie(e,t,n={deep:!0}){let o=r=>{try{let{pathname:s,searchParams:i}=new URL(r.trim(),"http://dummy");return n.deep?{pathname:m(s),params:Object.fromEntries(i)}:{pathname:m(s)}}catch{return{pathname:""}}};return W(o(t),o(e))}function R(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 Pe(e,t){let n=t??"/";if(!e||typeof window>"u"||!window.location?.origin)return n;try{let o=new URL(e,window.location.origin),r=o.origin===window.location.origin,s=o.pathname.startsWith("/")&&!o.pathname.startsWith("//"),i=/^\/:+$/.test(o.pathname),a=o.pathname==="/"&&!o.search&&o.hash;return r&&s&&!i&&!a?`${o.pathname}${o.search}${o.hash}`:n}catch{return e.startsWith("/")&&!e.startsWith("//")?e:n}}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 k='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function je(e){return e?`"${e}", ${k}`:k}function Fe(e){let t=parseFloat(e);return Math.round(t*16)}function Ne(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function B(e){if(!e)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(e))throw new Error(`Invalid hex color: ${e}`);let t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),o=parseInt(e.substring(5,7),16);return`${t} ${n} ${o}`}function Be(e){let t={};return Object.entries(e).forEach(([n,o])=>{o&&(t[`${n}Channel`]=B(o))}),{...e,...t}}function _(e,t){let n=s=>s.includes("var(--"),o=s=>s.trim().endsWith("%"),r={invalid:`[Alpha]: Invalid opacity "${e}" for ${t}.`,range:"Must be a number between 0 and 1 (e.g., 0.48).",format:'Must be a percentage (e.g., "48%") or CSS variable (e.g., "var(--opacity)").'};if(typeof e=="string"){if(o(e))return e;if(n(e))return`calc(${e} * 100%)`;let s=parseFloat(e.trim());if(!isNaN(s)&&s>=0&&s<=1)return`${Number((s*100).toFixed(2))}%`;throw new Error(`${r.invalid} ${r.format}`)}if(typeof e=="number"){if(e>=0&&e<=1)return`${Number((e*100).toFixed(2))}%`;throw new Error(`${r.invalid} ${r.range}`)}throw new Error(`${r.invalid}`)}function _e(e,t=1){if(!e?.trim())throw new Error("[Alpha]: Color is undefined or empty!");if(e.startsWith("#")||e.startsWith("rgb")||e.startsWith("rgba")||!e.includes("var")&&e.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${e}"`,"\u2705 Supported formats:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"\u274C Unsupported formats:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
|
|
2
|
+
`));let o=_(t,e);return e.toLowerCase()==="currentcolor"?`color-mix(in srgb, currentColor ${o}, transparent)`:`rgba(${e} / ${o})`}function Je(e,t){return!e||!t.length||typeof e!="object"?!1:t.every(n=>n in e)}function qe(){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 Ke(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:a}=n??{};try{let l=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),c=[`${e}=${l}`,`path=${i}`,r&&`SameSite=${r}`,s&&"Secure",a&&`domain=${a}`];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(l){console.error("Error setting cookie:",l)}}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 et(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(R(t));return n||w(t)?o===r||o.startsWith(`${r}/`)||o.startsWith(`${r}?`):o===r}function M(e,t){if(!z())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 L(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function z(){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 ot(e){if(typeof e!="string"||!e.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let t=e.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return t?t[1]:(console.error(`Invalid CSS variable format: "${e}". Expected format: var(--variable-name)`),"")}function st(e){if(typeof e!="string")return console.warn("Invalid CSS value provided"),"";let t=e.trim();return t?t.includes("/* @noflip */")?t:`${t} /* @noflip */`:(console.warn("Empty CSS value provided"),"")}function V(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function J(e){let n=V(e).replace(/[^0-9.]/g,""),[o,...r]=n.split(".");return r.length>0?`${o}.${r.join("")}`:o}function Y(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 at={onChange:J,onBlur:Y,value:V};import{useCallback as $,useState as q}from"react";function ct(e=!1){let[t,n]=q(e),o=$((s,i)=>{n(i)},[]),r=$(()=>{n(e)},[e]);return{value:t,setValue:n,onChange:o,reset:r}}import{useCallback as b,useState as G}from"react";function dt(e=!1){let[t,n]=G(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{useCallback as I,useState as K}from"react";function gt(){let[e,t]=K(null),n=I(r=>{t(r.currentTarget)},[]),o=I(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:n,onClose:o,setAnchorEl:t}}import{useCallback as S,useEffect as Q,useMemo as X,useState as Z}from"react";function xt(e,t,n){let{initializeWithValue:o=!0,...r}=n??{},s=t&&typeof t=="object",[i,a]=Z(t);Q(()=>{let u=U(e);u?a(s?d=>({...d,...u}):u):t&&o&&T(e,t,r)},[]);let l=S(u=>{s?a(d=>{let C={...d,...u};return T(e,C,r),C}):(T(e,u,r),a(u))},[r,s,e]),c=S((u,d)=>{s&&l({[u]:d})},[s,l]),p=S(u=>{a(u??t),O(e)},[t,e]);return X(()=>({state:i,setState:l,setField:c,resetState:p}),[p,c,l,i])}import{useEffect as ee,useState as te}from"react";function Ct(e,t=1e3){let[n,o]=te(e);return ee(()=>{let r=setTimeout(()=>{o(e)},t);return()=>{clearTimeout(r)}},[e,t]),n}import{useCallback as x,useState as ne}from"react";function Et(e){let[t,n]=ne(e),o=x(i=>{n(a=>({...a,...i}))},[]),r=x((i,a)=>{o({[i]:a})},[o]),s=x(i=>{n(i??e)},[e]);return{state:t,setState:o,setField:r,resetState:s}}import{useEffect as oe,useState as re}from"react";function Ot(){let[e,t]=re(!1);return oe(()=>{t(!0)},[]),e}import{useCallback as se,useEffect as ie,useMemo as ae,useState as le}from"react";function Vt(e,t){let[n,o]=le(!1),r=ue(e),s=se(()=>{let l=window.innerHeight,c=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(c/(p-l)*100);if(r.type==="percentage")o(f>=r.value);else{let u=p-l-c;o(r.value>=u)}},[r.type,r.value]),i=ae(()=>{let l;return()=>{clearTimeout(l),l=setTimeout(s,100)}},[s]);return ie(()=>{let l=t?i:s;return window.addEventListener("scroll",l),()=>{window.removeEventListener("scroll",l)}},[i,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:o}}function ue(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{useCallback as ce,useEffect as P,useLayoutEffect as pe,useMemo as A,useRef as fe,useState as D}from"react";function Pt(e,t){let n=fe(null),o=e||n,[r,s]=D(void 0),[i,a]=D(void 0),l=typeof window<"u"?pe:P,c=ce(()=>{if(o.current){let u=o.current.getBoundingClientRect();s(u),a({scrollWidth:o.current.scrollWidth,scrollHeight:o.current.scrollHeight})}},[o]);l(()=>{c()},[c]),P(()=>{let u=t||"resize";return window.addEventListener(u,c),()=>{window.removeEventListener(u,c)}},[t,c]);let p=A(()=>r,[r]),f=A(()=>i,[i]);return{elementRef:o,top:p?.top??0,right:p?.right??0,bottom:p?.bottom??0,left:p?.left??0,x:p?.x??0,y:p?.y??0,width:p?.width??0,height:p?.height??0,scrollWidth:f?.scrollWidth??0,scrollHeight:f?.scrollHeight??0}}import{useCallback as y,useMemo as de,useState as me}from"react";function Ht(e,t){let[n,o]=me(t??[]),r=y(l=>{o(c=>Te(c,l))},[]),s=y(()=>{o(l=>l.length===e.length?[]:e)},[e]),i=y(()=>{o([])},[]),a=de(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:a,setValues:o,onSelectAllItems:s,onDeSelectAllItems:i,onToggleSelectItem:r}}function Te(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}import{useCallback as H,useRef as ge}from"react";function Nt({click:e,doubleClick:t,timeout:n=250}){let o=ge(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{useCallback as v,useEffect as he,useMemo as be,useState as Se}from"react";function zt(e,t,n){let{initializeWithValue:o=!0}=n??{},r=t&&typeof t=="object",[s,i]=Se(t);he(()=>{let f=M(e);f?i(r?u=>({...u,...f}):f):t&&o&&g(e,t)},[]);let a=v(f=>{r?i(u=>{let d={...u,...f};return g(e,d),d}):(g(e,f),i(f))},[e,r]),l=v((f,u)=>{r&&a({[f]:u})},[r,a]),c=v(f=>{i(f??t),L(e)},[t,e]);return be(()=>({state:s,setState:a,setField:l,resetState:c}),[c,l,a,s])}import{useCallback as j,useRef as xe,useState as ye}from"react";function qt(e){let t=xe(null),n=e||t,[o,r]=ye(!1),s=j(()=>{r(!0)},[]),i=j(()=>{r(!1)},[]);return{elementRef:n,anchorEl:n.current,open:o,onOpen:s,onClose:i,setOpen:r}}import{useCallback as ve,useEffect as Ce,useState as we}from"react";function Qt(e,t="- -"){let[n,o]=we({days:t,hours:t,minutes:t,seconds:t}),r=ve(()=>{let s=new Date,{days:i,hours:a,minutes:l,seconds:c}=Re(e,s);o({days:h(i),hours:h(a),minutes:h(l),seconds:h(c)})},[e]);return Ce(()=>{r();let s=setInterval(r,1e3);return()=>clearInterval(s)},[]),n}function h(e){return String(e).length===1?`0${e}`:`${e}`}function Re(e,t){let n=e.getTime()-t.getTime();return{days:Math.floor(n/(1e3*60*60*24)),hours:Math.floor(n%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(n%(1e3*60*60)/(1e3*60)),seconds:Math.floor(n%(1e3*60)/1e3)}}import{useCallback as Ee,useEffect as ke,useRef as Ue,useState as Oe}from"react";function en(e=0){let t=Ue(null),[n,o]=Oe(!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 ke(()=>(r(),window.addEventListener("scroll",r),()=>{window.removeEventListener("scroll",r)}),[r]),{elementRef:t,offsetTop:n}}import{useCallback as F,useEffect as Me,useState as N}from"react";function on(e){let[t,n]=N(e),[o,r]=N(!1),s=F(()=>{r(!0)},[]),i=F(()=>{r(!1),n(e)},[e]);return Me(()=>{let a=null;return o&&t>0?a=setInterval(()=>{n(l=>l-1)},1e3):t<=0&&r(!1),()=>{a&&clearInterval(a)}},[o,t]),{value:t,setValue:n,isCounting:o,start:s,reset:i}}import{useCallback as Le,useState as Ve}from"react";function an(){let[e,t]=Ve(null);return{copy:Le(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,M as getStorage,Je as hasKeys,w as hasParams,B as hexToRgbChannel,et as isActiveLink,Ie as isEqualPath,E as isExternalLink,z as localStorageAvailable,Ke as mergeClasses,De as mergeRefs,st as noRtlFlip,ot as parseCssVar,Ne as pxToRem,Fe as remToPx,O as removeCookie,m as removeLastSlash,R as removeParams,L as removeStorage,Pe as safeReturnUrl,T as setCookie,je as setFont,g as setStorage,at as transformNumber,V as transformValue,Y as transformValueOnBlur,J as transformValueOnChange,Te as updateSelectedItems,Vt as useBackToTop,dt as useBoolean,Pt as useClientRect,xt as useCookies,an as useCopyToClipboard,Qt as useCountdownDate,on as useCountdownSeconds,Ct as useDebounce,Nt as useDoubleClick,Ot as useIsClient,zt as useLocalStorage,Ht as useMultiSelect,gt as usePopover,qt as usePopoverHover,en as useScrollOffsetTop,Et as useSetState,ct as useTabs,qe as uuidv4,_e as varAlpha};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var m=(t,n)=>{for(var s in n)a(t,s,{get:n[s],enumerable:!0})},f=(t,n,s,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of u(n))!p.call(t,r)&&r!==s&&a(t,r,{get:()=>n[r],enumerable:!(i=l(n,r))||i.enumerable});return t};var g=t=>f(a({},"__esModule",{value:!0}),t);var y={};m(y,{isActiveLink:()=>w});module.exports=g(y);var d=require("es-toolkit");function o(t){try{let n=new URL(t,window.location.origin);return Array.from(n.searchParams.keys()).length>0}catch{return!1}}function e(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function c(t){try{let n=new URL(t,window.location.origin);return e(n.pathname)}catch{return t}}function h(t){return/^https?:\/\//i.test(t)}function w(t,n,s=!0){if(!t||!n)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(n.startsWith("#")||h(n))return!1;let i=e(t),r=e(c(n));return s||o(n)?i===r||i.startsWith(`${r}/`)||i.startsWith(`${r}?`):i===r}0&&(module.exports={isActiveLink});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether a given target path is considered "active"
|
|
3
|
+
* based on the current pathname — typically used for highlighting
|
|
4
|
+
* active navigation links.
|
|
5
|
+
*
|
|
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.
|
|
10
|
+
*
|
|
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`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
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)
|
|
24
|
+
*/
|
|
25
|
+
declare function isActiveLink(currentPathname: string, targetPath: string, deep?: boolean): boolean;
|
|
26
|
+
|
|
27
|
+
export { isActiveLink };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether a given target path is considered "active"
|
|
3
|
+
* based on the current pathname — typically used for highlighting
|
|
4
|
+
* active navigation links.
|
|
5
|
+
*
|
|
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.
|
|
10
|
+
*
|
|
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`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
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)
|
|
24
|
+
*/
|
|
25
|
+
declare function isActiveLink(currentPathname: string, targetPath: string, deep?: boolean): boolean;
|
|
26
|
+
|
|
27
|
+
export { isActiveLink };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isEqual as u}from"es-toolkit";function e(t){try{let n=new URL(t,window.location.origin);return Array.from(n.searchParams.keys()).length>0}catch{return!1}}function s(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function a(t){try{let n=new URL(t,window.location.origin);return s(n.pathname)}catch{return t}}function o(t){return/^https?:\/\//i.test(t)}function f(t,n,c=!0){if(!t||!n)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(n.startsWith("#")||o(n))return!1;let r=s(t),i=s(a(n));return c||e(n)?r===i||r.startsWith(`${i}/`)||r.startsWith(`${i}?`):r===i}export{f as isActiveLink};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var m=(t,n)=>{for(var s in n)o(t,s,{get:n[s],enumerable:!0})},f=(t,n,s,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of p(n))!u.call(t,r)&&r!==s&&o(t,r,{get:()=>n[r],enumerable:!(i=l(n,r))||i.enumerable});return t};var g=t=>f(o({},"__esModule",{value:!0}),t);var x={};m(x,{isActiveLink:()=>w});module.exports=g(x);var d=require("es-toolkit");function a(t){try{let n=new URL(t,window.location.origin);return Array.from(n.searchParams.keys()).length>0}catch{return!1}}function e(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function c(t){try{let n=new URL(t,window.location.origin);return e(n.pathname)}catch{return t}}function h(t){return/^https?:\/\//i.test(t)}function w(t,n,s=!0){if(!t||!n)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(n.startsWith("#")||h(n))return!1;let i=e(t),r=e(c(n));return s||a(n)?i===r||i.startsWith(`${r}/`)||i.startsWith(`${r}?`):i===r}0&&(module.exports={isActiveLink});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isActiveLink } from './active-link.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isActiveLink } from './active-link.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isEqual as p}from"es-toolkit";function e(t){try{let n=new URL(t,window.location.origin);return Array.from(n.searchParams.keys()).length>0}catch{return!1}}function s(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function o(t){try{let n=new URL(t,window.location.origin);return s(n.pathname)}catch{return t}}function a(t){return/^https?:\/\//i.test(t)}function f(t,n,c=!0){if(!t||!n)return console.warn("isActiveLink: pathname or itemPath is empty!"),!1;if(n.startsWith("#")||a(n))return!1;let r=s(t),i=s(o(n));return c||e(n)?r===i||r.startsWith(`${i}/`)||r.startsWith(`${i}?`):r===i}export{f as isActiveLink};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var d=(r,n)=>{for(var i in n)s(r,i,{get:n[i],enumerable:!0})},g=(r,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of y(n))!a.call(r,t)&&t!==i&&s(r,t,{get:()=>n[t],enumerable:!(o=f(n,t))||o.enumerable});return r};var l=r=>g(s({},"__esModule",{value:!0}),r);var A={};d(A,{mergeClasses:()=>p});module.exports=l(A);function p(r,n){let i=r?Array.isArray(r)?r:[r]:[],o=Object.entries(n||{}).filter(([t,e])=>e!==void 0&&e!==!1).map(([t,e])=>Array.isArray(e)?e[0]?e[1]:"":e?t:"").filter(Boolean);return[...i.filter(Boolean),...o].join(" ")}0&&(module.exports={mergeClasses});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type StateProps = {
|
|
2
|
+
[key: string]: boolean | undefined | [boolean, string];
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Merges class names with state-based class names.
|
|
6
|
+
*
|
|
7
|
+
* @param {string | string[] | null} className - The base class name(s).
|
|
8
|
+
* @param {StateProps} state - The state object containing boolean or [boolean, string] pairs.
|
|
9
|
+
* @returns {string} - The merged class names.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* const classNames = mergeClasses('item__base', {
|
|
14
|
+
* ['active__class']: true,
|
|
15
|
+
* ['open__class']: true,
|
|
16
|
+
* ['disabled__class']: false,
|
|
17
|
+
* ['hover__class']: undefined,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* console.log(classNames);
|
|
21
|
+
* Output: 'item__base active__class open__class'
|
|
22
|
+
*/
|
|
23
|
+
declare function mergeClasses(className?: string | (string | undefined)[] | null, state?: StateProps): string;
|
|
24
|
+
|
|
25
|
+
export { type StateProps, mergeClasses };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type StateProps = {
|
|
2
|
+
[key: string]: boolean | undefined | [boolean, string];
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Merges class names with state-based class names.
|
|
6
|
+
*
|
|
7
|
+
* @param {string | string[] | null} className - The base class name(s).
|
|
8
|
+
* @param {StateProps} state - The state object containing boolean or [boolean, string] pairs.
|
|
9
|
+
* @returns {string} - The merged class names.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* const classNames = mergeClasses('item__base', {
|
|
14
|
+
* ['active__class']: true,
|
|
15
|
+
* ['open__class']: true,
|
|
16
|
+
* ['disabled__class']: false,
|
|
17
|
+
* ['hover__class']: undefined,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* console.log(classNames);
|
|
21
|
+
* Output: 'item__base active__class open__class'
|
|
22
|
+
*/
|
|
23
|
+
declare function mergeClasses(className?: string | (string | undefined)[] | null, state?: StateProps): string;
|
|
24
|
+
|
|
25
|
+
export { type StateProps, mergeClasses };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function s(n,e){let i=n?Array.isArray(n)?n:[n]:[],o=Object.entries(e||{}).filter(([t,r])=>r!==void 0&&r!==!1).map(([t,r])=>Array.isArray(r)?r[0]?r[1]:"":r?t:"").filter(Boolean);return[...i.filter(Boolean),...o].join(" ")}export{s as mergeClasses};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var d=(r,t)=>{for(var i in t)s(r,i,{get:t[i],enumerable:!0})},p=(r,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of y(t))!a.call(r,e)&&e!==i&&s(r,e,{get:()=>t[e],enumerable:!(o=f(t,e))||o.enumerable});return r};var g=r=>p(s({},"__esModule",{value:!0}),r);var A={};d(A,{mergeClasses:()=>l});module.exports=g(A);function l(r,t){let i=r?Array.isArray(r)?r:[r]:[],o=Object.entries(t||{}).filter(([e,n])=>n!==void 0&&n!==!1).map(([e,n])=>Array.isArray(n)?n[0]?n[1]:"":n?e:"").filter(Boolean);return[...i.filter(Boolean),...o].join(" ")}0&&(module.exports={mergeClasses});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StateProps, mergeClasses } from './classes.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StateProps, mergeClasses } from './classes.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function s(t,n){let i=t?Array.isArray(t)?t:[t]:[],o=Object.entries(n||{}).filter(([e,r])=>r!==void 0&&r!==!1).map(([e,r])=>Array.isArray(r)?r[0]?r[1]:"":r?e:"").filter(Boolean);return[...i.filter(Boolean),...o].join(" ")}export{s as mergeClasses};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var l=(n,r)=>{for(var t in r)a(n,t,{get:r[t],enumerable:!0})},f=(n,r,t,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of g(r))!d.call(n,s)&&s!==t&&a(n,s,{get:()=>r[s],enumerable:!(e=u(r,s))||e.enumerable});return n};var p=n=>f(a({},"__esModule",{value:!0}),n);var $={};l($,{createPaletteChannel:()=>h,hexToRgbChannel:()=>o,varAlpha:()=>c});module.exports=p($);function o(n){if(!n)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(n))throw new Error(`Invalid hex color: ${n}`);let r=parseInt(n.substring(1,3),16),t=parseInt(n.substring(3,5),16),e=parseInt(n.substring(5,7),16);return`${r} ${t} ${e}`}function h(n){let r={};return Object.entries(n).forEach(([t,e])=>{e&&(r[`${t}Channel`]=o(e))}),{...n,...r}}function b(n,r){let t=i=>i.includes("var(--"),e=i=>i.trim().endsWith("%"),s={invalid:`[Alpha]: Invalid opacity "${n}" for ${r}.`,range:"Must be a number between 0 and 1 (e.g., 0.48).",format:'Must be a percentage (e.g., "48%") or CSS variable (e.g., "var(--opacity)").'};if(typeof n=="string"){if(e(n))return n;if(t(n))return`calc(${n} * 100%)`;let i=parseFloat(n.trim());if(!isNaN(i)&&i>=0&&i<=1)return`${Number((i*100).toFixed(2))}%`;throw new Error(`${s.invalid} ${s.format}`)}if(typeof n=="number"){if(n>=0&&n<=1)return`${Number((n*100).toFixed(2))}%`;throw new Error(`${s.invalid} ${s.range}`)}throw new Error(`${s.invalid}`)}function c(n,r=1){if(!n?.trim())throw new Error("[Alpha]: Color is undefined or empty!");if(n.startsWith("#")||n.startsWith("rgb")||n.startsWith("rgba")||!n.includes("var")&&n.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${n}"`,"\u2705 Supported formats:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"\u274C Unsupported formats:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
|
|
2
|
+
`));let e=b(r,n);return n.toLowerCase()==="currentcolor"?`color-mix(in srgb, currentColor ${e}, transparent)`:`rgba(${n} / ${e})`}0&&(module.exports={createPaletteChannel,hexToRgbChannel,varAlpha});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a hex color to RGB channels.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} hexColor - The hex color string.
|
|
5
|
+
* @returns {string} - The RGB channels string.
|
|
6
|
+
* @throws {Error} - Throws an error if the hex color is invalid.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const rgbChannel = hexToRgbChannel("#C8FAD6");
|
|
10
|
+
* console.log(rgbChannel); // "200 250 214"
|
|
11
|
+
*/
|
|
12
|
+
declare function hexToRgbChannel(hexColor: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Converts a hex palette color to RGB channels palette.
|
|
15
|
+
*
|
|
16
|
+
* @typedef {Object} InputPalette - The input palette object with hex color strings.
|
|
17
|
+
* @property {string} lighter - The lighter hex color.
|
|
18
|
+
* @property {string} light - The light hex color.
|
|
19
|
+
* @property {string} main - The main hex color.
|
|
20
|
+
*
|
|
21
|
+
* @typedef {Object} ChannelPalette - The output palette object with RGB channels.
|
|
22
|
+
* @property {string} lighterChannel - The lighter RGB channels.
|
|
23
|
+
* @property {string} lightChannel - The light RGB channels.
|
|
24
|
+
* @property {string} mainChannel - The main RGB channels.
|
|
25
|
+
*
|
|
26
|
+
* @param {InputPalette} hexPalette - The input palette object.
|
|
27
|
+
* @returns {ChannelPalette} - The output palette object with RGB channels.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const palette = createPaletteChannel({
|
|
31
|
+
* lighter: "#C8FAD6",
|
|
32
|
+
* light: "#5BE49B",
|
|
33
|
+
* main: "#00A76F",
|
|
34
|
+
* });
|
|
35
|
+
* console.log(palette);
|
|
36
|
+
* // {
|
|
37
|
+
* // lighter: "#C8FAD6",
|
|
38
|
+
* // light: "#5BE49B",
|
|
39
|
+
* // main: "#00A76F",
|
|
40
|
+
* // lighterChannel: "200 250 214",
|
|
41
|
+
* // lightChannel: "91 228 155",
|
|
42
|
+
* // mainChannel: "0 167 111",
|
|
43
|
+
* // }
|
|
44
|
+
*/
|
|
45
|
+
type InputPalette = Record<string, string | undefined>;
|
|
46
|
+
type ChannelPalette<T extends InputPalette> = T & {
|
|
47
|
+
[K in keyof T as `${string & K}Channel`]: string;
|
|
48
|
+
};
|
|
49
|
+
declare function createPaletteChannel<T extends InputPalette>(hexPalette: T): ChannelPalette<T>;
|
|
50
|
+
declare function varAlpha(color: string, opacity?: string | number): string;
|
|
51
|
+
|
|
52
|
+
export { type ChannelPalette, type InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a hex color to RGB channels.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} hexColor - The hex color string.
|
|
5
|
+
* @returns {string} - The RGB channels string.
|
|
6
|
+
* @throws {Error} - Throws an error if the hex color is invalid.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const rgbChannel = hexToRgbChannel("#C8FAD6");
|
|
10
|
+
* console.log(rgbChannel); // "200 250 214"
|
|
11
|
+
*/
|
|
12
|
+
declare function hexToRgbChannel(hexColor: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Converts a hex palette color to RGB channels palette.
|
|
15
|
+
*
|
|
16
|
+
* @typedef {Object} InputPalette - The input palette object with hex color strings.
|
|
17
|
+
* @property {string} lighter - The lighter hex color.
|
|
18
|
+
* @property {string} light - The light hex color.
|
|
19
|
+
* @property {string} main - The main hex color.
|
|
20
|
+
*
|
|
21
|
+
* @typedef {Object} ChannelPalette - The output palette object with RGB channels.
|
|
22
|
+
* @property {string} lighterChannel - The lighter RGB channels.
|
|
23
|
+
* @property {string} lightChannel - The light RGB channels.
|
|
24
|
+
* @property {string} mainChannel - The main RGB channels.
|
|
25
|
+
*
|
|
26
|
+
* @param {InputPalette} hexPalette - The input palette object.
|
|
27
|
+
* @returns {ChannelPalette} - The output palette object with RGB channels.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const palette = createPaletteChannel({
|
|
31
|
+
* lighter: "#C8FAD6",
|
|
32
|
+
* light: "#5BE49B",
|
|
33
|
+
* main: "#00A76F",
|
|
34
|
+
* });
|
|
35
|
+
* console.log(palette);
|
|
36
|
+
* // {
|
|
37
|
+
* // lighter: "#C8FAD6",
|
|
38
|
+
* // light: "#5BE49B",
|
|
39
|
+
* // main: "#00A76F",
|
|
40
|
+
* // lighterChannel: "200 250 214",
|
|
41
|
+
* // lightChannel: "91 228 155",
|
|
42
|
+
* // mainChannel: "0 167 111",
|
|
43
|
+
* // }
|
|
44
|
+
*/
|
|
45
|
+
type InputPalette = Record<string, string | undefined>;
|
|
46
|
+
type ChannelPalette<T extends InputPalette> = T & {
|
|
47
|
+
[K in keyof T as `${string & K}Channel`]: string;
|
|
48
|
+
};
|
|
49
|
+
declare function createPaletteChannel<T extends InputPalette>(hexPalette: T): ChannelPalette<T>;
|
|
50
|
+
declare function varAlpha(color: string, opacity?: string | number): string;
|
|
51
|
+
|
|
52
|
+
export { type ChannelPalette, type InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function a(n){if(!n)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(n))throw new Error(`Invalid hex color: ${n}`);let e=parseInt(n.substring(1,3),16),s=parseInt(n.substring(3,5),16),r=parseInt(n.substring(5,7),16);return`${e} ${s} ${r}`}function u(n){let e={};return Object.entries(n).forEach(([s,r])=>{r&&(e[`${s}Channel`]=a(r))}),{...n,...e}}function o(n,e){let s=t=>t.includes("var(--"),r=t=>t.trim().endsWith("%"),i={invalid:`[Alpha]: Invalid opacity "${n}" for ${e}.`,range:"Must be a number between 0 and 1 (e.g., 0.48).",format:'Must be a percentage (e.g., "48%") or CSS variable (e.g., "var(--opacity)").'};if(typeof n=="string"){if(r(n))return n;if(s(n))return`calc(${n} * 100%)`;let t=parseFloat(n.trim());if(!isNaN(t)&&t>=0&&t<=1)return`${Number((t*100).toFixed(2))}%`;throw new Error(`${i.invalid} ${i.format}`)}if(typeof n=="number"){if(n>=0&&n<=1)return`${Number((n*100).toFixed(2))}%`;throw new Error(`${i.invalid} ${i.range}`)}throw new Error(`${i.invalid}`)}function g(n,e=1){if(!n?.trim())throw new Error("[Alpha]: Color is undefined or empty!");if(n.startsWith("#")||n.startsWith("rgb")||n.startsWith("rgba")||!n.includes("var")&&n.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${n}"`,"\u2705 Supported formats:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"\u274C Unsupported formats:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
|
|
2
|
+
`));let r=o(e,n);return n.toLowerCase()==="currentcolor"?`color-mix(in srgb, currentColor ${r}, transparent)`:`rgba(${n} / ${r})`}export{u as createPaletteChannel,a as hexToRgbChannel,g as varAlpha};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=(r,n)=>{for(var t in n)a(r,t,{get:n[t],enumerable:!0})},l=(r,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of g(n))!d.call(r,s)&&s!==t&&a(r,s,{get:()=>n[s],enumerable:!(e=u(n,s))||e.enumerable});return r};var p=r=>l(a({},"__esModule",{value:!0}),r);var $={};f($,{createPaletteChannel:()=>h,hexToRgbChannel:()=>o,varAlpha:()=>c});module.exports=p($);function o(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 n=parseInt(r.substring(1,3),16),t=parseInt(r.substring(3,5),16),e=parseInt(r.substring(5,7),16);return`${n} ${t} ${e}`}function h(r){let n={};return Object.entries(r).forEach(([t,e])=>{e&&(n[`${t}Channel`]=o(e))}),{...r,...n}}function b(r,n){let t=i=>i.includes("var(--"),e=i=>i.trim().endsWith("%"),s={invalid:`[Alpha]: Invalid opacity "${r}" for ${n}.`,range:"Must be a number between 0 and 1 (e.g., 0.48).",format:'Must be a percentage (e.g., "48%") or CSS variable (e.g., "var(--opacity)").'};if(typeof r=="string"){if(e(r))return r;if(t(r))return`calc(${r} * 100%)`;let i=parseFloat(r.trim());if(!isNaN(i)&&i>=0&&i<=1)return`${Number((i*100).toFixed(2))}%`;throw new Error(`${s.invalid} ${s.format}`)}if(typeof r=="number"){if(r>=0&&r<=1)return`${Number((r*100).toFixed(2))}%`;throw new Error(`${s.invalid} ${s.range}`)}throw new Error(`${s.invalid}`)}function c(r,n=1){if(!r?.trim())throw new Error("[Alpha]: Color is undefined or empty!");if(r.startsWith("#")||r.startsWith("rgb")||r.startsWith("rgba")||!r.includes("var")&&r.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${r}"`,"\u2705 Supported formats:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"\u274C Unsupported formats:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
|
|
2
|
+
`));let e=b(n,r);return r.toLowerCase()==="currentcolor"?`color-mix(in srgb, currentColor ${e}, transparent)`:`rgba(${r} / ${e})`}0&&(module.exports={createPaletteChannel,hexToRgbChannel,varAlpha});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './color.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './color.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function a(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),s=parseInt(r.substring(3,5),16),n=parseInt(r.substring(5,7),16);return`${e} ${s} ${n}`}function u(r){let e={};return Object.entries(r).forEach(([s,n])=>{n&&(e[`${s}Channel`]=a(n))}),{...r,...e}}function o(r,e){let s=t=>t.includes("var(--"),n=t=>t.trim().endsWith("%"),i={invalid:`[Alpha]: Invalid opacity "${r}" for ${e}.`,range:"Must be a number between 0 and 1 (e.g., 0.48).",format:'Must be a percentage (e.g., "48%") or CSS variable (e.g., "var(--opacity)").'};if(typeof r=="string"){if(n(r))return r;if(s(r))return`calc(${r} * 100%)`;let t=parseFloat(r.trim());if(!isNaN(t)&&t>=0&&t<=1)return`${Number((t*100).toFixed(2))}%`;throw new Error(`${i.invalid} ${i.format}`)}if(typeof r=="number"){if(r>=0&&r<=1)return`${Number((r*100).toFixed(2))}%`;throw new Error(`${i.invalid} ${i.range}`)}throw new Error(`${i.invalid}`)}function g(r,e=1){if(!r?.trim())throw new Error("[Alpha]: Color is undefined or empty!");if(r.startsWith("#")||r.startsWith("rgb")||r.startsWith("rgba")||!r.includes("var")&&r.includes("Channel"))throw new Error([`[Alpha]: Unsupported color format "${r}"`,"\u2705 Supported formats:",'- RGB channels: "0 184 217"','- CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)"',"\u274C Unsupported formats:",'- Hex: "#00B8D9"','- RGB: "rgb(0, 184, 217)"','- RGBA: "rgba(0, 184, 217, 1)"'].join(`
|
|
2
|
+
`));let n=o(e,r);return r.toLowerCase()==="currentcolor"?`color-mix(in srgb, currentColor ${n}, transparent)`:`rgba(${r} / ${n})`}export{u as createPaletteChannel,a as hexToRgbChannel,g as varAlpha};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var f=(e,o)=>{for(var t in o)a(e,t,{get:o[t],enumerable:!0})},g=(e,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of k(o))!m.call(e,r)&&r!==t&&a(e,r,{get:()=>o[r],enumerable:!(i=u(o,r))||i.enumerable});return e};var h=e=>g(a({},"__esModule",{value:!0}),e);var x={};f(x,{getCookie:()=>y,removeCookie:()=>S,setCookie:()=>C});module.exports=h(x);function y(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let o=`${e}=`,r=decodeURIComponent(document.cookie).split("; ").find(c=>c.startsWith(o));if(!r)return null;let n=r.substring(o.length);try{return JSON.parse(n)}catch{return n}}catch(o){return console.error("Error retrieving cookie:",o),null}}function C(e,o,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:i=0,sameSite:r="Strict",secure:n=!1,path:c="/",domain:d}=t??{};try{let s=encodeURIComponent(typeof o=="string"?o:JSON.stringify(o)),p=[`${e}=${s}`,`path=${c}`,r&&`SameSite=${r}`,n&&"Secure",d&&`domain=${d}`];if(i>0){let l=new Date(Date.now()+i*24*60*60*1e3);p.push(`expires=${l.toUTCString()}`)}document.cookie=p.filter(Boolean).join("; ")}catch(s){console.error("Error setting cookie:",s)}}function S(e,o){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:t="/",domain:i}=o??{};try{let r=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${t}`,i&&`domain=${i}`,"Secure"];document.cookie=r.filter(Boolean).join("; ")}catch(r){console.error("Error removing cookie:",r)}}0&&(module.exports={getCookie,removeCookie,setCookie});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type CookieOptions = {
|
|
2
|
+
secure?: boolean;
|
|
3
|
+
daysUntilExpiration?: number;
|
|
4
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
5
|
+
domain?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves a cookie value by key.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} key - The key of the cookie to retrieve.
|
|
12
|
+
* @returns {T | null} - The parsed value of the cookie, or null if not found or an error occurs.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const user = getCookie<{ name: string, age: number }>('user');
|
|
16
|
+
* console.log(user); // { name: 'John', age: 30 }
|
|
17
|
+
*/
|
|
18
|
+
declare function getCookie<T>(key: string): T | null;
|
|
19
|
+
/**
|
|
20
|
+
* Sets a cookie with a specified key, value, and options.
|
|
21
|
+
*
|
|
22
|
+
* @template T
|
|
23
|
+
* @param {string} key - The key of the cookie to set.
|
|
24
|
+
* @param {T} value - The value of the cookie to set.
|
|
25
|
+
* @param {CookieOptions} [options] - The options for the cookie.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* setCookie('user', { name: 'John', age: 30 }, { daysUntilExpiration: 7, sameSite: 'Lax', secure: true });
|
|
29
|
+
*/
|
|
30
|
+
declare function setCookie<T>(key: string, value: T, options?: CookieOptions): void;
|
|
31
|
+
/**
|
|
32
|
+
* Removes a cookie by key.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} key - The key of the cookie to remove.
|
|
35
|
+
* @param {Pick<CookieOptions, 'path' | 'domain'>} [options] - The options for the cookie removal.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* removeCookie('user');
|
|
39
|
+
*/
|
|
40
|
+
declare function removeCookie(key: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void;
|
|
41
|
+
|
|
42
|
+
export { type CookieOptions, getCookie, removeCookie, setCookie };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type CookieOptions = {
|
|
2
|
+
secure?: boolean;
|
|
3
|
+
daysUntilExpiration?: number;
|
|
4
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
5
|
+
domain?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves a cookie value by key.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} key - The key of the cookie to retrieve.
|
|
12
|
+
* @returns {T | null} - The parsed value of the cookie, or null if not found or an error occurs.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const user = getCookie<{ name: string, age: number }>('user');
|
|
16
|
+
* console.log(user); // { name: 'John', age: 30 }
|
|
17
|
+
*/
|
|
18
|
+
declare function getCookie<T>(key: string): T | null;
|
|
19
|
+
/**
|
|
20
|
+
* Sets a cookie with a specified key, value, and options.
|
|
21
|
+
*
|
|
22
|
+
* @template T
|
|
23
|
+
* @param {string} key - The key of the cookie to set.
|
|
24
|
+
* @param {T} value - The value of the cookie to set.
|
|
25
|
+
* @param {CookieOptions} [options] - The options for the cookie.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* setCookie('user', { name: 'John', age: 30 }, { daysUntilExpiration: 7, sameSite: 'Lax', secure: true });
|
|
29
|
+
*/
|
|
30
|
+
declare function setCookie<T>(key: string, value: T, options?: CookieOptions): void;
|
|
31
|
+
/**
|
|
32
|
+
* Removes a cookie by key.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} key - The key of the cookie to remove.
|
|
35
|
+
* @param {Pick<CookieOptions, 'path' | 'domain'>} [options] - The options for the cookie removal.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* removeCookie('user');
|
|
39
|
+
*/
|
|
40
|
+
declare function removeCookie(key: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void;
|
|
41
|
+
|
|
42
|
+
export { type CookieOptions, getCookie, removeCookie, setCookie };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function l(o){if(!o||typeof o!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${o}=`,r=decodeURIComponent(document.cookie).split("; ").find(c=>c.startsWith(e));if(!r)return null;let n=r.substring(e.length);try{return JSON.parse(n)}catch{return n}}catch(e){return console.error("Error retrieving cookie:",e),null}}function u(o,e,i){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:t=0,sameSite:r="Strict",secure:n=!1,path:c="/",domain:a}=i??{};try{let s=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),d=[`${o}=${s}`,`path=${c}`,r&&`SameSite=${r}`,n&&"Secure",a&&`domain=${a}`];if(t>0){let p=new Date(Date.now()+t*24*60*60*1e3);d.push(`expires=${p.toUTCString()}`)}document.cookie=d.filter(Boolean).join("; ")}catch(s){console.error("Error setting cookie:",s)}}function k(o,e){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{path:i="/",domain:t}=e??{};try{let r=[`${o}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${i}`,t&&`domain=${t}`,"Secure"];document.cookie=r.filter(Boolean).join("; ")}catch(r){console.error("Error removing cookie:",r)}}export{l as getCookie,k as removeCookie,u as setCookie};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var f=(e,o)=>{for(var t in o)a(e,t,{get:o[t],enumerable:!0})},g=(e,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of k(o))!m.call(e,r)&&r!==t&&a(e,r,{get:()=>o[r],enumerable:!(i=u(o,r))||i.enumerable});return e};var h=e=>g(a({},"__esModule",{value:!0}),e);var S={};f(S,{getCookie:()=>y,removeCookie:()=>x,setCookie:()=>C});module.exports=h(S);function y(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let o=`${e}=`,r=decodeURIComponent(document.cookie).split("; ").find(c=>c.startsWith(o));if(!r)return null;let n=r.substring(o.length);try{return JSON.parse(n)}catch{return n}}catch(o){return console.error("Error retrieving cookie:",o),null}}function C(e,o,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:i=0,sameSite:r="Strict",secure:n=!1,path:c="/",domain:d}=t??{};try{let s=encodeURIComponent(typeof o=="string"?o:JSON.stringify(o)),p=[`${e}=${s}`,`path=${c}`,r&&`SameSite=${r}`,n&&"Secure",d&&`domain=${d}`];if(i>0){let l=new Date(Date.now()+i*24*60*60*1e3);p.push(`expires=${l.toUTCString()}`)}document.cookie=p.filter(Boolean).join("; ")}catch(s){console.error("Error setting cookie:",s)}}function x(e,o){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:t="/",domain:i}=o??{};try{let r=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${t}`,i&&`domain=${i}`,"Secure"];document.cookie=r.filter(Boolean).join("; ")}catch(r){console.error("Error removing cookie:",r)}}0&&(module.exports={getCookie,removeCookie,setCookie});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CookieOptions, getCookie, removeCookie, setCookie } from './cookies.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CookieOptions, getCookie, removeCookie, setCookie } from './cookies.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function l(o){if(!o||typeof o!="string")return console.warn("Invalid cookie key provided"),null;try{let e=`${o}=`,r=decodeURIComponent(document.cookie).split("; ").find(c=>c.startsWith(e));if(!r)return null;let n=r.substring(e.length);try{return JSON.parse(n)}catch{return n}}catch(e){return console.error("Error retrieving cookie:",e),null}}function u(o,e,i){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:t=0,sameSite:r="Strict",secure:n=!1,path:c="/",domain:a}=i??{};try{let s=encodeURIComponent(typeof e=="string"?e:JSON.stringify(e)),d=[`${o}=${s}`,`path=${c}`,r&&`SameSite=${r}`,n&&"Secure",a&&`domain=${a}`];if(t>0){let p=new Date(Date.now()+t*24*60*60*1e3);d.push(`expires=${p.toUTCString()}`)}document.cookie=d.filter(Boolean).join("; ")}catch(s){console.error("Error setting cookie:",s)}}function k(o,e){if(!o||typeof o!="string"){console.error("Invalid cookie key provided");return}let{path:i="/",domain:t}=e??{};try{let r=[`${o}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${i}`,t&&`domain=${t}`,"Secure"];document.cookie=r.filter(Boolean).join("; ")}catch(r){console.error("Error removing cookie:",r)}}export{l as getCookie,k as removeCookie,u as setCookie};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var v=(r,n)=>{for(var e in n)a(r,e,{get:n[e],enumerable:!0})},f=(r,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of m(n))!s.call(r,t)&&t!==e&&a(r,t,{get:()=>n[t],enumerable:!(o=i(n,t))||o.enumerable});return r};var p=r=>f(a({},"__esModule",{value:!0}),r);var c={};v(c,{parseCssVar:()=>u});module.exports=p(c);function u(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let n=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return n?n[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}0&&(module.exports={parseCssVar});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the CSS variable name from a `var(--...)` expression.
|
|
3
|
+
*
|
|
4
|
+
* @param cssValue - A string like `var(--variable-name)` or `var(--variable-name, fallback)`.
|
|
5
|
+
* @returns The extracted CSS variable name (e.g., '--palette-Tooltip-bg').
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* parseCssVar('var(--palette-Tooltip-bg)'); // → '--palette-Tooltip-bg'
|
|
9
|
+
* parseCssVar('var(--palette-Tooltip-bg, rgba(69, 79, 91, 0.92))'); // → '--palette-Tooltip-bg'
|
|
10
|
+
* parseCssVar(theme.vars.palette.Tooltip.bg); // → '--palette-Tooltip-bg'
|
|
11
|
+
*/
|
|
12
|
+
declare function parseCssVar(cssValue: unknown): string;
|
|
13
|
+
|
|
14
|
+
export { parseCssVar };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the CSS variable name from a `var(--...)` expression.
|
|
3
|
+
*
|
|
4
|
+
* @param cssValue - A string like `var(--variable-name)` or `var(--variable-name, fallback)`.
|
|
5
|
+
* @returns The extracted CSS variable name (e.g., '--palette-Tooltip-bg').
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* parseCssVar('var(--palette-Tooltip-bg)'); // → '--palette-Tooltip-bg'
|
|
9
|
+
* parseCssVar('var(--palette-Tooltip-bg, rgba(69, 79, 91, 0.92))'); // → '--palette-Tooltip-bg'
|
|
10
|
+
* parseCssVar(theme.vars.palette.Tooltip.bg); // → '--palette-Tooltip-bg'
|
|
11
|
+
*/
|
|
12
|
+
declare function parseCssVar(cssValue: unknown): string;
|
|
13
|
+
|
|
14
|
+
export { parseCssVar };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(r){if(typeof r!="string"||!r.trim())return console.error("Invalid input: CSS value must be a non-empty string"),"";let n=r.match(/var\(\s*(--[\w-]+)(?:\s*,[^)]*)?\s*\)/);return n?n[1]:(console.error(`Invalid CSS variable format: "${r}". Expected format: var(--variable-name)`),"")}export{t as parseCssVar};
|