@overmap-ai/blocks 1.0.40-phone-input.0 → 1.0.40-slide-out-resize-handle.1

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.
Files changed (39) hide show
  1. package/dist/Layout/SlideOutClose.d.ts +5 -0
  2. package/dist/Layout/SlideOutContent.d.ts +6 -0
  3. package/dist/Layout/SlideOutHandle.d.ts +5 -0
  4. package/dist/Layout/SlideOutOverlay.d.ts +2 -5
  5. package/dist/Layout/SlideOutRoot.d.ts +10 -0
  6. package/dist/Layout/SlideOutTrigger.d.ts +2 -6
  7. package/dist/Layout/SlideOutViewport.d.ts +5 -0
  8. package/dist/Layout/context.d.ts +0 -1
  9. package/dist/Layout/index.d.ts +11 -3
  10. package/dist/Layout/typings.d.ts +3 -0
  11. package/dist/LuIcon/LuIcon.d.ts +4 -6
  12. package/dist/LuIcon/index.d.ts +1 -1
  13. package/dist/LuIcon/typings.d.ts +2 -2
  14. package/dist/SlideOut/Close.d.ts +4 -0
  15. package/dist/SlideOut/Content.d.ts +11 -0
  16. package/dist/SlideOut/Handle.d.ts +5 -0
  17. package/dist/SlideOut/Overlay.d.ts +4 -0
  18. package/dist/SlideOut/Root.d.ts +9 -0
  19. package/dist/SlideOut/Trigger.d.ts +4 -0
  20. package/dist/SlideOut/Viewport.d.ts +4 -0
  21. package/dist/SlideOut/constants.d.ts +1 -0
  22. package/dist/SlideOut/context.d.ts +17 -0
  23. package/dist/SlideOut/index.d.ts +18 -1
  24. package/dist/SlideOut/typings.d.ts +2 -0
  25. package/dist/blocks.js +387 -354
  26. package/dist/blocks.js.map +1 -1
  27. package/dist/blocks.umd.cjs +385 -350
  28. package/dist/blocks.umd.cjs.map +1 -1
  29. package/dist/index.d.ts +0 -1
  30. package/package.json +1 -2
  31. package/dist/Layout/SlideOut.d.ts +0 -20
  32. package/dist/PhoneNumberInput/CountrySelect.d.ts +0 -11
  33. package/dist/PhoneNumberInput/FlagComponent.d.ts +0 -2
  34. package/dist/PhoneNumberInput/InputComponent.d.ts +0 -5
  35. package/dist/PhoneNumberInput/PhoneNumberInput.d.ts +0 -6
  36. package/dist/PhoneNumberInput/context.d.ts +0 -4
  37. package/dist/PhoneNumberInput/index.d.ts +0 -2
  38. package/dist/PhoneNumberInput/typings.d.ts +0 -9
  39. package/dist/SlideOut/SlideOut.d.ts +0 -49
package/dist/blocks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as RadixAlertDialog from "@radix-ui/react-alert-dialog";
2
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { cva, cx } from "class-variance-authority";
4
4
  import { createContext, useContext, memo, useMemo, useState, useCallback, useEffect, useId, useLayoutEffect, use, useRef } from "react";
5
5
  import * as RadixAvatar from "@radix-ui/react-avatar";
@@ -9,18 +9,16 @@ import { CommandItem, CommandRoot, CommandEmpty, CommandGroup, CommandInput, use
9
9
  import * as RadixDialog from "@radix-ui/react-dialog";
10
10
  import { DialogPortal, DialogContent as DialogContent$1, DialogTitle, DialogDescription, DialogOverlay as DialogOverlay$1, DialogTrigger } from "@radix-ui/react-dialog";
11
11
  import { DayPicker as DayPicker$1 } from "react-day-picker";
12
- import { DynamicIcon } from "lucide-react/dynamic";
12
+ import { ChevronRight, ChevronLeft, ChevronDown, ChevronUp, AlertTriangle, RotateCcw, X } from "lucide-react";
13
13
  import * as RadixHoverCard from "@radix-ui/react-hover-card";
14
+ import { Slot } from "@radix-ui/react-slot";
14
15
  import { CSSTransition } from "react-transition-group";
16
+ import "react-transition-group/CSSTransition";
15
17
  import ReactDOM from "react-dom";
16
- import { Slot } from "@radix-ui/react-slot";
17
18
  import { useListItem, useMergeRefs, FloatingNode, FloatingPortal, FloatingOverlay, FloatingFocusManager, FloatingList, useFloatingNodeId, useFloating, offset, size, flip, shift, hide, autoUpdate, useRole, useDismiss, useClick, useListNavigation, useInteractions, FloatingTree, useHover, safePolygon } from "@floating-ui/react";
18
19
  import * as RadixSeparator from "@radix-ui/react-separator";
19
20
  import * as RadixOneTimePasswordField from "@radix-ui/react-one-time-password-field";
20
21
  import { useErrorBoundary, ErrorBoundary } from "react-error-boundary";
21
- import PhoneInput from "react-phone-number-input";
22
- import { PhoneIcon, ChevronDownIcon } from "lucide-react";
23
- import { getCountryCallingCode } from "react-phone-number-input/min";
24
22
  import * as RadixPopover from "@radix-ui/react-popover";
25
23
  import * as RadixProgress from "@radix-ui/react-progress";
26
24
  import * as RadixRadioGroup from "@radix-ui/react-radio-group";
@@ -1652,21 +1650,21 @@ const CommandMenu = {
1652
1650
  PageTriggerItem: CommandMenuPageTriggerItem
1653
1651
  };
1654
1652
  const LuIcon = memo((props) => {
1655
- const { ref, icon, className, size: size2 = "1em", ...rest } = props;
1656
- return /* @__PURE__ */ jsx(DynamicIcon, { ref, className: cx("shrink-0", className), size: size2, name: icon, ...rest });
1653
+ const { ref, icon: Icon, className, size: size2 = "1em", ...rest } = props;
1654
+ return /* @__PURE__ */ jsx(Icon, { ref, className: cx("shrink-0", className), size: size2, ...rest });
1657
1655
  });
1658
1656
  LuIcon.displayName = "LuIcon";
1659
1657
  const Chevron = (props) => {
1660
1658
  const { orientation, ...rest } = props;
1661
1659
  switch (orientation) {
1662
1660
  case "up":
1663
- return /* @__PURE__ */ jsx(LuIcon, { icon: "chevron-up", ...rest });
1661
+ return /* @__PURE__ */ jsx(LuIcon, { icon: ChevronUp, ...rest });
1664
1662
  case "down":
1665
- return /* @__PURE__ */ jsx(LuIcon, { icon: "chevron-down", ...rest });
1663
+ return /* @__PURE__ */ jsx(LuIcon, { icon: ChevronDown, ...rest });
1666
1664
  case "left":
1667
- return /* @__PURE__ */ jsx(LuIcon, { icon: "chevron-left", ...rest });
1665
+ return /* @__PURE__ */ jsx(LuIcon, { icon: ChevronLeft, ...rest });
1668
1666
  default:
1669
- return /* @__PURE__ */ jsx(LuIcon, { icon: "chevron-right", ...rest });
1667
+ return /* @__PURE__ */ jsx(LuIcon, { icon: ChevronRight, ...rest });
1670
1668
  }
1671
1669
  };
1672
1670
  const rootCva = cva(["relative", "size-max"], {
@@ -2231,9 +2229,9 @@ const Input = {
2231
2229
  const LayoutContext = createContext({});
2232
2230
  const useLayoutContext = () => useContext(LayoutContext);
2233
2231
  const LayoutContainer = memo((props) => {
2234
- const { ref, children, className, ...rest } = props;
2232
+ const { ref, children, ...rest } = props;
2235
2233
  const { hideLayout = false } = useLayoutContext();
2236
- return !hideLayout && /* @__PURE__ */ jsx("div", { className: cx("flex h-full grow", className), ref, ...rest, children });
2234
+ return !hideLayout && /* @__PURE__ */ jsx("div", { ref, ...rest, children });
2237
2235
  });
2238
2236
  LayoutContainer.displayName = "LayoutContainer";
2239
2237
  const LayoutRoot = memo((props) => {
@@ -2260,6 +2258,23 @@ const LayoutRoot = memo((props) => {
2260
2258
  return /* @__PURE__ */ jsx(LayoutContext.Provider, { value: contextValue, children });
2261
2259
  });
2262
2260
  LayoutRoot.displayName = "LayoutRoot";
2261
+ const SlideOutRootContext = createContext({});
2262
+ const SlideOutContextContext = createContext({});
2263
+ const SlideOutClose = memo((props) => {
2264
+ const { ref, onClick, disabled, ...rest } = props;
2265
+ const { setOpen } = use(SlideOutRootContext);
2266
+ const handleClick = useCallback(
2267
+ (e) => {
2268
+ onClick == null ? void 0 : onClick(e);
2269
+ if (e.defaultPrevented) return;
2270
+ setOpen(false);
2271
+ },
2272
+ [onClick, setOpen]
2273
+ );
2274
+ return /* @__PURE__ */ jsx(Slot, { ref, onClick: handleClick, "data-disabled": disabled ?? false, ...rest });
2275
+ });
2276
+ SlideOutClose.displayName = "SlideOutClose";
2277
+ const TIMEOUT_DURATION = 200;
2263
2278
  function usePointerDownOutside(onPointerDownOutside, ownerElement = globalThis == null ? void 0 : globalThis.document.body) {
2264
2279
  const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
2265
2280
  const isPointerInsideReactTreeRef = useRef(false);
@@ -2321,293 +2336,392 @@ function useCallbackRef(callback) {
2321
2336
  return (_a = callbackRef.current) == null ? void 0 : _a.call(callbackRef, ...args);
2322
2337
  }, []);
2323
2338
  }
2324
- const TIMEOUT_DURATION = 200;
2325
- const SlideOut = memo((props) => {
2326
- const {
2327
- ref,
2328
- children,
2329
- className,
2330
- style,
2331
- open,
2332
- hide: hide2 = false,
2333
- modal = false,
2334
- overlayComponent,
2335
- resizeable = true,
2336
- side,
2337
- position = "relative",
2338
- initialWidth,
2339
- minWidth,
2340
- maxWidth,
2341
- onDismiss,
2342
- onOpening,
2343
- onClosed,
2344
- content,
2345
- ...otherProps
2346
- } = props;
2347
- const isLeft = side === "left";
2348
- const [parentContainer, setParentContainer] = useState(document.body);
2349
- const childrenContainerRef = useRef(null);
2350
- const localRef = useRef(null);
2351
- const nodeRef = useRef(null);
2352
- const mergedRefs = mergeRefs([ref, localRef, nodeRef]);
2353
- const [isResizing, setIsResizing] = useState(false);
2354
- const [computedWidth, setComputedWidth] = useState(null);
2355
- const prevClientX = useRef(null);
2356
- const handleDismiss = useCallback(() => {
2357
- if (modal && onDismiss) {
2358
- onDismiss();
2359
- }
2360
- }, [modal, onDismiss]);
2361
- const handleAssignParentContainer = useCallback((element) => {
2362
- if (element) {
2363
- setParentContainer(element);
2339
+ const SlideOutContent = memo((props) => {
2340
+ const { ref, children, style, side, type, resizeable = false, initialSize, minSize, maxSize, ...rest } = props;
2341
+ const internalRef = useRef(null);
2342
+ const { open, setOpen, parentElement, modal, hide: hide2 } = use(SlideOutRootContext);
2343
+ const [computedSize, setComputedSize] = useState(null);
2344
+ const handleClose = useCallback(() => {
2345
+ if (modal) setOpen(false);
2346
+ }, [modal, setOpen]);
2347
+ const { onPointerDownCapture: handlePointerDownCapture } = usePointerDownOutside(
2348
+ handleClose,
2349
+ parentElement ?? void 0
2350
+ );
2351
+ useLayoutEffect(() => {
2352
+ if (!open || !internalRef.current) return;
2353
+ const { offsetWidth, offsetHeight } = internalRef.current;
2354
+ switch (side) {
2355
+ case "left":
2356
+ case "right":
2357
+ setComputedSize(offsetWidth);
2358
+ break;
2359
+ case "top":
2360
+ case "bottom":
2361
+ setComputedSize(offsetHeight);
2362
+ }
2363
+ }, [open, side]);
2364
+ const computedStyle = useMemo(() => {
2365
+ switch (side) {
2366
+ case "left":
2367
+ return {
2368
+ ...style,
2369
+ left: 0,
2370
+ width: computedSize ?? initialSize,
2371
+ maxWidth: maxSize,
2372
+ minWidth: minSize,
2373
+ position: type === "inline" ? "relative" : "absolute",
2374
+ "--slide-out-size": `${computedSize}px`
2375
+ };
2376
+ case "right":
2377
+ return {
2378
+ ...style,
2379
+ right: 0,
2380
+ width: computedSize ?? initialSize,
2381
+ maxWidth: maxSize,
2382
+ minWidth: minSize,
2383
+ position: type === "inline" ? "relative" : "absolute",
2384
+ "--slide-out-size": `${computedSize}px`
2385
+ };
2386
+ case "top":
2387
+ return {
2388
+ ...style,
2389
+ top: 0,
2390
+ height: computedSize ?? initialSize,
2391
+ maxHeight: maxSize,
2392
+ minHeight: minSize,
2393
+ position: type === "inline" ? "relative" : "absolute",
2394
+ "--slide-out-size": `${computedSize}px`
2395
+ };
2396
+ case "bottom":
2397
+ return {
2398
+ ...style,
2399
+ bottom: 0,
2400
+ height: computedSize ?? initialSize,
2401
+ maxHeight: maxSize,
2402
+ minHeight: minSize,
2403
+ position: type === "inline" ? "relative" : "absolute",
2404
+ "--slide-out-size": `${computedSize}px`
2405
+ };
2364
2406
  }
2365
- }, []);
2366
- useEffect(() => {
2367
- if (!childrenContainerRef.current) return;
2368
- const originalParentPointerEvents = childrenContainerRef.current.style.pointerEvents;
2369
- if (open && modal) {
2370
- childrenContainerRef.current.style.pointerEvents = "none";
2407
+ }, [computedSize, initialSize, maxSize, minSize, side, style, type]);
2408
+ const transitionClassNames = useMemo(() => {
2409
+ switch (side) {
2410
+ case "left":
2411
+ return {
2412
+ enter: "-ml-(--slide-out-size)",
2413
+ enterActive: "ease-linear duration-200 transition-[margin-left] ml-0",
2414
+ enterDone: "ml-0",
2415
+ exitActive: "ease-linear duration-200 transition-[margin-left] -ml-(--slide-out-size)",
2416
+ exitDone: "-ml-(--slide-out-size)"
2417
+ };
2418
+ case "right":
2419
+ return {
2420
+ enter: "-mr-(--slide-out-size)",
2421
+ enterActive: "ease-linear duration-200 transition-[margin-right] mr-0",
2422
+ enterDone: "mr-0",
2423
+ exitActive: "ease-linear duration-200 transition-[margin-right] -mr-(--slide-out-size)",
2424
+ exitDone: "-mr-(--slide-out-size)"
2425
+ };
2426
+ case "top":
2427
+ return {
2428
+ enter: "-mt-(--slide-out-size)",
2429
+ enterActive: "ease-linear duration-200 transition-[margin-top] mt-0",
2430
+ enterDone: "mt-0",
2431
+ exitActive: "ease-linear duration-200 transition-[margin-top] -mt-(--slide-out-size)",
2432
+ exitDone: "-mt-(--slide-out-size)"
2433
+ };
2434
+ case "bottom":
2435
+ return {
2436
+ enter: "-mb-(--slide-out-size)",
2437
+ enterActive: "ease-linear duration-200 transition-[margin-bottom] mb-0",
2438
+ enterDone: "mb-0",
2439
+ exitActive: "ease-linear duration-200 transition-[margin-bottom] -mb-(--slide-out-size)",
2440
+ exitDone: "-mb-(--slide-out-size)"
2441
+ };
2371
2442
  }
2372
- return () => {
2373
- if (childrenContainerRef.current) {
2374
- childrenContainerRef.current.style.pointerEvents = originalParentPointerEvents;
2375
- }
2376
- };
2377
- }, [modal, open, parentContainer.style]);
2378
- const { onPointerDownCapture: handlePointerDownCapture } = usePointerDownOutside(handleDismiss, parentContainer);
2379
- const CSSTransitionClassNames = useMemo(
2443
+ }, [side]);
2444
+ const contextValue = useMemo(
2380
2445
  () => ({
2381
- enter: isLeft ? "-ml-(--slide-out-width)" : "-mr-(--slide-out-width)",
2382
- enterActive: isLeft ? "ease-linear duration-200 transition-[margin-left] ml-0" : "ease-linear duration-200 transition-[margin-right] mr-0",
2383
- enterDone: isLeft ? "ml-0" : "mr-0",
2384
- exitActive: isLeft ? "ease-linear duration-200 transition-[margin-left] -ml-(--slide-out-width)" : "ease-linear duration-200 transition-[margin-right] -mr-(--slide-out-width)",
2385
- exitDone: isLeft ? "-ml-(--slide-out-width)" : "-mr-(--slide-out-width)"
2446
+ side,
2447
+ type,
2448
+ resizeable,
2449
+ computedSize,
2450
+ setComputedSize
2386
2451
  }),
2387
- [isLeft]
2452
+ [computedSize, resizeable, side, type]
2388
2453
  );
2389
- const handleMouseDown = useCallback((e) => {
2390
- const { clientX } = e;
2391
- prevClientX.current = clientX;
2392
- setIsResizing(true);
2393
- }, []);
2394
- const handleMouseMove = useCallback(
2454
+ return !hide2 ? (
2455
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2456
+ // @ts-ignore
2457
+ /* @__PURE__ */ jsx(
2458
+ CSSTransition,
2459
+ {
2460
+ classNames: transitionClassNames,
2461
+ in: open,
2462
+ timeout: TIMEOUT_DURATION,
2463
+ unmountOnExit: true,
2464
+ mountOnEnter: true,
2465
+ nodeRef: internalRef,
2466
+ children: /* @__PURE__ */ jsx(
2467
+ "div",
2468
+ {
2469
+ ref: mergeRefs([ref, internalRef]),
2470
+ onPointerDownCapture: handlePointerDownCapture,
2471
+ "data-open": open,
2472
+ "data-side": side,
2473
+ "data-type": type,
2474
+ style: computedStyle,
2475
+ ...rest,
2476
+ children: /* @__PURE__ */ jsx(SlideOutContextContext, { value: contextValue, children })
2477
+ }
2478
+ )
2479
+ }
2480
+ )
2481
+ ) : null;
2482
+ });
2483
+ SlideOutContent.displayName = "SlideOutContent";
2484
+ const SlideOutHandle = memo((props) => {
2485
+ const { ref, onMouseDown, disabled, ...rest } = props;
2486
+ const prevClientCoord = useRef(null);
2487
+ const [isResizing, setIsResizing] = useState(false);
2488
+ const { side, resizeable, computedSize, setComputedSize } = use(SlideOutContextContext);
2489
+ const computedDisabled = disabled ?? !resizeable;
2490
+ const setPrevClientCoord = useCallback(
2491
+ (clientX, clientY) => {
2492
+ switch (side) {
2493
+ case "left":
2494
+ prevClientCoord.current = clientX;
2495
+ break;
2496
+ case "right":
2497
+ prevClientCoord.current = clientX;
2498
+ break;
2499
+ case "top":
2500
+ prevClientCoord.current = clientY;
2501
+ break;
2502
+ case "bottom":
2503
+ prevClientCoord.current = clientY;
2504
+ break;
2505
+ }
2506
+ },
2507
+ [side]
2508
+ );
2509
+ const handlePointerDown = useCallback(
2510
+ (e) => {
2511
+ onMouseDown == null ? void 0 : onMouseDown(e);
2512
+ if (e.defaultPrevented || computedDisabled) return;
2513
+ e.preventDefault();
2514
+ setPrevClientCoord(e.clientX, e.clientY);
2515
+ setIsResizing(true);
2516
+ },
2517
+ [computedDisabled, onMouseDown, setPrevClientCoord]
2518
+ );
2519
+ const handlePointerMove = useCallback(
2395
2520
  (e) => {
2396
- if (!isResizing) return;
2397
- const { clientX } = e;
2398
- const deltaX = (clientX - prevClientX.current) * (isLeft ? 1 : -1);
2399
- prevClientX.current = clientX;
2400
- setComputedWidth((prevWidth) => prevWidth + deltaX);
2521
+ if (!isResizing || !prevClientCoord.current || computedDisabled) return;
2522
+ e.preventDefault();
2523
+ const { clientX, clientY } = e;
2524
+ let delta = 0;
2525
+ switch (side) {
2526
+ case "left":
2527
+ delta = clientX - prevClientCoord.current;
2528
+ break;
2529
+ case "right":
2530
+ delta = (clientX - prevClientCoord.current) * -1;
2531
+ break;
2532
+ case "top":
2533
+ delta = clientY - prevClientCoord.current;
2534
+ break;
2535
+ case "bottom":
2536
+ delta = (clientY - prevClientCoord.current) * -1;
2537
+ break;
2538
+ }
2539
+ setPrevClientCoord(clientX, clientY);
2540
+ setComputedSize(computedSize + delta);
2401
2541
  },
2402
- [isLeft, isResizing]
2542
+ [computedDisabled, computedSize, isResizing, setComputedSize, setPrevClientCoord, side]
2403
2543
  );
2404
- const handleMouseUp = useCallback(() => {
2405
- if (!isResizing) return;
2406
- prevClientX.current = null;
2544
+ const handlePointerUp = useCallback(() => {
2545
+ if (!isResizing || computedDisabled) return;
2546
+ prevClientCoord.current = null;
2407
2547
  setIsResizing(false);
2408
- }, [isResizing]);
2548
+ }, [computedDisabled, isResizing]);
2409
2549
  useEffect(() => {
2410
- window.addEventListener("mousemove", handleMouseMove);
2411
- window.addEventListener("mouseup", handleMouseUp);
2550
+ document.addEventListener("pointermove", handlePointerMove);
2551
+ document.addEventListener("pointerup", handlePointerUp);
2412
2552
  return () => {
2413
- window.removeEventListener("mousemove", handleMouseMove);
2414
- window.removeEventListener("mouseup", handleMouseUp);
2553
+ document.removeEventListener("pointermove", handlePointerMove);
2554
+ document.removeEventListener("pointerup", handlePointerUp);
2415
2555
  };
2416
- }, [handleMouseMove, handleMouseUp]);
2417
- useLayoutEffect(() => {
2418
- if (!open) return;
2419
- setComputedWidth(localRef.current.offsetWidth);
2420
- }, [open]);
2421
- const resizableStyle = useMemo(
2422
- () => ({
2423
- ...style,
2424
- width: computedWidth ?? initialWidth,
2425
- maxWidth,
2426
- minWidth,
2427
- position,
2428
- "--slide-out-width": `${computedWidth}${typeof computedWidth === "number" ? "px" : ""}`
2429
- }),
2430
- [computedWidth, initialWidth, maxWidth, minWidth, position, style]
2431
- );
2432
- const resizableEnable = useMemo(
2433
- () => ({ left: resizeable && !isLeft, right: resizeable && isLeft }),
2434
- [isLeft, resizeable]
2435
- );
2436
- const SlideOut2 = useMemo(
2437
- () => (
2438
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2439
- // @ts-ignore
2440
- /* @__PURE__ */ jsx(
2441
- CSSTransition,
2442
- {
2443
- classNames: CSSTransitionClassNames,
2444
- in: open,
2445
- timeout: TIMEOUT_DURATION,
2446
- unmountOnExit: true,
2447
- mountOnEnter: true,
2448
- onEntering: onOpening,
2449
- onExited: onClosed,
2450
- nodeRef,
2451
- children: /* @__PURE__ */ jsxs(
2452
- "div",
2453
- {
2454
- className: cx(
2455
- "top-0",
2456
- "bottom-0",
2457
- {
2458
- "left-0": isLeft,
2459
- "right-0": !isLeft,
2460
- absolute: position === "absolute",
2461
- relative: position === "relative"
2462
- },
2463
- className
2464
- ),
2465
- ref: mergedRefs,
2466
- onPointerDownCapture: handlePointerDownCapture,
2467
- "data-side": side,
2468
- style: resizableStyle,
2469
- children: [
2470
- /* @__PURE__ */ jsx(
2471
- "div",
2472
- {
2473
- className: cx("absolute top-0 bottom-0 w-[3px]", {
2474
- "right-0": isLeft,
2475
- "left-0": !isLeft,
2476
- "pointer-events-none": !resizableEnable
2477
- }),
2478
- onMouseDown: handleMouseDown,
2479
- "data-resizing": isResizing ? "" : void 0
2480
- }
2481
- ),
2482
- content
2483
- ]
2484
- }
2485
- )
2486
- }
2487
- )
2488
- ),
2489
- [
2490
- CSSTransitionClassNames,
2491
- open,
2492
- onOpening,
2493
- onClosed,
2494
- className,
2495
- isLeft,
2496
- position,
2497
- mergedRefs,
2498
- handlePointerDownCapture,
2499
- side,
2500
- resizableStyle,
2501
- handleMouseDown,
2502
- isResizing,
2503
- resizableEnable,
2504
- content
2505
- ]
2506
- );
2507
- return /* @__PURE__ */ jsxs(
2556
+ }, [handlePointerMove, handlePointerUp]);
2557
+ return /* @__PURE__ */ jsx(
2508
2558
  "div",
2509
2559
  {
2510
- className: "relative flex h-full max-h-full w-full max-w-full overflow-hidden",
2511
- ref: handleAssignParentContainer,
2512
- ...otherProps,
2513
- children: [
2514
- side === "left" && !hide2 && /* @__PURE__ */ jsxs(Fragment, { children: [
2515
- open && overlayComponent,
2516
- " ",
2517
- content && SlideOut2
2518
- ] }),
2519
- /* @__PURE__ */ jsx("div", { className: "flex h-full max-w-full grow overflow-hidden", ref: childrenContainerRef, children }),
2520
- side === "right" && !hide2 && /* @__PURE__ */ jsxs(Fragment, { children: [
2521
- open && overlayComponent,
2522
- " ",
2523
- content && SlideOut2
2524
- ] })
2525
- ]
2560
+ ref,
2561
+ onPointerDown: handlePointerDown,
2562
+ "data-resizing": isResizing,
2563
+ "data-side": side,
2564
+ "data-disabled": computedDisabled,
2565
+ ...rest
2526
2566
  }
2527
2567
  );
2528
2568
  });
2529
- SlideOut.displayName = "SlideOut";
2530
- const DEFAULT_INITIAL_WIDTH = "30%";
2531
- const LayoutSlideOut = memo((props) => {
2532
- const { small, hideLayout, isOpen, setOpen } = useLayoutContext();
2569
+ SlideOutHandle.displayName = "SlideOutHandle";
2570
+ const SlideOutOverlay = memo((props) => {
2571
+ const { ref, ...rest } = props;
2572
+ const { open, hide: hide2 } = use(SlideOutRootContext);
2573
+ return open && !hide2 ? /* @__PURE__ */ jsx("div", { ref, "data-open": open, ...rest }) : null;
2574
+ });
2575
+ SlideOutOverlay.displayName = "SlideOutOverlay";
2576
+ const SlideOutRoot = memo((props) => {
2533
2577
  const {
2534
2578
  ref,
2535
- id,
2536
2579
  children,
2537
- className,
2538
- defaultOpen,
2539
- side,
2540
- initialWidth = DEFAULT_INITIAL_WIDTH,
2541
- onDismiss,
2580
+ defaultOpen = false,
2581
+ open: controlledOpen,
2582
+ onOpenChange,
2583
+ modal = false,
2584
+ hide: hide2 = false,
2542
2585
  ...rest
2543
2586
  } = props;
2544
- const open = isOpen(id);
2587
+ const [parentElement, setParentElement] = useState(null);
2588
+ const [open, setOpen] = useControlledState(defaultOpen, controlledOpen, onOpenChange);
2589
+ const contextValue = useMemo(
2590
+ () => ({
2591
+ parentElement,
2592
+ open,
2593
+ setOpen,
2594
+ modal,
2595
+ hide: hide2
2596
+ }),
2597
+ [hide2, modal, open, parentElement, setOpen]
2598
+ );
2599
+ return /* @__PURE__ */ jsx("div", { ref: mergeRefs([ref, setParentElement]), ...rest, children: /* @__PURE__ */ jsx(SlideOutRootContext, { value: contextValue, children }) });
2600
+ });
2601
+ SlideOutRoot.displayName = "SlideOutRoot";
2602
+ const SlideOutTrigger = memo((props) => {
2603
+ const { ref, onClick, ...rest } = props;
2604
+ const { open, setOpen } = use(SlideOutRootContext);
2605
+ const handleClick = useCallback(
2606
+ (e) => {
2607
+ onClick == null ? void 0 : onClick(e);
2608
+ if (e.defaultPrevented) return;
2609
+ setOpen(!open);
2610
+ },
2611
+ [onClick, open, setOpen]
2612
+ );
2613
+ return /* @__PURE__ */ jsx(Slot, { ref, onClick: handleClick, "data-disabled": props.disabled ?? false, ...rest });
2614
+ });
2615
+ SlideOutTrigger.displayName = "SlideOutTrigger";
2616
+ const SlideOutViewport = memo((props) => {
2617
+ const { ref, ...rest } = props;
2618
+ const internalRef = useRef(null);
2619
+ const { open, modal, parentElement } = use(SlideOutRootContext);
2620
+ useEffect(() => {
2621
+ if (!internalRef.current) return;
2622
+ const internalElement = internalRef.current;
2623
+ const originalParentPointerEvents = internalElement.style.pointerEvents;
2624
+ if (open && modal) {
2625
+ internalElement.style.pointerEvents = "none";
2626
+ }
2627
+ return () => {
2628
+ internalElement.style.pointerEvents = originalParentPointerEvents;
2629
+ };
2630
+ }, [modal, open, parentElement == null ? void 0 : parentElement.style]);
2631
+ return /* @__PURE__ */ jsx("div", { ref: mergeRefs([ref, internalRef]), ...rest });
2632
+ });
2633
+ SlideOutViewport.displayName = "SlideOutViewport";
2634
+ const SlideOut = {
2635
+ Close: SlideOutClose,
2636
+ Content: SlideOutContent,
2637
+ Handle: SlideOutHandle,
2638
+ Overlay: SlideOutOverlay,
2639
+ Root: SlideOutRoot,
2640
+ Trigger: SlideOutTrigger,
2641
+ Viewport: SlideOutViewport
2642
+ };
2643
+ const LayoutSlideOutClose = memo((props) => {
2644
+ const { ref, ...rest } = props;
2645
+ return /* @__PURE__ */ jsx(SlideOutClose, { ref, ...rest });
2646
+ });
2647
+ LayoutSlideOutClose.displayName = "LayoutSlideOutClose";
2648
+ const LayoutSlideOutContent = memo((props) => {
2649
+ const { ref, type, ...rest } = props;
2650
+ const { small } = use(LayoutContext);
2651
+ return /* @__PURE__ */ jsx(SlideOutContent, { ref, type: type ?? (small ? "overlay" : "inline"), ...rest });
2652
+ });
2653
+ LayoutSlideOutContent.displayName = "LayoutSlideOutContent";
2654
+ const LayoutSlideOutHandle = memo((props) => {
2655
+ const { ref, ...rest } = props;
2656
+ return /* @__PURE__ */ jsx(SlideOutHandle, { ref, ...rest });
2657
+ });
2658
+ LayoutSlideOutHandle.displayName = "LayoutSlideOutHandle";
2659
+ const LayoutSlideOutOverlay = memo((props) => {
2660
+ const { ref, smallModeOnly = false, ...rest } = props;
2661
+ const { small, hideLayout } = useLayoutContext();
2662
+ const showOverlay = useMemo(() => {
2663
+ if (hideLayout) return false;
2664
+ if (smallModeOnly && !small) return false;
2665
+ return true;
2666
+ }, [hideLayout, small, smallModeOnly]);
2667
+ return showOverlay ? /* @__PURE__ */ jsx(SlideOutOverlay, { ref, ...rest }) : null;
2668
+ });
2669
+ LayoutSlideOutOverlay.displayName = "SlideOutOverlay";
2670
+ const LayoutSlideOutRoot = memo((props) => {
2671
+ const { ref, slideOutId, defaultOpen, hide: hide2, ...rest } = props;
2672
+ const { isOpen, setOpen, small, hideLayout } = use(LayoutContext);
2673
+ const open = isOpen(slideOutId);
2674
+ const handleOpenChange = useCallback(
2675
+ (open2) => {
2676
+ if (!open2) setOpen(slideOutId, false);
2677
+ },
2678
+ [setOpen, slideOutId]
2679
+ );
2545
2680
  useEffect(() => {
2546
2681
  if (small && (defaultOpen == null ? void 0 : defaultOpen.small) !== void 0) {
2547
- setOpen(id, defaultOpen == null ? void 0 : defaultOpen.small);
2682
+ setOpen(slideOutId, defaultOpen == null ? void 0 : defaultOpen.small);
2548
2683
  } else if (!small && (defaultOpen == null ? void 0 : defaultOpen.large) !== void 0) {
2549
- setOpen(id, defaultOpen == null ? void 0 : defaultOpen.large);
2550
- }
2551
- }, [defaultOpen, id, setOpen, small]);
2552
- const handleDismiss = useCallback(() => {
2553
- setOpen(id, false);
2554
- onDismiss == null ? void 0 : onDismiss();
2555
- }, [id, onDismiss, setOpen]);
2556
- return !hideLayout && /* @__PURE__ */ jsx(
2557
- SlideOut,
2684
+ setOpen(slideOutId, defaultOpen == null ? void 0 : defaultOpen.large);
2685
+ }
2686
+ }, [defaultOpen, slideOutId, setOpen, small]);
2687
+ return /* @__PURE__ */ jsx(
2688
+ SlideOutRoot,
2558
2689
  {
2559
- className: cx(`overmap-layout-slideOut-${side}`, className),
2560
- side,
2561
2690
  ref,
2562
2691
  open,
2563
- initialWidth,
2692
+ onOpenChange: handleOpenChange,
2564
2693
  modal: small,
2565
- onDismiss: handleDismiss,
2566
- position: small ? "absolute" : "relative",
2567
- ...rest,
2568
- children
2694
+ hide: hide2 ?? hideLayout,
2695
+ ...rest
2569
2696
  }
2570
2697
  );
2571
2698
  });
2572
- LayoutSlideOut.displayName = "LayoutSlideOut";
2573
- const LayoutSlideOutOverlay = memo((props) => {
2574
- const { ref, children, className, active, slideOutId, smallModeOnly = false, ...rest } = props;
2575
- const { small, hideLayout, isOpen } = useLayoutContext();
2576
- const showOverlay = useMemo(() => {
2577
- if (active !== void 0) return active;
2578
- if (hideLayout) return false;
2579
- if (smallModeOnly && !small) return false;
2580
- return isOpen(slideOutId);
2581
- }, [active, hideLayout, isOpen, slideOutId, small, smallModeOnly]);
2582
- return showOverlay && /* @__PURE__ */ jsx("div", { className: cx("overmap-layout-overlay", "fixed inset-0", className), ref, ...rest, children });
2583
- });
2584
- LayoutSlideOutOverlay.displayName = "SlideOutOverlay";
2585
- function nextStateBasedOnType(open, type) {
2586
- switch (type) {
2587
- case "toggle":
2588
- return !open;
2589
- case "open":
2590
- return true;
2591
- case "close":
2592
- return false;
2593
- }
2594
- }
2699
+ LayoutSlideOutRoot.displayName = "LayoutSlideOutRoot";
2595
2700
  const LayoutSlideOutTrigger = memo((props) => {
2596
- const { ref, slideOutId, type = "toggle", children, ...rest } = props;
2701
+ const { ref, slideOutId, children, ...rest } = props;
2597
2702
  const { isOpen, setOpen } = useLayoutContext();
2598
2703
  const open = isOpen(slideOutId);
2599
2704
  const handleClick = useCallback(() => {
2600
- setOpen(slideOutId, nextStateBasedOnType(open, type));
2601
- }, [open, setOpen, slideOutId, type]);
2705
+ setOpen(slideOutId, !open);
2706
+ }, [open, setOpen, slideOutId]);
2602
2707
  return /* @__PURE__ */ jsx(Slot, { "data-state": getOpenState(open), ref, onClick: handleClick, ...rest, children });
2603
2708
  });
2604
- LayoutSlideOutTrigger.displayName = "SlideOutTrigger";
2709
+ LayoutSlideOutTrigger.displayName = "LayoutSlideOutTrigger";
2710
+ const LayoutSlideOutViewport = memo((props) => {
2711
+ const { ref, ...rest } = props;
2712
+ return /* @__PURE__ */ jsx(SlideOutViewport, { ref, ...rest });
2713
+ });
2714
+ LayoutSlideOutViewport.displayName = "LayoutSlideOutViewport";
2605
2715
  const Layout = {
2606
2716
  Root: LayoutRoot,
2607
2717
  Container: LayoutContainer,
2718
+ SlideOutClose: LayoutSlideOutClose,
2719
+ SlideOutContent: LayoutSlideOutContent,
2720
+ SlideOutHandle: LayoutSlideOutHandle,
2608
2721
  SlideOutOverlay: LayoutSlideOutOverlay,
2609
- SlideOut: LayoutSlideOut,
2610
- SlideOutTrigger: LayoutSlideOutTrigger
2722
+ SlideOutRoot: LayoutSlideOutRoot,
2723
+ SlideOutTrigger: LayoutSlideOutTrigger,
2724
+ SlideOutViewport: LayoutSlideOutViewport
2611
2725
  };
2612
2726
  const linkCva = cva(["cursor-pointer"], {
2613
2727
  variants: {
@@ -4354,9 +4468,9 @@ const ErrorFallback = memo((props) => {
4354
4468
  }, [onRetry, resetBoundary]);
4355
4469
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full gap-2", style: outerFlexStyles, children: [
4356
4470
  /* @__PURE__ */ jsx("div", { style: { flexGrow: 1 } }),
4357
- /* @__PURE__ */ jsx(LuIcon, { icon: "alert-triangle", size: height, style: centerStyles }),
4471
+ /* @__PURE__ */ jsx(LuIcon, { icon: AlertTriangle, size: height, style: centerStyles }),
4358
4472
  /* @__PURE__ */ jsx("span", { style: { lineHeight: height, ...centerStyles }, children: message }),
4359
- /* @__PURE__ */ jsx(IconButton, { "aria-label": "Try again", variant: "soft", onClick: handleRetry, style: centerStyles, children: /* @__PURE__ */ jsx(LuIcon, { icon: "rotate-ccw", size: height }) }),
4473
+ /* @__PURE__ */ jsx(IconButton, { "aria-label": "Try again", variant: "soft", onClick: handleRetry, style: centerStyles, children: /* @__PURE__ */ jsx(LuIcon, { icon: RotateCcw, size: height }) }),
4360
4474
  /* @__PURE__ */ jsx("div", { style: { flexGrow: 1 } })
4361
4475
  ] });
4362
4476
  });
@@ -4382,95 +4496,6 @@ const OvermapErrorBoundary = memo((props) => {
4382
4496
  );
4383
4497
  });
4384
4498
  OvermapErrorBoundary.displayName = "OvermapErrorBoundary";
4385
- const PhoneNumberInputContext = createContext({});
4386
- const FlagComponent = memo((props) => {
4387
- const { country } = props;
4388
- return country ? country : /* @__PURE__ */ jsx(PhoneIcon, { size: 16 });
4389
- });
4390
- FlagComponent.displayName = "FlagComponent";
4391
- const CountrySelect = memo((props) => {
4392
- const { disabled, value, onChange, options } = props;
4393
- const { radius, size: size2, variant, accentColor } = use(PhoneNumberInputContext);
4394
- const handleSelect = useCallback(
4395
- (e) => {
4396
- onChange(e.target.value);
4397
- },
4398
- [onChange]
4399
- );
4400
- return /* @__PURE__ */ jsxs(
4401
- Button,
4402
- {
4403
- className: "relative",
4404
- accentColor,
4405
- radius,
4406
- size: size2,
4407
- variant,
4408
- disabled,
4409
- children: [
4410
- /* @__PURE__ */ jsx(FlagComponent, { country: value, countryName: value, "aria-hidden": "true" }),
4411
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16, "aria-hidden": "true" }),
4412
- /* @__PURE__ */ jsxs(
4413
- "select",
4414
- {
4415
- disabled,
4416
- value,
4417
- onChange: handleSelect,
4418
- className: "absolute inset-0 text-sm opacity-0",
4419
- "aria-label": "Select country",
4420
- children: [
4421
- /* @__PURE__ */ jsx("option", { value: "", children: "Select a country" }, "default"),
4422
- options.filter((x) => x.value).map((option, i) => /* @__PURE__ */ jsxs("option", { value: option.value, children: [
4423
- option.label,
4424
- " ",
4425
- option.value && `+${getCountryCallingCode(option.value)}`
4426
- ] }, option.value ?? `empty-${i}`))
4427
- ]
4428
- }
4429
- )
4430
- ]
4431
- }
4432
- );
4433
- });
4434
- CountrySelect.displayName = "CountrySelect";
4435
- const InputComponent = memo((props) => {
4436
- const { accentColor, radius, size: size2, variant } = use(PhoneNumberInputContext);
4437
- return /* @__PURE__ */ jsx(Input.Root, { variant, size: size2, radius, accentColor, children: /* @__PURE__ */ jsx(Input.Field, { ...props }) });
4438
- });
4439
- InputComponent.displayName = "InputComponent";
4440
- const PhoneNumberInput = memo((props) => {
4441
- const providerContext = useProvider();
4442
- const {
4443
- ref,
4444
- className,
4445
- size: size2 = "md",
4446
- variant = "outline",
4447
- radius = providerContext.radius,
4448
- accentColor = providerContext.accentColor,
4449
- ...rest
4450
- } = props;
4451
- const contextValue = useMemo(
4452
- () => ({
4453
- size: size2,
4454
- variant,
4455
- radius,
4456
- accentColor
4457
- }),
4458
- [accentColor, radius, size2, variant]
4459
- );
4460
- return /* @__PURE__ */ jsx(PhoneNumberInputContext, { value: contextValue, children: /* @__PURE__ */ jsx(
4461
- PhoneInput,
4462
- {
4463
- ref,
4464
- className: cx(className, "flex gap-1"),
4465
- flagComponent: FlagComponent,
4466
- countrySelectComponent: CountrySelect,
4467
- inputComponent: InputComponent,
4468
- "data-accent-color": accentColor,
4469
- ...rest
4470
- }
4471
- ) });
4472
- });
4473
- PhoneNumberInput.displayName = "PhoneNumberInput";
4474
4499
  const PopoverArrow = memo((props) => {
4475
4500
  const { ref, children, className, ...rest } = props;
4476
4501
  return /* @__PURE__ */ jsx(RadixPopover.Arrow, { className: cx("fill-(--base-6)", className), ref, ...rest, children });
@@ -6121,7 +6146,7 @@ const _Toast = function Toast2(props) {
6121
6146
  action && /* @__PURE__ */ jsx(RadixToast.Action, { className: "w-max", altText: action.altText, asChild: true, children: action.content })
6122
6147
  ] })
6123
6148
  ] }),
6124
- /* @__PURE__ */ jsx(RadixToast.Close, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { size: size2, "aria-label": "Close", variant: "ghost", accentColor, children: /* @__PURE__ */ jsx(LuIcon, { icon: "x" }) }) })
6149
+ /* @__PURE__ */ jsx(RadixToast.Close, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { size: size2, "aria-label": "Close", variant: "ghost", accentColor, children: /* @__PURE__ */ jsx(LuIcon, { icon: X }) }) })
6125
6150
  ]
6126
6151
  }
6127
6152
  );
@@ -6670,10 +6695,12 @@ export {
6670
6695
  InputSlot,
6671
6696
  Layout,
6672
6697
  LayoutContainer,
6673
- LayoutContext,
6674
6698
  LayoutRoot,
6675
- LayoutSlideOut,
6699
+ LayoutSlideOutClose,
6700
+ LayoutSlideOutContent,
6701
+ LayoutSlideOutHandle,
6676
6702
  LayoutSlideOutOverlay,
6703
+ LayoutSlideOutRoot,
6677
6704
  LayoutSlideOutTrigger,
6678
6705
  Link,
6679
6706
  LuIcon,
@@ -6734,7 +6761,6 @@ export {
6734
6761
  OverlayTitle,
6735
6762
  OverlayTrigger,
6736
6763
  OvermapErrorBoundary,
6737
- PhoneNumberInput,
6738
6764
  Popover,
6739
6765
  PopoverArrow,
6740
6766
  PopoverContent,
@@ -6760,6 +6786,13 @@ export {
6760
6786
  SegmentedTabsTrigger,
6761
6787
  Separator,
6762
6788
  SlideOut,
6789
+ SlideOutClose,
6790
+ SlideOutContent,
6791
+ SlideOutHandle,
6792
+ SlideOutOverlay,
6793
+ SlideOutRoot,
6794
+ SlideOutTrigger,
6795
+ SlideOutViewport,
6763
6796
  Slider,
6764
6797
  Spinner,
6765
6798
  Switch,