@bioturing/components 0.27.0 → 0.28.1
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/components/checkbox/component.js.map +1 -1
- package/dist/components/choice-list/component.js +9 -9
- package/dist/components/cmdk/index.js.map +1 -1
- package/dist/components/combobox/component.js +202 -0
- package/dist/components/combobox/component.js.map +1 -0
- package/dist/components/combobox/style.css +1 -0
- package/dist/components/combobox/trigger.js +89 -0
- package/dist/components/combobox/trigger.js.map +1 -0
- package/dist/components/dropdown-menu/component.js +176 -163
- package/dist/components/dropdown-menu/component.js.map +1 -1
- package/dist/components/dropdown-menu/divider.js +16 -0
- package/dist/components/dropdown-menu/divider.js.map +1 -0
- package/dist/components/dropdown-menu/item.css +1 -0
- package/dist/components/dropdown-menu/item.js +131 -0
- package/dist/components/dropdown-menu/item.js.map +1 -0
- package/dist/components/dropdown-menu/style.css +1 -1
- package/dist/components/hooks/useDraggable.js +77 -0
- package/dist/components/hooks/useDraggable.js.map +1 -0
- package/dist/components/hooks/useHover.js +26 -0
- package/dist/components/hooks/useHover.js.map +1 -0
- package/dist/components/hooks/useTransitionStatus.js +52 -0
- package/dist/components/hooks/useTransitionStatus.js.map +1 -0
- package/dist/components/nav/item.js +2 -2
- package/dist/components/popup-panel/component.js +81 -92
- package/dist/components/popup-panel/component.js.map +1 -1
- package/dist/components/resizable/component.js +165 -97
- package/dist/components/resizable/component.js.map +1 -1
- package/dist/components/resizable/style.css +1 -1
- package/dist/components/select/component.js +160 -91
- package/dist/components/select/component.js.map +1 -1
- package/dist/components/select/item.js +54 -0
- package/dist/components/select/item.js.map +1 -0
- package/dist/components/select/style.css +1 -1
- package/dist/components/splitter/splitter-panel.js +8 -8
- package/dist/components/splitter/splitter.js +9 -9
- package/dist/components/splitter/useSizes.js +10 -10
- package/dist/components/splitter/useSizes.js.map +1 -1
- package/dist/components/stack/StackChild.js +9 -9
- package/dist/components/transition/component.js +1 -1
- package/dist/components/transition/component.js.map +1 -1
- package/dist/index.d.ts +317 -5
- package/dist/index.js +204 -194
- package/dist/index.js.map +1 -1
- package/dist/metadata.js +21 -7
- package/dist/metadata.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as g, Fragment as k, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as x } from "react";
|
|
4
|
+
import { Command as E } from "../cmdk/index.js";
|
|
5
|
+
import { Menu as L } from "@base-ui-components/react/menu";
|
|
6
|
+
import './item.css';/* empty css */
|
|
7
|
+
import { Checkbox as h } from "antd";
|
|
8
|
+
import { useCls as b } from "../utils/antdUtils.js";
|
|
9
|
+
import { clsx as p } from "../utils/cn.js";
|
|
10
|
+
const C = ({
|
|
11
|
+
item: o,
|
|
12
|
+
inCombobox: u = !1,
|
|
13
|
+
selected: i = !1,
|
|
14
|
+
itemRender: t,
|
|
15
|
+
itemProps: w = {},
|
|
16
|
+
classNames: n,
|
|
17
|
+
onSelect: I,
|
|
18
|
+
showCheckbox: e,
|
|
19
|
+
indeterminate: M,
|
|
20
|
+
renderAsNativeElement: O
|
|
21
|
+
}) => {
|
|
22
|
+
const d = b(), y = x(
|
|
23
|
+
() => u ? E.Item : L.Item,
|
|
24
|
+
[u]
|
|
25
|
+
), f = x(() => ({
|
|
26
|
+
className: p(
|
|
27
|
+
d("dropdown-menu-item", u && "dropdown-menu-item-combobox"),
|
|
28
|
+
n == null ? void 0 : n.item,
|
|
29
|
+
o.className
|
|
30
|
+
),
|
|
31
|
+
disabled: o.disabled,
|
|
32
|
+
"data-danger": o.danger,
|
|
33
|
+
"data-actual-selected": i,
|
|
34
|
+
ref: o.ref,
|
|
35
|
+
onClick: o.onClick,
|
|
36
|
+
onMouseEnter: o.onMouseEnter,
|
|
37
|
+
onMouseLeave: o.onMouseLeave,
|
|
38
|
+
onMouseOver: o.onMouseOver,
|
|
39
|
+
onMouseOut: o.onMouseOut,
|
|
40
|
+
"data-value": typeof o.label == "string" ? o.label : String(o.key),
|
|
41
|
+
render: t ? (j) => t(o, j) : void 0,
|
|
42
|
+
children: u ? /* @__PURE__ */ g(k, { children: [
|
|
43
|
+
e && /* @__PURE__ */ r(
|
|
44
|
+
h,
|
|
45
|
+
{
|
|
46
|
+
checked: i,
|
|
47
|
+
tabIndex: -1,
|
|
48
|
+
indeterminate: M
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
o.icon && /* @__PURE__ */ r(
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
className: p(
|
|
55
|
+
d("dropdown-menu-item-icon"),
|
|
56
|
+
n == null ? void 0 : n.itemIcon
|
|
57
|
+
),
|
|
58
|
+
children: o.icon
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ r(
|
|
62
|
+
"span",
|
|
63
|
+
{
|
|
64
|
+
className: p(
|
|
65
|
+
d("dropdown-menu-item-text"),
|
|
66
|
+
n == null ? void 0 : n.itemText
|
|
67
|
+
),
|
|
68
|
+
children: o.label
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] }) : /* @__PURE__ */ g(k, { children: [
|
|
72
|
+
e && /* @__PURE__ */ r(
|
|
73
|
+
h,
|
|
74
|
+
{
|
|
75
|
+
checked: i,
|
|
76
|
+
tabIndex: -1,
|
|
77
|
+
indeterminate: M
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
o.icon && /* @__PURE__ */ r(
|
|
81
|
+
"span",
|
|
82
|
+
{
|
|
83
|
+
className: p(
|
|
84
|
+
d("dropdown-menu-item-icon"),
|
|
85
|
+
n == null ? void 0 : n.itemIcon
|
|
86
|
+
),
|
|
87
|
+
children: o.icon
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ r(
|
|
91
|
+
"span",
|
|
92
|
+
{
|
|
93
|
+
className: p(
|
|
94
|
+
d("dropdown-menu-item-text"),
|
|
95
|
+
n == null ? void 0 : n.itemText
|
|
96
|
+
),
|
|
97
|
+
children: o.label
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
] })
|
|
101
|
+
}), [
|
|
102
|
+
n == null ? void 0 : n.item,
|
|
103
|
+
n == null ? void 0 : n.itemIcon,
|
|
104
|
+
n == null ? void 0 : n.itemText,
|
|
105
|
+
d,
|
|
106
|
+
u,
|
|
107
|
+
M,
|
|
108
|
+
o,
|
|
109
|
+
t,
|
|
110
|
+
i,
|
|
111
|
+
e
|
|
112
|
+
]);
|
|
113
|
+
if (t)
|
|
114
|
+
return t(o, {
|
|
115
|
+
...f,
|
|
116
|
+
...w
|
|
117
|
+
});
|
|
118
|
+
const { render: v, ...T } = f;
|
|
119
|
+
return O ? v ? v(f) : /* @__PURE__ */ r("div", { onClick: I, ...T }) : /* @__PURE__ */ r(
|
|
120
|
+
y,
|
|
121
|
+
{
|
|
122
|
+
value: String(o.key),
|
|
123
|
+
onSelect: I,
|
|
124
|
+
...f
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
export {
|
|
129
|
+
C as DropdownMenuItem
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../src/components/dropdown-menu/item.tsx"],"sourcesContent":["\"use client\";\nimport React, { Ref, useMemo } from \"react\";\nimport { clsx, useCls } from \"../utils\";\nimport type { DropdownMenuItemType } from \"./component\";\nimport { Command } from \"../cmdk\";\nimport { Menu } from \"@base-ui-components/react/menu\";\n\nimport \"./item.css\";\nimport { Checkbox } from \"antd\";\n\nexport interface DropdownMenuItemProps {\n /** The menu item data */\n item: DropdownMenuItemType & { type: \"item\" };\n /** Custom render function for the item */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /** Additional props to pass to the item */\n itemProps?: React.HTMLAttributes<HTMLElement>;\n /** Class names from parent DropdownMenu */\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemText?: string;\n };\n onSelect?: () => void;\n /**\n * Whether the menu item is in a combobox\n */\n inCombobox?: boolean;\n /**\n * Whether the menu item is in a menu\n */\n renderAsNativeElement?: boolean;\n /**\n * Whether the menu item is selected (for combobox)\n * @default false\n */\n selected?: boolean;\n /**\n * Whether to show checkbox (only for decoration purpose)\n */\n showCheckbox?: boolean;\n /**\n * Whether the menu item checkbox is indeterminate (for combobox)\n * @default false\n */\n indeterminate?: boolean;\n}\n\nexport const DropdownMenuItem: React.FC<DropdownMenuItemProps> = ({\n item,\n inCombobox = false,\n selected = false,\n itemRender,\n itemProps = {},\n classNames,\n onSelect,\n showCheckbox,\n indeterminate,\n renderAsNativeElement,\n}) => {\n const cls = useCls();\n\n const MenuItem = useMemo(\n () => (inCombobox ? Command.Item : Menu.Item),\n [inCombobox]\n );\n\n const props = useMemo(() => {\n return {\n className: clsx(\n cls(\"dropdown-menu-item\", inCombobox && \"dropdown-menu-item-combobox\"),\n classNames?.item,\n item.className\n ),\n disabled: item.disabled,\n \"data-danger\": item.danger,\n \"data-actual-selected\": selected,\n ref: item.ref as Ref<HTMLDivElement>,\n onClick: item.onClick,\n onMouseEnter: item.onMouseEnter,\n onMouseLeave: item.onMouseLeave,\n onMouseOver: item.onMouseOver,\n onMouseOut: item.onMouseOut,\n \"data-value\":\n typeof item.label === \"string\" ? item.label : String(item.key),\n render: itemRender\n ? (itemProps: React.HTMLAttributes<HTMLElement>) =>\n itemRender(item, itemProps)\n : undefined,\n children: inCombobox ? (\n <>\n {showCheckbox && (\n <Checkbox\n checked={selected}\n tabIndex={-1}\n indeterminate={indeterminate}\n />\n )}\n {item.icon && (\n <span\n className={clsx(\n cls(\"dropdown-menu-item-icon\"),\n classNames?.itemIcon\n )}\n >\n {item.icon}\n </span>\n )}\n <span\n className={clsx(\n cls(\"dropdown-menu-item-text\"),\n classNames?.itemText\n )}\n >\n {item.label}\n </span>\n </>\n ) : (\n <>\n {showCheckbox && (\n <Checkbox\n checked={selected}\n tabIndex={-1}\n indeterminate={indeterminate}\n />\n )}\n {item.icon && (\n <span\n className={clsx(\n cls(\"dropdown-menu-item-icon\"),\n classNames?.itemIcon\n )}\n >\n {item.icon}\n </span>\n )}\n <span\n className={clsx(\n cls(\"dropdown-menu-item-text\"),\n classNames?.itemText\n )}\n >\n {item.label}\n </span>\n </>\n ),\n };\n }, [\n classNames?.item,\n classNames?.itemIcon,\n classNames?.itemText,\n cls,\n inCombobox,\n indeterminate,\n item,\n itemRender,\n selected,\n showCheckbox,\n ]);\n // If custom render function is provided, use it\n if (itemRender) {\n return itemRender(item, {\n ...props,\n ...itemProps,\n });\n }\n const { render, ...restProps } = props;\n // Default rendering\n return renderAsNativeElement ? (\n render ? (\n render(props)\n ) : (\n <div onClick={onSelect} {...restProps} />\n )\n ) : (\n <MenuItem\n value={String(item.key)}\n onSelect={onSelect}\n {...props}\n ></MenuItem>\n );\n};\n"],"names":["DropdownMenuItem","item","inCombobox","selected","itemRender","itemProps","classNames","onSelect","showCheckbox","indeterminate","renderAsNativeElement","cls","useCls","MenuItem","useMemo","Command","Menu","props","clsx","jsxs","Fragment","jsx","Checkbox","render","restProps"],"mappings":";;;;;;;;;AAmDO,MAAMA,IAAoD,CAAC;AAAA,EAChE,MAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,UAAAC,IAAW;AAAA,EACX,YAAAC;AAAA,EACA,WAAAC,IAAY,CAAC;AAAA,EACb,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,uBAAAC;AACF,MAAM;AACJ,QAAMC,IAAMC,EAAO,GAEbC,IAAWC;AAAA,IACf,MAAOZ,IAAaa,EAAQ,OAAOC,EAAK;AAAA,IACxC,CAACd,CAAU;AAAA,EACb,GAEMe,IAAQH,EAAQ,OACb;AAAA,IACL,WAAWI;AAAA,MACTP,EAAI,sBAAsBT,KAAc,6BAA6B;AAAA,MACrEI,KA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UACC,WAAWH;AAAA,YACTP,EAAI,yBAAyB;AAAA,YAC7BL,KAAA,gBAAAA,EAAY;AAAA,UACd;AAAA,UAEC,UAAKL,EAAA;AAAA,QAAA;AAAA,MACR;AAAA,MAEF,gBAAAoB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWH;AAAA,YACTP,EAAI,yBAAyB;AAAA,YAC7BL,KAAA,gBAAAA,EAAY;AAAA,UACd;AAAA,UAEC,UAAKL,EAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACR,EACF,CAAA;AAAA,EAEJ,IACC;AAAA,IACDK,KAAA,gBAAAA,EAAY;AAAA,IACZA,KAAA,gBAAAA,EAAY;AAAA,IACZA,KAAA,gBAAAA,EAAY;AAAA,IACZK;AAAA,IACAT;AAAA,IACAO;AAAA,IACAR;AAAA,IACAG;AAAA,IACAD;AAAA,IACAK;AAAA,EAAA,CACD;AAED,MAAIJ;AACF,WAAOA,EAAWH,GAAM;AAAA,MACtB,GAAGgB;AAAA,MACH,GAAGZ;AAAA,IAAA,CACJ;AAEH,QAAM,EAAE,QAAAkB,GAAQ,GAAGC,EAAA,IAAcP;AAE1B,SAAAP,IACLa,IACEA,EAAON,CAAK,IAEX,gBAAAI,EAAA,OAAA,EAAI,SAASd,GAAW,GAAGiB,EAAA,CAAW,IAGzC,gBAAAH;AAAA,IAACR;AAAA,IAAA;AAAA,MACC,OAAO,OAAOZ,EAAK,GAAG;AAAA,MACtB,UAAAM;AAAA,MACC,GAAGU;AAAA,IAAA;AAAA,EACL;AAEL;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-dropdown-menu-root{z-index:2000}.ds-dropdown-menu{box-shadow:var(--ds-box-shadow-secondary);border-radius:var(--ds-border-radius);background:var(--ds-color-bg-elevated);list-style:none;padding:.25rem;color:var(--ds-color-text);font-size:var(--ds-font-size);font-family:var(--ds-font-family);transition-property:transform,scale,opacity;transition-duration:.2s;transition-timing-function:var(--ds-motion-ease-out);transform-origin:var(--transform-origin);max-width:min(var(--size-width),var(--available-width));max-height:var(--available-height);display:flex;flex-direction:column}.ds-dropdown-menu[data-ending-style],.ds-dropdown-menu[data-starting-style]{transform:scale(.9);opacity:0}.ds-dropdown-menu:focus{outline:none}.ds-dropdown-menu .ds-dropdown-menu-container{flex-shrink:1;min-height:0;display:flex;flex-direction:column}.ds-dropdown-menu .ds-dropdown-menu-search{flex-shrink:0}.ds-dropdown-menu .ds-dropdown-menu-list{flex-shrink:1;min-height:0;display:flex;flex-direction:column}
|
|
1
|
+
@layer components{.ds-dropdown-menu-root{z-index:2000}.ds-dropdown-menu{box-shadow:var(--ds-box-shadow-secondary);border-radius:var(--ds-border-radius);background:var(--ds-color-bg-elevated);list-style:none;padding:.25rem;color:var(--ds-color-text);font-size:var(--ds-font-size);font-family:var(--ds-font-family);transition-property:transform,scale,opacity;transition-duration:.2s;transition-timing-function:var(--ds-motion-ease-out);transform-origin:var(--transform-origin);max-width:min(var(--size-width),var(--available-width));max-height:var(--available-height);display:flex;flex-direction:column}.ds-dropdown-menu[data-ending-style],.ds-dropdown-menu[data-starting-style]{transform:scale(.9);opacity:0}.ds-dropdown-menu:focus{outline:none}.ds-dropdown-menu .ds-dropdown-menu-container{flex-shrink:1;min-height:0;display:flex;flex-direction:column}.ds-dropdown-menu .ds-dropdown-menu-search{flex-shrink:0}.ds-dropdown-menu .ds-dropdown-menu-list{flex-shrink:1;min-height:0;display:flex;flex-direction:column}:is(.ds-dropdown-menu .ds-dropdown-menu-list) [cmdk-list-sizer]{flex-shrink:1;min-height:0;display:flex;flex-direction:column}.ds-dropdown-menu-search{margin-bottom:.25rem}.ds-dropdown-menu-divider{border-bottom:1px solid var(--ds-color-split);margin:.25rem 0}.ds-dropdown-menu-header{font-size:.75rem;font-weight:500;line-height:1rem;text-transform:uppercase;color:var(--ds-color-text-tertiary);padding:.75rem .75rem .25rem}.ds-dropdown-menu-header:first-child{padding-top:.5rem}.ds-dropdown-menu-empty{padding:.375rem .75rem;color:var(--ds-color-text-tertiary)}.ds-dropdown-menu-match-trigger-width{width:min(var(--anchor-width),var(--available-width))}}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback as H } from "react";
|
|
3
|
+
function T(d = !0) {
|
|
4
|
+
return { ref: H((n) => {
|
|
5
|
+
if (!n || !d) return;
|
|
6
|
+
let i = !1, m = 0, f = 0, v = 0, p = 0, o = null;
|
|
7
|
+
n.addEventListener("mousedown", h);
|
|
8
|
+
function z(t) {
|
|
9
|
+
var s, c;
|
|
10
|
+
let e = t;
|
|
11
|
+
for (; e && e !== n; ) {
|
|
12
|
+
if (e.classList.contains("resize-handle") || e.classList.contains("ds-resizable-resize-handle") || e.getAttribute("data-resize-handle") || (s = e.getAttribute("data-testid")) != null && s.includes("resize") || e.getAttribute("data-placement") || // Resizable handles have data-placement
|
|
13
|
+
(c = e.style.cursor) != null && c.includes("resize") || // Check for react-use-resizable specific classes/attributes
|
|
14
|
+
e.classList.contains("resizable-handle") || e.hasAttribute("data-resizable-handle") || // Check for common resize cursor styles
|
|
15
|
+
["n-resize", "s-resize", "e-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize"].includes(e.style.cursor))
|
|
16
|
+
return !0;
|
|
17
|
+
e = e.parentElement;
|
|
18
|
+
}
|
|
19
|
+
return !1;
|
|
20
|
+
}
|
|
21
|
+
function y(t) {
|
|
22
|
+
const e = window.getComputedStyle(t), s = new DOMMatrix(e.transform);
|
|
23
|
+
return {
|
|
24
|
+
x: s.m41 || parseInt(e.left) || 0,
|
|
25
|
+
y: s.m42 || parseInt(e.top) || 0
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function L(t, e, s) {
|
|
29
|
+
t.style.transform = `translate(${e}px, ${s}px)`;
|
|
30
|
+
}
|
|
31
|
+
function h(t) {
|
|
32
|
+
const e = t.target;
|
|
33
|
+
if (z(e))
|
|
34
|
+
return;
|
|
35
|
+
if (n.closest("[data-resizable]")) {
|
|
36
|
+
const r = n.getBoundingClientRect(), E = t.clientX - r.left, b = t.clientY - r.top, l = 8, w = b <= l, x = b >= r.height - l, S = E <= l, A = E >= r.width - l, D = n.querySelector('.ds-resizable-resize-handle[data-placement*="top"]'), X = n.querySelector('.ds-resizable-resize-handle[data-placement*="bottom"]'), Y = n.querySelector('.ds-resizable-resize-handle[data-placement*="left"]'), q = n.querySelector('.ds-resizable-resize-handle[data-placement*="right"]');
|
|
37
|
+
if (w && D || x && X || S && Y || A && q)
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
t.preventDefault(), t.stopPropagation(), i = !0, m = t.clientX, f = t.clientY;
|
|
41
|
+
const s = y(n);
|
|
42
|
+
v = s.x, p = s.y, document.body.style.cursor = "grabbing", document.body.style.userSelect = "none", n.querySelectorAll('button, a, input, select, textarea, [role="button"]').forEach((r) => {
|
|
43
|
+
r.style.pointerEvents = "auto";
|
|
44
|
+
}), document.addEventListener("mousemove", u, { passive: !1 }), document.addEventListener("mouseup", a), document.addEventListener("touchmove", g, { passive: !1 }), document.addEventListener("touchend", a);
|
|
45
|
+
}
|
|
46
|
+
function u(t) {
|
|
47
|
+
!i || !n || (t.preventDefault(), o && cancelAnimationFrame(o), o = requestAnimationFrame(() => {
|
|
48
|
+
const e = t.clientX - m, s = t.clientY - f, c = v + e, r = p + s;
|
|
49
|
+
L(n, c, r);
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
function g(t) {
|
|
53
|
+
if (!i || !n) return;
|
|
54
|
+
t.preventDefault();
|
|
55
|
+
const e = t.touches[0];
|
|
56
|
+
if (!e) return;
|
|
57
|
+
const s = new MouseEvent("mousemove", {
|
|
58
|
+
clientX: e.clientX,
|
|
59
|
+
clientY: e.clientY,
|
|
60
|
+
bubbles: !0
|
|
61
|
+
});
|
|
62
|
+
u(s);
|
|
63
|
+
}
|
|
64
|
+
function a() {
|
|
65
|
+
i && (i = !1, o && (cancelAnimationFrame(o), o = null), document.body.style.cursor = "", document.body.style.userSelect = "", n && n.querySelectorAll('button, a, input, select, textarea, [role="button"]').forEach((e) => {
|
|
66
|
+
e.style.pointerEvents = "";
|
|
67
|
+
}), document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", a), document.removeEventListener("touchmove", g), document.removeEventListener("touchend", a));
|
|
68
|
+
}
|
|
69
|
+
return () => {
|
|
70
|
+
n.removeEventListener("mousedown", h), a();
|
|
71
|
+
};
|
|
72
|
+
}, [d]) };
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
T as useDraggable
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=useDraggable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDraggable.js","sources":["../../../src/components/hooks/useDraggable.ts"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\n\nexport function useDraggable(enabled: boolean = true) {\n const ref = useCallback((element: HTMLElement | null) => {\n if (!element || !enabled) return;\n \n let isDragging = false;\n let startX = 0;\n let startY = 0;\n let initialLeft = 0;\n let initialTop = 0;\n let rafId: number | null = null;\n\n element.addEventListener(\"mousedown\", dragMouseDown);\n\n function isResizeHandle(target: HTMLElement): boolean {\n // Check if the element or any of its parents is a resize handle\n let current = target;\n while (current && current !== element) {\n // Check for various resize handle indicators\n if (\n current.classList.contains('resize-handle') ||\n current.classList.contains('ds-resizable-resize-handle') ||\n current.getAttribute('data-resize-handle') ||\n current.getAttribute('data-testid')?.includes('resize') ||\n current.getAttribute('data-placement') || // Resizable handles have data-placement\n current.style.cursor?.includes('resize') ||\n // Check for react-use-resizable specific classes/attributes\n current.classList.contains('resizable-handle') ||\n current.hasAttribute('data-resizable-handle') ||\n // Check for common resize cursor styles\n ['n-resize', 's-resize', 'e-resize', 'w-resize', 'ne-resize', 'nw-resize', 'se-resize', 'sw-resize'].includes(current.style.cursor)\n ) {\n return true;\n }\n current = current.parentElement as HTMLElement;\n }\n return false;\n }\n\n function getElementPosition(el: HTMLElement) {\n const style = window.getComputedStyle(el);\n const matrix = new DOMMatrix(style.transform);\n return {\n x: matrix.m41 || parseInt(style.left) || 0,\n y: matrix.m42 || parseInt(style.top) || 0\n };\n }\n\n function setElementPosition(el: HTMLElement, x: number, y: number) {\n // Use transform for better performance and smoother animation\n el.style.transform = `translate(${x}px, ${y}px)`;\n }\n\n function dragMouseDown(e: MouseEvent) {\n const target = e.target as HTMLElement;\n \n // Check if the click is on a resize handle\n if (isResizeHandle(target)) {\n return; // Don't start dragging\n }\n \n // Let resize handles take priority - if we reach this point and there's a resizable container,\n // we should check if there are actual resize handles present before preventing drag\n if (element.closest('[data-resizable]')) {\n const rect = element.getBoundingClientRect();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n const handleSize = 8;\n \n // Only prevent drag if we're near an edge AND there are actual resize handles\n const nearTopEdge = y <= handleSize;\n const nearBottomEdge = y >= rect.height - handleSize;\n const nearLeftEdge = x <= handleSize;\n const nearRightEdge = x >= rect.width - handleSize;\n \n // Check if resize handles exist for the edges we're near\n const hasTopHandle = element.querySelector('.ds-resizable-resize-handle[data-placement*=\"top\"]');\n const hasBottomHandle = element.querySelector('.ds-resizable-resize-handle[data-placement*=\"bottom\"]');\n const hasLeftHandle = element.querySelector('.ds-resizable-resize-handle[data-placement*=\"left\"]');\n const hasRightHandle = element.querySelector('.ds-resizable-resize-handle[data-placement*=\"right\"]');\n \n if (\n (nearTopEdge && hasTopHandle) ||\n (nearBottomEdge && hasBottomHandle) ||\n (nearLeftEdge && hasLeftHandle) ||\n (nearRightEdge && hasRightHandle)\n ) {\n return; // Let resize handle it\n }\n }\n \n e.preventDefault();\n e.stopPropagation();\n \n isDragging = true;\n \n // Store initial mouse position\n startX = e.clientX;\n startY = e.clientY;\n \n // Get initial element position\n const pos = getElementPosition(element);\n initialLeft = pos.x;\n initialTop = pos.y;\n \n // Set initial cursor style and prevent text selection\n document.body.style.cursor = 'grabbing';\n document.body.style.userSelect = 'none';\n \n // Only disable pointer events on content areas, not buttons/interactive elements\n const interactiveElements = element.querySelectorAll('button, a, input, select, textarea, [role=\"button\"]');\n interactiveElements.forEach(el => {\n (el as HTMLElement).style.pointerEvents = 'auto';\n });\n \n // Add move and up listeners\n document.addEventListener(\"mousemove\", elementDrag, { passive: false });\n document.addEventListener(\"mouseup\", closeDragElement);\n \n // Add touch events for mobile support\n document.addEventListener(\"touchmove\", handleTouchMove, { passive: false });\n document.addEventListener(\"touchend\", closeDragElement);\n }\n\n function elementDrag(e: MouseEvent) {\n if (!isDragging || !element) return;\n \n e.preventDefault();\n \n // Cancel any previous animation frame\n if (rafId) {\n cancelAnimationFrame(rafId);\n }\n \n // Use requestAnimationFrame for smooth animation\n rafId = requestAnimationFrame(() => {\n const deltaX = e.clientX - startX;\n const deltaY = e.clientY - startY;\n \n const newX = initialLeft + deltaX;\n const newY = initialTop + deltaY;\n \n // Apply position directly without bounds checking\n setElementPosition(element, newX, newY);\n });\n }\n\n function handleTouchMove(e: TouchEvent) {\n if (!isDragging || !element) return;\n \n e.preventDefault();\n \n const touch = e.touches[0];\n if (!touch) return;\n \n // Convert touch event to mouse-like event\n const mouseEvent = new MouseEvent('mousemove', {\n clientX: touch.clientX,\n clientY: touch.clientY,\n bubbles: true\n });\n \n elementDrag(mouseEvent);\n }\n\n function closeDragElement() {\n if (!isDragging) return;\n \n isDragging = false;\n \n // Cancel any pending animation frame\n if (rafId) {\n cancelAnimationFrame(rafId);\n rafId = null;\n }\n \n // Restore styles\n document.body.style.cursor = '';\n document.body.style.userSelect = '';\n \n // Restore pointer events for interactive elements\n if (element) {\n const interactiveElements = element.querySelectorAll('button, a, input, select, textarea, [role=\"button\"]');\n interactiveElements.forEach(el => {\n (el as HTMLElement).style.pointerEvents = '';\n });\n }\n \n // Remove event listeners\n document.removeEventListener(\"mousemove\", elementDrag);\n document.removeEventListener(\"mouseup\", closeDragElement);\n document.removeEventListener(\"touchmove\", handleTouchMove);\n document.removeEventListener(\"touchend\", closeDragElement);\n }\n\n // Cleanup function\n return () => {\n element.removeEventListener(\"mousedown\", dragMouseDown);\n closeDragElement();\n };\n }, [enabled]);\n \n return { ref };\n}\n"],"names":["useDraggable","enabled","useCallback","element","isDragging","startX","startY","initialLeft","initialTop","rafId","dragMouseDown","isResizeHandle","target","current","_a","_b","getElementPosition","el","style","matrix","setElementPosition","x","y","e","rect","handleSize","nearTopEdge","nearBottomEdge","nearLeftEdge","nearRightEdge","hasTopHandle","hasBottomHandle","hasLeftHandle","hasRightHandle","pos","elementDrag","closeDragElement","handleTouchMove","deltaX","deltaY","newX","newY","touch","mouseEvent"],"mappings":";;AAGgB,SAAAA,EAAaC,IAAmB,IAAM;AAyMpD,SAAO,EAAE,KAxMGC,EAAY,CAACC,MAAgC;AACnD,QAAA,CAACA,KAAW,CAACF,EAAS;AAE1B,QAAIG,IAAa,IACbC,IAAS,GACTC,IAAS,GACTC,IAAc,GACdC,IAAa,GACbC,IAAuB;AAEnB,IAAAN,EAAA,iBAAiB,aAAaO,CAAa;AAEnD,aAASC,EAAeC,GAA8B;;AAEpD,UAAIC,IAAUD;AACP,aAAAC,KAAWA,MAAYV,KAAS;AAGnC,YAAAU,EAAQ,UAAU,SAAS,eAAe,KAC1CA,EAAQ,UAAU,SAAS,4BAA4B,KACvDA,EAAQ,aAAa,oBAAoB,MACzCC,IAAAD,EAAQ,aAAa,aAAa,MAAlC,QAAAC,EAAqC,SAAS,aAC9CD,EAAQ,aAAa,gBAAgB;AAAA,SACrCE,IAAAF,EAAQ,MAAM,WAAd,QAAAE,EAAsB,SAAS;AAAA,QAE/BF,EAAQ,UAAU,SAAS,kBAAkB,KAC7CA,EAAQ,aAAa,uBAAuB;AAAA,QAE5C,CAAC,YAAY,YAAY,YAAY,YAAY,aAAa,aAAa,aAAa,WAAW,EAAE,SAASA,EAAQ,MAAM,MAAM;AAE3H,iBAAA;AAET,QAAAA,IAAUA,EAAQ;AAAA,MAAA;AAEb,aAAA;AAAA,IAAA;AAGT,aAASG,EAAmBC,GAAiB;AACrC,YAAAC,IAAQ,O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B,GAC/C,SAAA,oBAAoB,aAAaC,CAAe,GAChD,SAAA,oBAAoB,YAAYD,CAAgB;AAAA,IAAA;AAI3D,WAAO,MAAM;AACH,MAAAjC,EAAA,oBAAoB,aAAaO,CAAa,GACrC0B,EAAA;AAAA,IACnB;AAAA,EAAA,GACC,CAACnC,CAAO,CAAC,EAEC;AACf;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState as v, useRef as E, useCallback as n } from "react";
|
|
3
|
+
function l() {
|
|
4
|
+
const [c, u] = v(!1), t = E(null), r = n(() => {
|
|
5
|
+
u(!0);
|
|
6
|
+
}, []), s = n(() => {
|
|
7
|
+
u(!1);
|
|
8
|
+
}, []);
|
|
9
|
+
return [n(
|
|
10
|
+
(e) => {
|
|
11
|
+
var o;
|
|
12
|
+
((o = t.current) == null ? void 0 : o.nodeType) === Node.ELEMENT_NODE && (t.current.removeEventListener(
|
|
13
|
+
"mouseenter",
|
|
14
|
+
r
|
|
15
|
+
), t.current.removeEventListener(
|
|
16
|
+
"mouseleave",
|
|
17
|
+
s
|
|
18
|
+
)), (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE && (e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", s)), t.current = e;
|
|
19
|
+
},
|
|
20
|
+
[r, s]
|
|
21
|
+
), c];
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
l as useHover
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=useHover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHover.js","sources":["../../../src/components/hooks/useHover.ts"],"sourcesContent":["\"use client\";\n\nimport { useState, useCallback, useRef } from \"react\";\n\nexport function useHover<T extends HTMLElement>(): [\n (node: T) => void,\n boolean\n] {\n const [hovering, setHovering] = useState(false);\n const previousNode = useRef(null);\n\n const handleMouseEnter = useCallback(() => {\n setHovering(true);\n }, []);\n\n const handleMouseLeave = useCallback(() => {\n setHovering(false);\n }, []);\n\n const customRef = useCallback(\n (node: T) => {\n if (previousNode.current?.nodeType === Node.ELEMENT_NODE) {\n previousNode.current.removeEventListener(\n \"mouseenter\",\n handleMouseEnter\n );\n previousNode.current.removeEventListener(\n \"mouseleave\",\n handleMouseLeave\n );\n }\n\n if (node?.nodeType === Node.ELEMENT_NODE) {\n node.addEventListener(\"mouseenter\", handleMouseEnter);\n node.addEventListener(\"mouseleave\", handleMouseLeave);\n }\n\n previousNode.current = node;\n },\n [handleMouseEnter, handleMouseLeave]\n );\n\n return [customRef, hovering];\n}\n"],"names":["useHover","hovering","setHovering","useState","previousNode","useRef","handleMouseEnter","useCallback","handleMouseLeave","node","_a"],"mappings":";;AAIO,SAASA,IAGd;AACA,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GACxCC,IAAeC,EAAO,IAAI,GAE1BC,IAAmBC,EAAY,MAAM;AACzC,IAAAL,EAAY,EAAI;AAAA,EAClB,GAAG,EAAE,GAECM,IAAmBD,EAAY,MAAM;AACzC,IAAAL,EAAY,EAAK;AAAA,EACnB,GAAG,EAAE;AAyBE,SAAA,CAvBWK;AAAA,IAChB,CAACE,MAAY;;AACX,QAAIC,IAAAN,EAAa,YAAb,gBAAAM,EAAsB,cAAa,KAAK,iBAC1CN,EAAa,QAAQ;AAAA,QACnB;AAAA,QACAE;AAAA,MACF,GACAF,EAAa,QAAQ;AAAA,QACnB;AAAA,QACAI;AAAA,MACF,KAGEC,KAAA,gBAAAA,EAAM,cAAa,KAAK,iBACrBA,EAAA,iBAAiB,cAAcH,CAAgB,GAC/CG,EAAA,iBAAiB,cAAcD,CAAgB,IAGtDJ,EAAa,UAAUK;AAAA,IACzB;AAAA,IACA,CAACH,GAAkBE,CAAgB;AAAA,EACrC,GAEmBP,CAAQ;AAC7B;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import * as m from "react-dom";
|
|
4
|
+
import { useIsoLayoutEffect as e } from "@base-ui-components/utils/useIsoLayoutEffect";
|
|
5
|
+
import { AnimationFrame as u } from "@base-ui-components/utils/useAnimationFrame";
|
|
6
|
+
function g(t, n = !1, f = !1) {
|
|
7
|
+
const [r, s] = c.useState(
|
|
8
|
+
t && n ? "idle" : void 0
|
|
9
|
+
), [i, a] = c.useState(t);
|
|
10
|
+
return t && !i && (a(!0), s("starting")), !t && i && r !== "ending" && !f && s("ending"), !t && !i && r === "ending" && s(void 0), e(() => {
|
|
11
|
+
if (!t && i && r !== "ending" && f) {
|
|
12
|
+
const o = u.request(() => {
|
|
13
|
+
s("ending");
|
|
14
|
+
});
|
|
15
|
+
return () => {
|
|
16
|
+
u.cancel(o);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}, [t, i, r, f]), e(() => {
|
|
20
|
+
if (!t || n)
|
|
21
|
+
return;
|
|
22
|
+
const o = u.request(() => {
|
|
23
|
+
m.flushSync(() => {
|
|
24
|
+
s(void 0);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return () => {
|
|
28
|
+
u.cancel(o);
|
|
29
|
+
};
|
|
30
|
+
}, [n, t]), e(() => {
|
|
31
|
+
if (!t || !n)
|
|
32
|
+
return;
|
|
33
|
+
t && i && r !== "idle" && s("starting");
|
|
34
|
+
const o = u.request(() => {
|
|
35
|
+
s("idle");
|
|
36
|
+
});
|
|
37
|
+
return () => {
|
|
38
|
+
u.cancel(o);
|
|
39
|
+
};
|
|
40
|
+
}, [n, t, i, s, r]), c.useMemo(
|
|
41
|
+
() => ({
|
|
42
|
+
mounted: i,
|
|
43
|
+
setMounted: a,
|
|
44
|
+
transitionStatus: r
|
|
45
|
+
}),
|
|
46
|
+
[i, r]
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
g as useTransitionStatus
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=useTransitionStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTransitionStatus.js","sources":["../../../src/components/hooks/useTransitionStatus.ts"],"sourcesContent":["\"use client\";\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { useIsoLayoutEffect } from \"@base-ui-components/utils/useIsoLayoutEffect\";\nimport { AnimationFrame } from \"@base-ui-components/utils/useAnimationFrame\";\n\nexport type TransitionStatus = \"starting\" | \"ending\" | \"idle\" | undefined;\n\n/**\n * Provides a status string for CSS animations.\n * @param open - a boolean that determines if the element is open.\n * @param enableIdleState - a boolean that enables the `'idle'` state between `'starting'` and `'ending'`\n */\nexport function useTransitionStatus(\n open: boolean,\n enableIdleState: boolean = false,\n deferEndingState: boolean = false\n) {\n const [transitionStatus, setTransitionStatus] =\n React.useState<TransitionStatus>(\n open && enableIdleState ? \"idle\" : undefined\n );\n const [mounted, setMounted] = React.useState(open);\n\n if (open && !mounted) {\n setMounted(true);\n setTransitionStatus(\"starting\");\n }\n\n if (!open && mounted && transitionStatus !== \"ending\" && !deferEndingState) {\n setTransitionStatus(\"ending\");\n }\n\n if (!open && !mounted && transitionStatus === \"ending\") {\n setTransitionStatus(undefined);\n }\n\n useIsoLayoutEffect(() => {\n if (!open && mounted && transitionStatus !== \"ending\" && deferEndingState) {\n const frame = AnimationFrame.request(() => {\n setTransitionStatus(\"ending\");\n });\n\n return () => {\n AnimationFrame.cancel(frame);\n };\n }\n\n return undefined;\n }, [open, mounted, transitionStatus, deferEndingState]);\n\n useIsoLayoutEffect(() => {\n if (!open || enableIdleState) {\n return undefined;\n }\n\n const frame = AnimationFrame.request(() => {\n ReactDOM.flushSync(() => {\n setTransitionStatus(undefined);\n });\n });\n\n return () => {\n AnimationFrame.cancel(frame);\n };\n }, [enableIdleState, open]);\n\n useIsoLayoutEffect(() => {\n if (!open || !enableIdleState) {\n return undefined;\n }\n\n if (open && mounted && transitionStatus !== \"idle\") {\n setTransitionStatus(\"starting\");\n }\n\n const frame = AnimationFrame.request(() => {\n setTransitionStatus(\"idle\");\n });\n\n return () => {\n AnimationFrame.cancel(frame);\n };\n }, [enableIdleState, open, mounted, setTransitionStatus, transitionStatus]);\n\n return React.useMemo(\n () => ({\n mounted,\n setMounted,\n transitionStatus,\n }),\n [mounted, transitionStatus]\n );\n}\n"],"names":["useTransitionStatus","open","enableIdleState","deferEndingState","transitionStatus","setTransitionStatus","React","mounted","setMounted","useIsoLayoutEffect","frame","AnimationFrame","ReactDOM"],"mappings":";;;;;AAaO,SAASA,EACdC,GACAC,IAA2B,IAC3BC,IAA4B,IAC5B;AACA,QAAM,CAACC,GAAkBC,CAAmB,IAC1CC,EAAM;AAAA,IACJL,KAAQC,IAAkB,SAAS;AAAA,EACrC,GACI,CAACK,GAASC,CAAU,IAAIF,EAAM,SAASL,CAAI;AAE7C,SAAAA,KAAQ,CAACM,MACXC,EAAW,EAAI,GACfH,EAAoB,UAAU,IAG5B,CAACJ,KAAQM,KAAWH,MAAqB,YAAY,CAACD,KACxDE,EAAoB,QAAQ,GAG1B,CAACJ,KAAQ,CAACM,KAAWH,MAAqB,YAC5CC,EAAoB,MAAS,GAG/BI,EAAmB,MAAM;AACvB,QAAI,CAACR,KAAQM,KAAWH,MAAqB,YAAYD,GAAkB;AACnE,YAAAO,IAAQC,EAAe,QAAQ,MAAM;AACzC,QAAAN,EAAoB,QAAQ;AAAA,MAAA,CAC7B;AAED,aAAO,MAAM;AACX,QAAAM,EAAe,OAAOD,CAAK;AAAA,MAC7B;AAAA,IAAA;AAAA,KAID,CAACT,GAAMM,GAASH,GAAkBD,CAAgB,CAAC,GAEtDM,EAAmB,MAAM;AACnB,QAAA,CAACR,KAAQC;AACJ;AAGH,UAAAQ,IAAQC,EAAe,QAAQ,MAAM;AACzC,MAAAC,EAAS,UAAU,MAAM;AACvB,QAAAP,EAAoB,MAAS;AAAA,MAAA,CAC9B;AAAA,IAAA,CACF;AAED,WAAO,MAAM;AACX,MAAAM,EAAe,OAAOD,CAAK;AAAA,IAC7B;AAAA,EAAA,GACC,CAACR,GAAiBD,CAAI,CAAC,GAE1BQ,EAAmB,MAAM;AACnB,QAAA,CAACR,KAAQ,CAACC;AACL;AAGL,IAAAD,KAAQM,KAAWH,MAAqB,UAC1CC,EAAoB,UAAU;AAG1B,UAAAK,IAAQC,EAAe,QAAQ,MAAM;AACzC,MAAAN,EAAoB,MAAM;AAAA,IAAA,CAC3B;AAED,WAAO,MAAM;AACX,MAAAM,EAAe,OAAOD,CAAK;AAAA,IAC7B;AAAA,EAAA,GACC,CAACR,GAAiBD,GAAMM,GAASF,GAAqBD,CAAgB,CAAC,GAEnEE,EAAM;AAAA,IACX,OAAO;AAAA,MACL,SAAAC;AAAA,MACA,YAAAC;AAAA,MACA,kBAAAJ;AAAA,IAAA;AAAA,IAEF,CAACG,GAASH,CAAgB;AAAA,EAC5B;AACF;"}
|
|
@@ -1,66 +1,70 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as t, jsxs as f } from "react/jsx-runtime";
|
|
3
3
|
import { Popover as o } from "@base-ui-components/react/popover";
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { X as
|
|
6
|
-
import { PopupPanelSize as
|
|
7
|
-
import { Stack as
|
|
4
|
+
import { useMemo as _, useRef as A, useState as B, useEffect as m, useCallback as a } from "react";
|
|
5
|
+
import { X as N } from "@bioturing/assets";
|
|
6
|
+
import { PopupPanelSize as s } from "./constants.js";
|
|
7
|
+
import { Stack as ee } from "../stack/index.js";
|
|
8
8
|
import './style.css';/* empty css */
|
|
9
|
-
import { parseAntdPlacement as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { parseAntdPlacement as te, buildAntdPlacement as re } from "../utils/placement.js";
|
|
10
|
+
import { useDraggable as ne } from "../hooks/useDraggable.js";
|
|
11
|
+
import { Resizable as ie } from "../resizable/component.js";
|
|
12
|
+
import { useControlledState as oe } from "../hooks/useControlledState.js";
|
|
13
|
+
import { useCls as pe } from "../utils/antdUtils.js";
|
|
13
14
|
import { clsx as p } from "../utils/cn.js";
|
|
14
|
-
import { IconButton as
|
|
15
|
-
const
|
|
16
|
-
children:
|
|
17
|
-
placement:
|
|
18
|
-
openOnHover:
|
|
19
|
-
open:
|
|
20
|
-
onOpenChange:
|
|
21
|
-
content:
|
|
15
|
+
import { IconButton as ue } from "../icon-button/component.js";
|
|
16
|
+
const Ce = ({
|
|
17
|
+
children: K,
|
|
18
|
+
placement: j,
|
|
19
|
+
openOnHover: E = !1,
|
|
20
|
+
open: M,
|
|
21
|
+
onOpenChange: D,
|
|
22
|
+
content: F,
|
|
22
23
|
title: h,
|
|
23
|
-
trigger:
|
|
24
|
-
className:
|
|
25
|
-
anchor:
|
|
26
|
-
beforeCloseButton:
|
|
24
|
+
trigger: T = "click",
|
|
25
|
+
className: U,
|
|
26
|
+
anchor: V,
|
|
27
|
+
beforeCloseButton: C,
|
|
27
28
|
afterCloseButton: S,
|
|
28
29
|
afterTitle: b,
|
|
29
30
|
size: v = "medium",
|
|
30
31
|
footer: l,
|
|
31
|
-
defaultOpen:
|
|
32
|
-
resizable:
|
|
32
|
+
defaultOpen: X,
|
|
33
|
+
resizable: x = !1,
|
|
34
|
+
draggable: $ = !1,
|
|
35
|
+
maintainAspectRatio: q = !1,
|
|
33
36
|
classNames: e,
|
|
34
|
-
modal:
|
|
35
|
-
closeOnClickOutside:
|
|
36
|
-
onPlacementChange: P
|
|
37
|
+
modal: G = !1,
|
|
38
|
+
closeOnClickOutside: J = !0,
|
|
39
|
+
onPlacementChange: P,
|
|
40
|
+
...L
|
|
37
41
|
}) => {
|
|
38
|
-
const [w,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const [w, z] = oe(
|
|
43
|
+
M,
|
|
44
|
+
D,
|
|
45
|
+
X ?? !1
|
|
42
46
|
// Always provide a default value to prevent undefined
|
|
43
|
-
), r =
|
|
44
|
-
|
|
45
|
-
const u =
|
|
47
|
+
), r = pe(), c = te(j), k = _(() => /* @__PURE__ */ t(N, { size: 16 }), []), H = A(null), y = A(c.side), O = A(c.align), [Q, W] = B(0);
|
|
48
|
+
m(() => {
|
|
49
|
+
const u = H.current;
|
|
46
50
|
if (!u || !w) return;
|
|
47
51
|
const g = new MutationObserver((d) => {
|
|
48
|
-
let
|
|
52
|
+
let R = !1;
|
|
49
53
|
if (d.forEach((i) => {
|
|
50
54
|
if (i.type === "attributes" && i.attributeName === "data-side") {
|
|
51
55
|
const n = u.getAttribute(i.attributeName);
|
|
52
|
-
n && n !== y.current && (y.current = n,
|
|
56
|
+
n && n !== y.current && (y.current = n, R = !0);
|
|
53
57
|
}
|
|
54
58
|
if (i.type === "attributes" && i.attributeName === "data-align") {
|
|
55
59
|
const n = u.getAttribute(i.attributeName);
|
|
56
|
-
n && n !== O.current && (O.current = n,
|
|
60
|
+
n && n !== O.current && (O.current = n, R = !0);
|
|
57
61
|
}
|
|
58
|
-
}),
|
|
59
|
-
const i =
|
|
62
|
+
}), R) {
|
|
63
|
+
const i = re({
|
|
60
64
|
side: y.current,
|
|
61
65
|
align: O.current
|
|
62
66
|
});
|
|
63
|
-
|
|
67
|
+
W((n) => n + 1), P && P(i);
|
|
64
68
|
}
|
|
65
69
|
});
|
|
66
70
|
return g.observe(u, {
|
|
@@ -71,9 +75,9 @@ const ve = ({
|
|
|
71
75
|
g.disconnect();
|
|
72
76
|
};
|
|
73
77
|
}, [P, w]);
|
|
74
|
-
const
|
|
78
|
+
const Y = a(() => /* @__PURE__ */ f("div", { className: p(r("popup-panel-header"), e == null ? void 0 : e.header), children: [
|
|
75
79
|
/* @__PURE__ */ f(
|
|
76
|
-
|
|
80
|
+
ee,
|
|
77
81
|
{
|
|
78
82
|
align: "center",
|
|
79
83
|
gap: 8,
|
|
@@ -86,11 +90,11 @@ const ve = ({
|
|
|
86
90
|
}
|
|
87
91
|
),
|
|
88
92
|
/* @__PURE__ */ f("div", { className: "flex items-center gap-2", children: [
|
|
89
|
-
|
|
93
|
+
C,
|
|
90
94
|
/* @__PURE__ */ t(
|
|
91
95
|
o.Close,
|
|
92
96
|
{
|
|
93
|
-
render: /* @__PURE__ */ t(
|
|
97
|
+
render: /* @__PURE__ */ t(ue, { children: k })
|
|
94
98
|
}
|
|
95
99
|
),
|
|
96
100
|
S
|
|
@@ -102,87 +106,72 @@ const ve = ({
|
|
|
102
106
|
] }), [
|
|
103
107
|
S,
|
|
104
108
|
b,
|
|
105
|
-
|
|
109
|
+
C,
|
|
106
110
|
r,
|
|
107
111
|
e == null ? void 0 : e.header,
|
|
108
112
|
e == null ? void 0 : e.title,
|
|
109
|
-
|
|
113
|
+
k,
|
|
110
114
|
h
|
|
111
|
-
])
|
|
115
|
+
]), { ref: Z } = ne($), I = /* @__PURE__ */ f(
|
|
116
|
+
o.Popup,
|
|
117
|
+
{
|
|
118
|
+
className: p(
|
|
119
|
+
r("popup-panel"),
|
|
120
|
+
r(`popup-panel-size-${v}`),
|
|
121
|
+
U,
|
|
122
|
+
e == null ? void 0 : e.popup
|
|
123
|
+
),
|
|
124
|
+
ref: Z,
|
|
125
|
+
children: [
|
|
126
|
+
h && Y(),
|
|
127
|
+
/* @__PURE__ */ t("div", { className: p(r("popup-panel-content"), e == null ? void 0 : e.content), children: /* @__PURE__ */ t("div", { className: r("popup-panel-content-inner"), children: F }) }),
|
|
128
|
+
l && /* @__PURE__ */ t("div", { className: p(r("popup-panel-footer"), e == null ? void 0 : e.footer), children: typeof l == "function" ? l({ close: () => z(!1) }) : l })
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
);
|
|
112
132
|
return /* @__PURE__ */ f(
|
|
113
133
|
o.Root,
|
|
114
134
|
{
|
|
115
|
-
openOnHover:
|
|
135
|
+
openOnHover: T === "hover" ? !0 : E,
|
|
116
136
|
open: w,
|
|
117
137
|
onOpenChange: (u, g, d) => {
|
|
118
|
-
(d === "outside-press" || d === "focus-out") && !
|
|
138
|
+
(d === "outside-press" || d === "focus-out") && !J || z(u, g, d);
|
|
119
139
|
},
|
|
120
|
-
modal:
|
|
140
|
+
modal: G,
|
|
141
|
+
...L,
|
|
121
142
|
children: [
|
|
122
143
|
/* @__PURE__ */ t(
|
|
123
144
|
o.Trigger,
|
|
124
145
|
{
|
|
125
|
-
render:
|
|
146
|
+
render: K,
|
|
126
147
|
className: p(r("popup-panel-trigger"), e == null ? void 0 : e.trigger)
|
|
127
148
|
}
|
|
128
149
|
),
|
|
129
150
|
/* @__PURE__ */ t(o.Portal, { children: /* @__PURE__ */ t(
|
|
130
151
|
o.Positioner,
|
|
131
152
|
{
|
|
132
|
-
ref:
|
|
153
|
+
ref: H,
|
|
133
154
|
className: p(r("popup-panel-root"), e == null ? void 0 : e.root),
|
|
134
155
|
side: c.side,
|
|
135
156
|
align: c.align,
|
|
136
157
|
sideOffset: 4,
|
|
137
|
-
anchor:
|
|
158
|
+
anchor: V,
|
|
138
159
|
style: {
|
|
139
|
-
"--size-width": v ?
|
|
160
|
+
"--size-width": v ? s[v] : void 0
|
|
140
161
|
},
|
|
141
|
-
children: /* @__PURE__ */ t(
|
|
142
|
-
|
|
162
|
+
children: x ? /* @__PURE__ */ t(
|
|
163
|
+
ie,
|
|
143
164
|
{
|
|
144
|
-
resizable:
|
|
165
|
+
resizable: x,
|
|
145
166
|
absolutePositioning: !0,
|
|
146
|
-
resetKey:
|
|
167
|
+
resetKey: Q,
|
|
168
|
+
maintainAspectRatio: q,
|
|
147
169
|
classNames: {
|
|
148
170
|
resizeHandle: e == null ? void 0 : e.resizeHandle
|
|
149
171
|
},
|
|
150
|
-
children:
|
|
151
|
-
o.Popup,
|
|
152
|
-
{
|
|
153
|
-
className: p(
|
|
154
|
-
r("popup-panel"),
|
|
155
|
-
r(`popup-panel-size-${v}`),
|
|
156
|
-
T,
|
|
157
|
-
e == null ? void 0 : e.popup
|
|
158
|
-
),
|
|
159
|
-
children: [
|
|
160
|
-
h && J(),
|
|
161
|
-
/* @__PURE__ */ t(
|
|
162
|
-
"div",
|
|
163
|
-
{
|
|
164
|
-
className: p(
|
|
165
|
-
r("popup-panel-content"),
|
|
166
|
-
e == null ? void 0 : e.content
|
|
167
|
-
),
|
|
168
|
-
children: /* @__PURE__ */ t("div", { className: r("popup-panel-content-inner"), children: M })
|
|
169
|
-
}
|
|
170
|
-
),
|
|
171
|
-
l && /* @__PURE__ */ t(
|
|
172
|
-
"div",
|
|
173
|
-
{
|
|
174
|
-
className: p(
|
|
175
|
-
r("popup-panel-footer"),
|
|
176
|
-
e == null ? void 0 : e.footer
|
|
177
|
-
),
|
|
178
|
-
children: typeof l == "function" ? l({ close: () => x(!1) }) : l
|
|
179
|
-
}
|
|
180
|
-
)
|
|
181
|
-
]
|
|
182
|
-
}
|
|
183
|
-
)
|
|
172
|
+
children: I
|
|
184
173
|
}
|
|
185
|
-
)
|
|
174
|
+
) : I
|
|
186
175
|
}
|
|
187
176
|
) })
|
|
188
177
|
]
|
|
@@ -190,6 +179,6 @@ const ve = ({
|
|
|
190
179
|
);
|
|
191
180
|
};
|
|
192
181
|
export {
|
|
193
|
-
|
|
182
|
+
Ce as PopupPanel
|
|
194
183
|
};
|
|
195
184
|
//# sourceMappingURL=component.js.map
|