@chekinapp/ui 0.0.23 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2059,29 +2059,42 @@ function useAbortController() {
2059
2059
  }
2060
2060
 
2061
2061
  // src/hooks/use-click-escape.ts
2062
- import { useEffect as useEffect5, useRef as useRef3 } from "react";
2062
+ import { useEffect as useEffect5 } from "react";
2063
+
2064
+ // src/hooks/use-event.ts
2065
+ import { useCallback as useCallback2, useLayoutEffect, useRef as useRef3 } from "react";
2066
+ function useEvent(fn) {
2067
+ const fnRef = useRef3(fn);
2068
+ useLayoutEffect(() => {
2069
+ fnRef.current = fn;
2070
+ }, [fn]);
2071
+ const eventCb = useCallback2(
2072
+ (...args) => {
2073
+ return fnRef.current?.apply(null, args);
2074
+ },
2075
+ [fnRef]
2076
+ );
2077
+ return eventCb;
2078
+ }
2079
+
2080
+ // src/hooks/use-click-escape.ts
2063
2081
  function useClickEscape({ enabled = true, onClick }) {
2064
- const onClickRef = useRef3(onClick);
2065
- useEffect5(() => {
2066
- onClickRef.current = onClick;
2067
- }, [onClick]);
2082
+ const handler = useEvent(onClick);
2068
2083
  useEffect5(() => {
2069
2084
  const handleKeyDown = (event) => {
2070
2085
  if (event.key === "Escape" && enabled) {
2071
- onClickRef.current?.();
2086
+ handler();
2072
2087
  }
2073
2088
  };
2074
2089
  window.addEventListener("keydown", handleKeyDown);
2075
- return () => {
2076
- window.removeEventListener("keydown", handleKeyDown);
2077
- };
2078
- }, [enabled]);
2090
+ return () => window.removeEventListener("keydown", handleKeyDown);
2091
+ }, [handler, enabled]);
2079
2092
  }
2080
2093
 
2081
2094
  // src/hooks/use-combined-ref.ts
2082
- import { useCallback as useCallback2 } from "react";
2095
+ import { useCallback as useCallback3 } from "react";
2083
2096
  function useCombinedRef(...refs) {
2084
- return useCallback2(
2097
+ return useCallback3(
2085
2098
  (node) => {
2086
2099
  refs.forEach((ref) => {
2087
2100
  if (!ref) return;
@@ -2097,22 +2110,6 @@ function useCombinedRef(...refs) {
2097
2110
  );
2098
2111
  }
2099
2112
 
2100
- // src/hooks/use-event.ts
2101
- import { useCallback as useCallback3, useLayoutEffect, useRef as useRef4 } from "react";
2102
- function useEvent(fn) {
2103
- const fnRef = useRef4(fn);
2104
- useLayoutEffect(() => {
2105
- fnRef.current = fn;
2106
- }, [fn]);
2107
- const eventCb = useCallback3(
2108
- (...args) => {
2109
- return fnRef.current?.apply(null, args);
2110
- },
2111
- [fnRef]
2112
- );
2113
- return eventCb;
2114
- }
2115
-
2116
2113
  // src/hooks/use-is-mobile.ts
2117
2114
  import { useEffect as useEffect6, useState as useState5 } from "react";
2118
2115
  var MOBILE_BREAKPOINT = 768;
@@ -2133,9 +2130,9 @@ function useIsMobile({ breakpoint = MOBILE_BREAKPOINT } = {}) {
2133
2130
  }
2134
2131
 
2135
2132
  // src/hooks/use-is-mounted.ts
2136
- import { useEffect as useEffect7, useRef as useRef5 } from "react";
2133
+ import { useEffect as useEffect7, useRef as useRef4 } from "react";
2137
2134
  function useIsMounted() {
2138
- const isMounted = useRef5(false);
2135
+ const isMounted = useRef4(false);
2139
2136
  useEffect7(() => {
2140
2137
  isMounted.current = true;
2141
2138
  return () => {
@@ -2171,9 +2168,9 @@ function useModalControls(initState = false, { disabled } = {}) {
2171
2168
  }
2172
2169
 
2173
2170
  // src/hooks/use-outside-click.ts
2174
- import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef6 } from "react";
2171
+ import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef5 } from "react";
2175
2172
  function useOutsideClick(elementRef, onOutsideClick, nested) {
2176
- const handleOutsideClick = useRef6(onOutsideClick);
2173
+ const handleOutsideClick = useRef5(onOutsideClick);
2177
2174
  handleOutsideClick.current = onOutsideClick;
2178
2175
  const checkNestedElements = useCallback5(
2179
2176
  (event) => {
@@ -2309,6 +2306,33 @@ function useDebounce(value, delayMs = 1e3, handleChange) {
2309
2306
  return [debouncedValue, setDebouncedValue];
2310
2307
  }
2311
2308
 
2309
+ // src/hooks/use-debounced-function.ts
2310
+ import { useCallback as useCallback7, useRef as useRef6 } from "react";
2311
+ function useDebouncedFunction(callback, delay) {
2312
+ const timerRef = useRef6();
2313
+ const immediateCalling = useRef6(false);
2314
+ const callbackFn = useEvent(callback);
2315
+ const throttled = useCallback7(
2316
+ (...args) => {
2317
+ clearTimeout(timerRef.current);
2318
+ if (immediateCalling.current) {
2319
+ immediateCalling.current = false;
2320
+ callbackFn?.(...args);
2321
+ } else {
2322
+ timerRef.current = setTimeout(() => {
2323
+ immediateCalling.current = false;
2324
+ callbackFn?.(...args);
2325
+ }, delay);
2326
+ }
2327
+ },
2328
+ [callbackFn, delay]
2329
+ );
2330
+ const immediate = useCallback7(() => {
2331
+ immediateCalling.current = true;
2332
+ }, []);
2333
+ return { throttled, immediate };
2334
+ }
2335
+
2312
2336
  // src/hooks/use-previous.ts
2313
2337
  import { useEffect as useEffect11, useRef as useRef7 } from "react";
2314
2338
  function usePrevious(value, defaultValue) {
@@ -2319,12 +2343,187 @@ function usePrevious(value, defaultValue) {
2319
2343
  return ref.current;
2320
2344
  }
2321
2345
 
2346
+ // src/hooks/use-pagination.ts
2347
+ import { useCallback as useCallback8, useEffect as useEffect12, useMemo, useState as useState9 } from "react";
2348
+
2349
+ // src/storage/AbstractStorage.ts
2350
+ var AbstractStorage = class {
2351
+ static get(key) {
2352
+ if (!key) {
2353
+ throw new Error("The key is not valid");
2354
+ }
2355
+ return null;
2356
+ }
2357
+ static set(key, value) {
2358
+ if (!key) {
2359
+ throw new Error("The key is not valid");
2360
+ }
2361
+ if (!value) {
2362
+ throw new Error("The value not passed");
2363
+ }
2364
+ }
2365
+ static remove(key) {
2366
+ if (!key) {
2367
+ throw new Error("The key is not valid");
2368
+ }
2369
+ }
2370
+ static clear() {
2371
+ }
2372
+ };
2373
+ var AbstractStorage_default = AbstractStorage;
2374
+
2375
+ // src/storage/utils.ts
2376
+ function jsonParse(data) {
2377
+ try {
2378
+ if (data) {
2379
+ return JSON.parse(data);
2380
+ }
2381
+ return null;
2382
+ } catch {
2383
+ return data;
2384
+ }
2385
+ }
2386
+
2387
+ // src/storage/SessionStorage.ts
2388
+ var SessionStorage = class _SessionStorage extends AbstractStorage_default {
2389
+ static get(key) {
2390
+ const data = sessionStorage.getItem(key);
2391
+ return jsonParse(data);
2392
+ }
2393
+ static set(key, value) {
2394
+ if (value) {
2395
+ sessionStorage.setItem(key, JSON.stringify(value));
2396
+ }
2397
+ }
2398
+ static update(key, field, value) {
2399
+ const data = _SessionStorage.get(key);
2400
+ if (data) {
2401
+ data[field] = value;
2402
+ _SessionStorage.set(key, data);
2403
+ } else {
2404
+ _SessionStorage.set(key, { [field]: value });
2405
+ }
2406
+ }
2407
+ static remove(key) {
2408
+ sessionStorage.removeItem(key);
2409
+ }
2410
+ static clear() {
2411
+ sessionStorage.clear();
2412
+ }
2413
+ };
2414
+
2415
+ // src/hooks/use-pagination.ts
2416
+ var DEFAULT_PAGE_SIZE = 20;
2417
+ var DEFAULT_PAGE = 1;
2418
+ function usePagination(config) {
2419
+ const { key, defaultPageSize = DEFAULT_PAGE_SIZE, defaultPage = DEFAULT_PAGE } = config;
2420
+ const [state, setState] = useState9(() => {
2421
+ const stored = SessionStorage.get(`pagination-${key}`);
2422
+ if (stored) {
2423
+ return {
2424
+ page: stored.page || defaultPage,
2425
+ pageSize: stored.pageSize || defaultPageSize,
2426
+ totalItems: stored.totalItems || 0
2427
+ };
2428
+ }
2429
+ return {
2430
+ page: defaultPage,
2431
+ pageSize: defaultPageSize,
2432
+ totalItems: 0
2433
+ };
2434
+ });
2435
+ useEffect12(() => {
2436
+ SessionStorage.set(`pagination-${key}`, state);
2437
+ }, [key, state]);
2438
+ const pages = useMemo(() => {
2439
+ return state.totalItems > 0 ? Math.ceil(state.totalItems / state.pageSize) : 0;
2440
+ }, [state.totalItems, state.pageSize]);
2441
+ const hasNextPage = useMemo(() => state.page < pages, [state.page, pages]);
2442
+ const hasPreviousPage = useMemo(() => state.page > 1, [state.page]);
2443
+ const startItem = useMemo(() => {
2444
+ return state.totalItems === 0 ? 0 : (state.page - 1) * state.pageSize + 1;
2445
+ }, [state.page, state.pageSize, state.totalItems]);
2446
+ const endItem = useMemo(() => {
2447
+ return Math.min(state.page * state.pageSize, state.totalItems);
2448
+ }, [state.page, state.pageSize, state.totalItems]);
2449
+ const isEmpty = useMemo(() => state.totalItems === 0, [state.totalItems]);
2450
+ const setPage = useCallback8(
2451
+ (page) => {
2452
+ const clampedPage = Math.max(1, Math.min(page, pages || 1));
2453
+ setState((prev) => ({ ...prev, page: clampedPage }));
2454
+ },
2455
+ [pages]
2456
+ );
2457
+ const setPageSize = useCallback8((pageSize) => {
2458
+ const validPageSize = Math.max(1, pageSize);
2459
+ setState((prev) => {
2460
+ const currentFirstItem = (prev.page - 1) * prev.pageSize + 1;
2461
+ const newPage = Math.max(1, Math.ceil(currentFirstItem / validPageSize));
2462
+ return {
2463
+ ...prev,
2464
+ pageSize: validPageSize,
2465
+ page: newPage
2466
+ };
2467
+ });
2468
+ }, []);
2469
+ const setTotalItems = useCallback8((totalItems) => {
2470
+ const validTotalItems = Math.max(0, totalItems);
2471
+ setState((prev) => {
2472
+ const newPages = validTotalItems > 0 ? Math.ceil(validTotalItems / prev.pageSize) : 0;
2473
+ const clampedPage = prev.page > newPages && newPages > 0 ? newPages : prev.page;
2474
+ return {
2475
+ ...prev,
2476
+ totalItems: validTotalItems,
2477
+ page: clampedPage
2478
+ };
2479
+ });
2480
+ }, []);
2481
+ const nextPage = useCallback8(() => {
2482
+ setPage(state.page + 1);
2483
+ }, [setPage, state.page]);
2484
+ const previousPage = useCallback8(() => {
2485
+ setPage(state.page - 1);
2486
+ }, [setPage, state.page]);
2487
+ const goToFirstPage = useCallback8(() => {
2488
+ setPage(1);
2489
+ }, [setPage]);
2490
+ const goToLastPage = useCallback8(() => {
2491
+ setPage(pages);
2492
+ }, [setPage, pages]);
2493
+ const reset = useCallback8(() => {
2494
+ setState({
2495
+ page: defaultPage,
2496
+ pageSize: defaultPageSize,
2497
+ totalItems: 0
2498
+ });
2499
+ }, [defaultPage, defaultPageSize]);
2500
+ return {
2501
+ page: state.page,
2502
+ pageSize: state.pageSize,
2503
+ totalItems: state.totalItems,
2504
+ pages,
2505
+ setPage,
2506
+ setPageSize,
2507
+ setTotalItems,
2508
+ nextPage,
2509
+ previousPage,
2510
+ goToFirstPage,
2511
+ goToLastPage,
2512
+ reset,
2513
+ hasNextPage,
2514
+ hasPreviousPage,
2515
+ startItem,
2516
+ endItem,
2517
+ isEmpty
2518
+ };
2519
+ }
2520
+
2322
2521
  // src/hooks/use-timer.ts
2323
- import { useEffect as useEffect12, useState as useState9 } from "react";
2522
+ import { useEffect as useEffect13, useState as useState10 } from "react";
2324
2523
  var useTimer = ({ seconds }) => {
2325
- const [timeLeft, setTimeLeft] = useState9(seconds);
2326
- const [isTimerRunning, setIsTimerRunning] = useState9(true);
2327
- useEffect12(() => {
2524
+ const [timeLeft, setTimeLeft] = useState10(seconds);
2525
+ const [isTimerRunning, setIsTimerRunning] = useState10(true);
2526
+ useEffect13(() => {
2328
2527
  if (!isTimerRunning) return;
2329
2528
  const timer = setInterval(() => {
2330
2529
  setTimeLeft((prev) => {
@@ -2350,32 +2549,32 @@ var useTimer = ({ seconds }) => {
2350
2549
  };
2351
2550
 
2352
2551
  // src/hooks/use-timeout.ts
2353
- import { useCallback as useCallback7, useEffect as useEffect13, useRef as useRef8 } from "react";
2552
+ import { useCallback as useCallback9, useEffect as useEffect14, useRef as useRef8 } from "react";
2354
2553
  function useTimeout() {
2355
2554
  const timeoutRef = useRef8();
2356
- const clearTimeoutRef = useCallback7(() => {
2555
+ const clearTimeoutRef = useCallback9(() => {
2357
2556
  clearTimeout(timeoutRef.current);
2358
2557
  timeoutRef.current = void 0;
2359
2558
  }, []);
2360
- const scheduleTimeout = useCallback7(
2559
+ const scheduleTimeout = useCallback9(
2361
2560
  (callback, delay) => {
2362
2561
  clearTimeoutRef();
2363
2562
  timeoutRef.current = setTimeout(callback, delay);
2364
2563
  },
2365
2564
  [clearTimeoutRef]
2366
2565
  );
2367
- useEffect13(() => clearTimeoutRef, [clearTimeoutRef]);
2566
+ useEffect14(() => clearTimeoutRef, [clearTimeoutRef]);
2368
2567
  return { scheduleTimeout, clearTimeoutRef };
2369
2568
  }
2370
2569
 
2371
2570
  // src/hooks/use-hover.ts
2372
- import { useCallback as useCallback8, useState as useState10 } from "react";
2571
+ import { useCallback as useCallback10, useState as useState11 } from "react";
2373
2572
  function useHover() {
2374
- const [isHovering, setIsHovering] = useState10(false);
2375
- const handleMouseEnter = useCallback8(() => {
2573
+ const [isHovering, setIsHovering] = useState11(false);
2574
+ const handleMouseEnter = useCallback10(() => {
2376
2575
  setIsHovering(true);
2377
2576
  }, []);
2378
- const handleMouseLeave = useCallback8(() => {
2577
+ const handleMouseLeave = useCallback10(() => {
2379
2578
  setIsHovering(false);
2380
2579
  }, []);
2381
2580
  return {
@@ -2385,6 +2584,25 @@ function useHover() {
2385
2584
  };
2386
2585
  }
2387
2586
 
2587
+ // src/hooks/use-promised-modal-controls.ts
2588
+ import { useRef as useRef9 } from "react";
2589
+ var usePromisedModalControls = () => {
2590
+ const { closeModal, isOpen, openModal } = useModalControls();
2591
+ const resolveRef = useRef9();
2592
+ const openModalWithPromise = async () => {
2593
+ openModal();
2594
+ return new Promise((resolve) => {
2595
+ resolveRef.current = resolve;
2596
+ });
2597
+ };
2598
+ return {
2599
+ isOpen,
2600
+ openModal: openModalWithPromise,
2601
+ closeModal,
2602
+ resolveRef
2603
+ };
2604
+ };
2605
+
2388
2606
  // src/dialog/Dialog.tsx
2389
2607
  import { jsx as jsx29, jsxs as jsxs22 } from "react/jsx-runtime";
2390
2608
  function useIframeTitleFix(titleRef) {
@@ -2620,7 +2838,7 @@ function DownloadEntryFormsButton({
2620
2838
  }
2621
2839
 
2622
2840
  // src/dropdown-button/DropdownButton.tsx
2623
- import { useState as useState11 } from "react";
2841
+ import { useState as useState12 } from "react";
2624
2842
 
2625
2843
  // src/dropdown-menu/DropdownMenu.tsx
2626
2844
  import * as React13 from "react";
@@ -2684,7 +2902,7 @@ function DropdownButton({
2684
2902
  modal,
2685
2903
  className
2686
2904
  }) {
2687
- const [isOpen, setIsOpen] = useState11(false);
2905
+ const [isOpen, setIsOpen] = useState12(false);
2688
2906
  return /* @__PURE__ */ jsxs25(DropdownMenu, { onOpenChange: setIsOpen, modal, children: [
2689
2907
  /* @__PURE__ */ jsx34(DropdownMenuTrigger, { asChild: true, children: typeof trigger === "function" ? trigger(isOpen) : trigger }),
2690
2908
  /* @__PURE__ */ jsx34(
@@ -3022,7 +3240,7 @@ var Switch = React15.forwardRef(
3022
3240
  Switch.displayName = SwitchPrimitives.Root.displayName;
3023
3241
 
3024
3242
  // src/video-player/VideoPlayer.tsx
3025
- import { useEffect as useEffect15, useRef as useRef10, useState as useState12 } from "react";
3243
+ import { useEffect as useEffect16, useRef as useRef11, useState as useState13 } from "react";
3026
3244
  import { useTranslation as useTranslation8 } from "react-i18next";
3027
3245
  import {
3028
3246
  Loader2,
@@ -3046,20 +3264,20 @@ function VideoPlayer({
3046
3264
  autoPlay = false
3047
3265
  }) {
3048
3266
  const { t } = useTranslation8();
3049
- const videoRef = useRef10(null);
3050
- const iframeRef = useRef10(null);
3051
- const containerRef = useRef10(null);
3052
- const [isPlaying, setIsPlaying] = useState12(false);
3053
- const [isMuted, setIsMuted] = useState12(false);
3054
- const [currentTime, setCurrentTime] = useState12(0);
3055
- const [duration, setDuration] = useState12(0);
3056
- const [isFullScreenMode, setIsFullScreenMode] = useState12(isFullScreen);
3057
- const [isLoading, setIsLoading] = useState12(true);
3058
- const [videoSource, setVideoSource] = useState12("file");
3059
- const [youtubeEmbedUrl, setYoutubeEmbedUrl] = useState12("");
3060
- const [vimeoEmbedUrl, setVimeoEmbedUrl] = useState12("");
3267
+ const videoRef = useRef11(null);
3268
+ const iframeRef = useRef11(null);
3269
+ const containerRef = useRef11(null);
3270
+ const [isPlaying, setIsPlaying] = useState13(false);
3271
+ const [isMuted, setIsMuted] = useState13(false);
3272
+ const [currentTime, setCurrentTime] = useState13(0);
3273
+ const [duration, setDuration] = useState13(0);
3274
+ const [isFullScreenMode, setIsFullScreenMode] = useState13(isFullScreen);
3275
+ const [isLoading, setIsLoading] = useState13(true);
3276
+ const [videoSource, setVideoSource] = useState13("file");
3277
+ const [youtubeEmbedUrl, setYoutubeEmbedUrl] = useState13("");
3278
+ const [vimeoEmbedUrl, setVimeoEmbedUrl] = useState13("");
3061
3279
  useClickEscape({ enabled: isFullScreenMode, onClick: onClose });
3062
- useEffect15(() => {
3280
+ useEffect16(() => {
3063
3281
  const youtubeRegex = /(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/;
3064
3282
  const vimeoRegex = /(?:vimeo\.com\/|vimeo\.com\/video\/)(\d+)/;
3065
3283
  const youtubeMatch = src.match(youtubeRegex);
@@ -3088,7 +3306,7 @@ function VideoPlayer({
3088
3306
  setYoutubeEmbedUrl("");
3089
3307
  setVimeoEmbedUrl("");
3090
3308
  }, [src, autoPlay]);
3091
- useEffect15(() => {
3309
+ useEffect16(() => {
3092
3310
  if (videoSource !== "file") return;
3093
3311
  const video = videoRef.current;
3094
3312
  if (!video) return;
@@ -3116,7 +3334,7 @@ function VideoPlayer({
3116
3334
  video.removeEventListener("canplay", handleCanPlay);
3117
3335
  };
3118
3336
  }, [videoSource]);
3119
- useEffect15(() => {
3337
+ useEffect16(() => {
3120
3338
  if (isFullScreenMode && videoRef.current && videoSource === "file") {
3121
3339
  void videoRef.current.play();
3122
3340
  setIsPlaying(true);
@@ -3395,7 +3613,7 @@ function FeatureCard({
3395
3613
  // src/file-input-button/FileInputButton.tsx
3396
3614
  import {
3397
3615
  forwardRef as forwardRef19,
3398
- useCallback as useCallback9
3616
+ useCallback as useCallback11
3399
3617
  } from "react";
3400
3618
  import { Upload } from "lucide-react";
3401
3619
  import { jsx as jsx47, jsxs as jsxs31 } from "react/jsx-runtime";
@@ -3411,7 +3629,7 @@ var FileInputButton = forwardRef19(
3411
3629
  size = "default",
3412
3630
  ...props
3413
3631
  }, ref) => {
3414
- const handleChange = useCallback9(
3632
+ const handleChange = useCallback11(
3415
3633
  (event) => {
3416
3634
  onChange?.(event);
3417
3635
  event.target.value = "";
@@ -3494,7 +3712,7 @@ var FormBox = {
3494
3712
  import {
3495
3713
  forwardRef as forwardRef20,
3496
3714
  useId as useId4,
3497
- useState as useState13
3715
+ useState as useState14
3498
3716
  } from "react";
3499
3717
  import { useTranslation as useTranslation10 } from "react-i18next";
3500
3718
 
@@ -3526,8 +3744,8 @@ var FreeTextField = forwardRef20(
3526
3744
  }, ref) => {
3527
3745
  const { t } = useTranslation10();
3528
3746
  const inputId = useId4();
3529
- const [internalValue, setInternalValue] = useState13(defaultValue ?? "");
3530
- const [isFocused, setIsFocused] = useState13(false);
3747
+ const [internalValue, setInternalValue] = useState14(defaultValue ?? "");
3748
+ const [isFocused, setIsFocused] = useState14(false);
3531
3749
  const currentValue = value !== void 0 ? value : internalValue;
3532
3750
  const isEmpty = !currentValue || String(currentValue).length === 0;
3533
3751
  const hasError = Boolean(error);
@@ -3859,7 +4077,7 @@ function InfoBox({ className, children }) {
3859
4077
  }
3860
4078
 
3861
4079
  // src/image/Image.tsx
3862
- import { useState as useState14 } from "react";
4080
+ import { useState as useState15 } from "react";
3863
4081
  import { jsx as jsx59 } from "react/jsx-runtime";
3864
4082
  function Image2({
3865
4083
  src,
@@ -3868,7 +4086,7 @@ function Image2({
3868
4086
  fallbackSrc = "https://placehold.co/600x400?text=Image",
3869
4087
  ...props
3870
4088
  }) {
3871
- const [error, setError] = useState14(false);
4089
+ const [error, setError] = useState15(false);
3872
4090
  return /* @__PURE__ */ jsx59(
3873
4091
  "img",
3874
4092
  {
@@ -3927,7 +4145,7 @@ function extractDigits(str) {
3927
4145
  }
3928
4146
 
3929
4147
  // src/input-otp/useInputOTP.ts
3930
- import { useCallback as useCallback10, useEffect as useEffect16, useMemo, useRef as useRef11, useState as useState15 } from "react";
4148
+ import { useCallback as useCallback12, useEffect as useEffect17, useMemo as useMemo2, useRef as useRef12, useState as useState16 } from "react";
3931
4149
  function useInputOTP({
3932
4150
  maxLength,
3933
4151
  value,
@@ -3936,12 +4154,12 @@ function useInputOTP({
3936
4154
  autoFocus,
3937
4155
  error
3938
4156
  }) {
3939
- const [activeIndex, setActiveIndex] = useState15(-1);
3940
- const inputRefs = useRef11([]);
3941
- const containerRef = useRef11(null);
3942
- const blurTimeoutRef = useRef11();
3943
- const slotsRef = useRef11(Array.from({ length: maxLength }, () => ""));
3944
- const slots = useMemo(() => {
4157
+ const [activeIndex, setActiveIndex] = useState16(-1);
4158
+ const inputRefs = useRef12([]);
4159
+ const containerRef = useRef12(null);
4160
+ const blurTimeoutRef = useRef12();
4161
+ const slotsRef = useRef12(Array.from({ length: maxLength }, () => ""));
4162
+ const slots = useMemo2(() => {
3945
4163
  const nextSlots = Array.from({ length: maxLength }, () => "");
3946
4164
  for (let index = 0; index < Math.min(value.length, maxLength); index += 1) {
3947
4165
  const char = value[index];
@@ -3952,7 +4170,7 @@ function useInputOTP({
3952
4170
  return nextSlots;
3953
4171
  }, [value, maxLength]);
3954
4172
  slotsRef.current = slots;
3955
- const emitValue = useCallback10(
4173
+ const emitValue = useCallback12(
3956
4174
  (newSlots) => {
3957
4175
  let lastFilledIndex = -1;
3958
4176
  for (let index = newSlots.length - 1; index >= 0; index -= 1) {
@@ -3973,12 +4191,12 @@ function useInputOTP({
3973
4191
  },
3974
4192
  [onChange]
3975
4193
  );
3976
- useEffect16(() => {
4194
+ useEffect17(() => {
3977
4195
  if (autoFocus && inputRefs.current[0]) {
3978
4196
  inputRefs.current[0].focus();
3979
4197
  }
3980
4198
  }, [autoFocus]);
3981
- const handleContainerFocusIn = useCallback10((event) => {
4199
+ const handleContainerFocusIn = useCallback12((event) => {
3982
4200
  clearTimeout(blurTimeoutRef.current);
3983
4201
  const target = event.target;
3984
4202
  const slotIndex = inputRefs.current.indexOf(target);
@@ -3986,7 +4204,7 @@ function useInputOTP({
3986
4204
  setActiveIndex(slotIndex);
3987
4205
  }
3988
4206
  }, []);
3989
- const handleContainerFocusOut = useCallback10(() => {
4207
+ const handleContainerFocusOut = useCallback12(() => {
3990
4208
  clearTimeout(blurTimeoutRef.current);
3991
4209
  blurTimeoutRef.current = setTimeout(() => {
3992
4210
  if (!containerRef.current?.contains(document.activeElement)) {
@@ -3994,8 +4212,8 @@ function useInputOTP({
3994
4212
  }
3995
4213
  }, 0);
3996
4214
  }, []);
3997
- useEffect16(() => () => clearTimeout(blurTimeoutRef.current), []);
3998
- const handleDigitInput = useCallback10(
4215
+ useEffect17(() => () => clearTimeout(blurTimeoutRef.current), []);
4216
+ const handleDigitInput = useCallback12(
3999
4217
  (index, digit) => {
4000
4218
  if (!DIGIT_REGEX.test(digit)) return;
4001
4219
  const newSlots = [...slotsRef.current];
@@ -4009,7 +4227,7 @@ function useInputOTP({
4009
4227
  },
4010
4228
  [maxLength, emitValue]
4011
4229
  );
4012
- const handleDelete = useCallback10(
4230
+ const handleDelete = useCallback12(
4013
4231
  (index) => {
4014
4232
  const newSlots = [...slotsRef.current];
4015
4233
  if (newSlots[index]) {
@@ -4024,7 +4242,7 @@ function useInputOTP({
4024
4242
  },
4025
4243
  [emitValue]
4026
4244
  );
4027
- const handlePaste = useCallback10(
4245
+ const handlePaste = useCallback12(
4028
4246
  (text) => {
4029
4247
  const digits = extractDigits(text).slice(0, maxLength);
4030
4248
  if (digits.length > 0) {
@@ -4040,7 +4258,7 @@ function useInputOTP({
4040
4258
  },
4041
4259
  [maxLength, emitValue]
4042
4260
  );
4043
- const contextValue = useMemo(
4261
+ const contextValue = useMemo2(
4044
4262
  () => ({
4045
4263
  slots,
4046
4264
  activeIndex,
@@ -4074,7 +4292,7 @@ function useInputOTP({
4074
4292
 
4075
4293
  // src/input-otp/useInputOTPSlot.ts
4076
4294
  import {
4077
- useCallback as useCallback11
4295
+ useCallback as useCallback13
4078
4296
  } from "react";
4079
4297
  function useInputOTPSlot(index) {
4080
4298
  const {
@@ -4145,13 +4363,13 @@ function useInputOTPSlot(index) {
4145
4363
  event.preventDefault();
4146
4364
  handlePaste(event.clipboardData.getData("text/plain"));
4147
4365
  };
4148
- const setInputRef = useCallback11(
4366
+ const setInputRef = useCallback13(
4149
4367
  (element) => {
4150
4368
  inputRefs.current[index] = element;
4151
4369
  },
4152
4370
  [index, inputRefs]
4153
4371
  );
4154
- const focusSlot = useCallback11(() => {
4372
+ const focusSlot = useCallback13(() => {
4155
4373
  inputRefs.current[index]?.focus();
4156
4374
  }, [index, inputRefs]);
4157
4375
  return {
@@ -4253,7 +4471,7 @@ var InputOTPSeparator = React19.forwardRef(
4253
4471
  InputOTPSeparator.displayName = "InputOTPSeparator";
4254
4472
 
4255
4473
  // src/icons-dropdown/IconsDropdown.tsx
4256
- import { useState as useState16 } from "react";
4474
+ import { useState as useState17 } from "react";
4257
4475
  import { jsx as jsx62, jsxs as jsxs36 } from "react/jsx-runtime";
4258
4476
  function IconsDropdown({
4259
4477
  icons,
@@ -4265,7 +4483,7 @@ function IconsDropdown({
4265
4483
  defaultOpen,
4266
4484
  onOpenChange: onOpenChangeProp
4267
4485
  }) {
4268
- const [open, setOpen] = useState16(defaultOpen ?? false);
4486
+ const [open, setOpen] = useState17(defaultOpen ?? false);
4269
4487
  function handleOpenChange(value) {
4270
4488
  setOpen(value);
4271
4489
  onOpenChangeProp?.(value);
@@ -4872,14 +5090,14 @@ LinkInternal.displayName = "Link";
4872
5090
  var Link = memo3(LinkInternal);
4873
5091
 
4874
5092
  // src/image-full-screen-view/ImageFullScreenView.tsx
4875
- import { useState as useState17 } from "react";
5093
+ import { useState as useState18 } from "react";
4876
5094
  import { RotateCw, X as X4, ZoomIn, ZoomOut } from "lucide-react";
4877
5095
  import { useTranslation as useTranslation13 } from "react-i18next";
4878
5096
  import { jsx as jsx67, jsxs as jsxs40 } from "react/jsx-runtime";
4879
5097
  function ImageFullScreenView({ src, alt, onClose }) {
4880
5098
  const { t } = useTranslation13();
4881
- const [scale, setScale] = useState17(1);
4882
- const [rotation, setRotation] = useState17(0);
5099
+ const [scale, setScale] = useState18(1);
5100
+ const [rotation, setRotation] = useState18(0);
4883
5101
  useClickEscape({ onClick: onClose });
4884
5102
  const zoomIn = () => setScale((value) => Math.min(value + 0.25, 3));
4885
5103
  const zoomOut = () => setScale((value) => Math.max(value - 0.25, 0.5));
@@ -5077,7 +5295,7 @@ var METRIC_CARD_VARIANTS = {
5077
5295
  };
5078
5296
 
5079
5297
  // src/modal/Modal.tsx
5080
- import { forwardRef as forwardRef28, useRef as useRef12 } from "react";
5298
+ import { forwardRef as forwardRef28, useRef as useRef13 } from "react";
5081
5299
  import { X as X5 } from "lucide-react";
5082
5300
 
5083
5301
  // src/modal/styles.module.css
@@ -5108,7 +5326,7 @@ function Modal({
5108
5326
  container,
5109
5327
  modal
5110
5328
  }) {
5111
- const contentRef = useRef12(null);
5329
+ const contentRef = useRef13(null);
5112
5330
  useScrollFrameIntoView(open, { elementRef: contentRef });
5113
5331
  const handleClose = () => {
5114
5332
  onOpenChange?.(false);
@@ -5589,11 +5807,11 @@ var RadioGroupItem = React22.forwardRef(({ className, ...props }, ref) => /* @__
5589
5807
  RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
5590
5808
 
5591
5809
  // src/radio/useRadioOptions.ts
5592
- import { useCallback as useCallback12, useState as useState18 } from "react";
5810
+ import { useCallback as useCallback14, useState as useState19 } from "react";
5593
5811
  function useRadioOptions({ options, defaultValue, onChange }) {
5594
5812
  const initialValue = (typeof defaultValue === "string" ? options.find((option) => option.value === defaultValue) : defaultValue) || "";
5595
- const [selectedValue, setSelectedValue] = useState18(initialValue);
5596
- const handleValueChange = useCallback12(
5813
+ const [selectedValue, setSelectedValue] = useState19(initialValue);
5814
+ const handleValueChange = useCallback14(
5597
5815
  (value) => {
5598
5816
  setSelectedValue(value);
5599
5817
  const selectedOption = options.find((option) => option.value === value) || "";
@@ -6097,7 +6315,7 @@ import {
6097
6315
  cloneElement as cloneElement2,
6098
6316
  forwardRef as forwardRef34,
6099
6317
  isValidElement as isValidElement2,
6100
- useEffect as useEffect17
6318
+ useEffect as useEffect18
6101
6319
  } from "react";
6102
6320
 
6103
6321
  // src/selector-button/styles.module.css
@@ -6216,7 +6434,7 @@ function SelectorsInternal({
6216
6434
  }
6217
6435
  };
6218
6436
  const isAnyActive = getValueArray(value).length > 0;
6219
- useEffect17(() => {
6437
+ useEffect18(() => {
6220
6438
  onAnySelectorActive?.(isAnyActive);
6221
6439
  }, [isAnyActive, onAnySelectorActive]);
6222
6440
  return /* @__PURE__ */ jsxs56(Fragment8, { children: [
@@ -7274,7 +7492,7 @@ function SortingAction({
7274
7492
  }
7275
7493
 
7276
7494
  // src/status-button/StatusButton.tsx
7277
- import { useMemo as useMemo3 } from "react";
7495
+ import { useMemo as useMemo4 } from "react";
7278
7496
  import { useTranslation as useTranslation20 } from "react-i18next";
7279
7497
  import { AlertCircle as AlertCircle2, CheckCircle, Loader2 as Loader24 } from "lucide-react";
7280
7498
  import { jsx as jsx98, jsxs as jsxs62 } from "react/jsx-runtime";
@@ -7292,7 +7510,7 @@ function StatusButton({
7292
7510
  ...props
7293
7511
  }) {
7294
7512
  const { t } = useTranslation20();
7295
- const configMap = useMemo3(() => {
7513
+ const configMap = useMemo4(() => {
7296
7514
  const defaultLoadingConfig = {
7297
7515
  text: loadingText ?? `${t("saving")}...`,
7298
7516
  icon: /* @__PURE__ */ jsx98(Loader24, { className: "h-4 w-4 animate-spin" }),
@@ -7694,11 +7912,11 @@ var TASK_VARIANTS = {
7694
7912
  import { Toaster, toast as toast2 } from "sonner";
7695
7913
 
7696
7914
  // src/toaster/useUpdateToast.ts
7697
- import { useCallback as useCallback14, useRef as useRef14 } from "react";
7915
+ import { useCallback as useCallback16, useRef as useRef15 } from "react";
7698
7916
  import { toast } from "sonner";
7699
7917
  function useUpdateToast({ id }) {
7700
- const toastIdRef = useRef14("");
7701
- const getToastOptions = useCallback14(
7918
+ const toastIdRef = useRef15("");
7919
+ const getToastOptions = useCallback16(
7702
7920
  (options) => ({
7703
7921
  id: toastIdRef.current,
7704
7922
  dismissible: false,
@@ -7813,7 +8031,7 @@ var ToggleGroupItem = React27.forwardRef(({ className, children, variant, size,
7813
8031
  ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
7814
8032
 
7815
8033
  // src/toggle-group/Toggles.tsx
7816
- import { forwardRef as forwardRef40, useEffect as useEffect19 } from "react";
8034
+ import { forwardRef as forwardRef40, useEffect as useEffect20 } from "react";
7817
8035
  import { jsx as jsx108, jsxs as jsxs69 } from "react/jsx-runtime";
7818
8036
  var getValueArray2 = (value) => {
7819
8037
  if (value) {
@@ -7888,7 +8106,7 @@ function TogglesInternal({
7888
8106
  }
7889
8107
  };
7890
8108
  const isAnyActive = getValueArray2(value).length > 0;
7891
- useEffect19(() => {
8109
+ useEffect20(() => {
7892
8110
  onAnySelectorActive?.(isAnyActive);
7893
8111
  }, [isAnyActive, onAnySelectorActive]);
7894
8112
  const currentValue = getValueArray2(value).map((item) => String(item));
@@ -11032,7 +11250,7 @@ AirbnbSearchInput.displayName = "SearchInput";
11032
11250
  import * as React41 from "react";
11033
11251
  import { ChevronDown as ChevronDown3, Search as Search4 } from "lucide-react";
11034
11252
  import { useVirtualizer } from "@tanstack/react-virtual";
11035
- import { useCallback as useCallback23 } from "react";
11253
+ import { useCallback as useCallback25 } from "react";
11036
11254
  import { jsx as jsx133, jsxs as jsxs87 } from "react/jsx-runtime";
11037
11255
  var ROW_HEIGHT = 48;
11038
11256
  var DESKTOP_LIST_HEIGHT = 280;
@@ -11107,7 +11325,7 @@ var SearchableSelectInternal = ({
11107
11325
  const activeOptionId = highlightedIndex >= 0 ? getOptionId(reactId, highlightedIndex) : void 0;
11108
11326
  useOutsideClick(containerRef, open && !isMobile ? () => closeSelect() : null);
11109
11327
  const handleOnOpenChange = useEvent(onOpenChange);
11110
- const setSelectOpen = useCallback23(
11328
+ const setSelectOpen = useCallback25(
11111
11329
  (nextOpen, options2) => {
11112
11330
  setOpen(nextOpen);
11113
11331
  handleOnOpenChange?.(nextOpen);
@@ -11475,6 +11693,39 @@ function getNextEnabledIndex(options, startIndex, step) {
11475
11693
  }
11476
11694
  return -1;
11477
11695
  }
11696
+
11697
+ // src/lib/copy-to-clipboard.ts
11698
+ function copyToClipboardFallback(value) {
11699
+ const targetDocument = getDocument();
11700
+ const targetBody = targetDocument.body;
11701
+ if (!targetBody) {
11702
+ return;
11703
+ }
11704
+ const el = targetDocument.createElement("textarea");
11705
+ el.value = value;
11706
+ el.setAttribute("readonly", "");
11707
+ el.style.position = "fixed";
11708
+ el.style.opacity = "0";
11709
+ el.style.pointerEvents = "none";
11710
+ el.style.left = "-9999px";
11711
+ targetBody.appendChild(el);
11712
+ el.focus();
11713
+ el.select();
11714
+ targetDocument.execCommand("copy");
11715
+ targetBody.removeChild(el);
11716
+ }
11717
+ function copyToClipboard2(value) {
11718
+ const text = typeof value === "number" ? value.toString() : value;
11719
+ const targetDocument = getDocument();
11720
+ const clipboard = targetDocument.defaultView?.navigator?.clipboard ?? globalThis.navigator?.clipboard;
11721
+ if (!clipboard?.writeText) {
11722
+ copyToClipboardFallback(text);
11723
+ return;
11724
+ }
11725
+ void clipboard.writeText(text).catch(() => {
11726
+ copyToClipboardFallback(text);
11727
+ });
11728
+ }
11478
11729
  export {
11479
11730
  Accordion,
11480
11731
  AccordionContent,
@@ -11726,6 +11977,7 @@ export {
11726
11977
  buttonVariants,
11727
11978
  calendarClassNames,
11728
11979
  cn,
11980
+ copyToClipboard2 as copyToClipboard,
11729
11981
  emptyMediaVariants,
11730
11982
  getSidebarState,
11731
11983
  inputVariants,
@@ -11743,13 +11995,16 @@ export {
11743
11995
  useClickEscape,
11744
11996
  useCombinedRef,
11745
11997
  useDebounce,
11998
+ useDebouncedFunction,
11746
11999
  useEvent,
11747
12000
  useHover,
11748
12001
  useIsMobile,
11749
12002
  useIsMounted,
11750
12003
  useModalControls,
11751
12004
  useOutsideClick,
12005
+ usePagination,
11752
12006
  usePrevious,
12007
+ usePromisedModalControls,
11753
12008
  useRadioOptions,
11754
12009
  useScreenResize,
11755
12010
  useScrollFrameIntoView,