@particle-academy/react-fancy 1.3.5 → 1.5.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
@@ -3024,7 +3024,7 @@ var CarouselPanels = react.forwardRef(
3024
3024
  }
3025
3025
  }, [activeIndex, transition]);
3026
3026
  if (transition === "fade") {
3027
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("relative overflow-hidden", className), children: /* @__PURE__ */ jsxRuntime.jsx(
3027
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-react-fancy-carousel-panels": "", className: cn("relative overflow-hidden", className), children: /* @__PURE__ */ jsxRuntime.jsx(
3028
3028
  "div",
3029
3029
  {
3030
3030
  className: cn(
@@ -3038,13 +3038,13 @@ var CarouselPanels = react.forwardRef(
3038
3038
  activeIndex
3039
3039
  ) });
3040
3040
  }
3041
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("relative overflow-hidden", className), children: slides[activeIndex] });
3041
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-react-fancy-carousel-panels": "", className: cn("relative overflow-hidden", className), children: slides[activeIndex] });
3042
3042
  }
3043
3043
  );
3044
3044
  CarouselPanels.displayName = "CarouselPanels";
3045
3045
  var CarouselSlide = react.forwardRef(
3046
3046
  ({ children, className, name: _name }, ref) => {
3047
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("w-full", className), children });
3047
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-react-fancy-carousel-slide": "", className: cn("w-full", className), children });
3048
3048
  }
3049
3049
  );
3050
3050
  CarouselSlide.displayName = "CarouselSlide";
@@ -3062,7 +3062,7 @@ var CarouselControls = react.forwardRef(
3062
3062
  const isFirst = activeIndex === 0;
3063
3063
  const isLast = activeIndex === totalSlides - 1;
3064
3064
  if (variant === "wizard") {
3065
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: cn("flex items-center gap-2", className), children: [
3065
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, "data-react-fancy-carousel-controls": "", className: cn("flex items-center gap-2", className), children: [
3066
3066
  /* @__PURE__ */ jsxRuntime.jsx(
3067
3067
  "button",
3068
3068
  {
@@ -3094,7 +3094,7 @@ var CarouselControls = react.forwardRef(
3094
3094
  }
3095
3095
  const prevDisabled = !loop && isFirst;
3096
3096
  const nextDisabled = !loop && isLast;
3097
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: cn("flex items-center gap-2", className), children: [
3097
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, "data-react-fancy-carousel-controls": "", className: cn("flex items-center gap-2", className), children: [
3098
3098
  /* @__PURE__ */ jsxRuntime.jsx(
3099
3099
  "button",
3100
3100
  {
@@ -3126,7 +3126,7 @@ var CarouselSteps = react.forwardRef(
3126
3126
  return null;
3127
3127
  }
3128
3128
  if (variant === "wizard") {
3129
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex items-center gap-3", className), children: Array.from({ length: totalSlides }, (_, i) => {
3129
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-react-fancy-carousel-steps": "", className: cn("flex items-center gap-3", className), children: Array.from({ length: totalSlides }, (_, i) => {
3130
3130
  const isActive = i === activeIndex;
3131
3131
  const isCompleted = i < activeIndex;
3132
3132
  const name = slideNames[i];
@@ -3163,7 +3163,7 @@ var CarouselSteps = react.forwardRef(
3163
3163
  );
3164
3164
  }) });
3165
3165
  }
3166
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex items-center gap-1.5", className), children: Array.from({ length: totalSlides }, (_, i) => /* @__PURE__ */ jsxRuntime.jsx(
3166
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-react-fancy-carousel-steps": "", className: cn("flex items-center gap-1.5", className), children: Array.from({ length: totalSlides }, (_, i) => /* @__PURE__ */ jsxRuntime.jsx(
3167
3167
  "button",
3168
3168
  {
3169
3169
  type: "button",
@@ -3484,10 +3484,10 @@ function useTable() {
3484
3484
  return ctx;
3485
3485
  }
3486
3486
  function TableHead({ children, className }) {
3487
- return /* @__PURE__ */ jsxRuntime.jsx("thead", { className: cn("border-b border-zinc-200 dark:border-zinc-700", className), children });
3487
+ return /* @__PURE__ */ jsxRuntime.jsx("thead", { "data-react-fancy-table-head": "", className: cn("border-b border-zinc-200 dark:border-zinc-700", className), children });
3488
3488
  }
3489
3489
  function TableBody({ children, className }) {
3490
- return /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: cn("divide-y divide-zinc-100 dark:divide-zinc-800", className), children });
3490
+ return /* @__PURE__ */ jsxRuntime.jsx("tbody", { "data-react-fancy-table-body": "", className: cn("divide-y divide-zinc-100 dark:divide-zinc-800", className), children });
3491
3491
  }
3492
3492
  function TableRow({
3493
3493
  children,
@@ -3536,6 +3536,7 @@ function TableRow({
3536
3536
  /* @__PURE__ */ jsxRuntime.jsxs(
3537
3537
  "tr",
3538
3538
  {
3539
+ "data-react-fancy-table-row": "",
3539
3540
  className: cn(
3540
3541
  "transition-colors hover:bg-zinc-50 dark:hover:bg-zinc-800/50",
3541
3542
  onClick && "cursor-pointer",
@@ -3557,6 +3558,7 @@ function TableCell({ children, className, header }) {
3557
3558
  return /* @__PURE__ */ jsxRuntime.jsx(
3558
3559
  Tag,
3559
3560
  {
3561
+ "data-react-fancy-table-cell": "",
3560
3562
  className: cn(
3561
3563
  "px-4 py-3 text-sm",
3562
3564
  header && "text-left font-medium text-zinc-500 dark:text-zinc-400",
@@ -3572,6 +3574,7 @@ function TableColumn({ label, sortKey, className }) {
3572
3574
  return /* @__PURE__ */ jsxRuntime.jsx(
3573
3575
  "th",
3574
3576
  {
3577
+ "data-react-fancy-table-column": "",
3575
3578
  className: cn(
3576
3579
  "px-4 py-3 text-left text-sm font-medium text-zinc-500 dark:text-zinc-400",
3577
3580
  sortKey && "cursor-pointer select-none",
@@ -3593,7 +3596,7 @@ function TablePagination({
3593
3596
  const { page, setPage } = useTable();
3594
3597
  const totalPages = Math.ceil(total / pageSize);
3595
3598
  if (totalPages <= 1) return null;
3596
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center justify-between px-4 py-3 text-sm", className), children: [
3599
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-react-fancy-table-pagination": "", className: cn("flex items-center justify-between px-4 py-3 text-sm", className), children: [
3597
3600
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-zinc-500", children: [
3598
3601
  "Page ",
3599
3602
  page + 1,
@@ -3632,6 +3635,7 @@ function TableSearch({
3632
3635
  return /* @__PURE__ */ jsxRuntime.jsx(
3633
3636
  "input",
3634
3637
  {
3638
+ "data-react-fancy-table-search": "",
3635
3639
  type: "text",
3636
3640
  value: searchQuery,
3637
3641
  onChange: (e) => setSearchQuery(e.target.value),
@@ -3644,7 +3648,7 @@ function TableSearch({
3644
3648
  );
3645
3649
  }
3646
3650
  function TableTray({ children, className }) {
3647
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex items-center justify-between px-4 py-3", className), children });
3651
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-react-fancy-table-tray": "", className: cn("flex items-center justify-between px-4 py-3", className), children });
3648
3652
  }
3649
3653
  function TableRowTray({ children, className }) {
3650
3654
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -4506,6 +4510,13 @@ var Callout = react.forwardRef(
4506
4510
  }
4507
4511
  );
4508
4512
  Callout.displayName = "Callout";
4513
+ var TimelineContext = react.createContext({
4514
+ orientation: "vertical",
4515
+ index: 0
4516
+ });
4517
+ function useTimeline() {
4518
+ return react.useContext(TimelineContext);
4519
+ }
4509
4520
  var dotColorClasses2 = {
4510
4521
  blue: "bg-blue-500 dark:bg-blue-400",
4511
4522
  green: "bg-green-500 dark:bg-green-400",
@@ -4527,6 +4538,34 @@ var ringColorClasses = {
4527
4538
  red: "ring-red-500/30 dark:ring-red-400/30",
4528
4539
  zinc: "ring-zinc-400/30 dark:ring-zinc-500/30"
4529
4540
  };
4541
+ function Dot({ icon, color, active }) {
4542
+ const c = color ?? "zinc";
4543
+ if (icon) {
4544
+ return /* @__PURE__ */ jsxRuntime.jsx(
4545
+ "span",
4546
+ {
4547
+ className: cn(
4548
+ "flex h-6 w-6 items-center justify-center rounded-full bg-white dark:bg-zinc-900",
4549
+ iconColorClasses2[c],
4550
+ active && "ring-4",
4551
+ active && ringColorClasses[c]
4552
+ ),
4553
+ children: icon
4554
+ }
4555
+ );
4556
+ }
4557
+ return /* @__PURE__ */ jsxRuntime.jsx(
4558
+ "span",
4559
+ {
4560
+ className: cn(
4561
+ "h-3 w-3 rounded-full",
4562
+ dotColorClasses2[c],
4563
+ active && "ring-4",
4564
+ active && ringColorClasses[c]
4565
+ )
4566
+ }
4567
+ );
4568
+ }
4530
4569
  var TimelineItem = react.forwardRef(
4531
4570
  ({
4532
4571
  children,
@@ -4535,6 +4574,28 @@ var TimelineItem = react.forwardRef(
4535
4574
  active = false,
4536
4575
  className
4537
4576
  }, ref) => {
4577
+ const { orientation, index } = useTimeline();
4578
+ if (orientation === "horizontal") {
4579
+ const isTop = index % 2 === 0;
4580
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4581
+ "div",
4582
+ {
4583
+ ref,
4584
+ "data-react-fancy-timeline-item": "",
4585
+ className: cn("relative flex flex-col items-center", className),
4586
+ style: { minWidth: 120 },
4587
+ children: [
4588
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex min-h-[4rem] items-end pb-2", !isTop && "invisible"), children: isTop && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 text-center", children }) }),
4589
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex w-full items-center justify-center", children: [
4590
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-px flex-1 bg-zinc-200 dark:bg-zinc-700" }),
4591
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative z-10 flex shrink-0 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(Dot, { icon, color, active }) }),
4592
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-px flex-1 bg-zinc-200 dark:bg-zinc-700" })
4593
+ ] }),
4594
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex min-h-[4rem] items-start pt-2", isTop && "invisible"), children: !isTop && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 text-center", children }) })
4595
+ ]
4596
+ }
4597
+ );
4598
+ }
4538
4599
  return /* @__PURE__ */ jsxRuntime.jsxs(
4539
4600
  "div",
4540
4601
  {
@@ -4543,28 +4604,7 @@ var TimelineItem = react.forwardRef(
4543
4604
  className: cn("relative flex gap-4 pb-8 last:pb-0", className),
4544
4605
  children: [
4545
4606
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-[11px] top-6 bottom-0 w-px bg-zinc-200 last:hidden dark:bg-zinc-700" }),
4546
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative z-10 flex shrink-0", children: icon ? /* @__PURE__ */ jsxRuntime.jsx(
4547
- "span",
4548
- {
4549
- className: cn(
4550
- "flex h-6 w-6 items-center justify-center rounded-full bg-white dark:bg-zinc-900",
4551
- iconColorClasses2[color],
4552
- active && "ring-4",
4553
- active && ringColorClasses[color]
4554
- ),
4555
- children: icon
4556
- }
4557
- ) : /* @__PURE__ */ jsxRuntime.jsx(
4558
- "span",
4559
- {
4560
- className: cn(
4561
- "mt-1.5 h-3 w-3 rounded-full",
4562
- dotColorClasses2[color],
4563
- active && "ring-4",
4564
- active && ringColorClasses[color]
4565
- )
4566
- }
4567
- ) }),
4607
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative z-10 flex shrink-0 mt-1.5", children: /* @__PURE__ */ jsxRuntime.jsx(Dot, { icon, color, active }) }),
4568
4608
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 flex-1 pt-0.5", children })
4569
4609
  ]
4570
4610
  }
@@ -4594,14 +4634,19 @@ var TimelineBlock = react.forwardRef(
4594
4634
  );
4595
4635
  TimelineBlock.displayName = "TimelineBlock";
4596
4636
  var TimelineRoot = react.forwardRef(
4597
- ({ children, className }, ref) => {
4637
+ ({ children, orientation = "vertical", className }, ref) => {
4638
+ const items = react.Children.toArray(children);
4598
4639
  return /* @__PURE__ */ jsxRuntime.jsx(
4599
4640
  "div",
4600
4641
  {
4601
4642
  ref,
4602
4643
  "data-react-fancy-timeline": "",
4603
- className: cn("flex flex-col", className),
4604
- children
4644
+ "data-orientation": orientation,
4645
+ className: cn(
4646
+ orientation === "vertical" ? "flex flex-col" : "flex flex-row items-center overflow-x-auto",
4647
+ className
4648
+ ),
4649
+ children: items.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(TimelineContext.Provider, { value: { orientation, index: i }, children: child }, i))
4605
4650
  }
4606
4651
  );
4607
4652
  }
@@ -4767,24 +4812,22 @@ function PopoverTrigger({ children }) {
4767
4812
  });
4768
4813
  }
4769
4814
  PopoverTrigger.displayName = "PopoverTrigger";
4770
- function useOutsideClick(ref, handler, enabled = true) {
4815
+ function useOutsideClick(ref, handler, enabled = true, ignoreRef) {
4771
4816
  react.useEffect(() => {
4772
4817
  if (!enabled) return;
4773
4818
  const listener = (event) => {
4774
4819
  const el = ref.current;
4775
4820
  if (!el || el.contains(event.target)) return;
4821
+ if (ignoreRef?.current?.contains(event.target)) return;
4776
4822
  handler(event);
4777
4823
  };
4778
- const raf = requestAnimationFrame(() => {
4779
- document.addEventListener("mousedown", listener);
4780
- document.addEventListener("touchstart", listener);
4781
- });
4824
+ document.addEventListener("mousedown", listener);
4825
+ document.addEventListener("touchstart", listener);
4782
4826
  return () => {
4783
- cancelAnimationFrame(raf);
4784
4827
  document.removeEventListener("mousedown", listener);
4785
4828
  document.removeEventListener("touchstart", listener);
4786
4829
  };
4787
- }, [ref, handler, enabled]);
4830
+ }, [ref, handler, enabled, ignoreRef]);
4788
4831
  }
4789
4832
  function useEscapeKey(handler, enabled = true) {
4790
4833
  react.useEffect(() => {
@@ -4838,7 +4881,7 @@ function PopoverContent({ children, className }) {
4838
4881
  enabled: open
4839
4882
  });
4840
4883
  const close = react.useCallback(() => setOpen(false), [setOpen]);
4841
- useOutsideClick(outsideRef, close, open);
4884
+ useOutsideClick(outsideRef, close, open, anchorRef);
4842
4885
  useEscapeKey(close, open);
4843
4886
  const { mounted, className: animClass, ref: animRef } = useAnimation({
4844
4887
  open,
@@ -4923,7 +4966,7 @@ function DropdownItems({ children, className }) {
4923
4966
  setOpen(false);
4924
4967
  setActiveIndex(-1);
4925
4968
  }, [setOpen, setActiveIndex]);
4926
- useOutsideClick(outsideRef, close, open);
4969
+ useOutsideClick(outsideRef, close, open, anchorRef);
4927
4970
  useEscapeKey(close, open);
4928
4971
  const { mounted, className: animClass, ref: animRef } = useAnimation({
4929
4972
  open,
@@ -5010,6 +5053,7 @@ function DropdownSeparator({ className }) {
5010
5053
  return /* @__PURE__ */ jsxRuntime.jsx(
5011
5054
  "div",
5012
5055
  {
5056
+ "data-react-fancy-dropdown-separator": "",
5013
5057
  role: "separator",
5014
5058
  className: cn(
5015
5059
  "my-1 h-px bg-zinc-200 dark:bg-zinc-700",
@@ -5063,7 +5107,7 @@ function ContextMenuTrigger({
5063
5107
  },
5064
5108
  [ctx]
5065
5109
  );
5066
- return /* @__PURE__ */ jsxRuntime.jsx("div", { onContextMenu: handleContextMenu, className: cn(className), children });
5110
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-react-fancy-context-menu-trigger": "", onContextMenu: handleContextMenu, className: cn(className), children });
5067
5111
  }
5068
5112
  ContextMenuTrigger.displayName = "ContextMenuTrigger";
5069
5113
  function ContextMenuContent({
@@ -5113,6 +5157,7 @@ function ContextMenuItem({
5113
5157
  "button",
5114
5158
  {
5115
5159
  type: "button",
5160
+ "data-react-fancy-context-menu-item": "",
5116
5161
  role: "menuitem",
5117
5162
  disabled,
5118
5163
  "aria-disabled": disabled,
@@ -5136,6 +5181,7 @@ function ContextMenuSeparator({ className }) {
5136
5181
  return /* @__PURE__ */ jsxRuntime.jsx(
5137
5182
  "div",
5138
5183
  {
5184
+ "data-react-fancy-context-menu-separator": "",
5139
5185
  role: "separator",
5140
5186
  className: cn("my-1 h-px bg-zinc-200 dark:bg-zinc-700", className)
5141
5187
  }
@@ -5875,7 +5921,7 @@ function BreadcrumbsDropdown({ items, activeLabel }) {
5875
5921
  const ref = react.useRef(null);
5876
5922
  useOutsideClick(ref, () => setOpen(false), open);
5877
5923
  useEscapeKey(() => setOpen(false), open);
5878
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: "relative flex md:hidden", children: [
5924
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, "data-react-fancy-breadcrumbs-dropdown": "", className: "relative flex md:hidden", children: [
5879
5925
  /* @__PURE__ */ jsxRuntime.jsxs(
5880
5926
  "button",
5881
5927
  {
@@ -7397,6 +7443,7 @@ function ChartLine({
7397
7443
  "div",
7398
7444
  {
7399
7445
  ref: containerRef,
7446
+ "data-react-fancy-chart-line": "",
7400
7447
  className: cn("relative", className),
7401
7448
  onMouseMove: handleMouseMove,
7402
7449
  onMouseLeave: () => setHoverInfo(null),
@@ -7557,7 +7604,7 @@ function ChartPie({
7557
7604
  const rect = containerRef.current.getBoundingClientRect();
7558
7605
  setTooltipPos({ x: e.clientX - rect.left, y: e.clientY - rect.top });
7559
7606
  };
7560
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: cn("relative inline-flex items-center gap-6", className), onMouseMove: handleMouseMove, children: [
7607
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, "data-react-fancy-chart-pie": "", className: cn("relative inline-flex items-center gap-6", className), onMouseMove: handleMouseMove, children: [
7561
7608
  /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, children: slices.map((slice, i) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
7562
7609
  /* @__PURE__ */ jsxRuntime.jsx(
7563
7610
  "path",
@@ -7715,7 +7762,7 @@ function ChartStackedBar({
7715
7762
  setTooltipPos({ x: e.clientX - rect.left, y: e.clientY - rect.top });
7716
7763
  };
7717
7764
  const svgProps = responsive ? { viewBox: `0 0 ${width} ${height}`, width: "100%", preserveAspectRatio: "xMidYMid meet" } : { width, height };
7718
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: cn("relative", className), onMouseMove: handleMouseMove, children: [
7765
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, "data-react-fancy-chart-stacked-bar": "", className: cn("relative", className), onMouseMove: handleMouseMove, children: [
7719
7766
  /* @__PURE__ */ jsxRuntime.jsxs("svg", { ...svgProps, height: responsive ? void 0 : height, children: [
7720
7767
  grid && /* @__PURE__ */ jsxRuntime.jsx(
7721
7768
  ChartGrid,