@refineui/react 0.0.4 → 0.0.6
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 +609 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -1
- package/dist/index.d.ts +82 -1
- package/dist/index.js +618 -82
- package/dist/index.js.map +1 -1
- package/dist/spec/contract-index.json +1 -1
- package/dist/spec/token-trace-v2.json +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8572,7 +8572,6 @@ function DrawerClose({
|
|
|
8572
8572
|
// src/components/Dropdown/Dropdown.tsx
|
|
8573
8573
|
import { clsx as clsx70 } from "clsx";
|
|
8574
8574
|
import {
|
|
8575
|
-
cloneElement as cloneElement2,
|
|
8576
8575
|
createContext as createContext16,
|
|
8577
8576
|
useCallback as useCallback12,
|
|
8578
8577
|
useContext as useContext18,
|
|
@@ -8607,7 +8606,7 @@ var dropdownStyles = {
|
|
|
8607
8606
|
};
|
|
8608
8607
|
|
|
8609
8608
|
// src/components/Dropdown/Dropdown.tsx
|
|
8610
|
-
import { acquireBodyScrollLock as acquireBodyScrollLock3,
|
|
8609
|
+
import { Slot, acquireBodyScrollLock as acquireBodyScrollLock3, getMergeableTriggerChild } from "@refineui/utilities/react";
|
|
8611
8610
|
|
|
8612
8611
|
// src/components/Dropdown/positioning.ts
|
|
8613
8612
|
import { useEffect as useEffect10, useLayoutEffect as useLayoutEffect6 } from "react";
|
|
@@ -8791,27 +8790,27 @@ function DropdownTrigger({ children, className, ...props }) {
|
|
|
8791
8790
|
};
|
|
8792
8791
|
const mergeEl = getMergeableTriggerChild(children);
|
|
8793
8792
|
if (mergeEl) {
|
|
8794
|
-
const el = mergeEl;
|
|
8795
8793
|
const passthrough = props;
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8794
|
+
return /* @__PURE__ */ jsx53(
|
|
8795
|
+
Slot,
|
|
8796
|
+
{
|
|
8797
|
+
ref: triggerRef,
|
|
8798
|
+
...props,
|
|
8799
|
+
className,
|
|
8800
|
+
"aria-expanded": open,
|
|
8801
|
+
"aria-haspopup": "menu",
|
|
8802
|
+
"aria-controls": menuId,
|
|
8803
|
+
onClick: (event) => {
|
|
8804
|
+
passthrough.onClick?.(event);
|
|
8805
|
+
toggle();
|
|
8806
|
+
},
|
|
8807
|
+
onKeyDown: (event) => {
|
|
8808
|
+
passthrough.onKeyDown?.(event);
|
|
8809
|
+
onTriggerKeyDown(event);
|
|
8810
|
+
},
|
|
8811
|
+
children: mergeEl
|
|
8813
8812
|
}
|
|
8814
|
-
|
|
8813
|
+
);
|
|
8815
8814
|
}
|
|
8816
8815
|
const passthroughBtn = props;
|
|
8817
8816
|
return /* @__PURE__ */ jsx53(
|
|
@@ -9457,7 +9456,6 @@ function Link({
|
|
|
9457
9456
|
// src/components/Menu/Menu.tsx
|
|
9458
9457
|
import { clsx as clsx76 } from "clsx";
|
|
9459
9458
|
import {
|
|
9460
|
-
cloneElement as cloneElement3,
|
|
9461
9459
|
createContext as createContext17,
|
|
9462
9460
|
useCallback as useCallback13,
|
|
9463
9461
|
useContext as useContext19,
|
|
@@ -9470,7 +9468,7 @@ import {
|
|
|
9470
9468
|
import { createPortal as createPortal5 } from "react-dom";
|
|
9471
9469
|
import { iconSizes as iconSizes16, semanticInteraction as semanticInteraction5, spacings as spacings3, zIndex as zIndex2 } from "@refineui/tokens";
|
|
9472
9470
|
import { motionMsToNumber as motionMsToNumber3 } from "@refineui/utilities/animation";
|
|
9473
|
-
import { getMergeableTriggerChild as getMergeableTriggerChild2 } from "@refineui/utilities/react";
|
|
9471
|
+
import { Slot as Slot2, getMergeableTriggerChild as getMergeableTriggerChild2 } from "@refineui/utilities/react";
|
|
9474
9472
|
|
|
9475
9473
|
// src/components/Menu/style.ts
|
|
9476
9474
|
import { clsx as clsx75 } from "clsx";
|
|
@@ -9570,15 +9568,7 @@ function MenuTrigger({ children }) {
|
|
|
9570
9568
|
const { open, setOpen } = useMenuContext("MenuTrigger");
|
|
9571
9569
|
const mergeEl = getMergeableTriggerChild2(children);
|
|
9572
9570
|
if (mergeEl) {
|
|
9573
|
-
|
|
9574
|
-
return cloneElement3(el, {
|
|
9575
|
-
"aria-expanded": open,
|
|
9576
|
-
"aria-haspopup": "menu",
|
|
9577
|
-
onClick: (e) => {
|
|
9578
|
-
el.props.onClick?.(e);
|
|
9579
|
-
setOpen(!open);
|
|
9580
|
-
}
|
|
9581
|
-
});
|
|
9571
|
+
return /* @__PURE__ */ jsx58(Slot2, { "aria-expanded": open, "aria-haspopup": "menu", onClick: () => setOpen(!open), children: mergeEl });
|
|
9582
9572
|
}
|
|
9583
9573
|
return /* @__PURE__ */ jsx58(
|
|
9584
9574
|
"button",
|
|
@@ -11137,7 +11127,6 @@ function Pagination(props) {
|
|
|
11137
11127
|
// src/components/PopOver/PopOver.tsx
|
|
11138
11128
|
import { clsx as clsx85 } from "clsx";
|
|
11139
11129
|
import {
|
|
11140
|
-
cloneElement as cloneElement4,
|
|
11141
11130
|
createContext as createContext20,
|
|
11142
11131
|
useCallback as useCallback16,
|
|
11143
11132
|
useContext as useContext22,
|
|
@@ -11149,7 +11138,7 @@ import {
|
|
|
11149
11138
|
} from "react";
|
|
11150
11139
|
import { spacings as spacings4, strokeWidths as strokeWidths2 } from "@refineui/tokens";
|
|
11151
11140
|
import { resolveColorTokenValue as resolveColorTokenValue10 } from "@refineui/utilities/color";
|
|
11152
|
-
import {
|
|
11141
|
+
import { Slot as Slot3, getMergeableTriggerChild as getMergeableTriggerChild3 } from "@refineui/utilities/react";
|
|
11153
11142
|
|
|
11154
11143
|
// src/components/PopOver/style.ts
|
|
11155
11144
|
var popoverStyles = {
|
|
@@ -11307,27 +11296,27 @@ function PopoverTrigger({ children, className, ...props }) {
|
|
|
11307
11296
|
const { open, toggle, triggerRef, contentId, onTriggerKeyDown } = usePopoverContext("PopoverTrigger");
|
|
11308
11297
|
const mergeEl = getMergeableTriggerChild3(children);
|
|
11309
11298
|
if (mergeEl) {
|
|
11310
|
-
const el = mergeEl;
|
|
11311
11299
|
const passthrough = props;
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11300
|
+
return /* @__PURE__ */ jsx63(
|
|
11301
|
+
Slot3,
|
|
11302
|
+
{
|
|
11303
|
+
ref: triggerRef,
|
|
11304
|
+
...props,
|
|
11305
|
+
className,
|
|
11306
|
+
"aria-expanded": open,
|
|
11307
|
+
"aria-haspopup": "dialog",
|
|
11308
|
+
"aria-controls": contentId,
|
|
11309
|
+
onClick: (event) => {
|
|
11310
|
+
passthrough.onClick?.(event);
|
|
11311
|
+
toggle();
|
|
11312
|
+
},
|
|
11313
|
+
onKeyDown: (event) => {
|
|
11314
|
+
passthrough.onKeyDown?.(event);
|
|
11315
|
+
onTriggerKeyDown(event);
|
|
11316
|
+
},
|
|
11317
|
+
children: mergeEl
|
|
11329
11318
|
}
|
|
11330
|
-
|
|
11319
|
+
);
|
|
11331
11320
|
}
|
|
11332
11321
|
const passthroughBtn = props;
|
|
11333
11322
|
return /* @__PURE__ */ jsx63(
|
|
@@ -11586,7 +11575,7 @@ import { clsx as clsx89 } from "clsx";
|
|
|
11586
11575
|
import { iconSizes as iconSizes19 } from "@refineui/tokens";
|
|
11587
11576
|
import {
|
|
11588
11577
|
Children as Children6,
|
|
11589
|
-
cloneElement as
|
|
11578
|
+
cloneElement as cloneElement2,
|
|
11590
11579
|
createContext as createContext21,
|
|
11591
11580
|
forwardRef as forwardRef14,
|
|
11592
11581
|
isValidElement as isValidElement5,
|
|
@@ -11826,9 +11815,9 @@ function CarouselContent({ className, children, ...props }) {
|
|
|
11826
11815
|
setCount(slideCount);
|
|
11827
11816
|
}, [setCount, slideCount]);
|
|
11828
11817
|
const trackSlides = loop && slides.length > 1 ? [
|
|
11829
|
-
|
|
11818
|
+
cloneElement2(slides[slides.length - 1], { key: "__carousel-clone-last" }),
|
|
11830
11819
|
...slides,
|
|
11831
|
-
|
|
11820
|
+
cloneElement2(slides[0], { key: "__carousel-clone-first" })
|
|
11832
11821
|
] : slides;
|
|
11833
11822
|
const endDrag = useCallback17(
|
|
11834
11823
|
(clientX) => {
|
|
@@ -14413,9 +14402,9 @@ function TreeItemContent({ className, children, ...props }) {
|
|
|
14413
14402
|
|
|
14414
14403
|
// src/components/Tooltip/Tooltip.tsx
|
|
14415
14404
|
import { clsx as clsx105 } from "clsx";
|
|
14416
|
-
import {
|
|
14405
|
+
import { useId as useId16, useRef as useRef23, useState as useState30 } from "react";
|
|
14417
14406
|
import { resolveColorTokenValue as resolveColorTokenValue12 } from "@refineui/utilities/color";
|
|
14418
|
-
import { getMergeableTriggerChild as getMergeableTriggerChild4 } from "@refineui/utilities/react";
|
|
14407
|
+
import { Slot as Slot4, getMergeableTriggerChild as getMergeableTriggerChild4 } from "@refineui/utilities/react";
|
|
14419
14408
|
|
|
14420
14409
|
// src/components/Tooltip/style.ts
|
|
14421
14410
|
import { spacings as spacings6, strokeWidths as strokeWidths3 } from "@refineui/tokens";
|
|
@@ -14565,31 +14554,22 @@ function Tooltip({
|
|
|
14565
14554
|
const mergeEl = getMergeableTriggerChild4(trigger);
|
|
14566
14555
|
let triggerNode;
|
|
14567
14556
|
if (mergeEl != null) {
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
scheduleShow
|
|
14575
|
-
|
|
14576
|
-
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
|
|
14581
|
-
|
|
14582
|
-
scheduleShow();
|
|
14583
|
-
},
|
|
14584
|
-
onBlur: (e) => {
|
|
14585
|
-
el.props.onBlur?.(e);
|
|
14586
|
-
if (!e.currentTarget.contains(e.relatedTarget)) hide();
|
|
14587
|
-
},
|
|
14588
|
-
onKeyDown: (e) => {
|
|
14589
|
-
el.props.onKeyDown?.(e);
|
|
14590
|
-
if (e.key === "Escape") hide();
|
|
14557
|
+
triggerNode = /* @__PURE__ */ jsx76(
|
|
14558
|
+
Slot4,
|
|
14559
|
+
{
|
|
14560
|
+
"aria-describedby": describedBy,
|
|
14561
|
+
onMouseEnter: scheduleShow,
|
|
14562
|
+
onMouseLeave: hide,
|
|
14563
|
+
onFocus: scheduleShow,
|
|
14564
|
+
onBlur: (event) => {
|
|
14565
|
+
if (!event.currentTarget.contains(event.relatedTarget)) hide();
|
|
14566
|
+
},
|
|
14567
|
+
onKeyDown: (event) => {
|
|
14568
|
+
if (event.key === "Escape") hide();
|
|
14569
|
+
},
|
|
14570
|
+
children: mergeEl
|
|
14591
14571
|
}
|
|
14592
|
-
|
|
14572
|
+
);
|
|
14593
14573
|
} else {
|
|
14594
14574
|
triggerNode = /* @__PURE__ */ jsx76(
|
|
14595
14575
|
"span",
|
|
@@ -15373,6 +15353,546 @@ function ChartLegendItem({
|
|
|
15373
15353
|
}
|
|
15374
15354
|
);
|
|
15375
15355
|
}
|
|
15356
|
+
|
|
15357
|
+
// src/components/Slot/Slot.tsx
|
|
15358
|
+
import { Slot as Slot5 } from "@refineui/utilities/react";
|
|
15359
|
+
|
|
15360
|
+
// src/components/Collapsible/Collapsible.tsx
|
|
15361
|
+
import {
|
|
15362
|
+
createContext as createContext27,
|
|
15363
|
+
forwardRef as forwardRef16,
|
|
15364
|
+
useContext as useContext31,
|
|
15365
|
+
useEffect as useEffect21,
|
|
15366
|
+
useId as useId18,
|
|
15367
|
+
useLayoutEffect as useLayoutEffect14,
|
|
15368
|
+
useRef as useRef24,
|
|
15369
|
+
useState as useState32
|
|
15370
|
+
} from "react";
|
|
15371
|
+
import { clsx as clsx108 } from "clsx";
|
|
15372
|
+
import { semanticInteraction as semanticInteraction9 } from "@refineui/tokens";
|
|
15373
|
+
import { Slot as Slot6 } from "@refineui/utilities/react";
|
|
15374
|
+
import { jsx as jsx78 } from "react/jsx-runtime";
|
|
15375
|
+
var CollapsibleContext = createContext27(null);
|
|
15376
|
+
function useCollapsible() {
|
|
15377
|
+
const value = useContext31(CollapsibleContext);
|
|
15378
|
+
if (!value) throw new Error("Collapsible parts must be used inside Collapsible.Root");
|
|
15379
|
+
return value;
|
|
15380
|
+
}
|
|
15381
|
+
function usePrefersReducedMotion3() {
|
|
15382
|
+
const [reduce, setReduce] = useState32(false);
|
|
15383
|
+
useEffect21(() => {
|
|
15384
|
+
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
15385
|
+
const sync = () => setReduce(query.matches);
|
|
15386
|
+
sync();
|
|
15387
|
+
query.addEventListener("change", sync);
|
|
15388
|
+
return () => query.removeEventListener("change", sync);
|
|
15389
|
+
}, []);
|
|
15390
|
+
return reduce;
|
|
15391
|
+
}
|
|
15392
|
+
var CollapsibleRoot = forwardRef16(function CollapsibleRoot2({ open: openProp, defaultOpen = false, onOpenChange, asChild = false, className, children, ...props }, ref) {
|
|
15393
|
+
const [uncontrolled, setUncontrolled] = useState32(defaultOpen);
|
|
15394
|
+
const open = openProp ?? uncontrolled;
|
|
15395
|
+
const openRef = useRef24(open);
|
|
15396
|
+
openRef.current = open;
|
|
15397
|
+
const reactId = useId18();
|
|
15398
|
+
const reduceMotion = usePrefersReducedMotion3();
|
|
15399
|
+
const toggle = () => {
|
|
15400
|
+
const next = !openRef.current;
|
|
15401
|
+
if (openProp === void 0) setUncontrolled(next);
|
|
15402
|
+
onOpenChange?.(next);
|
|
15403
|
+
};
|
|
15404
|
+
const shared = {
|
|
15405
|
+
...props,
|
|
15406
|
+
ref,
|
|
15407
|
+
"data-state": open ? "open" : "closed",
|
|
15408
|
+
"data-refineui": "collapsible",
|
|
15409
|
+
className
|
|
15410
|
+
};
|
|
15411
|
+
return /* @__PURE__ */ jsx78(
|
|
15412
|
+
CollapsibleContext.Provider,
|
|
15413
|
+
{
|
|
15414
|
+
value: {
|
|
15415
|
+
open,
|
|
15416
|
+
toggle,
|
|
15417
|
+
contentId: `${reactId}-content`,
|
|
15418
|
+
triggerId: `${reactId}-trigger`,
|
|
15419
|
+
reduceMotion
|
|
15420
|
+
},
|
|
15421
|
+
children: asChild ? /* @__PURE__ */ jsx78(Slot6, { ...shared, children }) : /* @__PURE__ */ jsx78("div", { ...shared, children })
|
|
15422
|
+
}
|
|
15423
|
+
);
|
|
15424
|
+
});
|
|
15425
|
+
var CollapsibleTrigger = forwardRef16(function CollapsibleTrigger2({ asChild = false, onClick, className, children, ...props }, ref) {
|
|
15426
|
+
const { open, toggle, contentId, triggerId } = useCollapsible();
|
|
15427
|
+
const shared = {
|
|
15428
|
+
...props,
|
|
15429
|
+
ref,
|
|
15430
|
+
id: triggerId,
|
|
15431
|
+
"aria-expanded": open,
|
|
15432
|
+
"aria-controls": contentId,
|
|
15433
|
+
"data-state": open ? "open" : "closed",
|
|
15434
|
+
"data-refineui": "collapsible-trigger",
|
|
15435
|
+
className,
|
|
15436
|
+
onClick: (event) => {
|
|
15437
|
+
onClick?.(event);
|
|
15438
|
+
if (!event.defaultPrevented) toggle();
|
|
15439
|
+
}
|
|
15440
|
+
};
|
|
15441
|
+
if (asChild) return /* @__PURE__ */ jsx78(Slot6, { ...shared, children });
|
|
15442
|
+
return /* @__PURE__ */ jsx78("button", { ...shared, type: "button", children });
|
|
15443
|
+
});
|
|
15444
|
+
var CollapsibleContent = forwardRef16(function CollapsibleContent2({ className, children, style, ...props }, ref) {
|
|
15445
|
+
const { open, contentId, triggerId, reduceMotion } = useCollapsible();
|
|
15446
|
+
const innerRef = useRef24(null);
|
|
15447
|
+
const [size, setSize] = useState32({ height: 0, width: 0 });
|
|
15448
|
+
useLayoutEffect14(() => {
|
|
15449
|
+
const node = innerRef.current;
|
|
15450
|
+
if (!node) return;
|
|
15451
|
+
const measure = () => {
|
|
15452
|
+
setSize({ height: node.scrollHeight, width: node.scrollWidth });
|
|
15453
|
+
};
|
|
15454
|
+
measure();
|
|
15455
|
+
const observer = new ResizeObserver(measure);
|
|
15456
|
+
observer.observe(node);
|
|
15457
|
+
return () => observer.disconnect();
|
|
15458
|
+
}, [children, open]);
|
|
15459
|
+
const clipStyle = {
|
|
15460
|
+
["--refineui-collapsible-content-height"]: `${size.height}px`,
|
|
15461
|
+
["--refineui-collapsible-content-width"]: `${size.width}px`,
|
|
15462
|
+
height: open ? size.height : 0,
|
|
15463
|
+
overflow: "hidden",
|
|
15464
|
+
transition: reduceMotion ? void 0 : `height ${semanticInteraction9.duration.panel} ${semanticInteraction9.easing.panel}`
|
|
15465
|
+
};
|
|
15466
|
+
return /* @__PURE__ */ jsx78(
|
|
15467
|
+
"div",
|
|
15468
|
+
{
|
|
15469
|
+
...props,
|
|
15470
|
+
ref,
|
|
15471
|
+
id: contentId,
|
|
15472
|
+
role: "region",
|
|
15473
|
+
"aria-labelledby": triggerId,
|
|
15474
|
+
"aria-hidden": !open,
|
|
15475
|
+
"data-state": open ? "open" : "closed",
|
|
15476
|
+
"data-refineui": "collapsible-content",
|
|
15477
|
+
style: clipStyle,
|
|
15478
|
+
children: /* @__PURE__ */ jsx78("div", { ref: innerRef, className: clsx108(className), style, children })
|
|
15479
|
+
}
|
|
15480
|
+
);
|
|
15481
|
+
});
|
|
15482
|
+
var Collapsible = Object.assign(CollapsibleRoot, {
|
|
15483
|
+
Root: CollapsibleRoot,
|
|
15484
|
+
Trigger: CollapsibleTrigger,
|
|
15485
|
+
Content: CollapsibleContent
|
|
15486
|
+
});
|
|
15487
|
+
|
|
15488
|
+
// src/components/ContextMenu/ContextMenu.tsx
|
|
15489
|
+
import {
|
|
15490
|
+
createContext as createContext28,
|
|
15491
|
+
forwardRef as forwardRef17,
|
|
15492
|
+
useCallback as useCallback22,
|
|
15493
|
+
useContext as useContext32,
|
|
15494
|
+
useEffect as useEffect22,
|
|
15495
|
+
useLayoutEffect as useLayoutEffect15,
|
|
15496
|
+
useMemo as useMemo23,
|
|
15497
|
+
useRef as useRef25,
|
|
15498
|
+
useState as useState33
|
|
15499
|
+
} from "react";
|
|
15500
|
+
import { createPortal as createPortal7 } from "react-dom";
|
|
15501
|
+
import { clsx as clsx109 } from "clsx";
|
|
15502
|
+
import { componentSizes as componentSizes3, iconSizes as iconSizes24, semanticInteraction as semanticInteraction10 } from "@refineui/tokens";
|
|
15503
|
+
import { motionMsToNumber as motionMsToNumber7 } from "@refineui/utilities/animation";
|
|
15504
|
+
import { Slot as Slot7 } from "@refineui/utilities/react";
|
|
15505
|
+
import { Fragment as Fragment5, jsx as jsx79, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
15506
|
+
var MENU_ATTR = "data-refineui-context-menu";
|
|
15507
|
+
var CLOSE_MS = motionMsToNumber7(semanticInteraction10.duration.normal);
|
|
15508
|
+
var MenuContext2 = createContext28(null);
|
|
15509
|
+
var SubContext = createContext28(null);
|
|
15510
|
+
function useMenu() {
|
|
15511
|
+
const value = useContext32(MenuContext2);
|
|
15512
|
+
if (!value) throw new Error("Context menu parts must be used inside ContextMenu.Root");
|
|
15513
|
+
return value;
|
|
15514
|
+
}
|
|
15515
|
+
function placeInView(element, x, y) {
|
|
15516
|
+
const width = element.offsetWidth;
|
|
15517
|
+
const height = element.offsetHeight;
|
|
15518
|
+
const pad = 4;
|
|
15519
|
+
let left = x;
|
|
15520
|
+
let top = y;
|
|
15521
|
+
if (left + width > window.innerWidth - pad) left = Math.max(pad, window.innerWidth - width - pad);
|
|
15522
|
+
if (top + height > window.innerHeight - pad) top = Math.max(pad, window.innerHeight - height - pad);
|
|
15523
|
+
element.style.left = `${left}px`;
|
|
15524
|
+
element.style.top = `${top}px`;
|
|
15525
|
+
}
|
|
15526
|
+
function ContextMenuRoot({ modal = true, onOpenChange, children }) {
|
|
15527
|
+
void modal;
|
|
15528
|
+
const [open, setOpen] = useState33(false);
|
|
15529
|
+
const [point, setPoint] = useState33({ x: 0, y: 0 });
|
|
15530
|
+
const openRef = useRef25(false);
|
|
15531
|
+
const onOpenChangeRef = useRef25(onOpenChange);
|
|
15532
|
+
openRef.current = open;
|
|
15533
|
+
onOpenChangeRef.current = onOpenChange;
|
|
15534
|
+
const close = useCallback22(() => {
|
|
15535
|
+
if (!openRef.current) return;
|
|
15536
|
+
openRef.current = false;
|
|
15537
|
+
setOpen(false);
|
|
15538
|
+
onOpenChangeRef.current?.(false);
|
|
15539
|
+
}, []);
|
|
15540
|
+
const openAt = useCallback22((x, y) => {
|
|
15541
|
+
setPoint({ x, y });
|
|
15542
|
+
const wasOpen = openRef.current;
|
|
15543
|
+
openRef.current = true;
|
|
15544
|
+
setOpen(true);
|
|
15545
|
+
if (!wasOpen) onOpenChangeRef.current?.(true);
|
|
15546
|
+
}, []);
|
|
15547
|
+
const value = useMemo23(() => ({ open, point, openAt, close }), [open, point, openAt, close]);
|
|
15548
|
+
return /* @__PURE__ */ jsx79(MenuContext2.Provider, { value, children });
|
|
15549
|
+
}
|
|
15550
|
+
var ContextMenuTrigger = forwardRef17(function ContextMenuTrigger2({ asChild = false, onContextMenu, children, ...props }, ref) {
|
|
15551
|
+
const { openAt } = useMenu();
|
|
15552
|
+
const shared = {
|
|
15553
|
+
...props,
|
|
15554
|
+
ref,
|
|
15555
|
+
[MENU_ATTR]: "",
|
|
15556
|
+
onContextMenu: (event) => {
|
|
15557
|
+
onContextMenu?.(event);
|
|
15558
|
+
if (event.defaultPrevented) return;
|
|
15559
|
+
event.preventDefault();
|
|
15560
|
+
openAt(event.clientX, event.clientY);
|
|
15561
|
+
}
|
|
15562
|
+
};
|
|
15563
|
+
if (asChild) return /* @__PURE__ */ jsx79(Slot7, { ...shared, children });
|
|
15564
|
+
return /* @__PURE__ */ jsx79("span", { ...shared, className: clsx109(menuStyles.triggerFallback, props.className), children });
|
|
15565
|
+
});
|
|
15566
|
+
function ContextMenuPortal({ children }) {
|
|
15567
|
+
return /* @__PURE__ */ jsx79(Fragment5, { children });
|
|
15568
|
+
}
|
|
15569
|
+
var ContextMenuContent = forwardRef17(function ContextMenuContent2({ className, style, onPointerDown, children, ...props }, ref) {
|
|
15570
|
+
const { open, point, close } = useMenu();
|
|
15571
|
+
const localRef = useRef25(null);
|
|
15572
|
+
const [shouldRender, setShouldRender] = useState33(open);
|
|
15573
|
+
const [isClosing, setIsClosing] = useState33(false);
|
|
15574
|
+
useEffect22(() => {
|
|
15575
|
+
if (open) {
|
|
15576
|
+
setShouldRender(true);
|
|
15577
|
+
setIsClosing(false);
|
|
15578
|
+
return;
|
|
15579
|
+
}
|
|
15580
|
+
if (!shouldRender) return;
|
|
15581
|
+
setIsClosing(true);
|
|
15582
|
+
const timeout = window.setTimeout(() => {
|
|
15583
|
+
setShouldRender(false);
|
|
15584
|
+
setIsClosing(false);
|
|
15585
|
+
}, CLOSE_MS);
|
|
15586
|
+
return () => window.clearTimeout(timeout);
|
|
15587
|
+
}, [open, shouldRender]);
|
|
15588
|
+
useLayoutEffect15(() => {
|
|
15589
|
+
if (!shouldRender || !localRef.current) return;
|
|
15590
|
+
placeInView(localRef.current, point.x, point.y);
|
|
15591
|
+
}, [shouldRender, point.x, point.y]);
|
|
15592
|
+
useEffect22(() => {
|
|
15593
|
+
if (!open) return;
|
|
15594
|
+
const onKey = (event) => {
|
|
15595
|
+
if (event.key === "Escape") close();
|
|
15596
|
+
};
|
|
15597
|
+
const onPointer = (event) => {
|
|
15598
|
+
const target = event.target;
|
|
15599
|
+
if (target instanceof Element && target.closest(`[${MENU_ATTR}]`)) return;
|
|
15600
|
+
close();
|
|
15601
|
+
};
|
|
15602
|
+
document.addEventListener("keydown", onKey);
|
|
15603
|
+
document.addEventListener("pointerdown", onPointer);
|
|
15604
|
+
return () => {
|
|
15605
|
+
document.removeEventListener("keydown", onKey);
|
|
15606
|
+
document.removeEventListener("pointerdown", onPointer);
|
|
15607
|
+
};
|
|
15608
|
+
}, [open, close]);
|
|
15609
|
+
if (!shouldRender || typeof document === "undefined") return null;
|
|
15610
|
+
return createPortal7(
|
|
15611
|
+
/* @__PURE__ */ jsx79(
|
|
15612
|
+
"div",
|
|
15613
|
+
{
|
|
15614
|
+
...props,
|
|
15615
|
+
ref: (node) => {
|
|
15616
|
+
localRef.current = node;
|
|
15617
|
+
if (typeof ref === "function") ref(node);
|
|
15618
|
+
else if (ref) ref.current = node;
|
|
15619
|
+
},
|
|
15620
|
+
"data-refineui": "menu-popover",
|
|
15621
|
+
"data-state": isClosing ? "closed" : "open",
|
|
15622
|
+
...{ [MENU_ATTR]: "" },
|
|
15623
|
+
className: menuStyles.popover,
|
|
15624
|
+
style: {
|
|
15625
|
+
position: "fixed",
|
|
15626
|
+
top: point.y,
|
|
15627
|
+
left: point.x,
|
|
15628
|
+
width: componentSizes3.menuPanelWidth,
|
|
15629
|
+
minWidth: componentSizes3.menuPanelWidth,
|
|
15630
|
+
zIndex: 9999,
|
|
15631
|
+
...style
|
|
15632
|
+
},
|
|
15633
|
+
onPointerDown: (event) => {
|
|
15634
|
+
event.preventDefault();
|
|
15635
|
+
onPointerDown?.(event);
|
|
15636
|
+
},
|
|
15637
|
+
onContextMenu: (event) => event.preventDefault(),
|
|
15638
|
+
children: /* @__PURE__ */ jsx79("div", { role: "menu", "data-refineui": "menu", className: clsx109(menuStyles.list, className), children })
|
|
15639
|
+
}
|
|
15640
|
+
),
|
|
15641
|
+
document.body
|
|
15642
|
+
);
|
|
15643
|
+
});
|
|
15644
|
+
function runSelect(onSelect, close, disabled) {
|
|
15645
|
+
if (disabled) return;
|
|
15646
|
+
const selectEvent = {
|
|
15647
|
+
defaultPrevented: false,
|
|
15648
|
+
preventDefault() {
|
|
15649
|
+
selectEvent.defaultPrevented = true;
|
|
15650
|
+
}
|
|
15651
|
+
};
|
|
15652
|
+
onSelect?.(selectEvent);
|
|
15653
|
+
if (!selectEvent.defaultPrevented) close();
|
|
15654
|
+
}
|
|
15655
|
+
var ContextMenuItem = forwardRef17(function ContextMenuItem2({ disabled = false, description, shortcut, startIcon, endIcon, state = "default", onSelect, className, onClick, onKeyDown, children, ...props }, ref) {
|
|
15656
|
+
const { close } = useMenu();
|
|
15657
|
+
const isDisabled = disabled || state === "disabled";
|
|
15658
|
+
const slotted = startIcon != null || description != null || shortcut != null || endIcon != null;
|
|
15659
|
+
return /* @__PURE__ */ jsx79(
|
|
15660
|
+
"button",
|
|
15661
|
+
{
|
|
15662
|
+
ref,
|
|
15663
|
+
type: "button",
|
|
15664
|
+
role: "menuitem",
|
|
15665
|
+
disabled: isDisabled,
|
|
15666
|
+
"aria-disabled": isDisabled || void 0,
|
|
15667
|
+
"data-refineui": "menu-item",
|
|
15668
|
+
"data-state": isDisabled ? "disabled" : state,
|
|
15669
|
+
...{ [MENU_ATTR]: "" },
|
|
15670
|
+
className: clsx109(menuStyles.itemBase, isDisabled ? menuStyles.itemDisabled : menuStyles.itemEnabled, className),
|
|
15671
|
+
...props,
|
|
15672
|
+
onClick: (event) => {
|
|
15673
|
+
onClick?.(event);
|
|
15674
|
+
if (event.defaultPrevented) return;
|
|
15675
|
+
runSelect(onSelect, close, isDisabled);
|
|
15676
|
+
},
|
|
15677
|
+
onKeyDown: (event) => {
|
|
15678
|
+
onKeyDown?.(event);
|
|
15679
|
+
if (event.defaultPrevented) return;
|
|
15680
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
15681
|
+
event.preventDefault();
|
|
15682
|
+
runSelect(onSelect, close, isDisabled);
|
|
15683
|
+
}
|
|
15684
|
+
},
|
|
15685
|
+
children: slotted ? /* @__PURE__ */ jsxs33("span", { className: menuStyles.row, children: [
|
|
15686
|
+
startIcon ? /* @__PURE__ */ jsx79(
|
|
15687
|
+
"span",
|
|
15688
|
+
{
|
|
15689
|
+
className: menuStyles.iconWrap,
|
|
15690
|
+
style: { width: iconSizes24.small, minWidth: iconSizes24.small, height: iconSizes24.small },
|
|
15691
|
+
children: startIcon
|
|
15692
|
+
}
|
|
15693
|
+
) : null,
|
|
15694
|
+
/* @__PURE__ */ jsxs33("span", { className: menuStyles.textCol, children: [
|
|
15695
|
+
/* @__PURE__ */ jsx79("span", { className: menuStyles.title, children }),
|
|
15696
|
+
description ? /* @__PURE__ */ jsx79("span", { className: clsx109(menuStyles.description, isDisabled ? menuStyles.descriptionDisabled : menuStyles.descriptionEnabled), children: description }) : null
|
|
15697
|
+
] }),
|
|
15698
|
+
(shortcut || endIcon) && /* @__PURE__ */ jsxs33("span", { className: menuStyles.rightWrap, children: [
|
|
15699
|
+
shortcut ? /* @__PURE__ */ jsx79("span", { className: menuStyles.shortcut, children: shortcut }) : null,
|
|
15700
|
+
endIcon ? /* @__PURE__ */ jsx79(
|
|
15701
|
+
"span",
|
|
15702
|
+
{
|
|
15703
|
+
className: menuStyles.iconWrap,
|
|
15704
|
+
style: { width: iconSizes24.small, minWidth: iconSizes24.small, height: iconSizes24.small },
|
|
15705
|
+
children: endIcon
|
|
15706
|
+
}
|
|
15707
|
+
) : null
|
|
15708
|
+
] })
|
|
15709
|
+
] }) : /* @__PURE__ */ jsx79("span", { className: menuStyles.row, children })
|
|
15710
|
+
}
|
|
15711
|
+
);
|
|
15712
|
+
});
|
|
15713
|
+
var ContextMenuSeparator = forwardRef17(
|
|
15714
|
+
function ContextMenuSeparator2({ className, ...props }, ref) {
|
|
15715
|
+
return /* @__PURE__ */ jsx79(
|
|
15716
|
+
"div",
|
|
15717
|
+
{
|
|
15718
|
+
ref,
|
|
15719
|
+
role: "separator",
|
|
15720
|
+
"aria-orientation": "horizontal",
|
|
15721
|
+
"data-refineui": "menu-divider",
|
|
15722
|
+
...{ [MENU_ATTR]: "" },
|
|
15723
|
+
className: clsx109(menuStyles.dividerWrap, className),
|
|
15724
|
+
...props,
|
|
15725
|
+
children: /* @__PURE__ */ jsx79("div", { className: menuStyles.dividerLine })
|
|
15726
|
+
}
|
|
15727
|
+
);
|
|
15728
|
+
}
|
|
15729
|
+
);
|
|
15730
|
+
function ContextMenuSection({ className, children, ...props }) {
|
|
15731
|
+
return /* @__PURE__ */ jsx79("div", { "data-refineui": "menu-section", className: clsx109(menuStyles.section, className), ...props, children: /* @__PURE__ */ jsx79("span", { className: menuStyles.sectionText, children }) });
|
|
15732
|
+
}
|
|
15733
|
+
function ContextMenuSub({ children }) {
|
|
15734
|
+
const [open, setOpen] = useState33(false);
|
|
15735
|
+
const triggerRef = useRef25(null);
|
|
15736
|
+
const timer = useRef25(null);
|
|
15737
|
+
const clear = () => {
|
|
15738
|
+
if (timer.current != null) window.clearTimeout(timer.current);
|
|
15739
|
+
timer.current = null;
|
|
15740
|
+
};
|
|
15741
|
+
useEffect22(() => clear, []);
|
|
15742
|
+
const value = useMemo23(
|
|
15743
|
+
() => ({
|
|
15744
|
+
open,
|
|
15745
|
+
triggerRef,
|
|
15746
|
+
show: () => {
|
|
15747
|
+
clear();
|
|
15748
|
+
setOpen(true);
|
|
15749
|
+
},
|
|
15750
|
+
hideSoon: () => {
|
|
15751
|
+
clear();
|
|
15752
|
+
timer.current = window.setTimeout(() => setOpen(false), 150);
|
|
15753
|
+
}
|
|
15754
|
+
}),
|
|
15755
|
+
[open]
|
|
15756
|
+
);
|
|
15757
|
+
return /* @__PURE__ */ jsx79(SubContext.Provider, { value, children });
|
|
15758
|
+
}
|
|
15759
|
+
function useSub2() {
|
|
15760
|
+
const value = useContext32(SubContext);
|
|
15761
|
+
if (!value) throw new Error("ContextMenu.SubTrigger must be used inside ContextMenu.Sub");
|
|
15762
|
+
return value;
|
|
15763
|
+
}
|
|
15764
|
+
var ContextMenuSubTrigger = forwardRef17(
|
|
15765
|
+
function ContextMenuSubTrigger2({ asChild = false, description, startIcon, onMouseEnter, onMouseLeave, onClick, className, children, ...props }, ref) {
|
|
15766
|
+
const sub = useSub2();
|
|
15767
|
+
const shared = {
|
|
15768
|
+
...props,
|
|
15769
|
+
type: "button",
|
|
15770
|
+
role: "menuitem",
|
|
15771
|
+
"aria-haspopup": "menu",
|
|
15772
|
+
"aria-expanded": sub.open,
|
|
15773
|
+
"data-state": sub.open ? "active" : "default",
|
|
15774
|
+
"data-refineui": "menu-item",
|
|
15775
|
+
[MENU_ATTR]: "",
|
|
15776
|
+
className: clsx109(
|
|
15777
|
+
menuStyles.itemBase,
|
|
15778
|
+
menuStyles.itemEnabled,
|
|
15779
|
+
sub.open && "bg-refineui-alias-background-primary-hover",
|
|
15780
|
+
className
|
|
15781
|
+
),
|
|
15782
|
+
ref: (node) => {
|
|
15783
|
+
sub.triggerRef.current = node;
|
|
15784
|
+
if (typeof ref === "function") ref(node);
|
|
15785
|
+
else if (ref) ref.current = node;
|
|
15786
|
+
},
|
|
15787
|
+
onMouseEnter: (event) => {
|
|
15788
|
+
onMouseEnter?.(event);
|
|
15789
|
+
sub.show();
|
|
15790
|
+
},
|
|
15791
|
+
onMouseLeave: (event) => {
|
|
15792
|
+
onMouseLeave?.(event);
|
|
15793
|
+
sub.hideSoon();
|
|
15794
|
+
},
|
|
15795
|
+
onClick: (event) => {
|
|
15796
|
+
onClick?.(event);
|
|
15797
|
+
if (!event.defaultPrevented) sub.show();
|
|
15798
|
+
}
|
|
15799
|
+
};
|
|
15800
|
+
if (asChild) return /* @__PURE__ */ jsx79(Slot7, { ...shared, children });
|
|
15801
|
+
return /* @__PURE__ */ jsx79("button", { ...shared, children: /* @__PURE__ */ jsxs33("span", { className: menuStyles.row, children: [
|
|
15802
|
+
startIcon ? /* @__PURE__ */ jsx79(
|
|
15803
|
+
"span",
|
|
15804
|
+
{
|
|
15805
|
+
className: menuStyles.iconWrap,
|
|
15806
|
+
style: { width: iconSizes24.small, minWidth: iconSizes24.small, height: iconSizes24.small },
|
|
15807
|
+
children: startIcon
|
|
15808
|
+
}
|
|
15809
|
+
) : null,
|
|
15810
|
+
/* @__PURE__ */ jsxs33("span", { className: menuStyles.textCol, children: [
|
|
15811
|
+
/* @__PURE__ */ jsx79("span", { className: menuStyles.title, children }),
|
|
15812
|
+
description ? /* @__PURE__ */ jsx79("span", { className: clsx109(menuStyles.description, menuStyles.descriptionEnabled), children: description }) : null
|
|
15813
|
+
] }),
|
|
15814
|
+
/* @__PURE__ */ jsx79("span", { className: menuStyles.rightWrap, children: /* @__PURE__ */ jsx79(
|
|
15815
|
+
"span",
|
|
15816
|
+
{
|
|
15817
|
+
className: menuStyles.iconWrap,
|
|
15818
|
+
style: { width: iconSizes24.small, minWidth: iconSizes24.small, height: iconSizes24.small },
|
|
15819
|
+
children: /* @__PURE__ */ jsx79(WebIcon, { name: "chevron-right", size: iconSizes24.small, color: "currentColor", "aria-hidden": true })
|
|
15820
|
+
}
|
|
15821
|
+
) })
|
|
15822
|
+
] }) });
|
|
15823
|
+
}
|
|
15824
|
+
);
|
|
15825
|
+
var ContextMenuSubContent = forwardRef17(
|
|
15826
|
+
function ContextMenuSubContent2({ className, style, onPointerDown, onMouseEnter, onMouseLeave, ...props }, ref) {
|
|
15827
|
+
const sub = useSub2();
|
|
15828
|
+
const localRef = useRef25(null);
|
|
15829
|
+
const [side, setSide] = useState33("right");
|
|
15830
|
+
useLayoutEffect15(() => {
|
|
15831
|
+
const trigger = sub.triggerRef.current;
|
|
15832
|
+
const element = localRef.current;
|
|
15833
|
+
if (!sub.open || !trigger || !element) return;
|
|
15834
|
+
const rect = trigger.getBoundingClientRect();
|
|
15835
|
+
const width = element.offsetWidth;
|
|
15836
|
+
const pad = 4;
|
|
15837
|
+
let left = rect.right;
|
|
15838
|
+
let nextSide = "right";
|
|
15839
|
+
if (left + width > window.innerWidth - pad) {
|
|
15840
|
+
left = Math.max(pad, rect.left - width);
|
|
15841
|
+
nextSide = "left";
|
|
15842
|
+
}
|
|
15843
|
+
setSide(nextSide);
|
|
15844
|
+
placeInView(element, left, rect.top);
|
|
15845
|
+
}, [sub.open, sub.triggerRef]);
|
|
15846
|
+
if (!sub.open || typeof document === "undefined") return null;
|
|
15847
|
+
return createPortal7(
|
|
15848
|
+
/* @__PURE__ */ jsx79(
|
|
15849
|
+
"div",
|
|
15850
|
+
{
|
|
15851
|
+
...props,
|
|
15852
|
+
ref: (node) => {
|
|
15853
|
+
localRef.current = node;
|
|
15854
|
+
if (typeof ref === "function") ref(node);
|
|
15855
|
+
else if (ref) ref.current = node;
|
|
15856
|
+
},
|
|
15857
|
+
role: "menu",
|
|
15858
|
+
"data-refineui": "menu",
|
|
15859
|
+
"data-submenu": "true",
|
|
15860
|
+
"data-state": "open",
|
|
15861
|
+
"data-side": side,
|
|
15862
|
+
...{ [MENU_ATTR]: "" },
|
|
15863
|
+
className: clsx109(menuStyles.subPanel, className),
|
|
15864
|
+
style: { position: "fixed", zIndex: 1e4, ...style },
|
|
15865
|
+
onPointerDown: (event) => {
|
|
15866
|
+
event.preventDefault();
|
|
15867
|
+
onPointerDown?.(event);
|
|
15868
|
+
},
|
|
15869
|
+
onMouseEnter: (event) => {
|
|
15870
|
+
onMouseEnter?.(event);
|
|
15871
|
+
sub.show();
|
|
15872
|
+
},
|
|
15873
|
+
onMouseLeave: (event) => {
|
|
15874
|
+
onMouseLeave?.(event);
|
|
15875
|
+
sub.hideSoon();
|
|
15876
|
+
},
|
|
15877
|
+
onContextMenu: (event) => event.preventDefault()
|
|
15878
|
+
}
|
|
15879
|
+
),
|
|
15880
|
+
document.body
|
|
15881
|
+
);
|
|
15882
|
+
}
|
|
15883
|
+
);
|
|
15884
|
+
var ContextMenu = Object.assign(ContextMenuRoot, {
|
|
15885
|
+
Root: ContextMenuRoot,
|
|
15886
|
+
Trigger: ContextMenuTrigger,
|
|
15887
|
+
Portal: ContextMenuPortal,
|
|
15888
|
+
Content: ContextMenuContent,
|
|
15889
|
+
Item: ContextMenuItem,
|
|
15890
|
+
Section: ContextMenuSection,
|
|
15891
|
+
Separator: ContextMenuSeparator,
|
|
15892
|
+
Sub: ContextMenuSub,
|
|
15893
|
+
SubTrigger: ContextMenuSubTrigger,
|
|
15894
|
+
SubContent: ContextMenuSubContent
|
|
15895
|
+
});
|
|
15376
15896
|
export {
|
|
15377
15897
|
Accordion,
|
|
15378
15898
|
AccordionContent,
|
|
@@ -15442,6 +15962,10 @@ export {
|
|
|
15442
15962
|
ChartYAxisLabels,
|
|
15443
15963
|
Checkbox,
|
|
15444
15964
|
Chip,
|
|
15965
|
+
Collapsible,
|
|
15966
|
+
CollapsibleContent,
|
|
15967
|
+
CollapsibleRoot,
|
|
15968
|
+
CollapsibleTrigger,
|
|
15445
15969
|
Command,
|
|
15446
15970
|
CommandDialog,
|
|
15447
15971
|
CommandEmpty,
|
|
@@ -15453,6 +15977,17 @@ export {
|
|
|
15453
15977
|
CommandSeparator,
|
|
15454
15978
|
CommandShortcut,
|
|
15455
15979
|
Container,
|
|
15980
|
+
ContextMenu,
|
|
15981
|
+
ContextMenuContent,
|
|
15982
|
+
ContextMenuItem,
|
|
15983
|
+
ContextMenuPortal,
|
|
15984
|
+
ContextMenuRoot,
|
|
15985
|
+
ContextMenuSection,
|
|
15986
|
+
ContextMenuSeparator,
|
|
15987
|
+
ContextMenuSub,
|
|
15988
|
+
ContextMenuSubContent,
|
|
15989
|
+
ContextMenuSubTrigger,
|
|
15990
|
+
ContextMenuTrigger,
|
|
15456
15991
|
Dialog,
|
|
15457
15992
|
DialogClose,
|
|
15458
15993
|
DialogContent,
|
|
@@ -15595,6 +16130,7 @@ export {
|
|
|
15595
16130
|
SidebarPeekPin,
|
|
15596
16131
|
Skeleton,
|
|
15597
16132
|
Slider,
|
|
16133
|
+
Slot5 as Slot,
|
|
15598
16134
|
Spacer,
|
|
15599
16135
|
SpinButton,
|
|
15600
16136
|
Spinner,
|