@cloudvoyant/helical-react 0.19.0 → 0.20.0

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
@@ -675,7 +675,7 @@ function useIsMobile() {
675
675
  return isMobile && isMobileSet;
676
676
  }
677
677
  function Provider({
678
- defaultOpen = true,
678
+ defaultOpen = false,
679
679
  open: openProp,
680
680
  onOpenChange: setOpenProp,
681
681
  className,
@@ -685,6 +685,8 @@ function Provider({
685
685
  }) {
686
686
  const isMobile = useIsMobile();
687
687
  const [openMobile, setOpenMobile] = React2.useState(false);
688
+ const isControlled = openProp !== void 0;
689
+ const usesMobileSheetState = isMobile && !isControlled;
688
690
  const [_open, _setOpen] = React2.useState(defaultOpen);
689
691
  const open = openProp ?? _open;
690
692
  const setOpen = React2.useCallback(
@@ -702,8 +704,8 @@ function Provider({
702
704
  [setOpenProp, open]
703
705
  );
704
706
  const toggleSidebar = React2.useCallback(() => {
705
- return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
706
- }, [isMobile, setOpen, setOpenMobile]);
707
+ return usesMobileSheetState ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
708
+ }, [usesMobileSheetState, setOpen, setOpenMobile]);
707
709
  React2.useEffect(() => {
708
710
  if (openProp !== void 0) return;
709
711
  if (typeof document === "undefined") return;
@@ -731,9 +733,10 @@ function Provider({
731
733
  isMobile,
732
734
  openMobile,
733
735
  setOpenMobile,
734
- toggleSidebar
736
+ toggleSidebar,
737
+ isControlled
735
738
  }),
736
- [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
739
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar, isControlled]
737
740
  );
738
741
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
739
742
  Row,
@@ -763,7 +766,7 @@ function Root({
763
766
  children,
764
767
  ...props
765
768
  }) {
766
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
769
+ const { isMobile, state, open, setOpen, openMobile, setOpenMobile, isControlled } = useSidebar();
767
770
  if (collapsible === "none") {
768
771
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
769
772
  Col,
@@ -777,27 +780,40 @@ function Root({
777
780
  );
778
781
  }
779
782
  if (isMobile) {
783
+ const isBottomWidgetSheet = side === "right";
784
+ const mobileSheetOpen = isControlled ? open : openMobile;
785
+ const setMobileSheetOpen = isControlled ? setOpen : setOpenMobile;
786
+ const bottomSheetSnapProps = isBottomWidgetSheet ? {
787
+ snapPoints: import_helical_ui25.SIDEBAR_WIDGET_SNAP_POINTS,
788
+ defaultSnapPoint: import_helical_ui25.SIDEBAR_WIDGET_DEFAULT_SNAP_POINT,
789
+ snapToSequentialPoints: true
790
+ } : {};
780
791
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
781
792
  import_drawer.DrawerRoot,
782
793
  {
783
- open: openMobile,
784
- onOpenChange: (details) => setOpenMobile(details.open),
794
+ open: mobileSheetOpen,
795
+ onOpenChange: (details) => setMobileSheetOpen(details.open),
796
+ swipeDirection: side === "left" ? "start" : "down",
797
+ modal: !isBottomWidgetSheet,
798
+ ...bottomSheetSnapProps,
799
+ preventDragOnScroll: false,
785
800
  ...props,
786
801
  children: [
787
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_drawer.DrawerBackdrop, {}),
788
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_drawer.DrawerPositioner, { className: "w-(--sidebar-width)", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
802
+ !isBottomWidgetSheet && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_drawer.DrawerBackdrop, { className: import_helical_ui25.sidebarStyles.mobileBackdropClass }),
803
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_drawer.DrawerPositioner, { className: import_helical_ui25.sidebarStyles.mobilePositionerClass, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
789
804
  import_drawer.DrawerContent,
790
805
  {
791
806
  "data-sidebar": "sidebar",
792
807
  "data-slot": "sidebar",
793
808
  "data-mobile": "true",
794
- className: (0, import_helical_ui25.cn)("w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground", className),
809
+ className: (0, import_helical_ui25.cn)(import_helical_ui25.sidebarStyles.mobileContentClass, className),
795
810
  style: { "--sidebar-width": import_helical_ui25.SIDEBAR_WIDTH_MOBILE },
796
811
  children: [
797
812
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_drawer.DrawerTitle, { className: "sr-only", children: "Sidebar" }),
798
813
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_drawer.DrawerDescription, { className: "sr-only", children: "Displays the mobile sidebar." }),
799
814
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_drawer.DrawerCloseTrigger, { className: "hidden" }),
800
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Col, { className: "h-full w-full", children })
815
+ isBottomWidgetSheet && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_drawer.DrawerGrabber, { className: import_helical_ui25.sidebarStyles.mobileGrabberClass, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_drawer.DrawerGrabberIndicator, { className: import_helical_ui25.sidebarStyles.mobileGrabberIndicatorClass }) }),
816
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { "data-no-drag": true, className: "flex min-h-0 flex-1 flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Col, { className: "h-full w-full", children }) })
801
817
  ]
802
818
  }
803
819
  ) })
package/dist/index.js CHANGED
@@ -531,7 +531,7 @@ function useIsMobile() {
531
531
  return isMobile && isMobileSet;
532
532
  }
533
533
  function Provider({
534
- defaultOpen = true,
534
+ defaultOpen = false,
535
535
  open: openProp,
536
536
  onOpenChange: setOpenProp,
537
537
  className,
@@ -541,6 +541,8 @@ function Provider({
541
541
  }) {
542
542
  const isMobile = useIsMobile();
543
543
  const [openMobile, setOpenMobile] = React2.useState(false);
544
+ const isControlled = openProp !== void 0;
545
+ const usesMobileSheetState = isMobile && !isControlled;
544
546
  const [_open, _setOpen] = React2.useState(defaultOpen);
545
547
  const open = openProp ?? _open;
546
548
  const setOpen = React2.useCallback(
@@ -558,8 +560,8 @@ function Provider({
558
560
  [setOpenProp, open]
559
561
  );
560
562
  const toggleSidebar = React2.useCallback(() => {
561
- return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
562
- }, [isMobile, setOpen, setOpenMobile]);
563
+ return usesMobileSheetState ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
564
+ }, [usesMobileSheetState, setOpen, setOpenMobile]);
563
565
  React2.useEffect(() => {
564
566
  if (openProp !== void 0) return;
565
567
  if (typeof document === "undefined") return;
@@ -587,9 +589,10 @@ function Provider({
587
589
  isMobile,
588
590
  openMobile,
589
591
  setOpenMobile,
590
- toggleSidebar
592
+ toggleSidebar,
593
+ isControlled
591
594
  }),
592
- [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
595
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar, isControlled]
593
596
  );
594
597
  return /* @__PURE__ */ jsx24(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx24(
595
598
  Row,
@@ -615,9 +618,17 @@ import {
615
618
  DrawerContent,
616
619
  DrawerTitle,
617
620
  DrawerDescription,
618
- DrawerCloseTrigger
621
+ DrawerCloseTrigger,
622
+ DrawerGrabber,
623
+ DrawerGrabberIndicator
619
624
  } from "@ark-ui/react/drawer";
620
- import { SIDEBAR_WIDTH_MOBILE, sidebarStyles as sidebarStyles2, cn as cn25 } from "@cloudvoyant/helical-ui";
625
+ import {
626
+ SIDEBAR_WIDTH_MOBILE,
627
+ SIDEBAR_WIDGET_SNAP_POINTS,
628
+ SIDEBAR_WIDGET_DEFAULT_SNAP_POINT,
629
+ sidebarStyles as sidebarStyles2,
630
+ cn as cn25
631
+ } from "@cloudvoyant/helical-ui";
621
632
  import { jsx as jsx25, jsxs as jsxs5 } from "react/jsx-runtime";
622
633
  function Root({
623
634
  side = "left",
@@ -627,7 +638,7 @@ function Root({
627
638
  children,
628
639
  ...props
629
640
  }) {
630
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
641
+ const { isMobile, state, open, setOpen, openMobile, setOpenMobile, isControlled } = useSidebar();
631
642
  if (collapsible === "none") {
632
643
  return /* @__PURE__ */ jsx25(
633
644
  Col,
@@ -641,27 +652,40 @@ function Root({
641
652
  );
642
653
  }
643
654
  if (isMobile) {
655
+ const isBottomWidgetSheet = side === "right";
656
+ const mobileSheetOpen = isControlled ? open : openMobile;
657
+ const setMobileSheetOpen = isControlled ? setOpen : setOpenMobile;
658
+ const bottomSheetSnapProps = isBottomWidgetSheet ? {
659
+ snapPoints: SIDEBAR_WIDGET_SNAP_POINTS,
660
+ defaultSnapPoint: SIDEBAR_WIDGET_DEFAULT_SNAP_POINT,
661
+ snapToSequentialPoints: true
662
+ } : {};
644
663
  return /* @__PURE__ */ jsxs5(
645
664
  DrawerRoot,
646
665
  {
647
- open: openMobile,
648
- onOpenChange: (details) => setOpenMobile(details.open),
666
+ open: mobileSheetOpen,
667
+ onOpenChange: (details) => setMobileSheetOpen(details.open),
668
+ swipeDirection: side === "left" ? "start" : "down",
669
+ modal: !isBottomWidgetSheet,
670
+ ...bottomSheetSnapProps,
671
+ preventDragOnScroll: false,
649
672
  ...props,
650
673
  children: [
651
- /* @__PURE__ */ jsx25(DrawerBackdrop, {}),
652
- /* @__PURE__ */ jsx25(DrawerPositioner, { className: "w-(--sidebar-width)", children: /* @__PURE__ */ jsxs5(
674
+ !isBottomWidgetSheet && /* @__PURE__ */ jsx25(DrawerBackdrop, { className: sidebarStyles2.mobileBackdropClass }),
675
+ /* @__PURE__ */ jsx25(DrawerPositioner, { className: sidebarStyles2.mobilePositionerClass, children: /* @__PURE__ */ jsxs5(
653
676
  DrawerContent,
654
677
  {
655
678
  "data-sidebar": "sidebar",
656
679
  "data-slot": "sidebar",
657
680
  "data-mobile": "true",
658
- className: cn25("w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground", className),
681
+ className: cn25(sidebarStyles2.mobileContentClass, className),
659
682
  style: { "--sidebar-width": SIDEBAR_WIDTH_MOBILE },
660
683
  children: [
661
684
  /* @__PURE__ */ jsx25(DrawerTitle, { className: "sr-only", children: "Sidebar" }),
662
685
  /* @__PURE__ */ jsx25(DrawerDescription, { className: "sr-only", children: "Displays the mobile sidebar." }),
663
686
  /* @__PURE__ */ jsx25(DrawerCloseTrigger, { className: "hidden" }),
664
- /* @__PURE__ */ jsx25(Col, { className: "h-full w-full", children })
687
+ isBottomWidgetSheet && /* @__PURE__ */ jsx25(DrawerGrabber, { className: sidebarStyles2.mobileGrabberClass, children: /* @__PURE__ */ jsx25(DrawerGrabberIndicator, { className: sidebarStyles2.mobileGrabberIndicatorClass }) }),
688
+ /* @__PURE__ */ jsx25("div", { "data-no-drag": true, className: "flex min-h-0 flex-1 flex-col", children: /* @__PURE__ */ jsx25(Col, { className: "h-full w-full", children }) })
665
689
  ]
666
690
  }
667
691
  ) })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudvoyant/helical-react",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "helical-ui React UI components",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,7 +46,7 @@
46
46
  "@tiptap/react": "^3.31.3",
47
47
  "@tiptap/suggestion": "^3.31.3",
48
48
  "lucide-react": "^1.32.0",
49
- "@cloudvoyant/helical-ui": "0.19.0"
49
+ "@cloudvoyant/helical-ui": "0.20.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/katex": "^0.16.8",