@chekinapp/ui 0.0.104 → 0.0.105
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.cjs +52 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +126 -105
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2691,7 +2691,7 @@ function useIsMounted() {
|
|
|
2691
2691
|
}
|
|
2692
2692
|
|
|
2693
2693
|
// src/hooks/use-load-more.ts
|
|
2694
|
-
import { useEffect as useEffect8, useRef as useRef5 } from "react";
|
|
2694
|
+
import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef5 } from "react";
|
|
2695
2695
|
function useLoadMore({
|
|
2696
2696
|
hasNextPage,
|
|
2697
2697
|
loading,
|
|
@@ -2700,39 +2700,56 @@ function useLoadMore({
|
|
|
2700
2700
|
threshold = 0.1,
|
|
2701
2701
|
rootMargin
|
|
2702
2702
|
}) {
|
|
2703
|
-
const
|
|
2703
|
+
const elementRef = useRef5(null);
|
|
2704
|
+
const observerRef = useRef5(null);
|
|
2705
|
+
const handleLoadMore = useEvent(onLoadMore);
|
|
2706
|
+
const cleanupObserver = useCallback5(() => {
|
|
2707
|
+
observerRef.current?.disconnect();
|
|
2708
|
+
observerRef.current = null;
|
|
2709
|
+
}, []);
|
|
2710
|
+
const observeElement = useCallback5(
|
|
2711
|
+
(element) => {
|
|
2712
|
+
cleanupObserver();
|
|
2713
|
+
if (!element || typeof IntersectionObserver === "undefined") return;
|
|
2714
|
+
const observer = new IntersectionObserver(
|
|
2715
|
+
(entries) => {
|
|
2716
|
+
const entry = entries[0];
|
|
2717
|
+
if (!entry?.isIntersecting || !hasNextPage || loading || disabled) return;
|
|
2718
|
+
handleLoadMore();
|
|
2719
|
+
},
|
|
2720
|
+
{ threshold, rootMargin }
|
|
2721
|
+
);
|
|
2722
|
+
observer.observe(element);
|
|
2723
|
+
observerRef.current = observer;
|
|
2724
|
+
},
|
|
2725
|
+
[cleanupObserver, disabled, handleLoadMore, hasNextPage, loading, rootMargin, threshold]
|
|
2726
|
+
);
|
|
2727
|
+
const loadMoreRef = useCallback5(
|
|
2728
|
+
(element) => {
|
|
2729
|
+
elementRef.current = element;
|
|
2730
|
+
observeElement(element);
|
|
2731
|
+
},
|
|
2732
|
+
[observeElement]
|
|
2733
|
+
);
|
|
2704
2734
|
useEffect8(() => {
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
const observer = new IntersectionObserver(
|
|
2708
|
-
(entries) => {
|
|
2709
|
-
if (entries[0].isIntersecting && hasNextPage && !loading && !disabled) {
|
|
2710
|
-
onLoadMore();
|
|
2711
|
-
}
|
|
2712
|
-
},
|
|
2713
|
-
{ threshold, rootMargin }
|
|
2714
|
-
);
|
|
2715
|
-
observer.observe(element);
|
|
2716
|
-
return () => {
|
|
2717
|
-
observer.disconnect();
|
|
2718
|
-
};
|
|
2719
|
-
}, [hasNextPage, loading, disabled, onLoadMore, threshold, rootMargin]);
|
|
2735
|
+
return cleanupObserver;
|
|
2736
|
+
}, [cleanupObserver]);
|
|
2720
2737
|
return [loadMoreRef];
|
|
2721
2738
|
}
|
|
2722
2739
|
|
|
2723
2740
|
// src/hooks/use-modal-controls.ts
|
|
2724
|
-
import { useCallback as
|
|
2741
|
+
import { useCallback as useCallback6, useState as useState7 } from "react";
|
|
2725
2742
|
function useModalControls(initState = false, { disabled } = {}) {
|
|
2726
2743
|
const [isOpen, setIsOpen] = useState7(initState);
|
|
2727
|
-
const openModal =
|
|
2744
|
+
const openModal = useCallback6(() => {
|
|
2728
2745
|
if (disabled) return;
|
|
2729
2746
|
setIsOpen(true);
|
|
2730
2747
|
}, [disabled]);
|
|
2731
|
-
const closeModal =
|
|
2748
|
+
const closeModal = useCallback6(() => {
|
|
2732
2749
|
if (disabled) return;
|
|
2733
2750
|
setIsOpen(false);
|
|
2734
2751
|
}, [disabled]);
|
|
2735
|
-
const toggleModal =
|
|
2752
|
+
const toggleModal = useCallback6(() => {
|
|
2736
2753
|
if (disabled) return;
|
|
2737
2754
|
setIsOpen((value) => !value);
|
|
2738
2755
|
}, [disabled]);
|
|
@@ -2746,13 +2763,13 @@ function useModalControls(initState = false, { disabled } = {}) {
|
|
|
2746
2763
|
}
|
|
2747
2764
|
|
|
2748
2765
|
// src/hooks/use-modal-with-history-controls.ts
|
|
2749
|
-
import { useCallback as
|
|
2766
|
+
import { useCallback as useCallback8, useEffect as useEffect10, useRef as useRef7, useState as useState8 } from "react";
|
|
2750
2767
|
|
|
2751
2768
|
// src/hooks/use-timeout-ref.ts
|
|
2752
|
-
import { useCallback as
|
|
2769
|
+
import { useCallback as useCallback7, useEffect as useEffect9, useRef as useRef6 } from "react";
|
|
2753
2770
|
function useTimeoutRef() {
|
|
2754
2771
|
const timeoutIdRef = useRef6();
|
|
2755
|
-
const resetTimeout =
|
|
2772
|
+
const resetTimeout = useCallback7(() => {
|
|
2756
2773
|
if (timeoutIdRef.current) {
|
|
2757
2774
|
clearTimeout(timeoutIdRef.current);
|
|
2758
2775
|
}
|
|
@@ -2784,7 +2801,7 @@ function useModalWithHistoryControls({
|
|
|
2784
2801
|
const scrollRef = useRef7(0);
|
|
2785
2802
|
const resetDelayRef = useRef7(false);
|
|
2786
2803
|
const resetDelayTimeoutRef = useTimeoutRef();
|
|
2787
|
-
const addHash =
|
|
2804
|
+
const addHash = useCallback8(() => {
|
|
2788
2805
|
const targetWindow = getWindow();
|
|
2789
2806
|
const historyState = targetWindow.history.state;
|
|
2790
2807
|
if (enabled && historyState?.popupKey !== key) {
|
|
@@ -2801,11 +2818,11 @@ function useModalWithHistoryControls({
|
|
|
2801
2818
|
targetWindow.scrollTo(0, scrollRef.current);
|
|
2802
2819
|
}
|
|
2803
2820
|
}, [enabled, key]);
|
|
2804
|
-
const openModal =
|
|
2821
|
+
const openModal = useCallback8(() => {
|
|
2805
2822
|
setIsOpen(true);
|
|
2806
2823
|
addHash();
|
|
2807
2824
|
}, [addHash]);
|
|
2808
|
-
const resetHash =
|
|
2825
|
+
const resetHash = useCallback8(() => {
|
|
2809
2826
|
const targetWindow = getWindow();
|
|
2810
2827
|
const historyState = targetWindow.history.state;
|
|
2811
2828
|
if (enabled && historyState?.popupKey === key && !resetDelayRef.current) {
|
|
@@ -2816,11 +2833,11 @@ function useModalWithHistoryControls({
|
|
|
2816
2833
|
}, 300);
|
|
2817
2834
|
}
|
|
2818
2835
|
}, [enabled, key, resetDelayTimeoutRef]);
|
|
2819
|
-
const closeModal =
|
|
2836
|
+
const closeModal = useCallback8(() => {
|
|
2820
2837
|
setIsOpen(false);
|
|
2821
2838
|
resetHash();
|
|
2822
2839
|
}, [resetHash]);
|
|
2823
|
-
const toggleModal =
|
|
2840
|
+
const toggleModal = useCallback8(() => {
|
|
2824
2841
|
setIsOpen(!isOpen);
|
|
2825
2842
|
if (isOpen) {
|
|
2826
2843
|
resetHash();
|
|
@@ -2860,7 +2877,7 @@ function useModalWithHistoryControls({
|
|
|
2860
2877
|
}
|
|
2861
2878
|
|
|
2862
2879
|
// src/hooks/use-outside-click.ts
|
|
2863
|
-
import { useCallback as
|
|
2880
|
+
import { useCallback as useCallback9, useEffect as useEffect11, useRef as useRef8 } from "react";
|
|
2864
2881
|
function useOutsideClick({
|
|
2865
2882
|
elementRef,
|
|
2866
2883
|
onOutsideClick,
|
|
@@ -2870,7 +2887,7 @@ function useOutsideClick({
|
|
|
2870
2887
|
}) {
|
|
2871
2888
|
const handleOutsideClick = useRef8(onOutsideClick);
|
|
2872
2889
|
handleOutsideClick.current = onOutsideClick;
|
|
2873
|
-
const checkNestedElements =
|
|
2890
|
+
const checkNestedElements = useCallback9(
|
|
2874
2891
|
(event, ownerDocument) => {
|
|
2875
2892
|
const checkIsElementClickedBySelector = (selector) => {
|
|
2876
2893
|
const nestedElement = ownerDocument.querySelector(selector);
|
|
@@ -2962,12 +2979,12 @@ function useScreenResize(maxWidth, matchString) {
|
|
|
2962
2979
|
}
|
|
2963
2980
|
|
|
2964
2981
|
// src/hooks/use-lock-body-scroll.ts
|
|
2965
|
-
import { useCallback as
|
|
2982
|
+
import { useCallback as useCallback10, useLayoutEffect as useLayoutEffect2 } from "react";
|
|
2966
2983
|
function useLockBodyScroll(needLock) {
|
|
2967
|
-
const lockScroll =
|
|
2984
|
+
const lockScroll = useCallback10(() => {
|
|
2968
2985
|
getDocument().getElementsByTagName("body")[0].style.overflow = "hidden";
|
|
2969
2986
|
}, []);
|
|
2970
|
-
const resetScroll =
|
|
2987
|
+
const resetScroll = useCallback10(() => {
|
|
2971
2988
|
getDocument().getElementsByTagName("body")[0].style.overflow = "auto";
|
|
2972
2989
|
}, []);
|
|
2973
2990
|
useLayoutEffect2(() => {
|
|
@@ -3083,12 +3100,12 @@ function useDebounce(value, delayMs = 1e3, handleChange) {
|
|
|
3083
3100
|
}
|
|
3084
3101
|
|
|
3085
3102
|
// src/hooks/use-debounced-function.ts
|
|
3086
|
-
import { useCallback as
|
|
3103
|
+
import { useCallback as useCallback11, useRef as useRef10 } from "react";
|
|
3087
3104
|
function useDebouncedFunction(callback, delay) {
|
|
3088
3105
|
const timerRef = useRef10();
|
|
3089
3106
|
const immediateCalling = useRef10(false);
|
|
3090
3107
|
const callbackFn = useEvent(callback);
|
|
3091
|
-
const throttled =
|
|
3108
|
+
const throttled = useCallback11(
|
|
3092
3109
|
(...args) => {
|
|
3093
3110
|
clearTimeout(timerRef.current);
|
|
3094
3111
|
if (immediateCalling.current) {
|
|
@@ -3103,7 +3120,7 @@ function useDebouncedFunction(callback, delay) {
|
|
|
3103
3120
|
},
|
|
3104
3121
|
[callbackFn, delay]
|
|
3105
3122
|
);
|
|
3106
|
-
const immediate =
|
|
3123
|
+
const immediate = useCallback11(() => {
|
|
3107
3124
|
immediateCalling.current = true;
|
|
3108
3125
|
}, []);
|
|
3109
3126
|
return { throttled, immediate };
|
|
@@ -3120,7 +3137,7 @@ function usePrevious(value, defaultValue) {
|
|
|
3120
3137
|
}
|
|
3121
3138
|
|
|
3122
3139
|
// src/hooks/use-pagination.ts
|
|
3123
|
-
import { useCallback as
|
|
3140
|
+
import { useCallback as useCallback12, useEffect as useEffect16, useMemo, useState as useState11 } from "react";
|
|
3124
3141
|
|
|
3125
3142
|
// src/storage/AbstractStorage.ts
|
|
3126
3143
|
var AbstractStorage = class {
|
|
@@ -3223,14 +3240,14 @@ function usePagination(config) {
|
|
|
3223
3240
|
return Math.min(state.page * state.pageSize, state.totalItems);
|
|
3224
3241
|
}, [state.page, state.pageSize, state.totalItems]);
|
|
3225
3242
|
const isEmpty = useMemo(() => state.totalItems === 0, [state.totalItems]);
|
|
3226
|
-
const setPage =
|
|
3243
|
+
const setPage = useCallback12(
|
|
3227
3244
|
(page) => {
|
|
3228
3245
|
const clampedPage = Math.max(1, Math.min(page, pages || 1));
|
|
3229
3246
|
setState((prev) => ({ ...prev, page: clampedPage }));
|
|
3230
3247
|
},
|
|
3231
3248
|
[pages]
|
|
3232
3249
|
);
|
|
3233
|
-
const setPageSize =
|
|
3250
|
+
const setPageSize = useCallback12((pageSize) => {
|
|
3234
3251
|
const validPageSize = Math.max(1, pageSize);
|
|
3235
3252
|
setState((prev) => {
|
|
3236
3253
|
const currentFirstItem = (prev.page - 1) * prev.pageSize + 1;
|
|
@@ -3242,7 +3259,7 @@ function usePagination(config) {
|
|
|
3242
3259
|
};
|
|
3243
3260
|
});
|
|
3244
3261
|
}, []);
|
|
3245
|
-
const setTotalItems =
|
|
3262
|
+
const setTotalItems = useCallback12((totalItems) => {
|
|
3246
3263
|
const validTotalItems = Math.max(0, totalItems);
|
|
3247
3264
|
setState((prev) => {
|
|
3248
3265
|
const newPages = validTotalItems > 0 ? Math.ceil(validTotalItems / prev.pageSize) : 0;
|
|
@@ -3254,19 +3271,19 @@ function usePagination(config) {
|
|
|
3254
3271
|
};
|
|
3255
3272
|
});
|
|
3256
3273
|
}, []);
|
|
3257
|
-
const nextPage =
|
|
3274
|
+
const nextPage = useCallback12(() => {
|
|
3258
3275
|
setPage(state.page + 1);
|
|
3259
3276
|
}, [setPage, state.page]);
|
|
3260
|
-
const previousPage =
|
|
3277
|
+
const previousPage = useCallback12(() => {
|
|
3261
3278
|
setPage(state.page - 1);
|
|
3262
3279
|
}, [setPage, state.page]);
|
|
3263
|
-
const goToFirstPage =
|
|
3280
|
+
const goToFirstPage = useCallback12(() => {
|
|
3264
3281
|
setPage(1);
|
|
3265
3282
|
}, [setPage]);
|
|
3266
|
-
const goToLastPage =
|
|
3283
|
+
const goToLastPage = useCallback12(() => {
|
|
3267
3284
|
setPage(pages);
|
|
3268
3285
|
}, [setPage, pages]);
|
|
3269
|
-
const reset =
|
|
3286
|
+
const reset = useCallback12(() => {
|
|
3270
3287
|
setState({
|
|
3271
3288
|
page: defaultPage,
|
|
3272
3289
|
pageSize: defaultPageSize,
|
|
@@ -3295,11 +3312,11 @@ function usePagination(config) {
|
|
|
3295
3312
|
}
|
|
3296
3313
|
|
|
3297
3314
|
// src/hooks/use-search-input.ts
|
|
3298
|
-
import { useCallback as
|
|
3315
|
+
import { useCallback as useCallback13, useState as useState12 } from "react";
|
|
3299
3316
|
function useSearchInput({ value, onChange }) {
|
|
3300
3317
|
const [innerValue, setInnerValue] = useState12(value || "");
|
|
3301
3318
|
const [, setDebouncedValue] = useDebounce(innerValue, 600, onChange);
|
|
3302
|
-
const handleChange =
|
|
3319
|
+
const handleChange = useCallback13(
|
|
3303
3320
|
(event) => {
|
|
3304
3321
|
if (event.target.value === "") {
|
|
3305
3322
|
setDebouncedValue("");
|
|
@@ -3349,7 +3366,7 @@ function useStickyStuck(ref) {
|
|
|
3349
3366
|
}
|
|
3350
3367
|
|
|
3351
3368
|
// src/hooks/use-switch-section-active.ts
|
|
3352
|
-
import { useCallback as
|
|
3369
|
+
import { useCallback as useCallback14, useEffect as useEffect18, useLayoutEffect as useLayoutEffect3, useState as useState14 } from "react";
|
|
3353
3370
|
function useSwitchSectionActive(preloadedSectionActive, { canToggle, onToggle, onSectionActiveChange, onTouched } = {}) {
|
|
3354
3371
|
const [isSectionActive, setIsSectionActive] = useState14(false);
|
|
3355
3372
|
const [preloadedIsSendingEnabled, setPreloadedIsSendingEnabled] = useState14(null);
|
|
@@ -3367,7 +3384,7 @@ function useSwitchSectionActive(preloadedSectionActive, { canToggle, onToggle, o
|
|
|
3367
3384
|
},
|
|
3368
3385
|
[preloadedSectionActive]
|
|
3369
3386
|
);
|
|
3370
|
-
const toggleIsSectionActive =
|
|
3387
|
+
const toggleIsSectionActive = useCallback14(() => {
|
|
3371
3388
|
const isTogglingDisabled = canToggle && !canToggle(isSectionActive);
|
|
3372
3389
|
if (isTogglingDisabled) {
|
|
3373
3390
|
return;
|
|
@@ -3468,13 +3485,13 @@ function useTimeout(callback, ms = 0) {
|
|
|
3468
3485
|
}
|
|
3469
3486
|
|
|
3470
3487
|
// src/hooks/use-hover.ts
|
|
3471
|
-
import { useCallback as
|
|
3488
|
+
import { useCallback as useCallback15, useState as useState16 } from "react";
|
|
3472
3489
|
function useHover() {
|
|
3473
3490
|
const [isHovering, setIsHovering] = useState16(false);
|
|
3474
|
-
const handleMouseEnter =
|
|
3491
|
+
const handleMouseEnter = useCallback15(() => {
|
|
3475
3492
|
setIsHovering(true);
|
|
3476
3493
|
}, []);
|
|
3477
|
-
const handleMouseLeave =
|
|
3494
|
+
const handleMouseLeave = useCallback15(() => {
|
|
3478
3495
|
setIsHovering(false);
|
|
3479
3496
|
}, []);
|
|
3480
3497
|
return {
|
|
@@ -3485,7 +3502,7 @@ function useHover() {
|
|
|
3485
3502
|
}
|
|
3486
3503
|
|
|
3487
3504
|
// src/hooks/use-key-down.ts
|
|
3488
|
-
import { useCallback as
|
|
3505
|
+
import { useCallback as useCallback16, useEffect as useEffect21 } from "react";
|
|
3489
3506
|
function useKeyDown({
|
|
3490
3507
|
key,
|
|
3491
3508
|
cb,
|
|
@@ -3499,7 +3516,7 @@ function useKeyDown({
|
|
|
3499
3516
|
altKey = false
|
|
3500
3517
|
} = options ?? {};
|
|
3501
3518
|
const handleCallback = useEvent(cb);
|
|
3502
|
-
const handleKeyDown =
|
|
3519
|
+
const handleKeyDown = useCallback16(
|
|
3503
3520
|
(event) => {
|
|
3504
3521
|
const keys = Array.isArray(key) ? key : [key];
|
|
3505
3522
|
const isKeyMatch = keys.includes(event.key);
|
|
@@ -4553,7 +4570,7 @@ ExternalLink.displayName = "ExternalLink";
|
|
|
4553
4570
|
|
|
4554
4571
|
// src/expandable-content/ExpandableContent.tsx
|
|
4555
4572
|
import {
|
|
4556
|
-
useCallback as
|
|
4573
|
+
useCallback as useCallback18,
|
|
4557
4574
|
useEffect as useEffect24,
|
|
4558
4575
|
useRef as useRef16,
|
|
4559
4576
|
useState as useState19
|
|
@@ -4590,7 +4607,7 @@ function ExpandableContent({
|
|
|
4590
4607
|
const [internalOpen, setInternalOpen] = useState19(defaultOpen);
|
|
4591
4608
|
const isOpen = open ?? internalOpen;
|
|
4592
4609
|
const isOverflowing = contentHeight > heightLimit;
|
|
4593
|
-
const measureContent =
|
|
4610
|
+
const measureContent = useCallback18(() => {
|
|
4594
4611
|
const nextHeight = contentRef.current?.getBoundingClientRect().height ?? 0;
|
|
4595
4612
|
setContentHeight(nextHeight);
|
|
4596
4613
|
}, []);
|
|
@@ -4649,7 +4666,7 @@ function ExpandableContent({
|
|
|
4649
4666
|
// src/file-input-button/FileInputButton.tsx
|
|
4650
4667
|
import {
|
|
4651
4668
|
forwardRef as forwardRef24,
|
|
4652
|
-
useCallback as
|
|
4669
|
+
useCallback as useCallback19
|
|
4653
4670
|
} from "react";
|
|
4654
4671
|
import { Upload } from "lucide-react";
|
|
4655
4672
|
import { jsx as jsx54, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
@@ -4665,7 +4682,7 @@ var FileInputButton = forwardRef24(
|
|
|
4665
4682
|
size = "default",
|
|
4666
4683
|
...props
|
|
4667
4684
|
}, ref) => {
|
|
4668
|
-
const handleChange =
|
|
4685
|
+
const handleChange = useCallback19(
|
|
4669
4686
|
(event) => {
|
|
4670
4687
|
onChange?.(event);
|
|
4671
4688
|
event.target.value = "";
|
|
@@ -5084,7 +5101,7 @@ function extractDigits(str) {
|
|
|
5084
5101
|
}
|
|
5085
5102
|
|
|
5086
5103
|
// src/input-otp/useInputOTP.ts
|
|
5087
|
-
import { useCallback as
|
|
5104
|
+
import { useCallback as useCallback20, useEffect as useEffect25, useMemo as useMemo3, useRef as useRef17, useState as useState22 } from "react";
|
|
5088
5105
|
function useInputOTP({
|
|
5089
5106
|
maxLength,
|
|
5090
5107
|
value,
|
|
@@ -5109,7 +5126,7 @@ function useInputOTP({
|
|
|
5109
5126
|
return nextSlots;
|
|
5110
5127
|
}, [value, maxLength]);
|
|
5111
5128
|
slotsRef.current = slots;
|
|
5112
|
-
const emitValue =
|
|
5129
|
+
const emitValue = useCallback20(
|
|
5113
5130
|
(newSlots) => {
|
|
5114
5131
|
let lastFilledIndex = -1;
|
|
5115
5132
|
for (let index = newSlots.length - 1; index >= 0; index -= 1) {
|
|
@@ -5135,7 +5152,7 @@ function useInputOTP({
|
|
|
5135
5152
|
inputRefs.current[0].focus();
|
|
5136
5153
|
}
|
|
5137
5154
|
}, [autoFocus]);
|
|
5138
|
-
const handleContainerFocusIn =
|
|
5155
|
+
const handleContainerFocusIn = useCallback20((event) => {
|
|
5139
5156
|
clearTimeout(blurTimeoutRef.current);
|
|
5140
5157
|
const target = event.target;
|
|
5141
5158
|
const slotIndex = inputRefs.current.indexOf(target);
|
|
@@ -5143,7 +5160,7 @@ function useInputOTP({
|
|
|
5143
5160
|
setActiveIndex(slotIndex);
|
|
5144
5161
|
}
|
|
5145
5162
|
}, []);
|
|
5146
|
-
const handleContainerFocusOut =
|
|
5163
|
+
const handleContainerFocusOut = useCallback20(() => {
|
|
5147
5164
|
clearTimeout(blurTimeoutRef.current);
|
|
5148
5165
|
blurTimeoutRef.current = setTimeout(() => {
|
|
5149
5166
|
if (!containerRef.current?.contains(document.activeElement)) {
|
|
@@ -5152,7 +5169,7 @@ function useInputOTP({
|
|
|
5152
5169
|
}, 0);
|
|
5153
5170
|
}, []);
|
|
5154
5171
|
useEffect25(() => () => clearTimeout(blurTimeoutRef.current), []);
|
|
5155
|
-
const handleDigitInput =
|
|
5172
|
+
const handleDigitInput = useCallback20(
|
|
5156
5173
|
(index, digit) => {
|
|
5157
5174
|
if (!DIGIT_REGEX.test(digit)) return;
|
|
5158
5175
|
const newSlots = [...slotsRef.current];
|
|
@@ -5166,7 +5183,7 @@ function useInputOTP({
|
|
|
5166
5183
|
},
|
|
5167
5184
|
[maxLength, emitValue]
|
|
5168
5185
|
);
|
|
5169
|
-
const handleDelete =
|
|
5186
|
+
const handleDelete = useCallback20(
|
|
5170
5187
|
(index) => {
|
|
5171
5188
|
const newSlots = [...slotsRef.current];
|
|
5172
5189
|
if (newSlots[index]) {
|
|
@@ -5181,7 +5198,7 @@ function useInputOTP({
|
|
|
5181
5198
|
},
|
|
5182
5199
|
[emitValue]
|
|
5183
5200
|
);
|
|
5184
|
-
const handlePaste =
|
|
5201
|
+
const handlePaste = useCallback20(
|
|
5185
5202
|
(text) => {
|
|
5186
5203
|
const digits = extractDigits(text).slice(0, maxLength);
|
|
5187
5204
|
if (digits.length > 0) {
|
|
@@ -5231,7 +5248,7 @@ function useInputOTP({
|
|
|
5231
5248
|
|
|
5232
5249
|
// src/input-otp/useInputOTPSlot.ts
|
|
5233
5250
|
import {
|
|
5234
|
-
useCallback as
|
|
5251
|
+
useCallback as useCallback21
|
|
5235
5252
|
} from "react";
|
|
5236
5253
|
function useInputOTPSlot(index) {
|
|
5237
5254
|
const {
|
|
@@ -5302,13 +5319,13 @@ function useInputOTPSlot(index) {
|
|
|
5302
5319
|
event.preventDefault();
|
|
5303
5320
|
handlePaste(event.clipboardData.getData("text/plain"));
|
|
5304
5321
|
};
|
|
5305
|
-
const setInputRef =
|
|
5322
|
+
const setInputRef = useCallback21(
|
|
5306
5323
|
(element) => {
|
|
5307
5324
|
inputRefs.current[index] = element;
|
|
5308
5325
|
},
|
|
5309
5326
|
[index, inputRefs]
|
|
5310
5327
|
);
|
|
5311
|
-
const focusSlot =
|
|
5328
|
+
const focusSlot = useCallback21(() => {
|
|
5312
5329
|
inputRefs.current[index]?.focus();
|
|
5313
5330
|
}, [index, inputRefs]);
|
|
5314
5331
|
return {
|
|
@@ -6778,7 +6795,7 @@ var LegacyMultiSelect = forwardRef33(LegacyMultiSelectInner);
|
|
|
6778
6795
|
|
|
6779
6796
|
// src/legacy-fields/select/InfinitySelect.tsx
|
|
6780
6797
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
6781
|
-
import { useCallback as
|
|
6798
|
+
import { useCallback as useCallback22, useEffect as useEffect26, useId as useId7, useRef as useRef19, useState as useState27 } from "react";
|
|
6782
6799
|
import { jsx as jsx79, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
6783
6800
|
function LegacyInfinitySelect({
|
|
6784
6801
|
label,
|
|
@@ -6802,7 +6819,7 @@ function LegacyInfinitySelect({
|
|
|
6802
6819
|
estimateSize: () => itemHeight,
|
|
6803
6820
|
overscan: 5
|
|
6804
6821
|
});
|
|
6805
|
-
const loadMore =
|
|
6822
|
+
const loadMore = useCallback22(() => {
|
|
6806
6823
|
if (hasNextPage && !isFetchingNextPage) {
|
|
6807
6824
|
fetchNextPage();
|
|
6808
6825
|
}
|
|
@@ -7172,7 +7189,7 @@ var RadioGroupItem = React25.forwardRef(({ className, size = "default", ...props
|
|
|
7172
7189
|
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
7173
7190
|
|
|
7174
7191
|
// src/radio/useRadioOptions.ts
|
|
7175
|
-
import { useCallback as
|
|
7192
|
+
import { useCallback as useCallback23, useEffect as useEffect27, useState as useState28 } from "react";
|
|
7176
7193
|
function getSelectedValue(options, defaultValue) {
|
|
7177
7194
|
return (typeof defaultValue === "string" ? options.find((option) => option.value === defaultValue) : defaultValue) || "";
|
|
7178
7195
|
}
|
|
@@ -7183,7 +7200,7 @@ function useRadioOptions({ options, defaultValue, onChange }) {
|
|
|
7183
7200
|
useEffect27(() => {
|
|
7184
7201
|
setSelectedValue(getSelectedValue(options, defaultValue));
|
|
7185
7202
|
}, [defaultValue, options]);
|
|
7186
|
-
const handleValueChange =
|
|
7203
|
+
const handleValueChange = useCallback23(
|
|
7187
7204
|
(value) => {
|
|
7188
7205
|
setSelectedValue(value);
|
|
7189
7206
|
const selectedOption = options.find((option) => option.value === value) || "";
|
|
@@ -8848,7 +8865,7 @@ import {
|
|
|
8848
8865
|
useEffect as useEffect30,
|
|
8849
8866
|
useRef as useRef21,
|
|
8850
8867
|
useState as useState32,
|
|
8851
|
-
useCallback as
|
|
8868
|
+
useCallback as useCallback25,
|
|
8852
8869
|
useImperativeHandle,
|
|
8853
8870
|
useLayoutEffect as useLayoutEffect4
|
|
8854
8871
|
} from "react";
|
|
@@ -8864,7 +8881,13 @@ var SIGNATURE_PROPS = {
|
|
|
8864
8881
|
throttle: 16
|
|
8865
8882
|
};
|
|
8866
8883
|
var ASPECT_RATIO = 330 / 190;
|
|
8867
|
-
function
|
|
8884
|
+
function getCanvasPixelPadding(canvas, padding) {
|
|
8885
|
+
if (!Number.isFinite(padding) || padding <= 0) return 0;
|
|
8886
|
+
const cssWidth = canvas.getBoundingClientRect().width;
|
|
8887
|
+
const scale = cssWidth > 0 ? canvas.width / cssWidth : 1;
|
|
8888
|
+
return Math.round(padding * scale);
|
|
8889
|
+
}
|
|
8890
|
+
function getTrimmedCanvas(canvas, padding = 10) {
|
|
8868
8891
|
const ctx = canvas.getContext("2d");
|
|
8869
8892
|
if (!ctx) return null;
|
|
8870
8893
|
const { width, height } = canvas;
|
|
@@ -8880,18 +8903,19 @@ function getTrimmedCanvasData(canvas, padding = 10) {
|
|
|
8880
8903
|
const alpha = data[(y * width + x) * 4 + 3];
|
|
8881
8904
|
if (alpha > 0) {
|
|
8882
8905
|
hasContent = true;
|
|
8883
|
-
minX =
|
|
8884
|
-
minY =
|
|
8885
|
-
maxX =
|
|
8886
|
-
maxY =
|
|
8906
|
+
if (x < minX) minX = x;
|
|
8907
|
+
if (y < minY) minY = y;
|
|
8908
|
+
if (x > maxX) maxX = x;
|
|
8909
|
+
if (y > maxY) maxY = y;
|
|
8887
8910
|
}
|
|
8888
8911
|
}
|
|
8889
8912
|
}
|
|
8890
8913
|
if (!hasContent) return null;
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8914
|
+
const pixelPadding = getCanvasPixelPadding(canvas, padding);
|
|
8915
|
+
minX = Math.max(0, minX - pixelPadding);
|
|
8916
|
+
minY = Math.max(0, minY - pixelPadding);
|
|
8917
|
+
maxX = Math.min(width - 1, maxX + pixelPadding);
|
|
8918
|
+
maxY = Math.min(height - 1, maxY + pixelPadding);
|
|
8895
8919
|
const trimmedWidth = maxX - minX + 1;
|
|
8896
8920
|
const trimmedHeight = maxY - minY + 1;
|
|
8897
8921
|
const trimmedCanvas = document.createElement("canvas");
|
|
@@ -8910,10 +8934,7 @@ function getTrimmedCanvasData(canvas, padding = 10) {
|
|
|
8910
8934
|
trimmedWidth,
|
|
8911
8935
|
trimmedHeight
|
|
8912
8936
|
);
|
|
8913
|
-
return
|
|
8914
|
-
canvas: trimmedCanvas,
|
|
8915
|
-
bounds: { x: minX, y: minY, width: trimmedWidth, height: trimmedHeight }
|
|
8916
|
-
};
|
|
8937
|
+
return trimmedCanvas;
|
|
8917
8938
|
}
|
|
8918
8939
|
var SignatureCanvas = forwardRef41(
|
|
8919
8940
|
({ onClear, onEnd, onEnable, className, enabled }, ref) => {
|
|
@@ -8923,7 +8944,7 @@ var SignatureCanvas = forwardRef41(
|
|
|
8923
8944
|
const containerRef = useRef21(null);
|
|
8924
8945
|
const [size, setSize] = useState32({ width: 330, height: 190 });
|
|
8925
8946
|
const [hasSignature, setHasSignature] = useState32(false);
|
|
8926
|
-
const calculateSize =
|
|
8947
|
+
const calculateSize = useCallback25((containerWidth) => {
|
|
8927
8948
|
const width = Math.floor(Math.min(containerWidth, 646));
|
|
8928
8949
|
const height = Math.floor(width / ASPECT_RATIO);
|
|
8929
8950
|
setSize((prev) => {
|
|
@@ -8957,12 +8978,12 @@ var SignatureCanvas = forwardRef41(
|
|
|
8957
8978
|
canvas.style.width = `${size.width}px`;
|
|
8958
8979
|
canvas.style.height = `${size.height}px`;
|
|
8959
8980
|
}, [size, enabled]);
|
|
8960
|
-
const handleEnd =
|
|
8981
|
+
const handleEnd = useCallback25(() => {
|
|
8961
8982
|
const isEmpty = canvasRef.current?.isEmpty() ?? true;
|
|
8962
8983
|
setHasSignature(!isEmpty);
|
|
8963
8984
|
onEnd?.();
|
|
8964
8985
|
}, [onEnd]);
|
|
8965
|
-
const handleClear =
|
|
8986
|
+
const handleClear = useCallback25(() => {
|
|
8966
8987
|
canvasRef.current?.clear();
|
|
8967
8988
|
setHasSignature(false);
|
|
8968
8989
|
onClear?.();
|
|
@@ -8978,9 +8999,9 @@ var SignatureCanvas = forwardRef41(
|
|
|
8978
8999
|
toTrimmedDataURL: (type = "image/png", encoderOptions, padding = 10) => {
|
|
8979
9000
|
const canvas = canvasRef.current?.getCanvas();
|
|
8980
9001
|
if (!canvas) return "";
|
|
8981
|
-
const trimmed =
|
|
9002
|
+
const trimmed = getTrimmedCanvas(canvas, padding);
|
|
8982
9003
|
if (!trimmed) return "";
|
|
8983
|
-
return trimmed.
|
|
9004
|
+
return trimmed.toDataURL(type, encoderOptions);
|
|
8984
9005
|
},
|
|
8985
9006
|
getCanvas: (...args) => canvasRef.current?.getCanvas(...args)
|
|
8986
9007
|
}));
|
|
@@ -10085,11 +10106,11 @@ function TimelineDescription({ className, asChild, ...props }) {
|
|
|
10085
10106
|
import { Toaster, toast as toast2 } from "sonner";
|
|
10086
10107
|
|
|
10087
10108
|
// src/toaster/useUpdateToast.ts
|
|
10088
|
-
import { useCallback as
|
|
10109
|
+
import { useCallback as useCallback27, useRef as useRef22 } from "react";
|
|
10089
10110
|
import { toast } from "sonner";
|
|
10090
10111
|
function useUpdateToast({ id }) {
|
|
10091
10112
|
const toastIdRef = useRef22("");
|
|
10092
|
-
const getToastOptions =
|
|
10113
|
+
const getToastOptions = useCallback27(
|
|
10093
10114
|
(options) => ({
|
|
10094
10115
|
id: toastIdRef.current,
|
|
10095
10116
|
dismissible: false,
|
|
@@ -10924,7 +10945,7 @@ function VideoPlayer({
|
|
|
10924
10945
|
import {
|
|
10925
10946
|
forwardRef as forwardRef54,
|
|
10926
10947
|
memo as memo7,
|
|
10927
|
-
useCallback as
|
|
10948
|
+
useCallback as useCallback29,
|
|
10928
10949
|
useImperativeHandle as useImperativeHandle2,
|
|
10929
10950
|
useMemo as useMemo7,
|
|
10930
10951
|
useRef as useRef25,
|
|
@@ -10983,7 +11004,7 @@ async function compressImage(image) {
|
|
|
10983
11004
|
}
|
|
10984
11005
|
|
|
10985
11006
|
// src/webcam/useErrorHandler.ts
|
|
10986
|
-
import { useCallback as
|
|
11007
|
+
import { useCallback as useCallback28 } from "react";
|
|
10987
11008
|
import { useTranslation as useTranslation23 } from "react-i18next";
|
|
10988
11009
|
import { isSafari as isSafari2 } from "react-device-detect";
|
|
10989
11010
|
|
|
@@ -11149,7 +11170,7 @@ var GET_USER_MEDIA_ERROR = "getUserMedia is not implemented in this browser";
|
|
|
11149
11170
|
function useErrorHandler({ onError }) {
|
|
11150
11171
|
const { t } = useTranslation23();
|
|
11151
11172
|
const handleError = useEvent(onError);
|
|
11152
|
-
const handleUserMediaError =
|
|
11173
|
+
const handleUserMediaError = useCallback28(
|
|
11153
11174
|
(error) => {
|
|
11154
11175
|
console.error(error);
|
|
11155
11176
|
let errorText = "";
|
|
@@ -11279,7 +11300,7 @@ var Webcam = memo7(
|
|
|
11279
11300
|
onError(errorDetails);
|
|
11280
11301
|
}
|
|
11281
11302
|
});
|
|
11282
|
-
const handleUserMediaErrorWithFallback =
|
|
11303
|
+
const handleUserMediaErrorWithFallback = useCallback29(
|
|
11283
11304
|
(error) => {
|
|
11284
11305
|
if (error instanceof DOMException && error.name === "OverconstrainedError" && !useReducedConstraints && !videoConstraints) {
|
|
11285
11306
|
console.warn("Camera constraints failed, trying reduced constraints:", error);
|
|
@@ -11329,7 +11350,7 @@ var Webcam = memo7(
|
|
|
11329
11350
|
...webcamRef.current
|
|
11330
11351
|
})
|
|
11331
11352
|
);
|
|
11332
|
-
const handleUserMediaSuccess =
|
|
11353
|
+
const handleUserMediaSuccess = useCallback29(
|
|
11333
11354
|
(stream) => {
|
|
11334
11355
|
if (!isMobile2) {
|
|
11335
11356
|
const track = stream.getVideoTracks()[0];
|
|
@@ -11420,17 +11441,17 @@ Webcam.displayName = "Webcam";
|
|
|
11420
11441
|
|
|
11421
11442
|
// src/mobile-webcam/MobileWebcam.tsx
|
|
11422
11443
|
import { Camera, ChevronLeft as ChevronLeft4 } from "lucide-react";
|
|
11423
|
-
import { forwardRef as forwardRef55, useCallback as
|
|
11444
|
+
import { forwardRef as forwardRef55, useCallback as useCallback31 } from "react";
|
|
11424
11445
|
import { createPortal } from "react-dom";
|
|
11425
11446
|
import { useTranslation as useTranslation25 } from "react-i18next";
|
|
11426
11447
|
|
|
11427
11448
|
// src/mobile-webcam/DeviceCamera/DeviceCamera.tsx
|
|
11428
|
-
import { useCallback as
|
|
11449
|
+
import { useCallback as useCallback30 } from "react";
|
|
11429
11450
|
import { useTranslation as useTranslation24 } from "react-i18next";
|
|
11430
11451
|
import { jsx as jsx136, jsxs as jsxs84 } from "react/jsx-runtime";
|
|
11431
11452
|
function DeviceCamera({ onChange, facingMode, className }) {
|
|
11432
11453
|
const { t } = useTranslation24();
|
|
11433
|
-
const handleNativeScreenshot =
|
|
11454
|
+
const handleNativeScreenshot = useCallback30(
|
|
11434
11455
|
(event) => {
|
|
11435
11456
|
const file = event.target.files?.[0];
|
|
11436
11457
|
onChange(file ? compressImage(file) : void 0);
|
|
@@ -11478,7 +11499,7 @@ var MobileWebcam = forwardRef55(
|
|
|
11478
11499
|
({ onScreenshot, onBack, title, text, disabled, className, ...props }, ref) => {
|
|
11479
11500
|
const rootElement = getDocument()?.body;
|
|
11480
11501
|
const { t } = useTranslation25();
|
|
11481
|
-
const handleNativeScreenshot =
|
|
11502
|
+
const handleNativeScreenshot = useCallback31(
|
|
11482
11503
|
(photo) => onScreenshot({ isNative: true, photo }),
|
|
11483
11504
|
[onScreenshot]
|
|
11484
11505
|
);
|
|
@@ -18176,7 +18197,7 @@ AirbnbPhoneField.displayName = "AirbnbPhoneField";
|
|
|
18176
18197
|
import * as React71 from "react";
|
|
18177
18198
|
import { ChevronDown as ChevronDown6, Search as Search3 } from "lucide-react";
|
|
18178
18199
|
import { useVirtualizer as useVirtualizer3 } from "@tanstack/react-virtual";
|
|
18179
|
-
import { useCallback as
|
|
18200
|
+
import { useCallback as useCallback51 } from "react";
|
|
18180
18201
|
import { jsx as jsx178, jsxs as jsxs118 } from "react/jsx-runtime";
|
|
18181
18202
|
var ROW_HEIGHT = 48;
|
|
18182
18203
|
var DESKTOP_LIST_HEIGHT = 280;
|
|
@@ -18255,7 +18276,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
18255
18276
|
isDisabled: !open || isMobile3
|
|
18256
18277
|
});
|
|
18257
18278
|
const handleOnOpenChange = useEvent(onOpenChange);
|
|
18258
|
-
const setSelectOpen =
|
|
18279
|
+
const setSelectOpen = useCallback51(
|
|
18259
18280
|
(nextOpen, options2) => {
|
|
18260
18281
|
setOpen(nextOpen);
|
|
18261
18282
|
handleOnOpenChange?.(nextOpen);
|