@refineui/react 0.0.4 → 0.0.5

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
@@ -88,6 +88,10 @@ __export(index_exports, {
88
88
  ChartYAxisLabels: () => ChartYAxisLabels,
89
89
  Checkbox: () => Checkbox,
90
90
  Chip: () => Chip,
91
+ Collapsible: () => Collapsible,
92
+ CollapsibleContent: () => CollapsibleContent,
93
+ CollapsibleRoot: () => CollapsibleRoot,
94
+ CollapsibleTrigger: () => CollapsibleTrigger,
91
95
  Command: () => Command,
92
96
  CommandDialog: () => CommandDialog,
93
97
  CommandEmpty: () => CommandEmpty,
@@ -99,6 +103,17 @@ __export(index_exports, {
99
103
  CommandSeparator: () => CommandSeparator,
100
104
  CommandShortcut: () => CommandShortcut,
101
105
  Container: () => Container,
106
+ ContextMenu: () => ContextMenu,
107
+ ContextMenuContent: () => ContextMenuContent,
108
+ ContextMenuItem: () => ContextMenuItem,
109
+ ContextMenuPortal: () => ContextMenuPortal,
110
+ ContextMenuRoot: () => ContextMenuRoot,
111
+ ContextMenuSection: () => ContextMenuSection,
112
+ ContextMenuSeparator: () => ContextMenuSeparator,
113
+ ContextMenuSub: () => ContextMenuSub,
114
+ ContextMenuSubContent: () => ContextMenuSubContent,
115
+ ContextMenuSubTrigger: () => ContextMenuSubTrigger,
116
+ ContextMenuTrigger: () => ContextMenuTrigger,
102
117
  Dialog: () => Dialog,
103
118
  DialogClose: () => DialogClose,
104
119
  DialogContent: () => DialogContent,
@@ -197,7 +212,7 @@ __export(index_exports, {
197
212
  ResizableHandle: () => ResizableHandle,
198
213
  ResizablePanel: () => ResizablePanel,
199
214
  ResizablePanelGroup: () => ResizablePanelGroup,
200
- SEMANTIC_TEXT: () => import_tokens36.SEMANTIC_TEXT,
215
+ SEMANTIC_TEXT: () => import_tokens38.SEMANTIC_TEXT,
201
216
  ScrollArea: () => ScrollArea,
202
217
  ScrollAreaScrollbar: () => ScrollAreaScrollbar,
203
218
  ScrollAreaThumb: () => ScrollAreaThumb,
@@ -241,6 +256,7 @@ __export(index_exports, {
241
256
  SidebarPeekPin: () => SidebarPeekPin,
242
257
  Skeleton: () => Skeleton,
243
258
  Slider: () => Slider,
259
+ Slot: () => import_react57.Slot,
244
260
  Spacer: () => Spacer,
245
261
  SpinButton: () => SpinButton,
246
262
  Spinner: () => Spinner,
@@ -1365,7 +1381,7 @@ function buildSemanticTextClassMap(map) {
1365
1381
  }
1366
1382
 
1367
1383
  // src/index.ts
1368
- var import_tokens36 = require("@refineui/tokens");
1384
+ var import_tokens38 = require("@refineui/tokens");
1369
1385
 
1370
1386
  // src/componentSizes.ts
1371
1387
  var import_tokens3 = require("@refineui/tokens");
@@ -8973,27 +8989,27 @@ function DropdownTrigger({ children, className, ...props }) {
8973
8989
  };
8974
8990
  const mergeEl = (0, import_react35.getMergeableTriggerChild)(children);
8975
8991
  if (mergeEl) {
8976
- const el = mergeEl;
8977
8992
  const passthrough = props;
8978
- const passthroughCn = props.className;
8979
- return (0, import_react34.cloneElement)(el, {
8980
- ...props,
8981
- ref: (0, import_react35.composeRefs)(triggerRef, el.ref),
8982
- className: (0, import_clsx70.clsx)(className, passthroughCn, el.props.className),
8983
- "aria-expanded": open,
8984
- "aria-haspopup": "menu",
8985
- "aria-controls": menuId,
8986
- onClick: (e) => {
8987
- passthrough.onClick?.(e);
8988
- el.props.onClick?.(e);
8989
- toggle();
8990
- },
8991
- onKeyDown: (e) => {
8992
- passthrough.onKeyDown?.(e);
8993
- el.props.onKeyDown?.(e);
8994
- onTriggerKeyDown(e);
8993
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
8994
+ import_react35.Slot,
8995
+ {
8996
+ ref: triggerRef,
8997
+ ...props,
8998
+ className,
8999
+ "aria-expanded": open,
9000
+ "aria-haspopup": "menu",
9001
+ "aria-controls": menuId,
9002
+ onClick: (event) => {
9003
+ passthrough.onClick?.(event);
9004
+ toggle();
9005
+ },
9006
+ onKeyDown: (event) => {
9007
+ passthrough.onKeyDown?.(event);
9008
+ onTriggerKeyDown(event);
9009
+ },
9010
+ children: mergeEl
8995
9011
  }
8996
- });
9012
+ );
8997
9013
  }
8998
9014
  const passthroughBtn = props;
8999
9015
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
@@ -9742,15 +9758,7 @@ function MenuTrigger({ children }) {
9742
9758
  const { open, setOpen } = useMenuContext("MenuTrigger");
9743
9759
  const mergeEl = (0, import_react37.getMergeableTriggerChild)(children);
9744
9760
  if (mergeEl) {
9745
- const el = mergeEl;
9746
- return (0, import_react36.cloneElement)(el, {
9747
- "aria-expanded": open,
9748
- "aria-haspopup": "menu",
9749
- onClick: (e) => {
9750
- el.props.onClick?.(e);
9751
- setOpen(!open);
9752
- }
9753
- });
9761
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_react37.Slot, { "aria-expanded": open, "aria-haspopup": "menu", onClick: () => setOpen(!open), children: mergeEl });
9754
9762
  }
9755
9763
  return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
9756
9764
  "button",
@@ -11451,27 +11459,27 @@ function PopoverTrigger({ children, className, ...props }) {
11451
11459
  const { open, toggle, triggerRef, contentId, onTriggerKeyDown } = usePopoverContext("PopoverTrigger");
11452
11460
  const mergeEl = (0, import_react41.getMergeableTriggerChild)(children);
11453
11461
  if (mergeEl) {
11454
- const el = mergeEl;
11455
11462
  const passthrough = props;
11456
- const passthroughCn = props.className;
11457
- return (0, import_react40.cloneElement)(el, {
11458
- ...props,
11459
- ref: (0, import_react41.composeRefs)(triggerRef, el.ref),
11460
- className: (0, import_clsx85.clsx)(className, passthroughCn, el.props.className),
11461
- "aria-expanded": open,
11462
- "aria-haspopup": "dialog",
11463
- "aria-controls": contentId,
11464
- onClick: (e) => {
11465
- passthrough.onClick?.(e);
11466
- el.props.onClick?.(e);
11467
- toggle();
11468
- },
11469
- onKeyDown: (e) => {
11470
- passthrough.onKeyDown?.(e);
11471
- el.props.onKeyDown?.(e);
11472
- onTriggerKeyDown(e);
11463
+ return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
11464
+ import_react41.Slot,
11465
+ {
11466
+ ref: triggerRef,
11467
+ ...props,
11468
+ className,
11469
+ "aria-expanded": open,
11470
+ "aria-haspopup": "dialog",
11471
+ "aria-controls": contentId,
11472
+ onClick: (event) => {
11473
+ passthrough.onClick?.(event);
11474
+ toggle();
11475
+ },
11476
+ onKeyDown: (event) => {
11477
+ passthrough.onKeyDown?.(event);
11478
+ onTriggerKeyDown(event);
11479
+ },
11480
+ children: mergeEl
11473
11481
  }
11474
- });
11482
+ );
11475
11483
  }
11476
11484
  const passthroughBtn = props;
11477
11485
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
@@ -14659,31 +14667,22 @@ function Tooltip({
14659
14667
  const mergeEl = (0, import_react55.getMergeableTriggerChild)(trigger);
14660
14668
  let triggerNode;
14661
14669
  if (mergeEl != null) {
14662
- const el = mergeEl;
14663
- const prevDescribedBy = el.props["aria-describedby"];
14664
- triggerNode = (0, import_react54.cloneElement)(el, {
14665
- "aria-describedby": prevDescribedBy && describedBy ? `${prevDescribedBy} ${describedBy}` : describedBy ?? prevDescribedBy,
14666
- onMouseEnter: (e) => {
14667
- el.props.onMouseEnter?.(e);
14668
- scheduleShow();
14669
- },
14670
- onMouseLeave: (e) => {
14671
- el.props.onMouseLeave?.(e);
14672
- hide();
14673
- },
14674
- onFocus: (e) => {
14675
- el.props.onFocus?.(e);
14676
- scheduleShow();
14677
- },
14678
- onBlur: (e) => {
14679
- el.props.onBlur?.(e);
14680
- if (!e.currentTarget.contains(e.relatedTarget)) hide();
14681
- },
14682
- onKeyDown: (e) => {
14683
- el.props.onKeyDown?.(e);
14684
- if (e.key === "Escape") hide();
14670
+ triggerNode = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14671
+ import_react55.Slot,
14672
+ {
14673
+ "aria-describedby": describedBy,
14674
+ onMouseEnter: scheduleShow,
14675
+ onMouseLeave: hide,
14676
+ onFocus: scheduleShow,
14677
+ onBlur: (event) => {
14678
+ if (!event.currentTarget.contains(event.relatedTarget)) hide();
14679
+ },
14680
+ onKeyDown: (event) => {
14681
+ if (event.key === "Escape") hide();
14682
+ },
14683
+ children: mergeEl
14685
14684
  }
14686
- });
14685
+ );
14687
14686
  } else {
14688
14687
  triggerNode = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14689
14688
  "span",
@@ -15458,6 +15457,527 @@ function ChartLegendItem({
15458
15457
  }
15459
15458
  );
15460
15459
  }
15460
+
15461
+ // src/components/Slot/Slot.tsx
15462
+ var import_react57 = require("@refineui/utilities/react");
15463
+
15464
+ // src/components/Collapsible/Collapsible.tsx
15465
+ var import_react58 = require("react");
15466
+ var import_clsx108 = require("clsx");
15467
+ var import_tokens36 = require("@refineui/tokens");
15468
+ var import_react59 = require("@refineui/utilities/react");
15469
+ var import_jsx_runtime78 = require("react/jsx-runtime");
15470
+ var CollapsibleContext = (0, import_react58.createContext)(null);
15471
+ function useCollapsible() {
15472
+ const value = (0, import_react58.useContext)(CollapsibleContext);
15473
+ if (!value) throw new Error("Collapsible parts must be used inside Collapsible.Root");
15474
+ return value;
15475
+ }
15476
+ function usePrefersReducedMotion3() {
15477
+ const [reduce, setReduce] = (0, import_react58.useState)(false);
15478
+ (0, import_react58.useEffect)(() => {
15479
+ const query = window.matchMedia("(prefers-reduced-motion: reduce)");
15480
+ const sync = () => setReduce(query.matches);
15481
+ sync();
15482
+ query.addEventListener("change", sync);
15483
+ return () => query.removeEventListener("change", sync);
15484
+ }, []);
15485
+ return reduce;
15486
+ }
15487
+ var CollapsibleRoot = (0, import_react58.forwardRef)(function CollapsibleRoot2({ open: openProp, defaultOpen = false, onOpenChange, asChild = false, className, children, ...props }, ref) {
15488
+ const [uncontrolled, setUncontrolled] = (0, import_react58.useState)(defaultOpen);
15489
+ const open = openProp ?? uncontrolled;
15490
+ const openRef = (0, import_react58.useRef)(open);
15491
+ openRef.current = open;
15492
+ const reactId = (0, import_react58.useId)();
15493
+ const reduceMotion = usePrefersReducedMotion3();
15494
+ const toggle = () => {
15495
+ const next = !openRef.current;
15496
+ if (openProp === void 0) setUncontrolled(next);
15497
+ onOpenChange?.(next);
15498
+ };
15499
+ const shared = {
15500
+ ...props,
15501
+ ref,
15502
+ "data-state": open ? "open" : "closed",
15503
+ "data-refineui": "collapsible",
15504
+ className
15505
+ };
15506
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15507
+ CollapsibleContext.Provider,
15508
+ {
15509
+ value: {
15510
+ open,
15511
+ toggle,
15512
+ contentId: `${reactId}-content`,
15513
+ triggerId: `${reactId}-trigger`,
15514
+ reduceMotion
15515
+ },
15516
+ children: asChild ? /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_react59.Slot, { ...shared, children }) : /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { ...shared, children })
15517
+ }
15518
+ );
15519
+ });
15520
+ var CollapsibleTrigger = (0, import_react58.forwardRef)(function CollapsibleTrigger2({ asChild = false, onClick, className, children, ...props }, ref) {
15521
+ const { open, toggle, contentId, triggerId } = useCollapsible();
15522
+ const shared = {
15523
+ ...props,
15524
+ ref,
15525
+ id: triggerId,
15526
+ "aria-expanded": open,
15527
+ "aria-controls": contentId,
15528
+ "data-state": open ? "open" : "closed",
15529
+ "data-refineui": "collapsible-trigger",
15530
+ className,
15531
+ onClick: (event) => {
15532
+ onClick?.(event);
15533
+ if (!event.defaultPrevented) toggle();
15534
+ }
15535
+ };
15536
+ if (asChild) return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_react59.Slot, { ...shared, children });
15537
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("button", { ...shared, type: "button", children });
15538
+ });
15539
+ var CollapsibleContent = (0, import_react58.forwardRef)(function CollapsibleContent2({ className, children, style, ...props }, ref) {
15540
+ const { open, contentId, triggerId, reduceMotion } = useCollapsible();
15541
+ const innerRef = (0, import_react58.useRef)(null);
15542
+ const [size, setSize] = (0, import_react58.useState)({ height: 0, width: 0 });
15543
+ (0, import_react58.useLayoutEffect)(() => {
15544
+ const node = innerRef.current;
15545
+ if (!node) return;
15546
+ const measure = () => {
15547
+ setSize({ height: node.scrollHeight, width: node.scrollWidth });
15548
+ };
15549
+ measure();
15550
+ const observer = new ResizeObserver(measure);
15551
+ observer.observe(node);
15552
+ return () => observer.disconnect();
15553
+ }, [children, open]);
15554
+ const clipStyle = {
15555
+ ["--refineui-collapsible-content-height"]: `${size.height}px`,
15556
+ ["--refineui-collapsible-content-width"]: `${size.width}px`,
15557
+ height: open ? size.height : 0,
15558
+ overflow: "hidden",
15559
+ transition: reduceMotion ? void 0 : `height ${import_tokens36.semanticInteraction.duration.panel} ${import_tokens36.semanticInteraction.easing.panel}`
15560
+ };
15561
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15562
+ "div",
15563
+ {
15564
+ ...props,
15565
+ ref,
15566
+ id: contentId,
15567
+ role: "region",
15568
+ "aria-labelledby": triggerId,
15569
+ "aria-hidden": !open,
15570
+ "data-state": open ? "open" : "closed",
15571
+ "data-refineui": "collapsible-content",
15572
+ style: clipStyle,
15573
+ children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { ref: innerRef, className: (0, import_clsx108.clsx)(className), style, children })
15574
+ }
15575
+ );
15576
+ });
15577
+ var Collapsible = Object.assign(CollapsibleRoot, {
15578
+ Root: CollapsibleRoot,
15579
+ Trigger: CollapsibleTrigger,
15580
+ Content: CollapsibleContent
15581
+ });
15582
+
15583
+ // src/components/ContextMenu/ContextMenu.tsx
15584
+ var import_react60 = require("react");
15585
+ var import_react_dom7 = require("react-dom");
15586
+ var import_clsx109 = require("clsx");
15587
+ var import_tokens37 = require("@refineui/tokens");
15588
+ var import_animation9 = require("@refineui/utilities/animation");
15589
+ var import_react61 = require("@refineui/utilities/react");
15590
+ var import_jsx_runtime79 = require("react/jsx-runtime");
15591
+ var MENU_ATTR = "data-refineui-context-menu";
15592
+ var CLOSE_MS = (0, import_animation9.motionMsToNumber)(import_tokens37.semanticInteraction.duration.normal);
15593
+ var MenuContext2 = (0, import_react60.createContext)(null);
15594
+ var SubContext = (0, import_react60.createContext)(null);
15595
+ function useMenu() {
15596
+ const value = (0, import_react60.useContext)(MenuContext2);
15597
+ if (!value) throw new Error("Context menu parts must be used inside ContextMenu.Root");
15598
+ return value;
15599
+ }
15600
+ function placeInView(element, x, y) {
15601
+ const width = element.offsetWidth;
15602
+ const height = element.offsetHeight;
15603
+ const pad = 4;
15604
+ let left = x;
15605
+ let top = y;
15606
+ if (left + width > window.innerWidth - pad) left = Math.max(pad, window.innerWidth - width - pad);
15607
+ if (top + height > window.innerHeight - pad) top = Math.max(pad, window.innerHeight - height - pad);
15608
+ element.style.left = `${left}px`;
15609
+ element.style.top = `${top}px`;
15610
+ }
15611
+ function ContextMenuRoot({ modal = true, onOpenChange, children }) {
15612
+ void modal;
15613
+ const [open, setOpen] = (0, import_react60.useState)(false);
15614
+ const [point, setPoint] = (0, import_react60.useState)({ x: 0, y: 0 });
15615
+ const openRef = (0, import_react60.useRef)(false);
15616
+ const onOpenChangeRef = (0, import_react60.useRef)(onOpenChange);
15617
+ openRef.current = open;
15618
+ onOpenChangeRef.current = onOpenChange;
15619
+ const close = (0, import_react60.useCallback)(() => {
15620
+ if (!openRef.current) return;
15621
+ openRef.current = false;
15622
+ setOpen(false);
15623
+ onOpenChangeRef.current?.(false);
15624
+ }, []);
15625
+ const openAt = (0, import_react60.useCallback)((x, y) => {
15626
+ setPoint({ x, y });
15627
+ const wasOpen = openRef.current;
15628
+ openRef.current = true;
15629
+ setOpen(true);
15630
+ if (!wasOpen) onOpenChangeRef.current?.(true);
15631
+ }, []);
15632
+ const value = (0, import_react60.useMemo)(() => ({ open, point, openAt, close }), [open, point, openAt, close]);
15633
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(MenuContext2.Provider, { value, children });
15634
+ }
15635
+ var ContextMenuTrigger = (0, import_react60.forwardRef)(function ContextMenuTrigger2({ asChild = false, onContextMenu, children, ...props }, ref) {
15636
+ const { openAt } = useMenu();
15637
+ const shared = {
15638
+ ...props,
15639
+ ref,
15640
+ [MENU_ATTR]: "",
15641
+ onContextMenu: (event) => {
15642
+ onContextMenu?.(event);
15643
+ if (event.defaultPrevented) return;
15644
+ event.preventDefault();
15645
+ openAt(event.clientX, event.clientY);
15646
+ }
15647
+ };
15648
+ if (asChild) return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_react61.Slot, { ...shared, children });
15649
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { ...shared, className: (0, import_clsx109.clsx)(menuStyles.triggerFallback, props.className), children });
15650
+ });
15651
+ function ContextMenuPortal({ children }) {
15652
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_jsx_runtime79.Fragment, { children });
15653
+ }
15654
+ var ContextMenuContent = (0, import_react60.forwardRef)(function ContextMenuContent2({ className, style, onPointerDown, children, ...props }, ref) {
15655
+ const { open, point, close } = useMenu();
15656
+ const localRef = (0, import_react60.useRef)(null);
15657
+ const [shouldRender, setShouldRender] = (0, import_react60.useState)(open);
15658
+ const [isClosing, setIsClosing] = (0, import_react60.useState)(false);
15659
+ (0, import_react60.useEffect)(() => {
15660
+ if (open) {
15661
+ setShouldRender(true);
15662
+ setIsClosing(false);
15663
+ return;
15664
+ }
15665
+ if (!shouldRender) return;
15666
+ setIsClosing(true);
15667
+ const timeout = window.setTimeout(() => {
15668
+ setShouldRender(false);
15669
+ setIsClosing(false);
15670
+ }, CLOSE_MS);
15671
+ return () => window.clearTimeout(timeout);
15672
+ }, [open, shouldRender]);
15673
+ (0, import_react60.useLayoutEffect)(() => {
15674
+ if (!shouldRender || !localRef.current) return;
15675
+ placeInView(localRef.current, point.x, point.y);
15676
+ }, [shouldRender, point.x, point.y]);
15677
+ (0, import_react60.useEffect)(() => {
15678
+ if (!open) return;
15679
+ const onKey = (event) => {
15680
+ if (event.key === "Escape") close();
15681
+ };
15682
+ const onPointer = (event) => {
15683
+ const target = event.target;
15684
+ if (target instanceof Element && target.closest(`[${MENU_ATTR}]`)) return;
15685
+ close();
15686
+ };
15687
+ document.addEventListener("keydown", onKey);
15688
+ document.addEventListener("pointerdown", onPointer);
15689
+ return () => {
15690
+ document.removeEventListener("keydown", onKey);
15691
+ document.removeEventListener("pointerdown", onPointer);
15692
+ };
15693
+ }, [open, close]);
15694
+ if (!shouldRender || typeof document === "undefined") return null;
15695
+ return (0, import_react_dom7.createPortal)(
15696
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15697
+ "div",
15698
+ {
15699
+ ...props,
15700
+ ref: (node) => {
15701
+ localRef.current = node;
15702
+ if (typeof ref === "function") ref(node);
15703
+ else if (ref) ref.current = node;
15704
+ },
15705
+ "data-refineui": "menu-popover",
15706
+ "data-state": isClosing ? "closed" : "open",
15707
+ ...{ [MENU_ATTR]: "" },
15708
+ className: menuStyles.popover,
15709
+ style: {
15710
+ position: "fixed",
15711
+ top: point.y,
15712
+ left: point.x,
15713
+ width: import_tokens37.componentSizes.menuPanelWidth,
15714
+ minWidth: import_tokens37.componentSizes.menuPanelWidth,
15715
+ zIndex: 9999,
15716
+ ...style
15717
+ },
15718
+ onPointerDown: (event) => {
15719
+ event.preventDefault();
15720
+ onPointerDown?.(event);
15721
+ },
15722
+ onContextMenu: (event) => event.preventDefault(),
15723
+ children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { role: "menu", "data-refineui": "menu", className: (0, import_clsx109.clsx)(menuStyles.list, className), children })
15724
+ }
15725
+ ),
15726
+ document.body
15727
+ );
15728
+ });
15729
+ function runSelect(onSelect, close, disabled) {
15730
+ if (disabled) return;
15731
+ const selectEvent = {
15732
+ defaultPrevented: false,
15733
+ preventDefault() {
15734
+ selectEvent.defaultPrevented = true;
15735
+ }
15736
+ };
15737
+ onSelect?.(selectEvent);
15738
+ if (!selectEvent.defaultPrevented) close();
15739
+ }
15740
+ var ContextMenuItem = (0, import_react60.forwardRef)(function ContextMenuItem2({ disabled = false, description, shortcut, startIcon, endIcon, state = "default", onSelect, className, onClick, onKeyDown, children, ...props }, ref) {
15741
+ const { close } = useMenu();
15742
+ const isDisabled = disabled || state === "disabled";
15743
+ const slotted = startIcon != null || description != null || shortcut != null || endIcon != null;
15744
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15745
+ "button",
15746
+ {
15747
+ ref,
15748
+ type: "button",
15749
+ role: "menuitem",
15750
+ disabled: isDisabled,
15751
+ "aria-disabled": isDisabled || void 0,
15752
+ "data-refineui": "menu-item",
15753
+ "data-state": isDisabled ? "disabled" : state,
15754
+ ...{ [MENU_ATTR]: "" },
15755
+ className: (0, import_clsx109.clsx)(menuStyles.itemBase, isDisabled ? menuStyles.itemDisabled : menuStyles.itemEnabled, className),
15756
+ ...props,
15757
+ onClick: (event) => {
15758
+ onClick?.(event);
15759
+ if (event.defaultPrevented) return;
15760
+ runSelect(onSelect, close, isDisabled);
15761
+ },
15762
+ onKeyDown: (event) => {
15763
+ onKeyDown?.(event);
15764
+ if (event.defaultPrevented) return;
15765
+ if (event.key === "Enter" || event.key === " ") {
15766
+ event.preventDefault();
15767
+ runSelect(onSelect, close, isDisabled);
15768
+ }
15769
+ },
15770
+ children: slotted ? /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("span", { className: menuStyles.row, children: [
15771
+ startIcon ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15772
+ "span",
15773
+ {
15774
+ className: menuStyles.iconWrap,
15775
+ style: { width: import_tokens37.iconSizes.small, minWidth: import_tokens37.iconSizes.small, height: import_tokens37.iconSizes.small },
15776
+ children: startIcon
15777
+ }
15778
+ ) : null,
15779
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("span", { className: menuStyles.textCol, children: [
15780
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: menuStyles.title, children }),
15781
+ description ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: (0, import_clsx109.clsx)(menuStyles.description, isDisabled ? menuStyles.descriptionDisabled : menuStyles.descriptionEnabled), children: description }) : null
15782
+ ] }),
15783
+ (shortcut || endIcon) && /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("span", { className: menuStyles.rightWrap, children: [
15784
+ shortcut ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: menuStyles.shortcut, children: shortcut }) : null,
15785
+ endIcon ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15786
+ "span",
15787
+ {
15788
+ className: menuStyles.iconWrap,
15789
+ style: { width: import_tokens37.iconSizes.small, minWidth: import_tokens37.iconSizes.small, height: import_tokens37.iconSizes.small },
15790
+ children: endIcon
15791
+ }
15792
+ ) : null
15793
+ ] })
15794
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: menuStyles.row, children })
15795
+ }
15796
+ );
15797
+ });
15798
+ var ContextMenuSeparator = (0, import_react60.forwardRef)(
15799
+ function ContextMenuSeparator2({ className, ...props }, ref) {
15800
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15801
+ "div",
15802
+ {
15803
+ ref,
15804
+ role: "separator",
15805
+ "aria-orientation": "horizontal",
15806
+ "data-refineui": "menu-divider",
15807
+ ...{ [MENU_ATTR]: "" },
15808
+ className: (0, import_clsx109.clsx)(menuStyles.dividerWrap, className),
15809
+ ...props,
15810
+ children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: menuStyles.dividerLine })
15811
+ }
15812
+ );
15813
+ }
15814
+ );
15815
+ function ContextMenuSection({ className, children, ...props }) {
15816
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { "data-refineui": "menu-section", className: (0, import_clsx109.clsx)(menuStyles.section, className), ...props, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: menuStyles.sectionText, children }) });
15817
+ }
15818
+ function ContextMenuSub({ children }) {
15819
+ const [open, setOpen] = (0, import_react60.useState)(false);
15820
+ const triggerRef = (0, import_react60.useRef)(null);
15821
+ const timer = (0, import_react60.useRef)(null);
15822
+ const clear = () => {
15823
+ if (timer.current != null) window.clearTimeout(timer.current);
15824
+ timer.current = null;
15825
+ };
15826
+ (0, import_react60.useEffect)(() => clear, []);
15827
+ const value = (0, import_react60.useMemo)(
15828
+ () => ({
15829
+ open,
15830
+ triggerRef,
15831
+ show: () => {
15832
+ clear();
15833
+ setOpen(true);
15834
+ },
15835
+ hideSoon: () => {
15836
+ clear();
15837
+ timer.current = window.setTimeout(() => setOpen(false), 150);
15838
+ }
15839
+ }),
15840
+ [open]
15841
+ );
15842
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(SubContext.Provider, { value, children });
15843
+ }
15844
+ function useSub2() {
15845
+ const value = (0, import_react60.useContext)(SubContext);
15846
+ if (!value) throw new Error("ContextMenu.SubTrigger must be used inside ContextMenu.Sub");
15847
+ return value;
15848
+ }
15849
+ var ContextMenuSubTrigger = (0, import_react60.forwardRef)(
15850
+ function ContextMenuSubTrigger2({ asChild = false, description, startIcon, onMouseEnter, onMouseLeave, onClick, className, children, ...props }, ref) {
15851
+ const sub = useSub2();
15852
+ const shared = {
15853
+ ...props,
15854
+ type: "button",
15855
+ role: "menuitem",
15856
+ "aria-haspopup": "menu",
15857
+ "aria-expanded": sub.open,
15858
+ "data-state": sub.open ? "active" : "default",
15859
+ "data-refineui": "menu-item",
15860
+ [MENU_ATTR]: "",
15861
+ className: (0, import_clsx109.clsx)(
15862
+ menuStyles.itemBase,
15863
+ menuStyles.itemEnabled,
15864
+ sub.open && "bg-refineui-alias-background-primary-hover",
15865
+ className
15866
+ ),
15867
+ ref: (node) => {
15868
+ sub.triggerRef.current = node;
15869
+ if (typeof ref === "function") ref(node);
15870
+ else if (ref) ref.current = node;
15871
+ },
15872
+ onMouseEnter: (event) => {
15873
+ onMouseEnter?.(event);
15874
+ sub.show();
15875
+ },
15876
+ onMouseLeave: (event) => {
15877
+ onMouseLeave?.(event);
15878
+ sub.hideSoon();
15879
+ },
15880
+ onClick: (event) => {
15881
+ onClick?.(event);
15882
+ if (!event.defaultPrevented) sub.show();
15883
+ }
15884
+ };
15885
+ if (asChild) return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_react61.Slot, { ...shared, children });
15886
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("button", { ...shared, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("span", { className: menuStyles.row, children: [
15887
+ startIcon ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15888
+ "span",
15889
+ {
15890
+ className: menuStyles.iconWrap,
15891
+ style: { width: import_tokens37.iconSizes.small, minWidth: import_tokens37.iconSizes.small, height: import_tokens37.iconSizes.small },
15892
+ children: startIcon
15893
+ }
15894
+ ) : null,
15895
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("span", { className: menuStyles.textCol, children: [
15896
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: menuStyles.title, children }),
15897
+ description ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: (0, import_clsx109.clsx)(menuStyles.description, menuStyles.descriptionEnabled), children: description }) : null
15898
+ ] }),
15899
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: menuStyles.rightWrap, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15900
+ "span",
15901
+ {
15902
+ className: menuStyles.iconWrap,
15903
+ style: { width: import_tokens37.iconSizes.small, minWidth: import_tokens37.iconSizes.small, height: import_tokens37.iconSizes.small },
15904
+ children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(WebIcon, { name: "chevron-right", size: import_tokens37.iconSizes.small, color: "currentColor", "aria-hidden": true })
15905
+ }
15906
+ ) })
15907
+ ] }) });
15908
+ }
15909
+ );
15910
+ var ContextMenuSubContent = (0, import_react60.forwardRef)(
15911
+ function ContextMenuSubContent2({ className, style, onPointerDown, onMouseEnter, onMouseLeave, ...props }, ref) {
15912
+ const sub = useSub2();
15913
+ const localRef = (0, import_react60.useRef)(null);
15914
+ const [side, setSide] = (0, import_react60.useState)("right");
15915
+ (0, import_react60.useLayoutEffect)(() => {
15916
+ const trigger = sub.triggerRef.current;
15917
+ const element = localRef.current;
15918
+ if (!sub.open || !trigger || !element) return;
15919
+ const rect = trigger.getBoundingClientRect();
15920
+ const width = element.offsetWidth;
15921
+ const pad = 4;
15922
+ let left = rect.right;
15923
+ let nextSide = "right";
15924
+ if (left + width > window.innerWidth - pad) {
15925
+ left = Math.max(pad, rect.left - width);
15926
+ nextSide = "left";
15927
+ }
15928
+ setSide(nextSide);
15929
+ placeInView(element, left, rect.top);
15930
+ }, [sub.open, sub.triggerRef]);
15931
+ if (!sub.open || typeof document === "undefined") return null;
15932
+ return (0, import_react_dom7.createPortal)(
15933
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15934
+ "div",
15935
+ {
15936
+ ...props,
15937
+ ref: (node) => {
15938
+ localRef.current = node;
15939
+ if (typeof ref === "function") ref(node);
15940
+ else if (ref) ref.current = node;
15941
+ },
15942
+ role: "menu",
15943
+ "data-refineui": "menu",
15944
+ "data-submenu": "true",
15945
+ "data-state": "open",
15946
+ "data-side": side,
15947
+ ...{ [MENU_ATTR]: "" },
15948
+ className: (0, import_clsx109.clsx)(menuStyles.subPanel, className),
15949
+ style: { position: "fixed", zIndex: 1e4, ...style },
15950
+ onPointerDown: (event) => {
15951
+ event.preventDefault();
15952
+ onPointerDown?.(event);
15953
+ },
15954
+ onMouseEnter: (event) => {
15955
+ onMouseEnter?.(event);
15956
+ sub.show();
15957
+ },
15958
+ onMouseLeave: (event) => {
15959
+ onMouseLeave?.(event);
15960
+ sub.hideSoon();
15961
+ },
15962
+ onContextMenu: (event) => event.preventDefault()
15963
+ }
15964
+ ),
15965
+ document.body
15966
+ );
15967
+ }
15968
+ );
15969
+ var ContextMenu = Object.assign(ContextMenuRoot, {
15970
+ Root: ContextMenuRoot,
15971
+ Trigger: ContextMenuTrigger,
15972
+ Portal: ContextMenuPortal,
15973
+ Content: ContextMenuContent,
15974
+ Item: ContextMenuItem,
15975
+ Section: ContextMenuSection,
15976
+ Separator: ContextMenuSeparator,
15977
+ Sub: ContextMenuSub,
15978
+ SubTrigger: ContextMenuSubTrigger,
15979
+ SubContent: ContextMenuSubContent
15980
+ });
15461
15981
  // Annotate the CommonJS export names for ESM import in node:
15462
15982
  0 && (module.exports = {
15463
15983
  Accordion,
@@ -15528,6 +16048,10 @@ function ChartLegendItem({
15528
16048
  ChartYAxisLabels,
15529
16049
  Checkbox,
15530
16050
  Chip,
16051
+ Collapsible,
16052
+ CollapsibleContent,
16053
+ CollapsibleRoot,
16054
+ CollapsibleTrigger,
15531
16055
  Command,
15532
16056
  CommandDialog,
15533
16057
  CommandEmpty,
@@ -15539,6 +16063,17 @@ function ChartLegendItem({
15539
16063
  CommandSeparator,
15540
16064
  CommandShortcut,
15541
16065
  Container,
16066
+ ContextMenu,
16067
+ ContextMenuContent,
16068
+ ContextMenuItem,
16069
+ ContextMenuPortal,
16070
+ ContextMenuRoot,
16071
+ ContextMenuSection,
16072
+ ContextMenuSeparator,
16073
+ ContextMenuSub,
16074
+ ContextMenuSubContent,
16075
+ ContextMenuSubTrigger,
16076
+ ContextMenuTrigger,
15542
16077
  Dialog,
15543
16078
  DialogClose,
15544
16079
  DialogContent,
@@ -15681,6 +16216,7 @@ function ChartLegendItem({
15681
16216
  SidebarPeekPin,
15682
16217
  Skeleton,
15683
16218
  Slider,
16219
+ Slot,
15684
16220
  Spacer,
15685
16221
  SpinButton,
15686
16222
  Spinner,