@chekinapp/ui 0.0.30 → 0.0.32

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 CHANGED
@@ -284,6 +284,7 @@ __export(index_exports, {
284
284
  emptyMediaVariants: () => emptyMediaVariants,
285
285
  getSidebarState: () => getSidebarState,
286
286
  inputVariants: () => inputVariants,
287
+ isNumeric: () => isNumeric,
287
288
  labelVariants: () => labelVariants,
288
289
  sectionTagVariants: () => sectionTagVariants,
289
290
  switchThumbVariants: () => switchThumbVariants,
@@ -2486,18 +2487,25 @@ function useModalControls(initState = false, { disabled } = {}) {
2486
2487
 
2487
2488
  // src/hooks/use-outside-click.ts
2488
2489
  var import_react16 = require("react");
2489
- function useOutsideClick(elementRef, onOutsideClick, nested) {
2490
+ function useOutsideClick({
2491
+ elementRef,
2492
+ onOutsideClick,
2493
+ triggerRef,
2494
+ isDisabled,
2495
+ nested
2496
+ }) {
2490
2497
  const handleOutsideClick = (0, import_react16.useRef)(onOutsideClick);
2491
2498
  handleOutsideClick.current = onOutsideClick;
2492
2499
  const checkNestedElements = (0, import_react16.useCallback)(
2493
- (event) => {
2500
+ (event, ownerDocument) => {
2494
2501
  const checkIsElementClickedBySelector = (selector) => {
2495
- const nestedElement = getDocument().querySelector(selector);
2502
+ const nestedElement = ownerDocument.querySelector(selector);
2496
2503
  return nestedElement?.contains(event.target);
2497
2504
  };
2498
2505
  const checkDataAttribute = () => {
2499
2506
  const target = event.target;
2500
- if (!target || !(target instanceof HTMLElement)) {
2507
+ const HTMLElementConstructor = ownerDocument.defaultView?.HTMLElement ?? HTMLElement;
2508
+ if (!target || !(target instanceof HTMLElementConstructor)) {
2501
2509
  return false;
2502
2510
  }
2503
2511
  let current = target;
@@ -2521,19 +2529,29 @@ function useOutsideClick(elementRef, onOutsideClick, nested) {
2521
2529
  [nested]
2522
2530
  );
2523
2531
  (0, import_react16.useEffect)(() => {
2532
+ if (isDisabled || !handleOutsideClick.current) {
2533
+ return;
2534
+ }
2535
+ const ownerDocument = elementRef?.current?.ownerDocument ?? triggerRef?.current?.ownerDocument ?? getDocument();
2524
2536
  function handleClickOutside(event) {
2525
- const isNestedElement = checkNestedElements(event);
2526
- if (elementRef?.current && !elementRef.current.contains(event.target) && !isNestedElement) {
2537
+ const target = event.target;
2538
+ const NodeConstructor = ownerDocument.defaultView?.Node ?? Node;
2539
+ if (!target || !(target instanceof NodeConstructor)) {
2540
+ return;
2541
+ }
2542
+ const targetNode = target;
2543
+ const isNestedElement = checkNestedElements(event, ownerDocument);
2544
+ if (elementRef?.current && !elementRef.current.contains(targetNode) && !triggerRef?.current?.contains(targetNode) && !isNestedElement) {
2527
2545
  handleOutsideClick.current?.(event);
2528
2546
  }
2529
2547
  }
2530
- getDocument().addEventListener("mousedown", handleClickOutside, true);
2531
- getDocument().addEventListener("touchstart", handleClickOutside, true);
2548
+ ownerDocument.addEventListener("mousedown", handleClickOutside, true);
2549
+ ownerDocument.addEventListener("touchstart", handleClickOutside, true);
2532
2550
  return () => {
2533
- getDocument().removeEventListener("mousedown", handleClickOutside, true);
2534
- getDocument().removeEventListener("touchstart", handleClickOutside, true);
2551
+ ownerDocument.removeEventListener("mousedown", handleClickOutside, true);
2552
+ ownerDocument.removeEventListener("touchstart", handleClickOutside, true);
2535
2553
  };
2536
- }, [checkNestedElements, elementRef]);
2554
+ }, [checkNestedElements, elementRef, isDisabled, triggerRef]);
2537
2555
  }
2538
2556
 
2539
2557
  // src/hooks/use-screen-resize.ts
@@ -11292,7 +11310,11 @@ var AirbnbSelect = React38.forwardRef(function AirbnbSelect2({
11292
11310
  const combinedRef = useCombinedRef(ref, desktopTriggerRef);
11293
11311
  const activeMobileIndex = getOptionIndex(options, pendingValue);
11294
11312
  const valueLabel = value ? getValueLabel?.(value) ?? String(value.label) : void 0;
11295
- useOutsideClick(containerRef, isOpen && !isMobile ? () => setIsOpen(false) : null);
11313
+ useOutsideClick({
11314
+ elementRef: containerRef,
11315
+ onOutsideClick: () => setIsOpen(false),
11316
+ isDisabled: !isOpen || isMobile
11317
+ });
11296
11318
  React38.useEffect(() => {
11297
11319
  if (isBlocked) {
11298
11320
  setIsOpen(false);
@@ -11792,7 +11814,11 @@ var SearchableSelectInternal = ({
11792
11814
  const triggerError = error ?? invalid;
11793
11815
  const describedBy = error && !hideErrorMessage ? errorId : void 0;
11794
11816
  const activeOptionId = highlightedIndex >= 0 ? getOptionId(reactId, highlightedIndex) : void 0;
11795
- useOutsideClick(containerRef, open && !isMobile ? () => closeSelect() : null);
11817
+ useOutsideClick({
11818
+ elementRef: containerRef,
11819
+ onOutsideClick: () => closeSelect(),
11820
+ isDisabled: !open || isMobile
11821
+ });
11796
11822
  const handleOnOpenChange = useEvent(onOpenChange);
11797
11823
  const setSelectOpen = (0, import_react63.useCallback)(
11798
11824
  (nextOpen, options2) => {
@@ -12418,6 +12444,7 @@ function getNextEnabledIndex(options, startIndex, step) {
12418
12444
  emptyMediaVariants,
12419
12445
  getSidebarState,
12420
12446
  inputVariants,
12447
+ isNumeric,
12421
12448
  labelVariants,
12422
12449
  sectionTagVariants,
12423
12450
  switchThumbVariants,