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