@particle-academy/react-fancy 4.15.1 → 4.17.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
@@ -8607,6 +8607,208 @@ var Modal = Object.assign(ModalRoot, {
8607
8607
  Body: ModalBody,
8608
8608
  Footer: ModalFooter
8609
8609
  });
8610
+ var DrawerContext = react.createContext(null);
8611
+ function useDrawer() {
8612
+ const ctx = react.useContext(DrawerContext);
8613
+ if (!ctx) {
8614
+ throw new Error("Drawer compound components must be used within <Drawer>");
8615
+ }
8616
+ return ctx;
8617
+ }
8618
+ function DrawerHeader({ children, closable = true, className }) {
8619
+ const { close } = useDrawer();
8620
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8621
+ "div",
8622
+ {
8623
+ "data-react-fancy-drawer-header": "",
8624
+ className: cn(
8625
+ "flex shrink-0 items-center justify-between border-b border-zinc-200 px-4 py-3 dark:border-zinc-700",
8626
+ className
8627
+ ),
8628
+ children: [
8629
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold text-zinc-900 dark:text-zinc-100", children }),
8630
+ closable ? /* @__PURE__ */ jsxRuntime.jsx(
8631
+ "button",
8632
+ {
8633
+ type: "button",
8634
+ onClick: close,
8635
+ className: "rounded-lg p-1 text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300",
8636
+ "aria-label": "Close",
8637
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 18 })
8638
+ }
8639
+ ) : null
8640
+ ]
8641
+ }
8642
+ );
8643
+ }
8644
+ DrawerHeader.displayName = "DrawerHeader";
8645
+ function DrawerBody({ children, className }) {
8646
+ return /* @__PURE__ */ jsxRuntime.jsx(
8647
+ "div",
8648
+ {
8649
+ "data-react-fancy-drawer-body": "",
8650
+ className: cn("min-h-0 flex-1 overflow-auto px-4 py-3 text-zinc-700 dark:text-zinc-300", className),
8651
+ children
8652
+ }
8653
+ );
8654
+ }
8655
+ DrawerBody.displayName = "DrawerBody";
8656
+ function DrawerFooter({ children, className }) {
8657
+ return /* @__PURE__ */ jsxRuntime.jsx(
8658
+ "div",
8659
+ {
8660
+ "data-react-fancy-drawer-footer": "",
8661
+ className: cn(
8662
+ "flex shrink-0 items-center justify-end gap-2 border-t border-zinc-200 px-4 py-3 dark:border-zinc-700",
8663
+ className
8664
+ ),
8665
+ children
8666
+ }
8667
+ );
8668
+ }
8669
+ DrawerFooter.displayName = "DrawerFooter";
8670
+ function DrawerContainer({ children, className, ...rest }) {
8671
+ return /* @__PURE__ */ jsxRuntime.jsx(
8672
+ "div",
8673
+ {
8674
+ "data-react-fancy-drawer-container": "",
8675
+ ...rest,
8676
+ className: cn("relative overflow-hidden", className),
8677
+ children
8678
+ }
8679
+ );
8680
+ }
8681
+ DrawerContainer.displayName = "DrawerContainer";
8682
+ var WIDTH = {
8683
+ sm: "w-64",
8684
+ md: "w-80",
8685
+ lg: "w-96",
8686
+ xl: "w-[32rem]",
8687
+ full: "w-full"
8688
+ };
8689
+ var HEIGHT = {
8690
+ sm: "h-32",
8691
+ md: "h-64",
8692
+ lg: "h-96",
8693
+ xl: "h-[32rem]",
8694
+ full: "h-full"
8695
+ };
8696
+ var ANCHOR = {
8697
+ left: "inset-y-0 left-0",
8698
+ right: "inset-y-0 right-0",
8699
+ top: "inset-x-0 top-0",
8700
+ bottom: "inset-x-0 bottom-0"
8701
+ };
8702
+ var ENTER = {
8703
+ left: "fancy-slide-in-left",
8704
+ right: "fancy-slide-in-right",
8705
+ top: "fancy-slide-in-top",
8706
+ bottom: "fancy-slide-in-bottom"
8707
+ };
8708
+ var EXIT = {
8709
+ left: "fancy-slide-out-left",
8710
+ right: "fancy-slide-out-right",
8711
+ top: "fancy-slide-out-top",
8712
+ bottom: "fancy-slide-out-bottom"
8713
+ };
8714
+ var EDGE = {
8715
+ left: "border-r",
8716
+ right: "border-l",
8717
+ top: "border-b",
8718
+ bottom: "border-t"
8719
+ };
8720
+ function DrawerRoot({
8721
+ children,
8722
+ open,
8723
+ onClose,
8724
+ side = "right",
8725
+ size = "md",
8726
+ attach = "viewport",
8727
+ backdrop = true,
8728
+ dismissOnBackdrop = true,
8729
+ dismissOnEscape = true,
8730
+ className,
8731
+ ...rest
8732
+ }) {
8733
+ const panelRef = react.useRef(null);
8734
+ const horizontal = side === "left" || side === "right";
8735
+ const isViewport = attach === "viewport";
8736
+ const close = react.useCallback(() => onClose(), [onClose]);
8737
+ useEscapeKey(close, open && dismissOnEscape);
8738
+ useFocusTrap(panelRef, open && isViewport);
8739
+ react.useEffect(() => {
8740
+ if (!open || !isViewport) return;
8741
+ const original = document.body.style.overflow;
8742
+ document.body.style.overflow = "hidden";
8743
+ return () => {
8744
+ document.body.style.overflow = original;
8745
+ };
8746
+ }, [open, isViewport]);
8747
+ const { mounted, className: animClass, ref: animRef } = useAnimation({
8748
+ open,
8749
+ enterClass: ENTER[side],
8750
+ exitClass: EXIT[side]
8751
+ });
8752
+ const ctx = react.useMemo(() => ({ open, close, side }), [open, close, side]);
8753
+ if (!mounted) return null;
8754
+ const frame = /* @__PURE__ */ jsxRuntime.jsxs(
8755
+ "div",
8756
+ {
8757
+ "data-react-fancy-drawer-frame": "",
8758
+ className: cn(isViewport ? "fixed inset-0 z-50" : "absolute inset-0 z-20", !backdrop && "pointer-events-none"),
8759
+ children: [
8760
+ backdrop ? /* @__PURE__ */ jsxRuntime.jsx(
8761
+ "div",
8762
+ {
8763
+ "data-react-fancy-drawer-backdrop": "",
8764
+ className: cn(
8765
+ "absolute inset-0 bg-black/40 transition-opacity",
8766
+ isViewport && "backdrop-blur-sm",
8767
+ open ? "opacity-100" : "opacity-0"
8768
+ ),
8769
+ onClick: dismissOnBackdrop ? close : void 0,
8770
+ "aria-hidden": "true"
8771
+ }
8772
+ ) : null,
8773
+ /* @__PURE__ */ jsxRuntime.jsx(
8774
+ "div",
8775
+ {
8776
+ ref: (node) => {
8777
+ panelRef.current = node;
8778
+ animRef.current = node;
8779
+ },
8780
+ "data-react-fancy-drawer": "",
8781
+ "data-side": side,
8782
+ role: "dialog",
8783
+ "aria-modal": isViewport || void 0,
8784
+ ...rest,
8785
+ className: cn(
8786
+ "pointer-events-auto absolute flex flex-col border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900",
8787
+ ANCHOR[side],
8788
+ EDGE[side],
8789
+ horizontal ? WIDTH[size] : HEIGHT[size],
8790
+ // Cross-axis fills the anchor; the main axis is capped so a viewport
8791
+ // drawer can never grow past the screen on a small device.
8792
+ horizontal ? "h-full" : "w-full",
8793
+ isViewport && (horizontal ? "max-w-[90vw]" : "max-h-[90vh]"),
8794
+ !isViewport && (horizontal ? "max-w-full" : "max-h-full"),
8795
+ animClass,
8796
+ className
8797
+ ),
8798
+ children
8799
+ }
8800
+ )
8801
+ ]
8802
+ }
8803
+ );
8804
+ return /* @__PURE__ */ jsxRuntime.jsx(DrawerContext.Provider, { value: ctx, children: isViewport ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { children: frame }) : frame });
8805
+ }
8806
+ var Drawer = Object.assign(DrawerRoot, {
8807
+ Header: DrawerHeader,
8808
+ Body: DrawerBody,
8809
+ Footer: DrawerFooter,
8810
+ Container: DrawerContainer
8811
+ });
8610
8812
  var ToastContext = react.createContext(null);
8611
8813
  function useToast() {
8612
8814
  const ctx = react.useContext(ToastContext);
@@ -9149,6 +9351,7 @@ function BreadcrumbsItem({
9149
9351
  children,
9150
9352
  href,
9151
9353
  active = false,
9354
+ onClick,
9152
9355
  className
9153
9356
  }) {
9154
9357
  const baseClass = cn(
@@ -9159,6 +9362,18 @@ function BreadcrumbsItem({
9159
9362
  if (href && !active) {
9160
9363
  return /* @__PURE__ */ jsxRuntime.jsx("a", { "data-react-fancy-breadcrumbs-item": "", href, className: baseClass, children });
9161
9364
  }
9365
+ if (onClick && !active) {
9366
+ return /* @__PURE__ */ jsxRuntime.jsx(
9367
+ "button",
9368
+ {
9369
+ type: "button",
9370
+ "data-react-fancy-breadcrumbs-item": "",
9371
+ onClick,
9372
+ className: cn(baseClass, "cursor-pointer border-0 bg-transparent p-0"),
9373
+ children
9374
+ }
9375
+ );
9376
+ }
9162
9377
  return /* @__PURE__ */ jsxRuntime.jsx("span", { "data-react-fancy-breadcrumbs-item": "", className: baseClass, "aria-current": active ? "page" : void 0, children });
9163
9378
  }
9164
9379
  BreadcrumbsItem.displayName = "BreadcrumbsItem";
@@ -16093,6 +16308,7 @@ exports.ContentRenderer = ContentRenderer;
16093
16308
  exports.ContextMenu = ContextMenu;
16094
16309
  exports.DatePicker = DatePicker;
16095
16310
  exports.DisplayValue = DisplayValue;
16311
+ exports.Drawer = Drawer;
16096
16312
  exports.Dropdown = Dropdown;
16097
16313
  exports.EMOJI_CATEGORY_ORDER = EMOJI_CATEGORY_ORDER;
16098
16314
  exports.EMOJI_DATA = EMOJI_DATA;
@@ -16180,6 +16396,7 @@ exports.useCarousel = useCarousel;
16180
16396
  exports.useCommand = useCommand;
16181
16397
  exports.useContextMenu = useContextMenu;
16182
16398
  exports.useControllableState = useControllableState;
16399
+ exports.useDrawer = useDrawer;
16183
16400
  exports.useDropdown = useDropdown;
16184
16401
  exports.useEditor = useEditor;
16185
16402
  exports.useEscapeKey = useEscapeKey;