polpo 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.cjs +3654 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.css +2172 -1
- package/dist/components.css.map +1 -1
- package/dist/components.js +3575 -1
- package/dist/components.js.map +1 -1
- package/dist/helpers.cjs +310 -1
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.js +275 -1
- package/dist/helpers.js.map +1 -1
- package/dist/hooks.cjs +1064 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +997 -1
- package/dist/hooks.js.map +1 -1
- package/dist/layouts.cjs +145 -1
- package/dist/layouts.cjs.map +1 -1
- package/dist/layouts.css +4 -1
- package/dist/layouts.css.map +1 -1
- package/dist/layouts.js +118 -1
- package/dist/layouts.js.map +1 -1
- package/dist/types.cjs +18 -1
- package/dist/types.cjs.map +1 -1
- package/package.json +4 -3
package/dist/hooks.cjs
CHANGED
|
@@ -1,3 +1,1066 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var ae=Object.create;var g=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty;var de=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},U=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ce(t))!me.call(e,r)&&r!==n&&g(e,r,{get:()=>t[r],enumerable:!(o=ue(t,r))||o.enumerable});return e};var pe=(e,t,n)=>(n=e!=null?ae(le(e)):{},U(t||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),Te=e=>U(g({},"__esModule",{value:!0}),e);var Xe={};de(Xe,{FileTypeEnum:()=>te,ModalState:()=>re,useAsync:()=>Ee,useClassNames:()=>ve,useClickOutside:()=>xe,useConstant:()=>Me,useCookie:()=>ge,useDebounce:()=>w,useDebounceState:()=>he,useDimensions:()=>Pe,useDomContainer:()=>Ce,useEventListener:()=>l,useFileReader:()=>ke,useGeolocation:()=>Ne,useHover:()=>He,useInView:()=>Ie,useInputHandlers:()=>Ae,useIntersectionObserver:()=>B,useMediaQuery:()=>De,useModal:()=>Ge,useModalInContainer:()=>we,useModalTransition:()=>Be,useMousePosition:()=>je,useOnlineStatus:()=>Fe,useRenderCount:()=>_e,useResizeObserver:()=>x,useSafeDispatch:()=>G,useScroll:()=>$e,useStateHistory:()=>Ue,useToggle:()=>ze,useToggleValues:()=>Ve,useViewport:()=>Ye});module.exports=Te(Xe);var d=require("react");var v=require("react"),G=e=>{let t=(0,v.useRef)(!1);return(0,v.useLayoutEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),(0,v.useCallback)((...n)=>{t.current&&e(...n)},[e])};var fe=(e,t)=>{switch(t.type){case"pending":return{status:"pending",data:null,error:null};case"resolved":return{status:"resolved",data:t.data,error:null};case"rejected":return{status:"rejected",data:null,error:t.error};default:throw new Error(`Unhandled action: ${JSON.stringify(t)}`)}},Ee=e=>{let[t,n]=(0,d.useReducer)(fe,{status:"idle",data:null,error:null,...e}),o=G(n),r=(0,d.useCallback)(u=>{o({type:"pending"}),u.then(a=>{o({type:"resolved",data:a})},a=>{o({type:"rejected",error:a})})},[o]),s=(0,d.useCallback)(u=>o({type:"resolved",data:u}),[o]),i=(0,d.useCallback)(u=>o({type:"rejected",error:u}),[o]);return(0,d.useMemo)(()=>({setData:s,setError:i,run:r,...t}),[t,r,s,i])};var z=require("react"),ve=e=>(0,z.useMemo)(()=>Object.entries(e).reduce((t,[n,o])=>o?[...t,n]:t,[]).join(" "),[e]);var b=require("react");function l(e,t,n,o){let r=(0,b.useRef)(t);(0,b.useEffect)(()=>{r.current=t},[t]),(0,b.useLayoutEffect)(()=>{let s=n?.current??window;if(!(s&&s.addEventListener))return;let i=u=>r.current(u);return s.addEventListener(e,i,o),()=>{s.removeEventListener(e,i,o)}},[e,n,o])}var be=(e,t)=>e.current&&!e.current.contains(t),xe=(e,t)=>{l("keydown",n=>{n.key==="Escape"&&t()}),l("mousedown",n=>{let o=n.target;if(!o?.isConnected)return;(Array.isArray(e)?e:[e]).every(s=>be(s,o))&&t()})};var V=require("react"),Me=e=>(0,V.useState)(e)[0];var y=require("react"),Oe=e=>{let t=[];if(e.expires instanceof Date)t.push(`expires=${e.expires.toUTCString()}`);else if(typeof e.days=="number"){let n=new Date;n.setTime(n.getTime()+e.days*24*60*60*1e3),t.push(`expires=${n.toUTCString()}`)}return typeof e.maxAge=="number"&&t.push(`max-age=${e.maxAge}`),t.push(`path=${e.path??"/"}`),e.domain&&t.push(`domain=${e.domain}`),e.secure&&t.push("secure"),e.sameSite&&t.push(`SameSite=${e.sameSite}`),t.length>0?`; ${t.join("; ")}`:""},Y=(e,t,n={})=>{if(typeof document>"u")return;let o=encodeURIComponent(t),r=Oe(n);document.cookie=`${e}=${o}${r}`},ye=e=>{if(typeof document>"u")return null;let t=`${e}=`,n=document.cookie?document.cookie.split(";"):[];for(let o of n){let r=o.trim();if(r.indexOf(t)===0)return decodeURIComponent(r.substring(t.length))}return null},Re=(e,t={})=>{typeof document>"u"||Y(e,"",{...t,days:-1})},ge=(e,t,n={})=>{let[o,r]=(0,y.useState)(()=>{let u=ye(e);if(u!==null)try{return JSON.parse(u)}catch{return t}return t}),s=(0,y.useCallback)((u,a={})=>{let c={...n,...a},E=JSON.stringify(u);Y(e,E,c),r(u)},[e,n]),i=(0,y.useCallback)(()=>{Re(e,n),r(t)},[e,t,n]);return[o,s,i]};var h=require("react"),w=(e,t=500)=>{let[n,o]=(0,h.useState)(e);return(0,h.useEffect)(()=>{let r=setTimeout(()=>o(e),t);return()=>{clearTimeout(r)}},[e,t]),n};var X=require("react");var he=(e,t=500)=>{let[n,o]=(0,X.useState)(e),r=w(n,t);return[n,r,o]};var Q=require("react");var W=require("react"),x=(e,t)=>{(0,W.useEffect)(()=>{let n=Array.isArray(e)?e:[e],o=new ResizeObserver(t);return n.forEach(r=>r.current&&o.observe(r.current)),()=>{o.disconnect()}},[e,t])};var Pe=e=>{let[t,n]=(0,Q.useState)({width:0,height:0});return x(e,([o])=>{if((o?.borderBoxSize??[])[0]){let{inlineSize:r,blockSize:s}=o.borderBoxSize[0];n({width:r,height:s})}else if(o.contentRect){let{width:r,height:s}=o.contentRect;n({width:r,height:s})}}),t};var P=require("react"),J=e=>{let t=document.getElementById(e);return t===null&&(t=document.createElement("div"),t.setAttribute("id",e),document.body.appendChild(t)),t},Ce=e=>{let[t,n]=(0,P.useState)(()=>J(e));return(0,P.useEffect)(()=>{let o=document.getElementById(e);if(t===null||o===null){let r=J(e);n(r)}return()=>{t&&t.parentNode&&process.env.NODE_ENV==="production"&&document.body.removeChild(t)}},[t,e]),t};var C=require("react");var K=(e,t=2)=>{if(e===0)return"0 Bytes";let n=1e3,o=t<0?0:t,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],s=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,s)).toFixed(o))+" "+r[s]};var Z=({c:e,m:t,offset:n,position:o})=>{let r=e.y+e.h+n,s=e.x-(t.w-e.w)*(50/100);switch(o){case"top":case"top center":r=e.y-t.h-n,s=e.x-(t.w-e.w)/2;break;case"top left":r=e.y-t.h-n,s=e.x-t.w+e.w;break;case"top right":r=e.y-t.h-n,s=e.x;break;case"bottom":case"bottom center":r=e.y+e.h+n,s=e.x-(t.w-e.w)/2;break;case"bottom left":r=e.y+e.h+n,s=e.x-t.w+e.w;break;case"bottom right":r=e.y+e.h+n,s=e.x;break;case"left":case"left center":r=e.y-(t.h-e.h)/2,s=e.x-t.w-n;break;case"left top":r=e.y-t.h+e.h,s=e.x-t.w-n;break;case"left bottom":r=e.y,s=e.x-t.w-n;break;case"right":case"right center":r=e.y-(t.h-e.h)/2,s=e.x+e.w+n;break;case"right top":r=e.y-t.h+e.h,s=e.x+e.w+n;break;case"right bottom":r=e.y,s=e.x+e.w+n;break}return{left:Math.round(s),top:Math.round(r)}},Se=({top:e,left:t},n,o,r)=>{let s=n.split(" "),i=[],u=t+r.w+o-window.innerWidth,a=e+r.h+o-window.innerHeight;for(let c of s)c==="top"&&e<o?i.push("bottom"):c==="left"&&t<o?i.push("right"):c==="bottom"&&a>0?i.push("top"):c==="right"&&u>0?i.push("left"):i.push(c);return i.join(" ")},Le=({top:e,left:t},n,o)=>{let r=t+n.w+o-window.innerWidth,s=e+n.h+o-window.innerHeight;return t=r>0?t-r:t,e=s>0?e-s:e,t=t<o?o:t,e=e<o?o:e,{top:e,left:t}},q=({c:e,m:t,offset:n,windowOffset:o,position:r})=>{let s={c:e,m:t,offset:n,position:r},i=Z(s),u=Se(i,r,o,t);u!==r&&(i=Z({...s,position:u}));let a=Le(i,t,o);return{left:`${a.left}px`,top:`${a.top}px`}};var ee=({position:e,windowOffset:t})=>{switch(e){case"center":return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case"top":case"top center":return{top:`${t}px`,left:"50%",transform:"translateX(-50%)"};case"top left":case"left top":return{top:`${t}px`,left:`${t}px`};case"top right":case"right top":return{top:`${t}px`,right:`${t}px`};case"bottom":case"bottom center":return{bottom:`${t}px`,left:"50%",transform:"translateX(-50%)"};case"left bottom":case"bottom left":return{bottom:`${t}px`,left:`${t}px`};case"right bottom":case"bottom right":return{bottom:`${t}px`,right:`${t}px`};case"left":case"left center":return{top:"50%",left:`${t}px`,transform:"translateY(-50%)"};case"right":case"right center":return{top:"50%",right:`${t}px`,transform:"translateY(-50%)"}}return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"}};var te=(n=>(n.PNG="image/png",n.PDF="application/pdf",n))(te||{}),ke=e=>{let[t,n]=(0,C.useState)([]);return(0,C.useEffect)(()=>{let o=[],r=!1;if(!Array.isArray(e)||e.length===0)n([]);else{let s=e.map(i=>new Promise((u,a)=>{let c=new FileReader;o.push(c),c.onload=E=>{E.target?.result&&u({name:i.name,size:i.size,formatSize:K(i.size),type:i.type,url:E.target.result})},c.onabort=()=>{a(new Error("File reading aborted"))},c.onerror=()=>{a(new Error("Failed to read file"))},c.readAsDataURL(i)}));Promise.all(s).then(i=>{r||n(i)})}return()=>{r=!0,o.forEach(s=>{s.abort()})}},[e]),t};var p=require("react"),Ne=()=>{let[e,t]=(0,p.useState)(null),[n,o]=(0,p.useState)(null),[r,s]=(0,p.useState)(!0),i=(0,p.useRef)(null);return(0,p.useEffect)(()=>{if(!navigator.geolocation){o({code:0,message:"Geolocation is not supported by your browser."}),s(!1);return}let u=c=>{t({...c.coords,timestamp:c.timestamp}),s(!1)},a=c=>{o({code:c.code,message:c.message}),s(!1)};return navigator.geolocation.getCurrentPosition(u,a),i.current=navigator.geolocation.watchPosition(u,a),()=>{i.current!==null&&navigator.geolocation.clearWatch(i.current)}},[]),{data:e,error:n,isLoading:r}};var T=require("react");var He=()=>{let[e,t]=(0,T.useState)(!1),n=(0,T.useRef)(null),o=(0,T.useCallback)(()=>t(!0),[]),r=(0,T.useCallback)(()=>t(!1),[]);return l("mouseenter",o,n),l("mouseleave",r,n),e};var S=require("react");var ne=require("react"),B=(e,t,n={})=>{(0,ne.useEffect)(()=>{let o=Array.isArray(e)?e:[e],r=new IntersectionObserver(t,n);return o.forEach(s=>s.current&&r.observe(s.current)),()=>{r.disconnect()}},[t,n,e])};var Ie=(e={})=>{let[t,n]=(0,S.useState)(!1),o=(0,S.useRef)(null);return B(o,([r])=>{n(r.isIntersecting)},e),{ref:o,inView:t}};var M=require("react"),Ae=({onBlur:e,onFocus:t,onChange:n}={})=>{let[o,r]=(0,M.useState)(!1),s=(0,M.useCallback)(a=>{r(!0),t&&t(a)},[t]),i=(0,M.useCallback)(a=>{r(!1),e&&e(a)},[e]),u=(0,M.useCallback)(a=>{n&&n(a)},[n]);return{isFocus:o,handlers:{onFocus:s,onBlur:i,onChange:u}}};var L=require("react"),De=e=>{let[t,n]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{let o=window.matchMedia(e);o.matches!==t&&n(o.matches);let r=()=>{n(o.matches)};return o.addEventListener("change",r),()=>{o.removeEventListener("change",r)}},[t,e]),t};var k=require("react"),Ge=()=>{let e=(0,k.useRef)(null),[t,n]=(0,k.useState)(!1);return{containerRef:e,isOpen:t,openModal:()=>{n(!0)},closeModal:()=>{n(!1)}}};var f=require("react");var oe=e=>({x:e.x,y:e.y,w:e.width,h:e.height,top:e.top,left:e.left}),we=({offset:e=0,windowOffset:t=0,position:n="bottom",modalRef:o,containerRef:r,isOpen:s})=>{let i=(0,f.useRef)(null),u=(0,f.useCallback)((c,E)=>{let j=c.current?.getClientRects()[0],F=E.current?.getClientRects()[0];if(!j)return;let _=F?q({c:oe(F),m:oe(j),offset:e,windowOffset:t,position:n}):ee({position:n,windowOffset:t});Object.keys(_).forEach($=>{c.current?.style.setProperty($,_[$])})},[n,t,e]),a=(0,f.useCallback)(()=>{s&&u(o,r??i)},[u,s,r,o]);(0,f.useLayoutEffect)(a,[a]),x(r??i,a),x(o,a),l("resize",a),l("scroll",a,o)};var m=pe(require("react"),1),re=(r=>(r.OPENING="OPENING",r.OPEN="OPEN",r.CLOSING="CLOSING",r.CLOSED="CLOSED",r))(re||{}),Be=({transitionDuration:e=0,isOpen:t})=>{let[n,o]=m.default.useState("CLOSED"),r=(0,m.useMemo)(()=>n!=="CLOSED",[n]);(0,m.useEffect)(()=>{document.documentElement.style.overflow=r?"hidden":"auto"},[r]);let s=(0,m.useCallback)(()=>{["OPENING","OPEN"].includes(n)&&(e>0?(o("CLOSING"),setTimeout(()=>{o("CLOSED")},e)):o("CLOSED"))},[n,e]),i=(0,m.useCallback)(()=>{["CLOSING","CLOSED"].includes(n)&&(e>0?(o("OPENING"),setTimeout(()=>{o("OPEN")},e)):o("OPEN"))},[n,e]);return(0,m.useLayoutEffect)(()=>{n==="CLOSED"&&t?i():n==="OPEN"&&!t&&s()},[t,i,s,n]),{isVisible:r,modalState:n}};var N=require("react");var se=(e,t)=>{let{left:n,top:o}=e,r=n+window.scrollX,s=o+window.scrollY,i=t.pageX-r,u=t.pageY-s;return{x:t.pageX,y:t.pageY,elementX:i,elementY:u,elementPositionX:r,elementPositionY:s}},je=e=>{let t=(0,N.useRef)(null),[n,o]=(0,N.useState)({x:null,y:null,elementX:null,elementY:null,elementPositionX:null,elementPositionY:null});return l("mousemove",s=>{let{clientX:i,clientY:u}=s;if(o(a=>({...a,x:i,y:u})),e?.current instanceof Element){let a=se(e.current.getBoundingClientRect(),s);o(c=>({...c,...a}))}else if(t.current instanceof Element){let a=se(t.current.getBoundingClientRect(),s);o(c=>({...c,...a}))}}),{...n,ref:t}};var ie=require("react");var Fe=()=>{let[e,t]=(0,ie.useState)(navigator.onLine);return l("online",()=>t(navigator.onLine)),l("offline",()=>t(navigator.onLine)),e};var H=require("react"),_e=()=>{let e=(0,H.useRef)(1);return(0,H.useEffect)(()=>{e.current++}),e.current};var O=require("react"),$e=()=>{let e=(0,O.useRef)(null),[t,n]=(0,O.useState)([0,0]);return(0,O.useEffect)(()=>{let o=e.current,r=()=>{o&&n([o.scrollLeft,o.scrollTop])};return o&&o.addEventListener("scroll",r),()=>{o&&o.removeEventListener("scroll",r)}},[]),{ref:e,position:t}};var R=require("react");function Ue(e){let[t,n]=(0,R.useState)(e),[o,r]=(0,R.useState)([]);return(0,R.useEffect)(()=>{t!==void 0&&r(s=>[...s,t])},[t]),[t,n,o]}var I=require("react"),ze=(e=!1)=>{let[t,n]=(0,I.useState)(e),o=(0,I.useCallback)(()=>{n(r=>!r)},[]);return[t,o,n]};var A=require("react"),Ve=(e,t=0)=>{let[n,o]=(0,A.useState)(t),r=(0,A.useCallback)(s=>{o(s!==void 0?s:i=>(i+1)%e.length)},[e.length]);return[e[n],r]};var D=require("react");var Ye=()=>{let e=()=>{let{innerWidth:o,innerHeight:r}=window;return{width:o,height:r,orientation:o>r?"landscape":"portrait"}},[t,n]=(0,D.useState)(e);return l("resize",()=>{n(e())}),(0,D.useEffect)(()=>{n(e())},[]),t};0&&(module.exports={FileTypeEnum,ModalState,useAsync,useClassNames,useClickOutside,useConstant,useCookie,useDebounce,useDebounceState,useDimensions,useDomContainer,useEventListener,useFileReader,useGeolocation,useHover,useInView,useInputHandlers,useIntersectionObserver,useMediaQuery,useModal,useModalInContainer,useModalTransition,useMousePosition,useOnlineStatus,useRenderCount,useResizeObserver,useSafeDispatch,useScroll,useStateHistory,useToggle,useToggleValues,useViewport});
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/hooks/index.ts
|
|
32
|
+
var hooks_exports = {};
|
|
33
|
+
__export(hooks_exports, {
|
|
34
|
+
FileTypeEnum: () => FileTypeEnum,
|
|
35
|
+
ModalState: () => ModalState,
|
|
36
|
+
useAsync: () => useAsync,
|
|
37
|
+
useClassNames: () => useClassNames,
|
|
38
|
+
useClickOutside: () => useClickOutside,
|
|
39
|
+
useConstant: () => useConstant,
|
|
40
|
+
useCookie: () => useCookie,
|
|
41
|
+
useDebounce: () => useDebounce,
|
|
42
|
+
useDebounceState: () => useDebounceState,
|
|
43
|
+
useDimensions: () => useDimensions,
|
|
44
|
+
useDomContainer: () => useDomContainer,
|
|
45
|
+
useEventListener: () => useEventListener,
|
|
46
|
+
useFileReader: () => useFileReader,
|
|
47
|
+
useGeolocation: () => useGeolocation,
|
|
48
|
+
useHover: () => useHover,
|
|
49
|
+
useInView: () => useInView,
|
|
50
|
+
useInputHandlers: () => useInputHandlers,
|
|
51
|
+
useIntersectionObserver: () => useIntersectionObserver,
|
|
52
|
+
useMediaQuery: () => useMediaQuery,
|
|
53
|
+
useModal: () => useModal,
|
|
54
|
+
useModalInContainer: () => useModalInContainer,
|
|
55
|
+
useModalTransition: () => useModalTransition,
|
|
56
|
+
useMousePosition: () => useMousePosition,
|
|
57
|
+
useOnlineStatus: () => useOnlineStatus,
|
|
58
|
+
useRenderCount: () => useRenderCount,
|
|
59
|
+
useResizeObserver: () => useResizeObserver,
|
|
60
|
+
useSafeDispatch: () => useSafeDispatch,
|
|
61
|
+
useScroll: () => useScroll,
|
|
62
|
+
useStateHistory: () => useStateHistory,
|
|
63
|
+
useToggle: () => useToggle,
|
|
64
|
+
useToggleValues: () => useToggleValues,
|
|
65
|
+
useViewport: () => useViewport
|
|
66
|
+
});
|
|
67
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
68
|
+
|
|
69
|
+
// src/hooks/use-async.ts
|
|
70
|
+
var import_react2 = require("react");
|
|
71
|
+
|
|
72
|
+
// src/hooks/use-safe-dispatch.ts
|
|
73
|
+
var import_react = require("react");
|
|
74
|
+
var useSafeDispatch = (dispatch) => {
|
|
75
|
+
const mounted = (0, import_react.useRef)(false);
|
|
76
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
77
|
+
mounted.current = true;
|
|
78
|
+
return () => {
|
|
79
|
+
mounted.current = false;
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
82
|
+
return (0, import_react.useCallback)(
|
|
83
|
+
(...args) => {
|
|
84
|
+
if (mounted.current) {
|
|
85
|
+
dispatch(...args);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[dispatch]
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/hooks/use-async.ts
|
|
93
|
+
var asyncReducer = (_state, action) => {
|
|
94
|
+
switch (action.type) {
|
|
95
|
+
case "pending": {
|
|
96
|
+
return { status: "pending", data: null, error: null };
|
|
97
|
+
}
|
|
98
|
+
case "resolved": {
|
|
99
|
+
return { status: "resolved", data: action.data, error: null };
|
|
100
|
+
}
|
|
101
|
+
case "rejected": {
|
|
102
|
+
return { status: "rejected", data: null, error: action.error };
|
|
103
|
+
}
|
|
104
|
+
default: {
|
|
105
|
+
throw new Error(`Unhandled action: ${JSON.stringify(action)}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var useAsync = (initialState) => {
|
|
110
|
+
const [asyncState, unsafeDispatch] = (0, import_react2.useReducer)(asyncReducer, {
|
|
111
|
+
status: "idle",
|
|
112
|
+
data: null,
|
|
113
|
+
error: null,
|
|
114
|
+
...initialState
|
|
115
|
+
});
|
|
116
|
+
const dispatch = useSafeDispatch(unsafeDispatch);
|
|
117
|
+
const run = (0, import_react2.useCallback)(
|
|
118
|
+
(promise) => {
|
|
119
|
+
dispatch({ type: "pending" });
|
|
120
|
+
promise.then(
|
|
121
|
+
(data) => {
|
|
122
|
+
dispatch({ type: "resolved", data });
|
|
123
|
+
},
|
|
124
|
+
(error) => {
|
|
125
|
+
dispatch({ type: "rejected", error });
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
},
|
|
129
|
+
[dispatch]
|
|
130
|
+
);
|
|
131
|
+
const setData = (0, import_react2.useCallback)((data) => dispatch({ type: "resolved", data }), [dispatch]);
|
|
132
|
+
const setError = (0, import_react2.useCallback)((error) => dispatch({ type: "rejected", error }), [dispatch]);
|
|
133
|
+
return (0, import_react2.useMemo)(
|
|
134
|
+
() => ({
|
|
135
|
+
setData,
|
|
136
|
+
setError,
|
|
137
|
+
run,
|
|
138
|
+
...asyncState
|
|
139
|
+
}),
|
|
140
|
+
[asyncState, run, setData, setError]
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// src/hooks/use-classnames.ts
|
|
145
|
+
var import_react3 = require("react");
|
|
146
|
+
var useClassNames = (classes) => (0, import_react3.useMemo)(
|
|
147
|
+
() => Object.entries(classes).reduce(
|
|
148
|
+
(compiledClassNames, [classname, value]) => value ? [...compiledClassNames, classname] : compiledClassNames,
|
|
149
|
+
[]
|
|
150
|
+
).join(" "),
|
|
151
|
+
[classes]
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
// src/hooks/use-event-listener.ts
|
|
155
|
+
var import_react4 = require("react");
|
|
156
|
+
function useEventListener(eventName, callback, element, options) {
|
|
157
|
+
const callbackRef = (0, import_react4.useRef)(callback);
|
|
158
|
+
(0, import_react4.useEffect)(() => {
|
|
159
|
+
callbackRef.current = callback;
|
|
160
|
+
}, [callback]);
|
|
161
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
162
|
+
const targetElement = element?.current ?? window;
|
|
163
|
+
if (!(targetElement && targetElement.addEventListener)) return;
|
|
164
|
+
const listener = (event) => callbackRef.current(event);
|
|
165
|
+
targetElement.addEventListener(eventName, listener, options);
|
|
166
|
+
return () => {
|
|
167
|
+
targetElement.removeEventListener(eventName, listener, options);
|
|
168
|
+
};
|
|
169
|
+
}, [eventName, element, options]);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/hooks/use-click-outside.ts
|
|
173
|
+
var checkIsOutside = (ref, target) => {
|
|
174
|
+
return ref.current && !ref.current.contains(target);
|
|
175
|
+
};
|
|
176
|
+
var useClickOutside = (ref, callback) => {
|
|
177
|
+
useEventListener("keydown", (e) => {
|
|
178
|
+
if (e.key === "Escape") {
|
|
179
|
+
callback();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
useEventListener("mousedown", (event) => {
|
|
183
|
+
const target = event.target;
|
|
184
|
+
if (!target?.isConnected) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const isOutside = (Array.isArray(ref) ? ref : [ref]).every((r) => checkIsOutside(r, target));
|
|
188
|
+
if (isOutside) {
|
|
189
|
+
callback();
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// src/hooks/use-constant.ts
|
|
195
|
+
var import_react5 = require("react");
|
|
196
|
+
var useConstant = (initializer) => (0, import_react5.useState)(initializer)[0];
|
|
197
|
+
|
|
198
|
+
// src/hooks/use-cookie.ts
|
|
199
|
+
var import_react6 = require("react");
|
|
200
|
+
var generateCookieAttributes = (options) => {
|
|
201
|
+
const parts = [];
|
|
202
|
+
if (options.expires instanceof Date) {
|
|
203
|
+
parts.push(`expires=${options.expires.toUTCString()}`);
|
|
204
|
+
} else if (typeof options.days === "number") {
|
|
205
|
+
const date = /* @__PURE__ */ new Date();
|
|
206
|
+
date.setTime(date.getTime() + options.days * 24 * 60 * 60 * 1e3);
|
|
207
|
+
parts.push(`expires=${date.toUTCString()}`);
|
|
208
|
+
}
|
|
209
|
+
if (typeof options.maxAge === "number") {
|
|
210
|
+
parts.push(`max-age=${options.maxAge}`);
|
|
211
|
+
}
|
|
212
|
+
parts.push(`path=${options.path ?? "/"}`);
|
|
213
|
+
if (options.domain) {
|
|
214
|
+
parts.push(`domain=${options.domain}`);
|
|
215
|
+
}
|
|
216
|
+
if (options.secure) {
|
|
217
|
+
parts.push("secure");
|
|
218
|
+
}
|
|
219
|
+
if (options.sameSite) {
|
|
220
|
+
parts.push(`SameSite=${options.sameSite}`);
|
|
221
|
+
}
|
|
222
|
+
return parts.length > 0 ? `; ${parts.join("; ")}` : "";
|
|
223
|
+
};
|
|
224
|
+
var setCookie = (name, value, options = {}) => {
|
|
225
|
+
if (typeof document === "undefined") {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const encodedValue = encodeURIComponent(value);
|
|
229
|
+
const attributes = generateCookieAttributes(options);
|
|
230
|
+
document.cookie = `${name}=${encodedValue}${attributes}`;
|
|
231
|
+
};
|
|
232
|
+
var getCookie = (name) => {
|
|
233
|
+
if (typeof document === "undefined") {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
const nameEq = `${name}=`;
|
|
237
|
+
const cookies = document.cookie ? document.cookie.split(";") : [];
|
|
238
|
+
for (const cookie of cookies) {
|
|
239
|
+
const cookieTrimmed = cookie.trim();
|
|
240
|
+
if (cookieTrimmed.indexOf(nameEq) === 0) {
|
|
241
|
+
return decodeURIComponent(cookieTrimmed.substring(nameEq.length));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return null;
|
|
245
|
+
};
|
|
246
|
+
var deleteCookie = (name, options = {}) => {
|
|
247
|
+
if (typeof document === "undefined") {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
setCookie(name, "", {
|
|
251
|
+
...options,
|
|
252
|
+
days: -1
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
var useCookie = (cookieName, defaultValue, options = {}) => {
|
|
256
|
+
const [cookieValue, setCookieValue] = (0, import_react6.useState)(() => {
|
|
257
|
+
const rawCookie = getCookie(cookieName);
|
|
258
|
+
if (rawCookie !== null) {
|
|
259
|
+
try {
|
|
260
|
+
return JSON.parse(rawCookie);
|
|
261
|
+
} catch {
|
|
262
|
+
return defaultValue;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return defaultValue;
|
|
266
|
+
});
|
|
267
|
+
const updateCookie = (0, import_react6.useCallback)(
|
|
268
|
+
(value, overrideOptions = {}) => {
|
|
269
|
+
const mergedOptions = { ...options, ...overrideOptions };
|
|
270
|
+
const stringValue = JSON.stringify(value);
|
|
271
|
+
setCookie(cookieName, stringValue, mergedOptions);
|
|
272
|
+
setCookieValue(value);
|
|
273
|
+
},
|
|
274
|
+
[cookieName, options]
|
|
275
|
+
);
|
|
276
|
+
const removeCookie = (0, import_react6.useCallback)(() => {
|
|
277
|
+
deleteCookie(cookieName, options);
|
|
278
|
+
setCookieValue(defaultValue);
|
|
279
|
+
}, [cookieName, defaultValue, options]);
|
|
280
|
+
return [cookieValue, updateCookie, removeCookie];
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/hooks/use-debounce.ts
|
|
284
|
+
var import_react7 = require("react");
|
|
285
|
+
var useDebounce = (value, delay = 500) => {
|
|
286
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react7.useState)(value);
|
|
287
|
+
(0, import_react7.useEffect)(() => {
|
|
288
|
+
const timer = setTimeout(() => setDebouncedValue(value), delay);
|
|
289
|
+
return () => {
|
|
290
|
+
clearTimeout(timer);
|
|
291
|
+
};
|
|
292
|
+
}, [value, delay]);
|
|
293
|
+
return debouncedValue;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
// src/hooks/use-debounce-state.ts
|
|
297
|
+
var import_react8 = require("react");
|
|
298
|
+
var useDebounceState = (defaultValue, delay = 500) => {
|
|
299
|
+
const [value, setValue] = (0, import_react8.useState)(defaultValue);
|
|
300
|
+
const debouncedValue = useDebounce(value, delay);
|
|
301
|
+
return [value, debouncedValue, setValue];
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// src/hooks/use-dimensions.ts
|
|
305
|
+
var import_react10 = require("react");
|
|
306
|
+
|
|
307
|
+
// src/hooks/use-resize-observer.ts
|
|
308
|
+
var import_react9 = require("react");
|
|
309
|
+
var useResizeObserver = (ref, callback) => {
|
|
310
|
+
(0, import_react9.useEffect)(() => {
|
|
311
|
+
const refs = Array.isArray(ref) ? ref : [ref];
|
|
312
|
+
const observer = new ResizeObserver(callback);
|
|
313
|
+
refs.forEach((r) => r.current && observer.observe(r.current));
|
|
314
|
+
return () => {
|
|
315
|
+
observer.disconnect();
|
|
316
|
+
};
|
|
317
|
+
}, [ref, callback]);
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// src/hooks/use-dimensions.ts
|
|
321
|
+
var useDimensions = (ref) => {
|
|
322
|
+
const [dimensions, setDimensions] = (0, import_react10.useState)({ width: 0, height: 0 });
|
|
323
|
+
useResizeObserver(ref, ([entry]) => {
|
|
324
|
+
if ((entry?.borderBoxSize ?? [])[0]) {
|
|
325
|
+
const { inlineSize: width, blockSize: height } = entry.borderBoxSize[0];
|
|
326
|
+
setDimensions({ width, height });
|
|
327
|
+
} else if (entry.contentRect) {
|
|
328
|
+
const { width, height } = entry.contentRect;
|
|
329
|
+
setDimensions({ width, height });
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
return dimensions;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// src/hooks/use-dom-container.ts
|
|
336
|
+
var import_react11 = require("react");
|
|
337
|
+
var createContainer = (containerID) => {
|
|
338
|
+
let domContainer = document.getElementById(containerID);
|
|
339
|
+
if (domContainer === null) {
|
|
340
|
+
domContainer = document.createElement("div");
|
|
341
|
+
domContainer.setAttribute("id", containerID);
|
|
342
|
+
document.body.appendChild(domContainer);
|
|
343
|
+
}
|
|
344
|
+
return domContainer;
|
|
345
|
+
};
|
|
346
|
+
var useDomContainer = (containerID) => {
|
|
347
|
+
const [container, setContainer] = (0, import_react11.useState)(() => createContainer(containerID));
|
|
348
|
+
(0, import_react11.useEffect)(() => {
|
|
349
|
+
const domContainer = document.getElementById(containerID);
|
|
350
|
+
if (container === null || domContainer === null) {
|
|
351
|
+
const domContainer2 = createContainer(containerID);
|
|
352
|
+
setContainer(domContainer2);
|
|
353
|
+
}
|
|
354
|
+
return () => {
|
|
355
|
+
if (container && container.parentNode && process.env.NODE_ENV === "production") {
|
|
356
|
+
document.body.removeChild(container);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}, [container, containerID]);
|
|
360
|
+
return container;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// src/hooks/use-file-reader.ts
|
|
364
|
+
var import_react12 = require("react");
|
|
365
|
+
|
|
366
|
+
// src/helpers/format-bytes.ts
|
|
367
|
+
var formatBytes = (bytes, decimals = 2) => {
|
|
368
|
+
if (bytes === 0) return "0 Bytes";
|
|
369
|
+
const k = 1e3;
|
|
370
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
371
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
372
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
373
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
// src/helpers/get-modal-position.ts
|
|
377
|
+
var getModalPosition = ({ c, m, offset, position }) => {
|
|
378
|
+
let top = c.y + c.h + offset;
|
|
379
|
+
let left = c.x - (m.w - c.w) * (50 / 100);
|
|
380
|
+
switch (position) {
|
|
381
|
+
case "top" /* TOP */:
|
|
382
|
+
case "top center" /* TOP_CENTER */:
|
|
383
|
+
top = c.y - m.h - offset;
|
|
384
|
+
left = c.x - (m.w - c.w) / 2;
|
|
385
|
+
break;
|
|
386
|
+
case "top left" /* TOP_LEFT */:
|
|
387
|
+
top = c.y - m.h - offset;
|
|
388
|
+
left = c.x - m.w + c.w;
|
|
389
|
+
break;
|
|
390
|
+
case "top right" /* TOP_RIGHT */:
|
|
391
|
+
top = c.y - m.h - offset;
|
|
392
|
+
left = c.x;
|
|
393
|
+
break;
|
|
394
|
+
case "bottom" /* BOTTOM */:
|
|
395
|
+
case "bottom center" /* BOTTOM_CENTER */:
|
|
396
|
+
top = c.y + c.h + offset;
|
|
397
|
+
left = c.x - (m.w - c.w) / 2;
|
|
398
|
+
break;
|
|
399
|
+
case "bottom left" /* BOTTOM_LEFT */:
|
|
400
|
+
top = c.y + c.h + offset;
|
|
401
|
+
left = c.x - m.w + c.w;
|
|
402
|
+
break;
|
|
403
|
+
case "bottom right" /* BOTTOM_RIGHT */:
|
|
404
|
+
top = c.y + c.h + offset;
|
|
405
|
+
left = c.x;
|
|
406
|
+
break;
|
|
407
|
+
case "left" /* LEFT */:
|
|
408
|
+
case "left center" /* LEFT_CENTER */:
|
|
409
|
+
top = c.y - (m.h - c.h) / 2;
|
|
410
|
+
left = c.x - m.w - offset;
|
|
411
|
+
break;
|
|
412
|
+
case "left top" /* LEFT_TOP */:
|
|
413
|
+
top = c.y - m.h + c.h;
|
|
414
|
+
left = c.x - m.w - offset;
|
|
415
|
+
break;
|
|
416
|
+
case "left bottom" /* LEFT_BOTTOM */:
|
|
417
|
+
top = c.y;
|
|
418
|
+
left = c.x - m.w - offset;
|
|
419
|
+
break;
|
|
420
|
+
case "right" /* RIGHT */:
|
|
421
|
+
case "right center" /* RIGHT_CENTER */:
|
|
422
|
+
top = c.y - (m.h - c.h) / 2;
|
|
423
|
+
left = c.x + c.w + offset;
|
|
424
|
+
break;
|
|
425
|
+
case "right top" /* RIGHT_TOP */:
|
|
426
|
+
top = c.y - m.h + c.h;
|
|
427
|
+
left = c.x + c.w + offset;
|
|
428
|
+
break;
|
|
429
|
+
case "right bottom" /* RIGHT_BOTTOM */:
|
|
430
|
+
top = c.y;
|
|
431
|
+
left = c.x + c.w + offset;
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
left: Math.round(left),
|
|
436
|
+
top: Math.round(top)
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
var getOppositePosition = ({ top, left }, position, windowOffset, m) => {
|
|
440
|
+
const positions = position.split(" ");
|
|
441
|
+
const newPosition = [];
|
|
442
|
+
const rightOffset = left + m.w + windowOffset - window.innerWidth;
|
|
443
|
+
const bottomOffset = top + m.h + windowOffset - window.innerHeight;
|
|
444
|
+
for (const p of positions) {
|
|
445
|
+
if (p === "top" /* TOP */ && top < windowOffset) {
|
|
446
|
+
newPosition.push("bottom" /* BOTTOM */);
|
|
447
|
+
} else if (p === "left" /* LEFT */ && left < windowOffset) {
|
|
448
|
+
newPosition.push("right" /* RIGHT */);
|
|
449
|
+
} else if (p === "bottom" /* BOTTOM */ && bottomOffset > 0) {
|
|
450
|
+
newPosition.push("top" /* TOP */);
|
|
451
|
+
} else if (p === "right" /* RIGHT */ && rightOffset > 0) {
|
|
452
|
+
newPosition.push("left" /* LEFT */);
|
|
453
|
+
} else {
|
|
454
|
+
newPosition.push(p);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return newPosition.join(" ");
|
|
458
|
+
};
|
|
459
|
+
var fixModalPosition = ({ top, left }, m, windowOffset) => {
|
|
460
|
+
const rightOffset = left + m.w + windowOffset - window.innerWidth;
|
|
461
|
+
const bottomOffset = top + m.h + windowOffset - window.innerHeight;
|
|
462
|
+
left = rightOffset > 0 ? left - rightOffset : left;
|
|
463
|
+
top = bottomOffset > 0 ? top - bottomOffset : top;
|
|
464
|
+
left = left < windowOffset ? windowOffset : left;
|
|
465
|
+
top = top < windowOffset ? windowOffset : top;
|
|
466
|
+
return { top, left };
|
|
467
|
+
};
|
|
468
|
+
var getModalPositionRelativeToContainer = ({
|
|
469
|
+
c,
|
|
470
|
+
m,
|
|
471
|
+
offset,
|
|
472
|
+
windowOffset,
|
|
473
|
+
position
|
|
474
|
+
}) => {
|
|
475
|
+
const params = { c, m, offset, position };
|
|
476
|
+
let modalContainerStyle = getModalPosition(params);
|
|
477
|
+
const oppositePosition = getOppositePosition(modalContainerStyle, position, windowOffset, m);
|
|
478
|
+
if (oppositePosition !== position) {
|
|
479
|
+
modalContainerStyle = getModalPosition({
|
|
480
|
+
...params,
|
|
481
|
+
position: oppositePosition
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
const fixedPosition = fixModalPosition(modalContainerStyle, m, windowOffset);
|
|
485
|
+
return {
|
|
486
|
+
left: `${fixedPosition.left}px`,
|
|
487
|
+
top: `${fixedPosition.top}px`
|
|
488
|
+
};
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
// src/helpers/get-modal-position-relative-to-screen.ts
|
|
492
|
+
var getModalPositionRelativeToScreen = ({
|
|
493
|
+
position,
|
|
494
|
+
windowOffset
|
|
495
|
+
}) => {
|
|
496
|
+
switch (position) {
|
|
497
|
+
case "center" /* CENTER */:
|
|
498
|
+
return {
|
|
499
|
+
top: "50%",
|
|
500
|
+
left: "50%",
|
|
501
|
+
transform: "translate(-50%, -50%)"
|
|
502
|
+
};
|
|
503
|
+
case "top" /* TOP */:
|
|
504
|
+
case "top center" /* TOP_CENTER */:
|
|
505
|
+
return {
|
|
506
|
+
top: `${windowOffset}px`,
|
|
507
|
+
left: "50%",
|
|
508
|
+
transform: "translateX(-50%)"
|
|
509
|
+
};
|
|
510
|
+
case "top left" /* TOP_LEFT */:
|
|
511
|
+
case "left top" /* LEFT_TOP */:
|
|
512
|
+
return {
|
|
513
|
+
top: `${windowOffset}px`,
|
|
514
|
+
left: `${windowOffset}px`
|
|
515
|
+
};
|
|
516
|
+
case "top right" /* TOP_RIGHT */:
|
|
517
|
+
case "right top" /* RIGHT_TOP */:
|
|
518
|
+
return {
|
|
519
|
+
top: `${windowOffset}px`,
|
|
520
|
+
right: `${windowOffset}px`
|
|
521
|
+
};
|
|
522
|
+
case "bottom" /* BOTTOM */:
|
|
523
|
+
case "bottom center" /* BOTTOM_CENTER */:
|
|
524
|
+
return {
|
|
525
|
+
bottom: `${windowOffset}px`,
|
|
526
|
+
left: "50%",
|
|
527
|
+
transform: "translateX(-50%)"
|
|
528
|
+
};
|
|
529
|
+
case "left bottom" /* LEFT_BOTTOM */:
|
|
530
|
+
case "bottom left" /* BOTTOM_LEFT */:
|
|
531
|
+
return {
|
|
532
|
+
bottom: `${windowOffset}px`,
|
|
533
|
+
left: `${windowOffset}px`
|
|
534
|
+
};
|
|
535
|
+
case "right bottom" /* RIGHT_BOTTOM */:
|
|
536
|
+
case "bottom right" /* BOTTOM_RIGHT */:
|
|
537
|
+
return {
|
|
538
|
+
bottom: `${windowOffset}px`,
|
|
539
|
+
right: `${windowOffset}px`
|
|
540
|
+
};
|
|
541
|
+
case "left" /* LEFT */:
|
|
542
|
+
case "left center" /* LEFT_CENTER */:
|
|
543
|
+
return {
|
|
544
|
+
top: "50%",
|
|
545
|
+
left: `${windowOffset}px`,
|
|
546
|
+
transform: "translateY(-50%)"
|
|
547
|
+
};
|
|
548
|
+
case "right" /* RIGHT */:
|
|
549
|
+
case "right center" /* RIGHT_CENTER */:
|
|
550
|
+
return {
|
|
551
|
+
top: "50%",
|
|
552
|
+
right: `${windowOffset}px`,
|
|
553
|
+
transform: "translateY(-50%)"
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
return {
|
|
557
|
+
top: "50%",
|
|
558
|
+
left: "50%",
|
|
559
|
+
transform: "translate(-50%, -50%)"
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
// src/hooks/use-file-reader.ts
|
|
564
|
+
var FileTypeEnum = /* @__PURE__ */ ((FileTypeEnum2) => {
|
|
565
|
+
FileTypeEnum2["PNG"] = "image/png";
|
|
566
|
+
FileTypeEnum2["PDF"] = "application/pdf";
|
|
567
|
+
return FileTypeEnum2;
|
|
568
|
+
})(FileTypeEnum || {});
|
|
569
|
+
var useFileReader = (inputFiles) => {
|
|
570
|
+
const [files, setFiles] = (0, import_react12.useState)([]);
|
|
571
|
+
(0, import_react12.useEffect)(() => {
|
|
572
|
+
const fileReaders = [];
|
|
573
|
+
let isCancel = false;
|
|
574
|
+
if (!Array.isArray(inputFiles) || inputFiles.length === 0) {
|
|
575
|
+
setFiles([]);
|
|
576
|
+
} else {
|
|
577
|
+
const promises = inputFiles.map((file) => {
|
|
578
|
+
return new Promise((resolve, reject) => {
|
|
579
|
+
const fileReader = new FileReader();
|
|
580
|
+
fileReaders.push(fileReader);
|
|
581
|
+
fileReader.onload = (e) => {
|
|
582
|
+
if (e.target?.result) {
|
|
583
|
+
resolve({
|
|
584
|
+
name: file.name,
|
|
585
|
+
size: file.size,
|
|
586
|
+
formatSize: formatBytes(file.size),
|
|
587
|
+
type: file.type,
|
|
588
|
+
url: e.target.result
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
fileReader.onabort = () => {
|
|
593
|
+
reject(new Error("File reading aborted"));
|
|
594
|
+
};
|
|
595
|
+
fileReader.onerror = () => {
|
|
596
|
+
reject(new Error("Failed to read file"));
|
|
597
|
+
};
|
|
598
|
+
fileReader.readAsDataURL(file);
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
Promise.all(promises).then((files2) => {
|
|
602
|
+
if (!isCancel) {
|
|
603
|
+
setFiles(files2);
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
return () => {
|
|
608
|
+
isCancel = true;
|
|
609
|
+
fileReaders.forEach((fileReader) => {
|
|
610
|
+
fileReader.abort();
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
}, [inputFiles]);
|
|
614
|
+
return files;
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
// src/hooks/use-geolocation.ts
|
|
618
|
+
var import_react13 = require("react");
|
|
619
|
+
var useGeolocation = () => {
|
|
620
|
+
const [data, setData] = (0, import_react13.useState)(null);
|
|
621
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
622
|
+
const [isLoading, setIsLoading] = (0, import_react13.useState)(true);
|
|
623
|
+
const watchIdRef = (0, import_react13.useRef)(null);
|
|
624
|
+
(0, import_react13.useEffect)(() => {
|
|
625
|
+
if (!navigator.geolocation) {
|
|
626
|
+
setError({
|
|
627
|
+
code: 0,
|
|
628
|
+
message: "Geolocation is not supported by your browser."
|
|
629
|
+
});
|
|
630
|
+
setIsLoading(false);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
const handleSuccess = (position) => {
|
|
634
|
+
setData({
|
|
635
|
+
...position.coords,
|
|
636
|
+
timestamp: position.timestamp
|
|
637
|
+
});
|
|
638
|
+
setIsLoading(false);
|
|
639
|
+
};
|
|
640
|
+
const handleError = (geolocationError) => {
|
|
641
|
+
setError({
|
|
642
|
+
code: geolocationError.code,
|
|
643
|
+
message: geolocationError.message
|
|
644
|
+
});
|
|
645
|
+
setIsLoading(false);
|
|
646
|
+
};
|
|
647
|
+
navigator.geolocation.getCurrentPosition(handleSuccess, handleError);
|
|
648
|
+
watchIdRef.current = navigator.geolocation.watchPosition(handleSuccess, handleError);
|
|
649
|
+
return () => {
|
|
650
|
+
if (watchIdRef.current !== null) {
|
|
651
|
+
navigator.geolocation.clearWatch(watchIdRef.current);
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
}, []);
|
|
655
|
+
return { data, error, isLoading };
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// src/hooks/use-hover.ts
|
|
659
|
+
var import_react14 = require("react");
|
|
660
|
+
var useHover = () => {
|
|
661
|
+
const [isHovered, setIsHovered] = (0, import_react14.useState)(false);
|
|
662
|
+
const ref = (0, import_react14.useRef)(null);
|
|
663
|
+
const handleMouseEnter = (0, import_react14.useCallback)(() => setIsHovered(true), []);
|
|
664
|
+
const handleMouseLeave = (0, import_react14.useCallback)(() => setIsHovered(false), []);
|
|
665
|
+
useEventListener("mouseenter", handleMouseEnter, ref);
|
|
666
|
+
useEventListener("mouseleave", handleMouseLeave, ref);
|
|
667
|
+
return isHovered;
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
// src/hooks/use-in-view.ts
|
|
671
|
+
var import_react16 = require("react");
|
|
672
|
+
|
|
673
|
+
// src/hooks/use-intersection-observer.ts
|
|
674
|
+
var import_react15 = require("react");
|
|
675
|
+
var useIntersectionObserver = (ref, callback, initOptions = {}) => {
|
|
676
|
+
(0, import_react15.useEffect)(() => {
|
|
677
|
+
const refs = Array.isArray(ref) ? ref : [ref];
|
|
678
|
+
const observer = new IntersectionObserver(callback, initOptions);
|
|
679
|
+
refs.forEach((r) => r.current && observer.observe(r.current));
|
|
680
|
+
return () => {
|
|
681
|
+
observer.disconnect();
|
|
682
|
+
};
|
|
683
|
+
}, [callback, initOptions, ref]);
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
// src/hooks/use-in-view.ts
|
|
687
|
+
var useInView = (initOptions = {}) => {
|
|
688
|
+
const [inView, setInView] = (0, import_react16.useState)(false);
|
|
689
|
+
const ref = (0, import_react16.useRef)(null);
|
|
690
|
+
useIntersectionObserver(
|
|
691
|
+
ref,
|
|
692
|
+
([entry]) => {
|
|
693
|
+
setInView(entry.isIntersecting);
|
|
694
|
+
},
|
|
695
|
+
initOptions
|
|
696
|
+
);
|
|
697
|
+
return { ref, inView };
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
// src/hooks/use-input-handlers.ts
|
|
701
|
+
var import_react17 = require("react");
|
|
702
|
+
var useInputHandlers = ({
|
|
703
|
+
onBlur,
|
|
704
|
+
onFocus,
|
|
705
|
+
onChange
|
|
706
|
+
} = {}) => {
|
|
707
|
+
const [isFocus, setIsFocus] = (0, import_react17.useState)(false);
|
|
708
|
+
const handleFocus = (0, import_react17.useCallback)(
|
|
709
|
+
(e) => {
|
|
710
|
+
setIsFocus(true);
|
|
711
|
+
onFocus && onFocus(e);
|
|
712
|
+
},
|
|
713
|
+
[onFocus]
|
|
714
|
+
);
|
|
715
|
+
const handleBlur = (0, import_react17.useCallback)(
|
|
716
|
+
(e) => {
|
|
717
|
+
setIsFocus(false);
|
|
718
|
+
onBlur && onBlur(e);
|
|
719
|
+
},
|
|
720
|
+
[onBlur]
|
|
721
|
+
);
|
|
722
|
+
const handleChange = (0, import_react17.useCallback)(
|
|
723
|
+
(e) => {
|
|
724
|
+
onChange && onChange(e);
|
|
725
|
+
},
|
|
726
|
+
[onChange]
|
|
727
|
+
);
|
|
728
|
+
return {
|
|
729
|
+
isFocus,
|
|
730
|
+
handlers: {
|
|
731
|
+
onFocus: handleFocus,
|
|
732
|
+
onBlur: handleBlur,
|
|
733
|
+
onChange: handleChange
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
// src/hooks/use-media-query.ts
|
|
739
|
+
var import_react18 = require("react");
|
|
740
|
+
var useMediaQuery = (query) => {
|
|
741
|
+
const [matches, setMatches] = (0, import_react18.useState)(false);
|
|
742
|
+
(0, import_react18.useEffect)(() => {
|
|
743
|
+
const media = window.matchMedia(query);
|
|
744
|
+
if (media.matches !== matches) {
|
|
745
|
+
setMatches(media.matches);
|
|
746
|
+
}
|
|
747
|
+
const listener = () => {
|
|
748
|
+
setMatches(media.matches);
|
|
749
|
+
};
|
|
750
|
+
media.addEventListener("change", listener);
|
|
751
|
+
return () => {
|
|
752
|
+
media.removeEventListener("change", listener);
|
|
753
|
+
};
|
|
754
|
+
}, [matches, query]);
|
|
755
|
+
return matches;
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
// src/hooks/use-modal.ts
|
|
759
|
+
var import_react19 = require("react");
|
|
760
|
+
var useModal = () => {
|
|
761
|
+
const containerRef = (0, import_react19.useRef)(null);
|
|
762
|
+
const [isOpen, setIsOpen] = (0, import_react19.useState)(false);
|
|
763
|
+
const openModal = () => {
|
|
764
|
+
setIsOpen(true);
|
|
765
|
+
};
|
|
766
|
+
const closeModal = () => {
|
|
767
|
+
setIsOpen(false);
|
|
768
|
+
};
|
|
769
|
+
return {
|
|
770
|
+
containerRef,
|
|
771
|
+
isOpen,
|
|
772
|
+
openModal,
|
|
773
|
+
closeModal
|
|
774
|
+
};
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
// src/hooks/use-modal-in-container.ts
|
|
778
|
+
var import_react20 = require("react");
|
|
779
|
+
var convertDOMRectToPosition = (rect) => ({
|
|
780
|
+
x: rect.x,
|
|
781
|
+
y: rect.y,
|
|
782
|
+
w: rect.width,
|
|
783
|
+
h: rect.height,
|
|
784
|
+
top: rect.top,
|
|
785
|
+
left: rect.left
|
|
786
|
+
});
|
|
787
|
+
var useModalInContainer = ({
|
|
788
|
+
offset = 0,
|
|
789
|
+
windowOffset = 0,
|
|
790
|
+
position = "bottom" /* BOTTOM */,
|
|
791
|
+
modalRef,
|
|
792
|
+
containerRef,
|
|
793
|
+
isOpen
|
|
794
|
+
}) => {
|
|
795
|
+
const containerTemporalRef = (0, import_react20.useRef)(null);
|
|
796
|
+
const getPosition = (0, import_react20.useCallback)(
|
|
797
|
+
(modalRef2, containerRef2) => {
|
|
798
|
+
const modal = modalRef2.current?.getClientRects()[0];
|
|
799
|
+
const container = containerRef2.current?.getClientRects()[0];
|
|
800
|
+
if (!modal) {
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
const modalStyle = !container ? getModalPositionRelativeToScreen({ position, windowOffset }) : getModalPositionRelativeToContainer({
|
|
804
|
+
c: convertDOMRectToPosition(container),
|
|
805
|
+
m: convertDOMRectToPosition(modal),
|
|
806
|
+
offset,
|
|
807
|
+
windowOffset,
|
|
808
|
+
position
|
|
809
|
+
});
|
|
810
|
+
Object.keys(modalStyle).forEach((key) => {
|
|
811
|
+
modalRef2.current?.style.setProperty(key, modalStyle[key]);
|
|
812
|
+
});
|
|
813
|
+
},
|
|
814
|
+
[position, windowOffset, offset]
|
|
815
|
+
);
|
|
816
|
+
const callback = (0, import_react20.useCallback)(() => {
|
|
817
|
+
if (isOpen) {
|
|
818
|
+
getPosition(modalRef, containerRef ?? containerTemporalRef);
|
|
819
|
+
}
|
|
820
|
+
}, [getPosition, isOpen, containerRef, modalRef]);
|
|
821
|
+
(0, import_react20.useLayoutEffect)(callback, [callback]);
|
|
822
|
+
useResizeObserver(containerRef ?? containerTemporalRef, callback);
|
|
823
|
+
useResizeObserver(modalRef, callback);
|
|
824
|
+
useEventListener("resize", callback);
|
|
825
|
+
useEventListener("scroll", callback, modalRef);
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
// src/hooks/use-modal-transition.ts
|
|
829
|
+
var import_react21 = __toESM(require("react"), 1);
|
|
830
|
+
var ModalState = /* @__PURE__ */ ((ModalState2) => {
|
|
831
|
+
ModalState2["OPENING"] = "OPENING";
|
|
832
|
+
ModalState2["OPEN"] = "OPEN";
|
|
833
|
+
ModalState2["CLOSING"] = "CLOSING";
|
|
834
|
+
ModalState2["CLOSED"] = "CLOSED";
|
|
835
|
+
return ModalState2;
|
|
836
|
+
})(ModalState || {});
|
|
837
|
+
var useModalTransition = ({ transitionDuration = 0, isOpen }) => {
|
|
838
|
+
const [modalState, setModalState] = import_react21.default.useState("CLOSED" /* CLOSED */);
|
|
839
|
+
const isVisible = (0, import_react21.useMemo)(() => {
|
|
840
|
+
return modalState !== "CLOSED" /* CLOSED */;
|
|
841
|
+
}, [modalState]);
|
|
842
|
+
(0, import_react21.useEffect)(() => {
|
|
843
|
+
document.documentElement.style.overflow = isVisible ? "hidden" : "auto";
|
|
844
|
+
}, [isVisible]);
|
|
845
|
+
const closeModal = (0, import_react21.useCallback)(() => {
|
|
846
|
+
if (["OPENING" /* OPENING */, "OPEN" /* OPEN */].includes(modalState)) {
|
|
847
|
+
if (transitionDuration > 0) {
|
|
848
|
+
setModalState("CLOSING" /* CLOSING */);
|
|
849
|
+
setTimeout(() => {
|
|
850
|
+
setModalState("CLOSED" /* CLOSED */);
|
|
851
|
+
}, transitionDuration);
|
|
852
|
+
} else {
|
|
853
|
+
setModalState("CLOSED" /* CLOSED */);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}, [modalState, transitionDuration]);
|
|
857
|
+
const openModal = (0, import_react21.useCallback)(() => {
|
|
858
|
+
if (["CLOSING" /* CLOSING */, "CLOSED" /* CLOSED */].includes(modalState)) {
|
|
859
|
+
if (transitionDuration > 0) {
|
|
860
|
+
setModalState("OPENING" /* OPENING */);
|
|
861
|
+
setTimeout(() => {
|
|
862
|
+
setModalState("OPEN" /* OPEN */);
|
|
863
|
+
}, transitionDuration);
|
|
864
|
+
} else {
|
|
865
|
+
setModalState("OPEN" /* OPEN */);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}, [modalState, transitionDuration]);
|
|
869
|
+
(0, import_react21.useLayoutEffect)(() => {
|
|
870
|
+
if (modalState === "CLOSED" /* CLOSED */ && isOpen) {
|
|
871
|
+
openModal();
|
|
872
|
+
} else if (modalState === "OPEN" /* OPEN */ && !isOpen) {
|
|
873
|
+
closeModal();
|
|
874
|
+
}
|
|
875
|
+
}, [isOpen, openModal, closeModal, modalState]);
|
|
876
|
+
return {
|
|
877
|
+
isVisible,
|
|
878
|
+
modalState
|
|
879
|
+
};
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
// src/hooks/use-mouse-position.ts
|
|
883
|
+
var import_react22 = require("react");
|
|
884
|
+
var getMousePosition = (domRect, e) => {
|
|
885
|
+
const { left, top } = domRect;
|
|
886
|
+
const containerPositionX = left + window.scrollX;
|
|
887
|
+
const containerPositionY = top + window.scrollY;
|
|
888
|
+
const containerX = e.pageX - containerPositionX;
|
|
889
|
+
const containerY = e.pageY - containerPositionY;
|
|
890
|
+
return {
|
|
891
|
+
x: e.pageX,
|
|
892
|
+
y: e.pageY,
|
|
893
|
+
elementX: containerX,
|
|
894
|
+
elementY: containerY,
|
|
895
|
+
elementPositionX: containerPositionX,
|
|
896
|
+
elementPositionY: containerPositionY
|
|
897
|
+
};
|
|
898
|
+
};
|
|
899
|
+
var useMousePosition = (containerRef) => {
|
|
900
|
+
const ref = (0, import_react22.useRef)(null);
|
|
901
|
+
const [position, setPosition] = (0, import_react22.useState)({
|
|
902
|
+
x: null,
|
|
903
|
+
y: null,
|
|
904
|
+
elementX: null,
|
|
905
|
+
elementY: null,
|
|
906
|
+
elementPositionX: null,
|
|
907
|
+
elementPositionY: null
|
|
908
|
+
});
|
|
909
|
+
const mouseMove = (e) => {
|
|
910
|
+
const { clientX, clientY } = e;
|
|
911
|
+
setPosition((prev) => ({ ...prev, x: clientX, y: clientY }));
|
|
912
|
+
if (containerRef?.current instanceof Element) {
|
|
913
|
+
const newState = getMousePosition(containerRef.current.getBoundingClientRect(), e);
|
|
914
|
+
setPosition((prev) => ({
|
|
915
|
+
...prev,
|
|
916
|
+
...newState
|
|
917
|
+
}));
|
|
918
|
+
} else if (ref.current instanceof Element) {
|
|
919
|
+
const newState = getMousePosition(ref.current.getBoundingClientRect(), e);
|
|
920
|
+
setPosition((prev) => ({
|
|
921
|
+
...prev,
|
|
922
|
+
...newState
|
|
923
|
+
}));
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
useEventListener("mousemove", mouseMove);
|
|
927
|
+
return { ...position, ref };
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
// src/hooks/use-online-status.ts
|
|
931
|
+
var import_react23 = require("react");
|
|
932
|
+
var useOnlineStatus = () => {
|
|
933
|
+
const [online, setOnline] = (0, import_react23.useState)(navigator.onLine);
|
|
934
|
+
useEventListener("online", () => setOnline(navigator.onLine));
|
|
935
|
+
useEventListener("offline", () => setOnline(navigator.onLine));
|
|
936
|
+
return online;
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
// src/hooks/use-render-count.ts
|
|
940
|
+
var import_react24 = require("react");
|
|
941
|
+
var useRenderCount = () => {
|
|
942
|
+
const count = (0, import_react24.useRef)(1);
|
|
943
|
+
(0, import_react24.useEffect)(() => {
|
|
944
|
+
count.current++;
|
|
945
|
+
});
|
|
946
|
+
return count.current;
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
// src/hooks/use-scroll.ts
|
|
950
|
+
var import_react25 = require("react");
|
|
951
|
+
var useScroll = () => {
|
|
952
|
+
const ref = (0, import_react25.useRef)(null);
|
|
953
|
+
const [position, setPosition] = (0, import_react25.useState)([0, 0]);
|
|
954
|
+
(0, import_react25.useEffect)(() => {
|
|
955
|
+
const element = ref.current;
|
|
956
|
+
const handleScroll = () => {
|
|
957
|
+
if (!element) return;
|
|
958
|
+
setPosition([element.scrollLeft, element.scrollTop]);
|
|
959
|
+
};
|
|
960
|
+
if (element) {
|
|
961
|
+
element.addEventListener("scroll", handleScroll);
|
|
962
|
+
}
|
|
963
|
+
return () => {
|
|
964
|
+
if (element) {
|
|
965
|
+
element.removeEventListener("scroll", handleScroll);
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
}, []);
|
|
969
|
+
return {
|
|
970
|
+
ref,
|
|
971
|
+
position
|
|
972
|
+
};
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
// src/hooks/use-state-history.ts
|
|
976
|
+
var import_react26 = require("react");
|
|
977
|
+
function useStateHistory(initialState) {
|
|
978
|
+
const [state, setState] = (0, import_react26.useState)(initialState);
|
|
979
|
+
const [history, setHistory] = (0, import_react26.useState)([]);
|
|
980
|
+
(0, import_react26.useEffect)(() => {
|
|
981
|
+
if (state !== void 0) {
|
|
982
|
+
setHistory((prevHistory) => [...prevHistory, state]);
|
|
983
|
+
}
|
|
984
|
+
}, [state]);
|
|
985
|
+
return [state, setState, history];
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// src/hooks/use-toggle.ts
|
|
989
|
+
var import_react27 = require("react");
|
|
990
|
+
var useToggle = (defaultValue = false) => {
|
|
991
|
+
const [value, setValue] = (0, import_react27.useState)(defaultValue);
|
|
992
|
+
const toggle = (0, import_react27.useCallback)(() => {
|
|
993
|
+
setValue((prev) => !prev);
|
|
994
|
+
}, []);
|
|
995
|
+
return [value, toggle, setValue];
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
// src/hooks/use-toggle-values.ts
|
|
999
|
+
var import_react28 = require("react");
|
|
1000
|
+
var useToggleValues = (values, defaultIndex = 0) => {
|
|
1001
|
+
const [index, setIndex] = (0, import_react28.useState)(defaultIndex);
|
|
1002
|
+
const toggle = (0, import_react28.useCallback)(
|
|
1003
|
+
(index2) => {
|
|
1004
|
+
setIndex(index2 !== void 0 ? index2 : (prev) => (prev + 1) % values.length);
|
|
1005
|
+
},
|
|
1006
|
+
[values.length]
|
|
1007
|
+
);
|
|
1008
|
+
return [values[index], toggle];
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
// src/hooks/use-viewport.ts
|
|
1012
|
+
var import_react29 = require("react");
|
|
1013
|
+
var useViewport = () => {
|
|
1014
|
+
const getData = () => {
|
|
1015
|
+
const { innerWidth, innerHeight } = window;
|
|
1016
|
+
return {
|
|
1017
|
+
width: innerWidth,
|
|
1018
|
+
height: innerHeight,
|
|
1019
|
+
orientation: innerWidth > innerHeight ? "landscape" /* LANDSCAPE */ : "portrait" /* PORTRAIT */
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
const [data, setData] = (0, import_react29.useState)(getData);
|
|
1023
|
+
useEventListener("resize", () => {
|
|
1024
|
+
setData(getData());
|
|
1025
|
+
});
|
|
1026
|
+
(0, import_react29.useEffect)(() => {
|
|
1027
|
+
setData(getData());
|
|
1028
|
+
}, []);
|
|
1029
|
+
return data;
|
|
1030
|
+
};
|
|
1031
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1032
|
+
0 && (module.exports = {
|
|
1033
|
+
FileTypeEnum,
|
|
1034
|
+
ModalState,
|
|
1035
|
+
useAsync,
|
|
1036
|
+
useClassNames,
|
|
1037
|
+
useClickOutside,
|
|
1038
|
+
useConstant,
|
|
1039
|
+
useCookie,
|
|
1040
|
+
useDebounce,
|
|
1041
|
+
useDebounceState,
|
|
1042
|
+
useDimensions,
|
|
1043
|
+
useDomContainer,
|
|
1044
|
+
useEventListener,
|
|
1045
|
+
useFileReader,
|
|
1046
|
+
useGeolocation,
|
|
1047
|
+
useHover,
|
|
1048
|
+
useInView,
|
|
1049
|
+
useInputHandlers,
|
|
1050
|
+
useIntersectionObserver,
|
|
1051
|
+
useMediaQuery,
|
|
1052
|
+
useModal,
|
|
1053
|
+
useModalInContainer,
|
|
1054
|
+
useModalTransition,
|
|
1055
|
+
useMousePosition,
|
|
1056
|
+
useOnlineStatus,
|
|
1057
|
+
useRenderCount,
|
|
1058
|
+
useResizeObserver,
|
|
1059
|
+
useSafeDispatch,
|
|
1060
|
+
useScroll,
|
|
1061
|
+
useStateHistory,
|
|
1062
|
+
useToggle,
|
|
1063
|
+
useToggleValues,
|
|
1064
|
+
useViewport
|
|
1065
|
+
});
|
|
3
1066
|
//# sourceMappingURL=hooks.cjs.map
|