minimal-shared 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. package/dist/hooks/index.cjs +1 -0
  2. package/dist/hooks/index.d.cts +19 -0
  3. package/dist/hooks/index.js +1 -17
  4. package/dist/hooks/use-back-to-top/index.cjs +1 -0
  5. package/dist/hooks/use-back-to-top/index.d.cts +2 -0
  6. package/dist/hooks/use-back-to-top/index.js +1 -1
  7. package/dist/hooks/use-back-to-top/use-back-to-top.cjs +1 -0
  8. package/dist/hooks/use-back-to-top/use-back-to-top.d.cts +33 -0
  9. package/dist/hooks/use-boolean/index.cjs +1 -0
  10. package/dist/hooks/use-boolean/index.d.cts +2 -0
  11. package/dist/hooks/use-boolean/index.js +1 -1
  12. package/dist/hooks/use-boolean/use-boolean.cjs +1 -0
  13. package/dist/hooks/use-boolean/use-boolean.d.cts +29 -0
  14. package/dist/hooks/use-client-rect/index.cjs +1 -0
  15. package/dist/hooks/use-client-rect/index.d.cts +2 -0
  16. package/dist/hooks/use-client-rect/index.js +1 -1
  17. package/dist/hooks/use-client-rect/use-client-rect.cjs +1 -0
  18. package/dist/hooks/use-client-rect/use-client-rect.d.cts +29 -0
  19. package/dist/hooks/use-cookies/index.cjs +1 -0
  20. package/dist/hooks/use-cookies/index.d.cts +2 -0
  21. package/dist/hooks/use-cookies/index.js +1 -1
  22. package/dist/hooks/use-cookies/use-cookies.cjs +1 -0
  23. package/dist/hooks/use-cookies/use-cookies.d.cts +40 -0
  24. package/dist/hooks/use-copy-to-clipboard/index.cjs +1 -0
  25. package/dist/hooks/use-copy-to-clipboard/index.d.cts +1 -0
  26. package/dist/hooks/use-copy-to-clipboard/index.js +1 -1
  27. package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.cjs +1 -0
  28. package/dist/hooks/use-copy-to-clipboard/use-copy-to-clipboard.d.cts +26 -0
  29. package/dist/hooks/use-countdown-date/index.cjs +1 -0
  30. package/dist/hooks/use-countdown-date/index.d.cts +1 -0
  31. package/dist/hooks/use-countdown-date/index.js +1 -1
  32. package/dist/hooks/use-countdown-date/use-countdown-date.cjs +1 -0
  33. package/dist/hooks/use-countdown-date/use-countdown-date.d.cts +29 -0
  34. package/dist/hooks/use-countdown-seconds/index.cjs +1 -0
  35. package/dist/hooks/use-countdown-seconds/index.d.cts +2 -0
  36. package/dist/hooks/use-countdown-seconds/index.js +1 -1
  37. package/dist/hooks/use-countdown-seconds/use-countdown-seconds.cjs +1 -0
  38. package/dist/hooks/use-countdown-seconds/use-countdown-seconds.d.cts +35 -0
  39. package/dist/hooks/use-debounce/index.cjs +1 -0
  40. package/dist/hooks/use-debounce/index.d.cts +1 -0
  41. package/dist/hooks/use-debounce/index.js +1 -1
  42. package/dist/hooks/use-debounce/use-debounce.cjs +1 -0
  43. package/dist/hooks/use-debounce/use-debounce.d.cts +21 -0
  44. package/dist/hooks/use-double-click/index.cjs +1 -0
  45. package/dist/hooks/use-double-click/index.d.cts +2 -0
  46. package/dist/hooks/use-double-click/index.js +1 -1
  47. package/dist/hooks/use-double-click/use-double-click.cjs +1 -0
  48. package/dist/hooks/use-double-click/use-double-click.d.cts +28 -0
  49. package/dist/hooks/use-is-client/index.cjs +1 -0
  50. package/dist/hooks/use-is-client/index.d.cts +1 -0
  51. package/dist/hooks/use-is-client/index.js +1 -1
  52. package/dist/hooks/use-is-client/use-is-client.cjs +1 -0
  53. package/dist/hooks/use-is-client/use-is-client.d.cts +18 -0
  54. package/dist/hooks/use-local-storage/index.cjs +1 -0
  55. package/dist/hooks/use-local-storage/index.d.cts +1 -0
  56. package/dist/hooks/use-local-storage/index.js +1 -1
  57. package/dist/hooks/use-local-storage/use-local-storage.cjs +1 -0
  58. package/dist/hooks/use-local-storage/use-local-storage.d.cts +38 -0
  59. package/dist/hooks/use-multi-select/index.cjs +1 -0
  60. package/dist/hooks/use-multi-select/index.d.cts +2 -0
  61. package/dist/hooks/use-multi-select/index.js +1 -1
  62. package/dist/hooks/use-multi-select/use-multi-select.cjs +1 -0
  63. package/dist/hooks/use-multi-select/use-multi-select.d.cts +55 -0
  64. package/dist/hooks/use-popover/index.cjs +1 -0
  65. package/dist/hooks/use-popover/index.d.cts +2 -0
  66. package/dist/hooks/use-popover/index.js +1 -1
  67. package/dist/hooks/use-popover/use-popover.cjs +1 -0
  68. package/dist/hooks/use-popover/use-popover.d.cts +35 -0
  69. package/dist/hooks/use-popover-hover/index.cjs +1 -0
  70. package/dist/hooks/use-popover-hover/index.d.cts +2 -0
  71. package/dist/hooks/use-popover-hover/index.js +1 -1
  72. package/dist/hooks/use-popover-hover/use-popover-hover.cjs +1 -0
  73. package/dist/hooks/use-popover-hover/use-popover-hover.d.cts +41 -0
  74. package/dist/hooks/use-scroll-offset-top/index.cjs +1 -0
  75. package/dist/hooks/use-scroll-offset-top/index.d.cts +2 -0
  76. package/dist/hooks/use-scroll-offset-top/index.js +1 -1
  77. package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.cjs +1 -0
  78. package/dist/hooks/use-scroll-offset-top/use-scroll-offset-top.d.cts +28 -0
  79. package/dist/hooks/use-set-state/index.cjs +1 -0
  80. package/dist/hooks/use-set-state/index.d.cts +1 -0
  81. package/dist/hooks/use-set-state/index.js +1 -1
  82. package/dist/hooks/use-set-state/use-set-state.cjs +1 -0
  83. package/dist/hooks/use-set-state/use-set-state.d.cts +32 -0
  84. package/dist/hooks/use-tabs/index.cjs +1 -0
  85. package/dist/hooks/use-tabs/index.d.cts +2 -0
  86. package/dist/hooks/use-tabs/index.js +1 -1
  87. package/dist/hooks/use-tabs/use-tabs.cjs +1 -0
  88. package/dist/hooks/use-tabs/use-tabs.d.cts +30 -0
  89. package/dist/index.cjs +9 -0
  90. package/dist/index.d.cts +28 -0
  91. package/dist/index.js +9 -2
  92. package/dist/utils/active-link/active-link.cjs +1 -0
  93. package/dist/utils/active-link/active-link.d.cts +16 -0
  94. package/dist/utils/active-link/index.cjs +1 -0
  95. package/dist/utils/active-link/index.d.cts +1 -0
  96. package/dist/utils/active-link/index.js +1 -1
  97. package/dist/utils/classes/classes.cjs +1 -0
  98. package/dist/utils/classes/classes.d.cts +25 -0
  99. package/dist/utils/classes/index.cjs +1 -0
  100. package/dist/utils/classes/index.d.cts +1 -0
  101. package/dist/utils/classes/index.js +1 -1
  102. package/dist/utils/color/color.cjs +9 -0
  103. package/dist/utils/color/color.d.cts +67 -0
  104. package/dist/utils/color/index.cjs +9 -0
  105. package/dist/utils/color/index.d.cts +1 -0
  106. package/dist/utils/color/index.js +9 -1
  107. package/dist/utils/cookies/cookies.cjs +1 -0
  108. package/dist/utils/cookies/cookies.d.cts +42 -0
  109. package/dist/utils/cookies/index.cjs +1 -0
  110. package/dist/utils/cookies/index.d.cts +1 -0
  111. package/dist/utils/cookies/index.js +1 -1
  112. package/dist/utils/font/font.cjs +1 -0
  113. package/dist/utils/font/font.d.cts +37 -0
  114. package/dist/utils/font/index.cjs +1 -0
  115. package/dist/utils/font/index.d.cts +1 -0
  116. package/dist/utils/font/index.js +1 -1
  117. package/dist/utils/index.cjs +9 -0
  118. package/dist/utils/index.d.cts +10 -0
  119. package/dist/utils/index.js +9 -10
  120. package/dist/utils/local-storage/index.cjs +1 -0
  121. package/dist/utils/local-storage/index.d.cts +1 -0
  122. package/dist/utils/local-storage/index.js +1 -1
  123. package/dist/utils/local-storage/local-storage.cjs +1 -0
  124. package/dist/utils/local-storage/local-storage.d.cts +43 -0
  125. package/dist/utils/object/index.cjs +1 -0
  126. package/dist/utils/object/index.d.cts +1 -0
  127. package/dist/utils/object/index.js +1 -1
  128. package/dist/utils/object/object.cjs +1 -0
  129. package/dist/utils/object/object.d.cts +26 -0
  130. package/dist/utils/transform-number/index.cjs +1 -0
  131. package/dist/utils/transform-number/index.d.cts +1 -0
  132. package/dist/utils/transform-number/index.js +1 -1
  133. package/dist/utils/transform-number/transform-number.cjs +1 -0
  134. package/dist/utils/transform-number/transform-number.d.cts +31 -0
  135. package/dist/utils/url/index.cjs +1 -0
  136. package/dist/utils/url/index.d.cts +1 -0
  137. package/dist/utils/url/index.js +1 -1
  138. package/dist/utils/url/url.cjs +1 -0
  139. package/dist/utils/url/url.d.cts +54 -0
  140. package/dist/utils/uuidv4/index.cjs +1 -0
  141. package/dist/utils/uuidv4/index.d.cts +1 -0
  142. package/dist/utils/uuidv4/index.js +1 -1
  143. package/dist/utils/uuidv4/uuidv4.cjs +1 -0
  144. package/dist/utils/uuidv4/uuidv4.d.cts +12 -0
  145. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ "use strict";var T=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var o in t)T(e,o,{get:t[o],enumerable:!0})},h=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of v(t))!w.call(e,r)&&r!==o&&T(e,r,{get:()=>t[r],enumerable:!(i=_(t,r))||i.enumerable});return e};var x=e=>h(T({},"__esModule",{value:!0}),e);var z={};y(z,{useLocalStorage:()=>V});module.exports=x(z);var s=require("react");function S(e,t){if(!b())return t??null;let o=localStorage.getItem(e);if(o!=="undefined"){if(o)try{return JSON.parse(o)}catch{return o??t??null}return t??null}}function c(e,t){try{let o=JSON.stringify(t);window.localStorage.setItem(e,o)}catch(o){console.error("Error while setting storage:",o)}}function p(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function b(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function V(e,t,o){let{initializeWithValue:i=!0}=o??{},r=t&&typeof t=="object",[d,n]=(0,s.useState)(t);(0,s.useEffect)(()=>{let a=S(e);a?n(r?l=>({...l,...a}):a):t&&i&&c(e,t)},[]);let u=(0,s.useCallback)(a=>{r?n(l=>{let m={...l,...a};return c(e,m),m}):(c(e,a),n(a))},[e,r]),g=(0,s.useCallback)((a,l)=>{r&&u({[a]:l})},[r,u]),f=(0,s.useCallback)(a=>{n(a??t),p(e)},[t,e]);return(0,s.useMemo)(()=>({state:d,setState:u,setField:g,resetState:f}),[f,g,u,d])}0&&(module.exports={useLocalStorage});
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Custom hook to manage state with local storage.
3
+ *
4
+ * @param {string} key - The key for the local storage.
5
+ * @param {T} initialState - The initial state value.
6
+ * @param {Object} [options] - Optional settings.
7
+ * @param {boolean} [options.initializeWithValue=true] - Whether to initialize the local storage with the initial state value.
8
+ *
9
+ * @returns {UseLocalStorageReturn<T>} - An object containing:
10
+ * - `state`: The current state.
11
+ * - `resetState`: A function to reset the state to the initial value and remove it from local storage.
12
+ * - `setState`: A function to update the state and save it to local storage.
13
+ * - `setField`: A function to update a specific field in the state and save it to local storage.
14
+ *
15
+ * @example
16
+ * const { state, resetState, setState, setField } = useLocalStorage('settings', initialState);
17
+ *
18
+ * return (
19
+ * <div>
20
+ * <p>State: {JSON.stringify(state)}</p>
21
+ * <button onClick={() => setState({name: 'John', age: 20})}>Set State</button>
22
+ * <button onClick={() => setField('name', 'John')}>Set Name</button>
23
+ * <button onClick={resetState}>Reset</button>
24
+ * </div>
25
+ * );
26
+ */
27
+ type UseLocalStorageOptions = {
28
+ initializeWithValue?: boolean;
29
+ };
30
+ type UseLocalStorageReturn<T> = {
31
+ state: T;
32
+ resetState: (defaultState?: T) => void;
33
+ setState: (updateState: T | Partial<T>) => void;
34
+ setField: (name: keyof T, updateValue: T[keyof T]) => void;
35
+ };
36
+ declare function useLocalStorage<T>(key: string, initialState?: T, options?: UseLocalStorageOptions): UseLocalStorageReturn<T>;
37
+
38
+ export { type UseLocalStorageOptions, type UseLocalStorageReturn, useLocalStorage };
@@ -0,0 +1 @@
1
+ "use strict";var i=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},m=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of p(t))!d.call(e,c)&&c!==n&&i(e,c,{get:()=>t[c],enumerable:!(l=h(t,c))||l.enumerable});return e};var A=e=>m(i({},"__esModule",{value:!0}),e);var v={};f(v,{updateSelectedItems:()=>u,useMultiSelect:()=>k});module.exports=A(v);var r=require("react");function k(e,t){let[n,l]=(0,r.useState)(t??[]),c=(0,r.useCallback)(o=>{l(S=>u(S,o))},[]),s=(0,r.useCallback)(()=>{l(o=>o.length===e.length?[]:e)},[e]),g=(0,r.useCallback)(()=>{l([])},[]),a=(0,r.useMemo)(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:a,setValues:l,onSelectAllItems:s,onDeSelectAllItems:g,onToggleSelectItem:c}}function u(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}0&&(module.exports={updateSelectedItems,useMultiSelect});
@@ -0,0 +1,2 @@
1
+ export { UseMultiSelectReturn, updateSelectedItems, useMultiSelect } from './use-multi-select.cjs';
2
+ import 'react';
@@ -1 +1 @@
1
- export * from './use-multi-select';
1
+ import{useMemo as a,useState as S,useCallback as c}from"react";function d(e,n){let[t,r]=S(n??[]),o=c(l=>{r(g=>h(g,l))},[]),i=c(()=>{r(l=>l.length===e.length?[]:e)},[e]),u=c(()=>{r([])},[]),s=a(()=>t.length===0?"unchecked":t.length===e.length?"checked":"indeterminate",[e.length,t.length]);return{values:t,status:s,setValues:r,onSelectAllItems:i,onDeSelectAllItems:u,onToggleSelectItem:o}}function h(e,n){return e.includes(n)?e.filter(t=>t!==n):[...e,n]}export{h as updateSelectedItems,d as useMultiSelect};
@@ -0,0 +1 @@
1
+ "use strict";var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},m=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of p(t))!d.call(e,c)&&c!==n&&o(e,c,{get:()=>t[c],enumerable:!(r=h(t,c))||r.enumerable});return e};var A=e=>m(o({},"__esModule",{value:!0}),e);var v={};f(v,{updateSelectedItems:()=>u,useMultiSelect:()=>k});module.exports=A(v);var l=require("react");function k(e,t){let[n,r]=(0,l.useState)(t??[]),c=(0,l.useCallback)(i=>{r(S=>u(S,i))},[]),s=(0,l.useCallback)(()=>{r(i=>i.length===e.length?[]:e)},[e]),g=(0,l.useCallback)(()=>{r([])},[]),a=(0,l.useMemo)(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:a,setValues:r,onSelectAllItems:s,onDeSelectAllItems:g,onToggleSelectItem:c}}function u(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}0&&(module.exports={updateSelectedItems,useMultiSelect});
@@ -0,0 +1,55 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+
3
+ /**
4
+ * Custom hook to manage the selection state of a list of items.
5
+ *
6
+ * @param {string[]} itemIds - The list of item IDs to manage.
7
+ * @param {string[]} [defaultSelected=[]] - The list of default selected item IDs.
8
+ *
9
+ * @returns {UseMultiSelectReturn} - An object containing:
10
+ * - `values`: The current list of selected item IDs.
11
+ * - `status`: The current selection status ('checked', 'unchecked', 'indeterminate').
12
+ * - `setValues`: A function to manually set the selected item IDs.
13
+ * - `onSelectAllItems`: A function to select all items.
14
+ * - `onDeSelectAllItems`: A function to deselect all items.
15
+ * - `onToggleSelectItem`: A function to toggle the selection of a specific item.
16
+ *
17
+ * @example
18
+ * const { values, status, onSelectAllItems, onDeSelectAllItems, onToggleSelectItem } = useMultiSelect(['item1', 'item2', 'item3'], ['item1']);
19
+ *
20
+ * return (
21
+ * <div>
22
+ * <button onClick={onSelectAllItems}>Select All</button>
23
+ * <button onClick={onDeSelectAllItems}>Deselect All</button>
24
+ * {itemIds.map(itemId => (
25
+ * <div key={itemId}>
26
+ * <input
27
+ * type="checkbox"
28
+ * checked={values.includes(itemId)}
29
+ * onChange={() => onToggleSelectItem(itemId)}
30
+ * />
31
+ * {itemId}
32
+ * </div>
33
+ * ))}
34
+ * </div>
35
+ * );
36
+ */
37
+ type UseMultiSelectReturn = {
38
+ values: string[];
39
+ status: 'checked' | 'unchecked' | 'indeterminate';
40
+ setValues: Dispatch<SetStateAction<string[]>>;
41
+ onSelectAllItems: () => void;
42
+ onDeSelectAllItems: () => void;
43
+ onToggleSelectItem: (inputValue: string) => void;
44
+ };
45
+ declare function useMultiSelect(listItems: string[], defaultSelectedItems?: string[]): UseMultiSelectReturn;
46
+ /**
47
+ * Updates the selected items list by adding or removing the specified item.
48
+ *
49
+ * @param {string[]} selectedItems - The current list of selected items.
50
+ * @param {string} newItem - The item to add or remove.
51
+ * @returns {string[]} - The updated list of selected items.
52
+ */
53
+ declare function updateSelectedItems(selectedItems: string[], newItem: string): string[];
54
+
55
+ export { type UseMultiSelectReturn, updateSelectedItems, useMultiSelect };
@@ -0,0 +1 @@
1
+ "use strict";var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var a=(o,e)=>{for(var n in e)s(o,n,{get:e[n],enumerable:!0})},T=(o,e,n,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of u(e))!c.call(o,t)&&t!==n&&s(o,t,{get:()=>e[t],enumerable:!(l=p(e,t))||l.enumerable});return o};var E=o=>T(s({},"__esModule",{value:!0}),o);var v={};a(v,{usePopover:()=>i});module.exports=E(v);var r=require("react");function i(){let[o,e]=(0,r.useState)(null),n=(0,r.useCallback)(t=>{e(t.currentTarget)},[]),l=(0,r.useCallback)(()=>{e(null)},[]);return{open:!!o,anchorEl:o,onOpen:n,onClose:l,setAnchorEl:e}}0&&(module.exports={usePopover});
@@ -0,0 +1,2 @@
1
+ export { UsePopoverReturn, usePopover } from './use-popover.cjs';
2
+ import 'react';
@@ -1 +1 @@
1
- export * from './use-popover';
1
+ import{useState as s,useCallback as t}from"react";function u(){let[o,e]=s(null),n=t(l=>{e(l.currentTarget)},[]),r=t(()=>{e(null)},[]);return{open:!!o,anchorEl:o,onOpen:n,onClose:r,setAnchorEl:e}}export{u as usePopover};
@@ -0,0 +1 @@
1
+ "use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var a=(t,e)=>{for(var o in e)s(t,o,{get:e[o],enumerable:!0})},T=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of c(e))!p.call(t,n)&&n!==o&&s(t,n,{get:()=>e[n],enumerable:!(r=u(e,n))||r.enumerable});return t};var E=t=>T(s({},"__esModule",{value:!0}),t);var v={};a(v,{usePopover:()=>i});module.exports=E(v);var l=require("react");function i(){let[t,e]=(0,l.useState)(null),o=(0,l.useCallback)(n=>{e(n.currentTarget)},[]),r=(0,l.useCallback)(()=>{e(null)},[]);return{open:!!t,anchorEl:t,onOpen:o,onClose:r,setAnchorEl:e}}0&&(module.exports={usePopover});
@@ -0,0 +1,35 @@
1
+ import { MouseEvent, Dispatch, SetStateAction } from 'react';
2
+
3
+ /**
4
+ * Custom hook to manage the state of a popover.
5
+ *
6
+ * @returns {UsePopoverReturn<T>} - An object containing:
7
+ * - `open`: A boolean indicating whether the popover is open.
8
+ * - `anchorEl`: The current element that the popover is anchored to.
9
+ * - `onClose`: A function to close the popover.
10
+ * - `onOpen`: A function to open the popover.
11
+ * - `setAnchorEl`: A function to manually set the anchor element.
12
+ *
13
+ * @example
14
+ * const { open, anchorEl, onOpen, onClose } = usePopover<HTMLButtonElement>();
15
+ *
16
+ * return (
17
+ * <>
18
+ * <button variant="contained" onClick={onOpen}>Click me</button>
19
+ *
20
+ * <Popover open={open} onClose={onClose} anchorEl={anchorEl}>
21
+ * Popover content
22
+ * </Popover>
23
+ * </>
24
+ * );
25
+ */
26
+ type UsePopoverReturn<T> = {
27
+ open: boolean;
28
+ anchorEl: T | null;
29
+ onClose: () => void;
30
+ onOpen: (event: MouseEvent<HTMLElement>) => void;
31
+ setAnchorEl: Dispatch<SetStateAction<T | null>>;
32
+ };
33
+ declare function usePopover<T extends HTMLElement>(): UsePopoverReturn<T>;
34
+
35
+ export { type UsePopoverReturn, usePopover };
@@ -0,0 +1 @@
1
+ "use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var i=(o,e)=>{for(var n in e)s(o,n,{get:e[n],enumerable:!0})},R=(o,e,n,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of f(e))!u.call(o,t)&&t!==n&&s(o,t,{get:()=>e[t],enumerable:!(l=a(e,t))||l.enumerable});return o};var m=o=>R(s({},"__esModule",{value:!0}),o);var T={};i(T,{usePopoverHover:()=>v});module.exports=m(T);var r=require("react");function v(o){let e=(0,r.useRef)(null),n=o||e,[l,t]=(0,r.useState)(!1),c=(0,r.useCallback)(()=>{t(!0)},[]),p=(0,r.useCallback)(()=>{t(!1)},[]);return{elementRef:n,anchorEl:n.current,open:l,onOpen:c,onClose:p,setOpen:t}}0&&(module.exports={usePopoverHover});
@@ -0,0 +1,2 @@
1
+ export { usePopoverHover } from './use-popover-hover.cjs';
2
+ import 'react';
@@ -1 +1 @@
1
- export * from './use-popover-hover';
1
+ import{useRef as p,useState as a,useCallback as t}from"react";function u(n){let r=p(null),o=n||r,[l,e]=a(!1),s=t(()=>{e(!0)},[]),c=t(()=>{e(!1)},[]);return{elementRef:o,anchorEl:o.current,open:l,onOpen:s,onClose:c,setOpen:e}}export{u as usePopoverHover};
@@ -0,0 +1 @@
1
+ "use strict";var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var i=(o,e)=>{for(var n in e)s(o,n,{get:e[n],enumerable:!0})},R=(o,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of u(e))!f.call(o,t)&&t!==n&&s(o,t,{get:()=>e[t],enumerable:!(r=p(e,t))||r.enumerable});return o};var v=o=>R(s({},"__esModule",{value:!0}),o);var b={};i(b,{usePopoverHover:()=>T});module.exports=v(b);var l=require("react");function T(o){let e=(0,l.useRef)(null),n=o||e,[r,t]=(0,l.useState)(!1),c=(0,l.useCallback)(()=>{t(!0)},[]),a=(0,l.useCallback)(()=>{t(!1)},[]);return{elementRef:n,anchorEl:n.current,open:r,onOpen:c,onClose:a,setOpen:t}}0&&(module.exports={usePopoverHover});
@@ -0,0 +1,41 @@
1
+ import { RefObject, Dispatch, SetStateAction } from 'react';
2
+
3
+ /**
4
+ * Custom hook to manage the state of a popover that opens on hover.
5
+ *
6
+ * @param {RefObject<T>} [inputRef] - An optional ref object to use for the popover element.
7
+ *
8
+ * @returns {UsePopoverHoverReturn<T>} - An object containing:
9
+ * - `open`: A boolean indicating whether the popover is open.
10
+ * - `onOpen`: A function to open the popover.
11
+ * - `anchorEl`: The current element that the popover is anchored to.
12
+ * - `onClose`: A function to close the popover.
13
+ * - `elementRef`: A ref object for the popover element.
14
+ * - `setOpen`: A function to manually set the open state of the popover.
15
+ *
16
+ * @example
17
+ * const { open, onOpen, onClose, elementRef } = usePopoverHover<HTMLButtonElement>();
18
+ *
19
+ * return (
20
+ * <>
21
+ * <button ref={elementRef} onMouseEnter={onOpen} onMouseLeave={onClose}>
22
+ * Hover me
23
+ * </button>
24
+ *
25
+ * <Popover open={open} anchorEl={anchorEl}>
26
+ * Popover content
27
+ * </Popover>
28
+ * </>
29
+ * );
30
+ */
31
+ type UsePopoverHoverReturn<T> = {
32
+ open: boolean;
33
+ onOpen: () => void;
34
+ anchorEl: T | null;
35
+ onClose: () => void;
36
+ elementRef: RefObject<T>;
37
+ setOpen: Dispatch<SetStateAction<boolean>>;
38
+ };
39
+ declare function usePopoverHover<T extends HTMLElement>(inputRef?: RefObject<T>): UsePopoverHoverReturn<T>;
40
+
41
+ export { usePopoverHover };
@@ -0,0 +1 @@
1
+ "use strict";var f=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var r in e)f(o,r,{get:e[r],enumerable:!0})},i=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of T(e))!m.call(o,t)&&t!==r&&f(o,t,{get:()=>e[t],enumerable:!(s=p(e,t))||s.enumerable});return o};var w=o=>i(f({},"__esModule",{value:!0}),o);var R={};u(R,{useScrollOffsetTop:()=>O});module.exports=w(R);var n=require("react");function O(o=0){let e=(0,n.useRef)(null),[r,s]=(0,n.useState)(!1),t=(0,n.useCallback)(()=>{let l=window.scrollY;if(e.current){let c=e.current.offsetTop;s(l>c-o)}else s(l>o)},[o]);return(0,n.useEffect)(()=>(t(),window.addEventListener("scroll",t),()=>{window.removeEventListener("scroll",t)}),[t]),{elementRef:e,offsetTop:r}}0&&(module.exports={useScrollOffsetTop});
@@ -0,0 +1,2 @@
1
+ export { UseScrollOffsetTopReturn, useScrollOffsetTop } from './use-scroll-offset-top.cjs';
2
+ import 'react';
@@ -1 +1 @@
1
- export * from './use-scroll-offset-top';
1
+ import{useRef as l,useState as c,useEffect as p,useCallback as T}from"react";function u(o=0){let t=l(null),[s,n]=c(!1),e=T(()=>{let r=window.scrollY;if(t.current){let f=t.current.offsetTop;n(r>f-o)}else n(r>o)},[o]);return p(()=>(e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}),[e]),{elementRef:t,offsetTop:s}}export{u as useScrollOffsetTop};
@@ -0,0 +1 @@
1
+ "use strict";var l=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var i=(o,e)=>{for(var r in e)l(o,r,{get:e[r],enumerable:!0})},m=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of T(e))!u.call(o,t)&&t!==r&&l(o,t,{get:()=>e[t],enumerable:!(s=p(e,t))||s.enumerable});return o};var w=o=>m(l({},"__esModule",{value:!0}),o);var R={};i(R,{useScrollOffsetTop:()=>O});module.exports=w(R);var n=require("react");function O(o=0){let e=(0,n.useRef)(null),[r,s]=(0,n.useState)(!1),t=(0,n.useCallback)(()=>{let f=window.scrollY;if(e.current){let c=e.current.offsetTop;s(f>c-o)}else s(f>o)},[o]);return(0,n.useEffect)(()=>(t(),window.addEventListener("scroll",t),()=>{window.removeEventListener("scroll",t)}),[t]),{elementRef:e,offsetTop:r}}0&&(module.exports={useScrollOffsetTop});
@@ -0,0 +1,28 @@
1
+ import { RefObject } from 'react';
2
+
3
+ /**
4
+ * Custom hook to manage the offset top state based on scroll position.
5
+ *
6
+ * @param {number} [defaultValue=0] - The offset value at which the state changes.
7
+ *
8
+ * @returns {UseScrollOffsetTopReturn<T>} - An object containing:
9
+ * - `offsetTop`: A boolean indicating whether the scroll position is past the offset.
10
+ * - `elementRef`: A ref object to attach to the element to track its offset.
11
+ *
12
+ * @example
13
+ * 1.Applies to top <header/>
14
+ * const { offsetTop } = useScrollOffsetTop(80);
15
+ *
16
+ * Or
17
+ *
18
+ * 2.Applies to element
19
+ * const { offsetTop, elementRef } = useScrollOffsetTop(80);
20
+ * <div ref={elementRef} />
21
+ */
22
+ type UseScrollOffsetTopReturn<T> = {
23
+ offsetTop: boolean;
24
+ elementRef: RefObject<T>;
25
+ };
26
+ declare function useScrollOffsetTop<T extends HTMLElement>(defaultValue?: number): UseScrollOffsetTopReturn<T>;
27
+
28
+ export { type UseScrollOffsetTopReturn, useScrollOffsetTop };
@@ -0,0 +1 @@
1
+ "use strict";var d=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var a in e)d(t,a,{get:e[a],enumerable:!0})},c=(t,e,a,T)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of f(e))!p.call(t,s)&&s!==a&&d(t,s,{get:()=>e[s],enumerable:!(T=n(e,s))||T.enumerable});return t};var i=t=>c(d({},"__esModule",{value:!0}),t);var y={};l(y,{useSetState:()=>k});module.exports=i(y);var o=require("react");function k(t){let[e,a]=(0,o.useState)(t),T=(0,o.useCallback)(r=>{a(u=>({...u,...r}))},[]),s=(0,o.useCallback)((r,u)=>{T({[r]:u})},[T]),S=(0,o.useCallback)(r=>{a(r??t)},[t]);return{state:e,setState:T,setField:s,resetState:S}}0&&(module.exports={useSetState});
@@ -0,0 +1 @@
1
+ export { UseSetStateReturn, useSetState } from './use-set-state.cjs';
@@ -1 +1 @@
1
- export * from './use-set-state';
1
+ import{useState as S,useCallback as T}from"react";function f(e){let[r,o]=S(e),a=T(t=>{o(s=>({...s,...t}))},[]),u=T((t,s)=>{a({[t]:s})},[a]),d=T(t=>{o(t??e)},[e]);return{state:r,setState:a,setField:u,resetState:d}}export{f as useSetState};
@@ -0,0 +1 @@
1
+ "use strict";var r=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var a in e)r(t,a,{get:e[a],enumerable:!0})},c=(t,e,a,T)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of f(e))!l.call(t,s)&&s!==a&&r(t,s,{get:()=>e[s],enumerable:!(T=n(e,s))||T.enumerable});return t};var i=t=>c(r({},"__esModule",{value:!0}),t);var y={};p(y,{useSetState:()=>k});module.exports=i(y);var o=require("react");function k(t){let[e,a]=(0,o.useState)(t),T=(0,o.useCallback)(u=>{a(d=>({...d,...u}))},[]),s=(0,o.useCallback)((u,d)=>{T({[u]:d})},[T]),S=(0,o.useCallback)(u=>{a(u??t)},[t]);return{state:e,setState:T,setField:s,resetState:S}}0&&(module.exports={useSetState});
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Custom hook to manage state with utility functions to set state, set a specific field, and reset state.
3
+ *
4
+ * @param {T} initialState - The initial state value.
5
+ *
6
+ * @returns {UseSetStateReturn<T>} - An object containing:
7
+ * - `state`: The current state.
8
+ * - `resetState`: A function to reset the state to the initial value.
9
+ * - `setState`: A function to update the state.
10
+ * - `setField`: A function to update a specific field in the state.
11
+ *
12
+ * @example
13
+ * const { state, setState, setField, resetState } = useSetState({ name: '', age: 0 });
14
+ *
15
+ * return (
16
+ * <div>
17
+ * <p>Name: {state.name}</p>
18
+ * <p>Age: {state.age}</p>
19
+ * <button onClick={() => setField('name', 'John')}>Set Name</button>
20
+ * <button onClick={resetState}>Reset</button>
21
+ * </div>
22
+ * );
23
+ */
24
+ type UseSetStateReturn<T> = {
25
+ state: T;
26
+ resetState: (defaultState?: T) => void;
27
+ setState: (updateState: T | Partial<T>) => void;
28
+ setField: (name: keyof T, updateValue: T[keyof T]) => void;
29
+ };
30
+ declare function useSetState<T>(initialState?: T): UseSetStateReturn<T>;
31
+
32
+ export { type UseSetStateReturn, useSetState };
@@ -0,0 +1 @@
1
+ "use strict";var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},S=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!p.call(e,s)&&s!==n&&i(e,s,{get:()=>t[s],enumerable:!(a=c(t,s))||a.enumerable});return e};var g=e=>S(i({},"__esModule",{value:!0}),e);var l={};v(l,{useTabs:()=>h});module.exports=g(l);var r=require("react");function h(e){let[t,n]=(0,r.useState)(e),a=(0,r.useCallback)((s,o)=>{n(o)},[]);return{value:t,setValue:n,onChange:a}}0&&(module.exports={useTabs});
@@ -0,0 +1,2 @@
1
+ export { UseTabsReturn, useTabs } from './use-tabs.cjs';
2
+ import 'react';
@@ -1 +1 @@
1
- export * from './use-tabs';
1
+ import{useState as r,useCallback as i}from"react";function u(e){let[n,t]=r(e),s=i((o,a)=>{t(a)},[]);return{value:n,setValue:t,onChange:s}}export{u as useTabs};
@@ -0,0 +1 @@
1
+ "use strict";var r=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},S=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!p.call(e,s)&&s!==n&&r(e,s,{get:()=>t[s],enumerable:!(a=c(t,s))||a.enumerable});return e};var g=e=>S(r({},"__esModule",{value:!0}),e);var l={};v(l,{useTabs:()=>h});module.exports=g(l);var i=require("react");function h(e){let[t,n]=(0,i.useState)(e),a=(0,i.useCallback)((s,o)=>{n(o)},[]);return{value:t,setValue:n,onChange:a}}0&&(module.exports={useTabs});
@@ -0,0 +1,30 @@
1
+ import { Dispatch, SetStateAction, SyntheticEvent } from 'react';
2
+
3
+ /**
4
+ * Custom hook to manage the state of tabs.
5
+ *
6
+ * @param {string} defaultValue - The initial value of the tab.
7
+ *
8
+ * @returns {UseTabsReturn} - An object containing:
9
+ * - `value`: The current value of the tab.
10
+ * - `setValue`: A function to manually set the value of the tab.
11
+ * - `onChange`: A function to handle the change event when a new tab is selected.
12
+ *
13
+ * @example
14
+ * const { value, onChange } = useTabs('tab1');
15
+ *
16
+ * return (
17
+ * <Tabs value={value} onChange={onChange}>
18
+ * <Tab label="Tab 1" value="tab1" />
19
+ * <Tab label="Tab 2" value="tab2" />
20
+ * </Tabs>
21
+ * );
22
+ */
23
+ type UseTabsReturn = {
24
+ value: string;
25
+ setValue: Dispatch<SetStateAction<string>>;
26
+ onChange: (event: SyntheticEvent, newValue: string) => void;
27
+ };
28
+ declare function useTabs(defaultValue: string): UseTabsReturn;
29
+
30
+ export { type UseTabsReturn, useTabs };
package/dist/index.cjs ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";var M=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var ee=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},te=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of X(t))!Z.call(e,o)&&o!==n&&M(e,o,{get:()=>t[o],enumerable:!(r=Q(t,o))||r.enumerable});return e};var ne=e=>te(M({},"__esModule",{value:!0}),e);var Ie={};ee(Ie,{createPaletteChannel:()=>ae,getCookie:()=>B,getStorage:()=>N,hasKeys:()=>le,hasParams:()=>L,hexToRgbChannel:()=>J,isActiveLink:()=>fe,isEqualPath:()=>oe,isExternalLink:()=>$,localStorageAvailable:()=>Y,mergeClasses:()=>pe,pxToRem:()=>ie,remToPx:()=>se,removeCookie:()=>F,removeLastSlash:()=>v,removeParams:()=>H,removeStorage:()=>j,setCookie:()=>w,setFont:()=>re,setStorage:()=>E,transformNumber:()=>de,transformValue:()=>W,transformValueOnBlur:()=>K,transformValueOnChange:()=>G,updateSelectedItems:()=>q,useBackToTop:()=>ye,useBoolean:()=>ge,useClientRect:()=>Ce,useCookies:()=>he,useCopyToClipboard:()=>Ae,useCountdownDate:()=>Ue,useCountdownSeconds:()=>De,useDebounce:()=>Se,useDoubleClick:()=>ke,useIsClient:()=>xe,useLocalStorage:()=>we,useMultiSelect:()=>Re,usePopover:()=>Te,usePopoverHover:()=>Ee,useScrollOffsetTop:()=>Oe,useSetState:()=>be,useTabs:()=>me,uuidv4:()=>ce,varAlpha:()=>ue});module.exports=ne(Ie);var L=e=>{let t=e.split("?")[1];return t?new URLSearchParams(t).toString().length>0:!1};function v(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function oe(e,t){return v(e)===v(t)}function H(e){try{let t=new URL(e,window.location.origin);return v(t.pathname)}catch{return e}}function $(e){return e.startsWith("http")}var z='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function re(e){return e?`"${e}", ${z}`:z}function se(e){let t=parseFloat(e);return Math.round(t*16)}function ie(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function J(e){if(!e)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(e))throw new Error(`Invalid hex color: ${e}`);let t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),r=parseInt(e.substring(5,7),16);return`${t} ${n} ${r}`}function ae(e){let t={};return Object.entries(e).forEach(([n,r])=>{r&&(t[`${n}Channel`]=J(r))}),{...e,...t}}function ue(e,t=1){if(!e)throw new Error("[Alpha]: Color is undefined!");if(e.startsWith("#")||e.startsWith("rgb")||e.startsWith("rgba")||!e.includes("var")&&e.includes("Channel"))throw new Error(`[Alpha]: Unsupported color format "${e}".
2
+ Supported formats are:
3
+ - RGB channels: "0 184 217".
4
+ - CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)".
5
+ Unsupported formats are:
6
+ - Hex: "#00B8D9".
7
+ - RGB: "rgb(0, 184, 217)".
8
+ - RGBA: "rgba(0, 184, 217, 1)".
9
+ `);return`rgba(${e} / ${t})`}function le(e,t){return!e||!t.length||typeof e!="object"?!1:t.every(n=>n in e)}function ce(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function pe(e,t){let n=e?Array.isArray(e)?e:[e]:[],r=Object.entries(t||{}).filter(([o,s])=>s!==void 0&&s!==!1).map(([o,s])=>Array.isArray(s)?s[0]?s[1]:"":s?o:"").filter(Boolean);return[...n.filter(Boolean),...r].join(" ")}function B(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,o=decodeURIComponent(document.cookie).split("; ").find(i=>i.startsWith(t));if(!o)return null;let s=o.substring(t.length);try{return JSON.parse(s)}catch{return s}}catch(t){return console.error("Error retrieving cookie:",t),null}}function w(e,t,n){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:r=0,sameSite:o="Strict",secure:s=!1,path:i="/",domain:u}=n??{};try{let a=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),c=[`${e}=${a}`,`path=${i}`,o&&`SameSite=${o}`,s&&"Secure",u&&`domain=${u}`];if(r>0){let p=new Date(Date.now()+r*24*60*60*1e3);c.push(`expires=${p.toUTCString()}`)}document.cookie=c.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}function F(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:n="/",domain:r}=t??{};try{let o=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${n}`,r&&`domain=${r}`,"Secure"];document.cookie=o.filter(Boolean).join("; ")}catch(o){console.error("Error removing cookie:",o)}}function fe(e,t,n=!0){let r=v(e),o=L(t);if(t.startsWith("#")||$(t))return!1;if(n||o){let u=r.includes(t),a=H(t);return u||o&&a===r}return r===t}function N(e,t){if(!Y())return t??null;let n=localStorage.getItem(e);if(n!=="undefined"){if(n)try{return JSON.parse(n)}catch{return n??t??null}return t??null}}function E(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function j(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function Y(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function W(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function G(e){let n=W(e).replace(/[^0-9.]/g,""),[r,...o]=n.split(".");return o.length>0?`${r}.${o.join("")}`:r}function K(e,t=""){if(e==null||typeof e=="number"&&Number.isNaN(e))return t;let n=parseFloat(e.toString());return Number.isNaN(n)?t:n}var de={onChange:G,onBlur:K,value:W};var O=require("react");function me(e){let[t,n]=(0,O.useState)(e),r=(0,O.useCallback)((o,s)=>{n(s)},[]);return{value:t,setValue:n,onChange:r}}var C=require("react");function ge(e=!1){let[t,n]=(0,C.useState)(e),r=(0,C.useCallback)(()=>{n(!0)},[]),o=(0,C.useCallback)(()=>{n(!1)},[]),s=(0,C.useCallback)(()=>{n(i=>!i)},[]);return{value:t,onTrue:r,onFalse:o,onToggle:s,setValue:n}}var U=require("react");function Te(){let[e,t]=(0,U.useState)(null),n=(0,U.useCallback)(o=>{t(o.currentTarget)},[]),r=(0,U.useCallback)(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:n,onClose:r,setAnchorEl:t}}var m=require("react");function he(e,t,n){let{initializeWithValue:r=!0,...o}=n??{},s=t&&typeof t=="object",[i,u]=(0,m.useState)(t);(0,m.useEffect)(()=>{let l=B(e);l?u(s?T=>({...T,...l}):l):t&&r&&w(e,t,o)},[]);let a=(0,m.useCallback)(l=>{s?u(T=>{let _={...T,...l};return w(e,_,o),_}):(w(e,l,o),u(l))},[o,s,e]),c=(0,m.useCallback)((l,T)=>{s&&a({[l]:T})},[s,a]),p=(0,m.useCallback)(l=>{u(l??t),F(e)},[t,e]);return(0,m.useMemo)(()=>({state:i,setState:a,setField:c,resetState:p}),[p,c,a,i])}var D=require("react");function Se(e,t=1e3){let[n,r]=(0,D.useState)(e);return(0,D.useEffect)(()=>{let o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}var R=require("react");function be(e){let[t,n]=(0,R.useState)(e),r=(0,R.useCallback)(i=>{n(u=>({...u,...i}))},[]),o=(0,R.useCallback)((i,u)=>{r({[i]:u})},[r]),s=(0,R.useCallback)(i=>{n(i??e)},[e]);return{state:t,setState:r,setField:o,resetState:s}}var A=require("react");function xe(){let[e,t]=(0,A.useState)(!1);return(0,A.useEffect)(()=>{t(!0)},[]),e}var h=require("react");function ye(e,t){let[n,r]=(0,h.useState)(!1),o=ve(e),s=(0,h.useCallback)(()=>{let a=window.innerHeight,c=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(c/(p-a)*100);if(o.type==="percentage")r(f>=o.value);else{let l=p-a-c;r(o.value>=l)}},[o.type,o.value]),i=(0,h.useMemo)(()=>{let a;return()=>{clearTimeout(a),a=setTimeout(s,100)}},[s]);return(0,h.useEffect)(()=>{let a=t?i:s;return window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a)}},[i,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:r}}function ve(e){let t,n;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else t=e,n="number";return{value:t,type:n}}var d=require("react");function Ce(e,t){let n=(0,d.useRef)(null),r=e||n,[o,s]=(0,d.useState)(void 0),[i,u]=(0,d.useState)(void 0),a=typeof window<"u"?d.useLayoutEffect:d.useEffect,c=(0,d.useCallback)(()=>{if(r.current){let l=r.current.getBoundingClientRect();s(l),u({scrollWidth:r.current.scrollWidth,scrollHeight:r.current.scrollHeight})}},[r]);a(()=>{c()},[c]),(0,d.useEffect)(()=>{let l=t||"resize";return window.addEventListener(l,c),()=>{window.removeEventListener(l,c)}},[t,c]);let p=(0,d.useMemo)(()=>o,[o]),f=(0,d.useMemo)(()=>i,[i]);return{elementRef:r,top:p?.top??0,right:p?.right??0,bottom:p?.bottom??0,left:p?.left??0,x:p?.x??0,y:p?.y??0,width:p?.width??0,height:p?.height??0,scrollWidth:f?.scrollWidth??0,scrollHeight:f?.scrollHeight??0}}var S=require("react");function Re(e,t){let[n,r]=(0,S.useState)(t??[]),o=(0,S.useCallback)(a=>{r(c=>q(c,a))},[]),s=(0,S.useCallback)(()=>{r(a=>a.length===e.length?[]:e)},[e]),i=(0,S.useCallback)(()=>{r([])},[]),u=(0,S.useMemo)(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:u,setValues:r,onSelectAllItems:s,onDeSelectAllItems:i,onToggleSelectItem:o}}function q(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}var V=require("react");function ke({click:e,doubleClick:t,timeout:n=250}){let r=(0,V.useRef)(null),o=(0,V.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return(0,V.useCallback)(i=>{o(),e&&i.detail===1&&(r.current=setTimeout(()=>{e(i)},n)),i.detail%2===0&&t(i)},[e,t,n,o])}var g=require("react");function we(e,t,n){let{initializeWithValue:r=!0}=n??{},o=t&&typeof t=="object",[s,i]=(0,g.useState)(t);(0,g.useEffect)(()=>{let f=N(e);f?i(o?l=>({...l,...f}):f):t&&r&&E(e,t)},[]);let u=(0,g.useCallback)(f=>{o?i(l=>{let T={...l,...f};return E(e,T),T}):(E(e,f),i(f))},[e,o]),a=(0,g.useCallback)((f,l)=>{o&&u({[f]:l})},[o,u]),c=(0,g.useCallback)(f=>{i(f??t),j(e)},[t,e]);return(0,g.useMemo)(()=>({state:s,setState:u,setField:a,resetState:c}),[c,a,u,s])}var y=require("react");function Ee(e){let t=(0,y.useRef)(null),n=e||t,[r,o]=(0,y.useState)(!1),s=(0,y.useCallback)(()=>{o(!0)},[]),i=(0,y.useCallback)(()=>{o(!1)},[]);return{elementRef:n,anchorEl:n.current,open:r,onOpen:s,onClose:i,setOpen:o}}var k=require("react");function Ue(e,t="- -"){let[n,r]=(0,k.useState)({days:t,hours:t,minutes:t,seconds:t}),o=(0,k.useCallback)(()=>{let s=new Date,{days:i,hours:u,minutes:a,seconds:c}=Ve(e,s);r({days:I(i),hours:I(u),minutes:I(a),seconds:I(c)})},[e]);return(0,k.useEffect)(()=>{o();let s=setInterval(o,1e3);return()=>clearInterval(s)},[]),n}function I(e){return String(e).length===1?`0${e}`:`${e}`}function Ve(e,t){let n=e.getTime()-t.getTime();return{days:Math.floor(n/(1e3*60*60*24)),hours:Math.floor(n%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(n%(1e3*60*60)/(1e3*60)),seconds:Math.floor(n%(1e3*60)/1e3)}}var b=require("react");function Oe(e=0){let t=(0,b.useRef)(null),[n,r]=(0,b.useState)(!1),o=(0,b.useCallback)(()=>{let s=window.scrollY;if(t.current){let i=t.current.offsetTop;r(s>i-e)}else r(s>e)},[e]);return(0,b.useEffect)(()=>(o(),window.addEventListener("scroll",o),()=>{window.removeEventListener("scroll",o)}),[o]),{elementRef:t,offsetTop:n}}var x=require("react");function De(e){let[t,n]=(0,x.useState)(e),[r,o]=(0,x.useState)(!1),s=(0,x.useCallback)(()=>{o(!0)},[]),i=(0,x.useCallback)(()=>{o(!1),n(e)},[e]);return(0,x.useEffect)(()=>{let u=null;return r&&t>0?u=setInterval(()=>{n(a=>a-1)},1e3):t<=0&&o(!1),()=>{u&&clearInterval(u)}},[r,t]),{value:t,setValue:n,isCounting:r,start:s,reset:i}}var P=require("react");function Ae(){let[e,t]=(0,P.useState)(null);return{copy:(0,P.useCallback)(async r=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(r),t(r),!0}catch(o){return console.warn("Copy failed",o),t(null),!1}},[t]),copiedText:e}}0&&(module.exports={createPaletteChannel,getCookie,getStorage,hasKeys,hasParams,hexToRgbChannel,isActiveLink,isEqualPath,isExternalLink,localStorageAvailable,mergeClasses,pxToRem,remToPx,removeCookie,removeLastSlash,removeParams,removeStorage,setCookie,setFont,setStorage,transformNumber,transformValue,transformValueOnBlur,transformValueOnChange,updateSelectedItems,useBackToTop,useBoolean,useClientRect,useCookies,useCopyToClipboard,useCountdownDate,useCountdownSeconds,useDebounce,useDoubleClick,useIsClient,useLocalStorage,useMultiSelect,usePopover,usePopoverHover,useScrollOffsetTop,useSetState,useTabs,uuidv4,varAlpha});
@@ -0,0 +1,28 @@
1
+ export { hasParams, isEqualPath, isExternalLink, removeLastSlash, removeParams } from './utils/url/url.cjs';
2
+ export { pxToRem, remToPx, setFont } from './utils/font/font.cjs';
3
+ export { ChannelPalette, InputPalette, createPaletteChannel, hexToRgbChannel, varAlpha } from './utils/color/color.cjs';
4
+ export { hasKeys } from './utils/object/object.cjs';
5
+ export { uuidv4 } from './utils/uuidv4/uuidv4.cjs';
6
+ export { StateProps, mergeClasses } from './utils/classes/classes.cjs';
7
+ export { CookieOptions, getCookie, removeCookie, setCookie } from './utils/cookies/cookies.cjs';
8
+ export { isActiveLink } from './utils/active-link/active-link.cjs';
9
+ export { getStorage, localStorageAvailable, removeStorage, setStorage } from './utils/local-storage/local-storage.cjs';
10
+ export { InputValue, transformNumber, transformValue, transformValueOnBlur, transformValueOnChange } from './utils/transform-number/transform-number.cjs';
11
+ export { UseTabsReturn, useTabs } from './hooks/use-tabs/use-tabs.cjs';
12
+ export { UseBooleanReturn, useBoolean } from './hooks/use-boolean/use-boolean.cjs';
13
+ export { UsePopoverReturn, usePopover } from './hooks/use-popover/use-popover.cjs';
14
+ export { UseCookiesOptions, UseCookiesReturn, useCookies } from './hooks/use-cookies/use-cookies.cjs';
15
+ export { UseDebounceReturn, useDebounce } from './hooks/use-debounce/use-debounce.cjs';
16
+ export { UseSetStateReturn, useSetState } from './hooks/use-set-state/use-set-state.cjs';
17
+ export { UseIsClientReturn, useIsClient } from './hooks/use-is-client/use-is-client.cjs';
18
+ export { UseBackToTopReturn, useBackToTop } from './hooks/use-back-to-top/use-back-to-top.cjs';
19
+ export { UseClientRectReturn, useClientRect } from './hooks/use-client-rect/use-client-rect.cjs';
20
+ export { UseMultiSelectReturn, updateSelectedItems, useMultiSelect } from './hooks/use-multi-select/use-multi-select.cjs';
21
+ export { UseDoubleClickReturn, useDoubleClick } from './hooks/use-double-click/use-double-click.cjs';
22
+ export { UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from './hooks/use-local-storage/use-local-storage.cjs';
23
+ export { usePopoverHover } from './hooks/use-popover-hover/use-popover-hover.cjs';
24
+ export { UseCountdownDateReturn, useCountdownDate } from './hooks/use-countdown-date/use-countdown-date.cjs';
25
+ export { UseScrollOffsetTopReturn, useScrollOffsetTop } from './hooks/use-scroll-offset-top/use-scroll-offset-top.cjs';
26
+ export { UseCountdownSecondsReturn, useCountdownSeconds } from './hooks/use-countdown-seconds/use-countdown-seconds.cjs';
27
+ export { CopiedValue, CopyFn, UseCopyToClipboardReturn, useCopyToClipboard } from './hooks/use-copy-to-clipboard/use-copy-to-clipboard.cjs';
28
+ import 'react';
package/dist/index.js CHANGED
@@ -1,2 +1,9 @@
1
- export * from './utils';
2
- export * from './hooks';
1
+ var R=e=>{let t=e.split("?")[1];return t?new URLSearchParams(t).toString().length>0:!1};function m(e){return e!=="/"&&e.endsWith("/")?e.slice(0,-1):e}function De(e,t){return m(e)===m(t)}function k(e){try{let t=new URL(e,window.location.origin);return m(t.pathname)}catch{return e}}function w(e){return e.startsWith("http")}var E='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';function Ie(e){return e?`"${e}", ${E}`:E}function Pe(e){let t=parseFloat(e);return Math.round(t*16)}function Me(e){if(typeof e!="number"||isNaN(e))throw new Error(`Invalid pixel value: ${e}`);return`${e/16}rem`}function N(e){if(!e)throw new Error("Hex color is undefined!");if(!/^#[0-9A-F]{6}$/i.test(e))throw new Error(`Invalid hex color: ${e}`);let t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),o=parseInt(e.substring(5,7),16);return`${t} ${n} ${o}`}function He(e){let t={};return Object.entries(e).forEach(([n,o])=>{o&&(t[`${n}Channel`]=N(o))}),{...e,...t}}function $e(e,t=1){if(!e)throw new Error("[Alpha]: Color is undefined!");if(e.startsWith("#")||e.startsWith("rgb")||e.startsWith("rgba")||!e.includes("var")&&e.includes("Channel"))throw new Error(`[Alpha]: Unsupported color format "${e}".
2
+ Supported formats are:
3
+ - RGB channels: "0 184 217".
4
+ - CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)".
5
+ Unsupported formats are:
6
+ - Hex: "#00B8D9".
7
+ - RGB: "rgb(0, 184, 217)".
8
+ - RGBA: "rgba(0, 184, 217, 1)".
9
+ `);return`rgba(${e} / ${t})`}function Fe(e,t){return!e||!t.length||typeof e!="object"?!1:t.every(n=>n in e)}function je(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function _e(e,t){let n=e?Array.isArray(e)?e:[e]:[],o=Object.entries(t||{}).filter(([r,s])=>s!==void 0&&s!==!1).map(([r,s])=>Array.isArray(s)?s[0]?s[1]:"":s?r:"").filter(Boolean);return[...n.filter(Boolean),...o].join(" ")}function U(e){if(!e||typeof e!="string")return console.warn("Invalid cookie key provided"),null;try{let t=`${e}=`,r=decodeURIComponent(document.cookie).split("; ").find(i=>i.startsWith(t));if(!r)return null;let s=r.substring(t.length);try{return JSON.parse(s)}catch{return s}}catch(t){return console.error("Error retrieving cookie:",t),null}}function g(e,t,n){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{daysUntilExpiration:o=0,sameSite:r="Strict",secure:s=!1,path:i="/",domain:u}=n??{};try{let a=encodeURIComponent(typeof t=="string"?t:JSON.stringify(t)),c=[`${e}=${a}`,`path=${i}`,r&&`SameSite=${r}`,s&&"Secure",u&&`domain=${u}`];if(o>0){let p=new Date(Date.now()+o*24*60*60*1e3);c.push(`expires=${p.toUTCString()}`)}document.cookie=c.filter(Boolean).join("; ")}catch(a){console.error("Error setting cookie:",a)}}function V(e,t){if(!e||typeof e!="string"){console.error("Invalid cookie key provided");return}let{path:n="/",domain:o}=t??{};try{let r=[`${e}=`,"expires=Thu, 01 Jan 1970 00:00:00 GMT",`path=${n}`,o&&`domain=${o}`,"Secure"];document.cookie=r.filter(Boolean).join("; ")}catch(r){console.error("Error removing cookie:",r)}}function Ge(e,t,n=!0){let o=m(e),r=R(t);if(t.startsWith("#")||w(t))return!1;if(n||r){let u=o.includes(t),a=k(t);return u||r&&a===o}return o===t}function O(e,t){if(!j())return t??null;let n=localStorage.getItem(e);if(n!=="undefined"){if(n)try{return JSON.parse(n)}catch{return n??t??null}return t??null}}function T(e,t){try{let n=JSON.stringify(t);window.localStorage.setItem(e,n)}catch(n){console.error("Error while setting storage:",n)}}function D(e){try{window.localStorage.removeItem(e)}catch(t){console.error("Error while removing from storage:",t)}}function j(){try{let e="__some_random_key_you_are_not_going_to_use__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}function A(e,t=""){return e==null||typeof e=="number"&&Number.isNaN(e)?t:e.toString()}function W(e){let n=A(e).replace(/[^0-9.]/g,""),[o,...r]=n.split(".");return r.length>0?`${o}.${r.join("")}`:o}function _(e,t=""){if(e==null||typeof e=="number"&&Number.isNaN(e))return t;let n=parseFloat(e.toString());return Number.isNaN(n)?t:n}var Qe={onChange:W,onBlur:_,value:A};import{useState as z,useCallback as J}from"react";function et(e){let[t,n]=z(e),o=J((r,s)=>{n(s)},[]);return{value:t,setValue:n,onChange:o}}import{useState as Y,useCallback as S}from"react";function ot(e=!1){let[t,n]=Y(e),o=S(()=>{n(!0)},[]),r=S(()=>{n(!1)},[]),s=S(()=>{n(i=>!i)},[]);return{value:t,onTrue:o,onFalse:r,onToggle:s,setValue:n}}import{useState as G,useCallback as I}from"react";function it(){let[e,t]=G(null),n=I(r=>{t(r.currentTarget)},[]),o=I(()=>{t(null)},[]);return{open:!!e,anchorEl:e,onOpen:n,onClose:o,setAnchorEl:t}}import{useMemo as K,useState as q,useEffect as Q,useCallback as b}from"react";function ct(e,t,n){let{initializeWithValue:o=!0,...r}=n??{},s=t&&typeof t=="object",[i,u]=q(t);Q(()=>{let l=U(e);l?u(s?d=>({...d,...l}):l):t&&o&&g(e,t,r)},[]);let a=b(l=>{s?u(d=>{let C={...d,...l};return g(e,C,r),C}):(g(e,l,r),u(l))},[r,s,e]),c=b((l,d)=>{s&&a({[l]:d})},[s,a]),p=b(l=>{u(l??t),V(e)},[t,e]);return K(()=>({state:i,setState:a,setField:c,resetState:p}),[p,c,a,i])}import{useState as X,useEffect as Z}from"react";function dt(e,t=1e3){let[n,o]=X(e);return Z(()=>{let r=setTimeout(()=>{o(e)},t);return()=>{clearTimeout(r)}},[e,t]),n}import{useState as ee,useCallback as x}from"react";function Tt(e){let[t,n]=ee(e),o=x(i=>{n(u=>({...u,...i}))},[]),r=x((i,u)=>{o({[i]:u})},[o]),s=x(i=>{n(i??e)},[e]);return{state:t,setState:o,setField:r,resetState:s}}import{useState as te,useEffect as ne}from"react";function bt(){let[e,t]=te(!1);return ne(()=>{t(!0)},[]),e}import{useMemo as oe,useState as re,useEffect as se,useCallback as ie}from"react";function vt(e,t){let[n,o]=re(!1),r=ae(e),s=ie(()=>{let a=window.innerHeight,c=Math.round(window.scrollY),p=document.body.offsetHeight,f=Math.round(c/(p-a)*100);if(r.type==="percentage")o(f>=r.value);else{let l=p-a-c;o(r.value>=l)}},[r.type,r.value]),i=oe(()=>{let a;return()=>{clearTimeout(a),a=setTimeout(s,100)}},[s]);return se(()=>{let a=t?i:s;return window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a)}},[i,s,t]),{isVisible:n,onBackToTop:()=>{window.scrollTo({top:0,behavior:"smooth"})},setIsVisible:o}}function ae(e){let t,n;if(typeof e=="string")if(e.endsWith("%")){if(t=Number(e.slice(0,-1)),isNaN(t))throw new Error("Invalid percentage value");n="percentage"}else throw new Error("String input must end with %");else t=e,n="number";return{value:t,type:n}}import{useRef as ue,useMemo as P,useState as M,useEffect as L,useCallback as le,useLayoutEffect as ce}from"react";function kt(e,t){let n=ue(null),o=e||n,[r,s]=M(void 0),[i,u]=M(void 0),a=typeof window<"u"?ce:L,c=le(()=>{if(o.current){let l=o.current.getBoundingClientRect();s(l),u({scrollWidth:o.current.scrollWidth,scrollHeight:o.current.scrollHeight})}},[o]);a(()=>{c()},[c]),L(()=>{let l=t||"resize";return window.addEventListener(l,c),()=>{window.removeEventListener(l,c)}},[t,c]);let p=P(()=>r,[r]),f=P(()=>i,[i]);return{elementRef:o,top:p?.top??0,right:p?.right??0,bottom:p?.bottom??0,left:p?.left??0,x:p?.x??0,y:p?.y??0,width:p?.width??0,height:p?.height??0,scrollWidth:f?.scrollWidth??0,scrollHeight:f?.scrollHeight??0}}import{useMemo as pe,useState as fe,useCallback as y}from"react";function Ut(e,t){let[n,o]=fe(t??[]),r=y(a=>{o(c=>de(c,a))},[]),s=y(()=>{o(a=>a.length===e.length?[]:e)},[e]),i=y(()=>{o([])},[]),u=pe(()=>n.length===0?"unchecked":n.length===e.length?"checked":"indeterminate",[e.length,n.length]);return{values:n,status:u,setValues:o,onSelectAllItems:s,onDeSelectAllItems:i,onToggleSelectItem:r}}function de(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}import{useRef as me,useCallback as H}from"react";function Dt({click:e,doubleClick:t,timeout:n=250}){let o=me(null),r=H(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]);return H(i=>{r(),e&&i.detail===1&&(o.current=setTimeout(()=>{e(i)},n)),i.detail%2===0&&t(i)},[e,t,n,r])}import{useMemo as ge,useState as Te,useEffect as he,useCallback as v}from"react";function Mt(e,t,n){let{initializeWithValue:o=!0}=n??{},r=t&&typeof t=="object",[s,i]=Te(t);he(()=>{let f=O(e);f?i(r?l=>({...l,...f}):f):t&&o&&T(e,t)},[]);let u=v(f=>{r?i(l=>{let d={...l,...f};return T(e,d),d}):(T(e,f),i(f))},[e,r]),a=v((f,l)=>{r&&u({[f]:l})},[r,u]),c=v(f=>{i(f??t),D(e)},[t,e]);return ge(()=>({state:s,setState:u,setField:a,resetState:c}),[c,a,u,s])}import{useRef as Se,useState as be,useCallback as $}from"react";function $t(e){let t=Se(null),n=e||t,[o,r]=be(!1),s=$(()=>{r(!0)},[]),i=$(()=>{r(!1)},[]);return{elementRef:n,anchorEl:n.current,open:o,onOpen:s,onClose:i,setOpen:r}}import{useState as xe,useEffect as ye,useCallback as ve}from"react";function Nt(e,t="- -"){let[n,o]=xe({days:t,hours:t,minutes:t,seconds:t}),r=ve(()=>{let s=new Date,{days:i,hours:u,minutes:a,seconds:c}=Ce(e,s);o({days:h(i),hours:h(u),minutes:h(a),seconds:h(c)})},[e]);return ye(()=>{r();let s=setInterval(r,1e3);return()=>clearInterval(s)},[]),n}function h(e){return String(e).length===1?`0${e}`:`${e}`}function Ce(e,t){let n=e.getTime()-t.getTime();return{days:Math.floor(n/(1e3*60*60*24)),hours:Math.floor(n%(1e3*60*60*24)/(1e3*60*60)),minutes:Math.floor(n%(1e3*60*60)/(1e3*60)),seconds:Math.floor(n%(1e3*60)/1e3)}}import{useRef as Re,useState as ke,useEffect as we,useCallback as Ee}from"react";function _t(e=0){let t=Re(null),[n,o]=ke(!1),r=Ee(()=>{let s=window.scrollY;if(t.current){let i=t.current.offsetTop;o(s>i-e)}else o(s>e)},[e]);return we(()=>(r(),window.addEventListener("scroll",r),()=>{window.removeEventListener("scroll",r)}),[r]),{elementRef:t,offsetTop:n}}import{useState as B,useEffect as Ue,useCallback as F}from"react";function Yt(e){let[t,n]=B(e),[o,r]=B(!1),s=F(()=>{r(!0)},[]),i=F(()=>{r(!1),n(e)},[e]);return Ue(()=>{let u=null;return o&&t>0?u=setInterval(()=>{n(a=>a-1)},1e3):t<=0&&r(!1),()=>{u&&clearInterval(u)}},[o,t]),{value:t,setValue:n,isCounting:o,start:s,reset:i}}import{useState as Ve,useCallback as Oe}from"react";function qt(){let[e,t]=Ve(null);return{copy:Oe(async o=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(o),t(o),!0}catch(r){return console.warn("Copy failed",r),t(null),!1}},[t]),copiedText:e}}export{He as createPaletteChannel,U as getCookie,O as getStorage,Fe as hasKeys,R as hasParams,N as hexToRgbChannel,Ge as isActiveLink,De as isEqualPath,w as isExternalLink,j as localStorageAvailable,_e as mergeClasses,Me as pxToRem,Pe as remToPx,V as removeCookie,m as removeLastSlash,k as removeParams,D as removeStorage,g as setCookie,Ie as setFont,T as setStorage,Qe as transformNumber,A as transformValue,_ as transformValueOnBlur,W as transformValueOnChange,de as updateSelectedItems,vt as useBackToTop,ot as useBoolean,kt as useClientRect,ct as useCookies,qt as useCopyToClipboard,Nt as useCountdownDate,Yt as useCountdownSeconds,dt as useDebounce,Dt as useDoubleClick,bt as useIsClient,Mt as useLocalStorage,Ut as useMultiSelect,it as usePopover,$t as usePopoverHover,_t as useScrollOffsetTop,Tt as useSetState,et as useTabs,je as uuidv4,$e as varAlpha};
@@ -0,0 +1 @@
1
+ "use strict";var o=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var m=(t,n)=>{for(var s in n)o(t,s,{get:n[s],enumerable:!0})},v=(t,n,s,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of p(n))!h.call(t,r)&&r!==s&&o(t,r,{get:()=>n[r],enumerable:!(e=f(n,r))||e.enumerable});return t};var x=t=>v(o({},"__esModule",{value:!0}),t);var b={};m(b,{isActiveLink:()=>L});module.exports=x(b);var a=t=>{let n=t.split("?")[1];return n?new URLSearchParams(n).toString().length>0:!1};function i(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function c(t){try{let n=new URL(t,window.location.origin);return i(n.pathname)}catch{return t}}function l(t){return t.startsWith("http")}function L(t,n,s=!0){let e=i(t),r=a(n);if(n.startsWith("#")||l(n))return!1;if(s||r){let u=e.includes(n),g=c(n);return u||r&&g===e}return e===n}0&&(module.exports={isActiveLink});
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Determines if a given link is active based on the current pathname.
3
+ *
4
+ * @param {string} pathnameProps - The current pathname.
5
+ * @param {string} itemPath - The path of the item to check.
6
+ * @param {boolean} [deep=true] - Whether to perform a deep check, including child paths and parameters.
7
+ *
8
+ * @returns {boolean} - True if the link is active, false otherwise.
9
+ *
10
+ * @example
11
+ * const isActive = isActiveLink('/dashboard/user', '/dashboard/user', true);
12
+ * console.log(isActive); // true
13
+ */
14
+ declare function isActiveLink(pathnameProps: string, itemPath: string, deep?: boolean): boolean;
15
+
16
+ export { isActiveLink };
@@ -0,0 +1 @@
1
+ "use strict";var o=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var m=(t,r)=>{for(var s in r)o(t,s,{get:r[s],enumerable:!0})},x=(t,r,s,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of p(r))!h.call(t,n)&&n!==s&&o(t,n,{get:()=>r[n],enumerable:!(e=f(r,n))||e.enumerable});return t};var v=t=>x(o({},"__esModule",{value:!0}),t);var b={};m(b,{isActiveLink:()=>L});module.exports=v(b);var a=t=>{let r=t.split("?")[1];return r?new URLSearchParams(r).toString().length>0:!1};function i(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function c(t){try{let r=new URL(t,window.location.origin);return i(r.pathname)}catch{return t}}function l(t){return t.startsWith("http")}function L(t,r,s=!0){let e=i(t),n=a(r);if(r.startsWith("#")||l(r))return!1;if(s||n){let u=e.includes(r),g=c(r);return u||n&&g===e}return e===r}0&&(module.exports={isActiveLink});
@@ -0,0 +1 @@
1
+ export { isActiveLink } from './active-link.cjs';
@@ -1 +1 @@
1
- export * from './active-link';
1
+ var o=t=>{let r=t.split("?")[1];return r?new URLSearchParams(r).toString().length>0:!1};function s(t){return t!=="/"&&t.endsWith("/")?t.slice(0,-1):t}function i(t){try{let r=new URL(t,window.location.origin);return s(r.pathname)}catch{return t}}function a(t){return t.startsWith("http")}function x(t,r,c=!0){let n=s(t),e=o(r);if(r.startsWith("#")||a(r))return!1;if(c||e){let l=n.includes(r),u=i(r);return l||e&&u===n}return n===r}export{x 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 @@
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';
@@ -1 +1 @@
1
- export * from './classes';
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,9 @@
1
+ "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=(n,t)=>{for(var e in t)a(n,e,{get:t[e],enumerable:!0})},h=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!d.call(n,s)&&s!==e&&a(n,s,{get:()=>t[s],enumerable:!(r=p(t,s))||r.enumerable});return n};var o=n=>h(a({},"__esModule",{value:!0}),n);var c={};g(c,{createPaletteChannel:()=>l,hexToRgbChannel:()=>i,varAlpha:()=>f});module.exports=o(c);function i(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 t=parseInt(n.substring(1,3),16),e=parseInt(n.substring(3,5),16),r=parseInt(n.substring(5,7),16);return`${t} ${e} ${r}`}function l(n){let t={};return Object.entries(n).forEach(([e,r])=>{r&&(t[`${e}Channel`]=i(r))}),{...n,...t}}function f(n,t=1){if(!n)throw new Error("[Alpha]: Color is undefined!");if(n.startsWith("#")||n.startsWith("rgb")||n.startsWith("rgba")||!n.includes("var")&&n.includes("Channel"))throw new Error(`[Alpha]: Unsupported color format "${n}".
2
+ Supported formats are:
3
+ - RGB channels: "0 184 217".
4
+ - CSS variables with "Channel" prefix: "var(--palette-common-blackChannel, #000000)".
5
+ Unsupported formats are:
6
+ - Hex: "#00B8D9".
7
+ - RGB: "rgb(0, 184, 217)".
8
+ - RGBA: "rgba(0, 184, 217, 1)".
9
+ `);return`rgba(${n} / ${t})`}0&&(module.exports={createPaletteChannel,hexToRgbChannel,varAlpha});