@bioturing/components 0.15.2 → 0.15.3
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/DropdownMenu/component.js +131 -79
- package/dist/components/DropdownMenu/component.js.map +1 -1
- package/dist/components/DropdownMenu/style.css +1 -1
- package/dist/components/PopupPanel/component.js +151 -125
- package/dist/components/PopupPanel/component.js.map +1 -1
- package/dist/components/PopupPanel/style.css +1 -1
- package/dist/components/ScrollArea/style.css +1 -1
- package/dist/index.d.ts +56 -2
- package/package.json +2 -1
|
@@ -1,94 +1,146 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Menu as
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { useControlled as
|
|
1
|
+
import { jsxs as l, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { Menu as p } from "@base-ui-components/react/menu";
|
|
3
|
+
import { useCallback as A, useRef as E } from "react";
|
|
4
|
+
import { useControlled as R } from "@base-ui-components/react/utils";
|
|
5
5
|
import './style.css';/* empty css */
|
|
6
|
-
import { useCls as
|
|
7
|
-
import { clsx as
|
|
8
|
-
const
|
|
9
|
-
children:
|
|
10
|
-
items:
|
|
11
|
-
placement:
|
|
12
|
-
openOnHover:
|
|
13
|
-
open:
|
|
14
|
-
onOpenChange:
|
|
6
|
+
import { useCls as D, useAntdCssVarClassname as S, parseAntdPlacement as T } from "../utils/antdUtils.js";
|
|
7
|
+
import { clsx as u } from "../utils/cn.js";
|
|
8
|
+
const J = ({
|
|
9
|
+
children: M,
|
|
10
|
+
items: w,
|
|
11
|
+
placement: v,
|
|
12
|
+
openOnHover: y,
|
|
13
|
+
open: C,
|
|
14
|
+
onOpenChange: i,
|
|
15
|
+
className: L,
|
|
16
|
+
itemRender: h,
|
|
17
|
+
classNames: o
|
|
15
18
|
}) => {
|
|
16
|
-
const [
|
|
17
|
-
controlled:
|
|
19
|
+
const [P, f] = R({
|
|
20
|
+
controlled: C,
|
|
18
21
|
default: !1,
|
|
19
22
|
name: "open"
|
|
20
|
-
}),
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
+
}), x = A(
|
|
24
|
+
(n) => {
|
|
25
|
+
f(n), i == null || i(n);
|
|
23
26
|
},
|
|
24
|
-
[
|
|
25
|
-
),
|
|
27
|
+
[f, i]
|
|
28
|
+
), t = D(), b = S(), g = T(v), G = E(null), k = w.reduce((n, e) => (n.length === 0 && e.type !== "header" && n.push({
|
|
26
29
|
label: null,
|
|
27
30
|
items: []
|
|
28
|
-
}),
|
|
29
|
-
label:
|
|
31
|
+
}), e.type === "header" ? n.push({
|
|
32
|
+
label: e.title,
|
|
30
33
|
items: []
|
|
31
|
-
}) : (
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
|
|
34
|
+
}) : (e.type === "item" || e.type === "divider") && n.length > 0 && n[n.length - 1].items.push(e), n), []);
|
|
35
|
+
return /* @__PURE__ */ l(
|
|
36
|
+
p.Root,
|
|
34
37
|
{
|
|
35
|
-
openOnHover:
|
|
36
|
-
open:
|
|
37
|
-
onOpenChange:
|
|
38
|
+
openOnHover: y,
|
|
39
|
+
open: P,
|
|
40
|
+
onOpenChange: x,
|
|
38
41
|
children: [
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
|
|
41
|
-
l.Positioner,
|
|
42
|
+
/* @__PURE__ */ d(
|
|
43
|
+
p.Trigger,
|
|
42
44
|
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
render: M,
|
|
46
|
+
ref: G,
|
|
47
|
+
className: u(
|
|
48
|
+
t("dropdown-menu-trigger"),
|
|
49
|
+
o == null ? void 0 : o.trigger,
|
|
50
|
+
b
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ d(p.Portal, { children: /* @__PURE__ */ d(
|
|
55
|
+
p.Positioner,
|
|
56
|
+
{
|
|
57
|
+
side: g.placement,
|
|
58
|
+
align: g.align,
|
|
45
59
|
sideOffset: 4,
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
className: u(t("dropdown-menu-root"), o == null ? void 0 : o.root),
|
|
61
|
+
children: /* @__PURE__ */ d(
|
|
62
|
+
p.Popup,
|
|
48
63
|
{
|
|
49
|
-
className:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
e
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
64
|
+
className: u(
|
|
65
|
+
t("dropdown-menu"),
|
|
66
|
+
L,
|
|
67
|
+
o == null ? void 0 : o.popup,
|
|
68
|
+
b
|
|
69
|
+
),
|
|
70
|
+
children: k.map((n, e) => /* @__PURE__ */ l(
|
|
71
|
+
p.Group,
|
|
72
|
+
{
|
|
73
|
+
className: u(
|
|
74
|
+
t("dropdown-menu-group"),
|
|
75
|
+
o == null ? void 0 : o.group
|
|
76
|
+
),
|
|
77
|
+
children: [
|
|
78
|
+
n.label && /* @__PURE__ */ d(
|
|
79
|
+
p.GroupLabel,
|
|
80
|
+
{
|
|
81
|
+
className: u(
|
|
82
|
+
t("dropdown-menu-header"),
|
|
83
|
+
o == null ? void 0 : o.groupLabel
|
|
84
|
+
),
|
|
85
|
+
children: /* @__PURE__ */ d("span", { children: n.label })
|
|
86
|
+
},
|
|
87
|
+
e
|
|
88
|
+
),
|
|
89
|
+
n.items.map((r, I) => r.type == "item" ? /* @__PURE__ */ l(
|
|
90
|
+
p.Item,
|
|
91
|
+
{
|
|
92
|
+
className: u(
|
|
93
|
+
t("dropdown-menu-item"),
|
|
94
|
+
o == null ? void 0 : o.item
|
|
95
|
+
),
|
|
96
|
+
disabled: r.disabled,
|
|
97
|
+
"data-danger": r.danger,
|
|
98
|
+
ref: r.ref,
|
|
99
|
+
onClick: r.onClick,
|
|
100
|
+
onMouseEnter: r.onMouseEnter,
|
|
101
|
+
onMouseLeave: r.onMouseLeave,
|
|
102
|
+
onMouseOver: r.onMouseOver,
|
|
103
|
+
onMouseOut: r.onMouseOut,
|
|
104
|
+
render: h ? (j) => h(r, j) : void 0,
|
|
105
|
+
children: [
|
|
106
|
+
r.icon && /* @__PURE__ */ d(
|
|
107
|
+
"span",
|
|
108
|
+
{
|
|
109
|
+
className: u(
|
|
110
|
+
t("dropdown-menu-item-icon"),
|
|
111
|
+
o == null ? void 0 : o.itemIcon
|
|
112
|
+
),
|
|
113
|
+
children: r.icon
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ d("span", { children: r.label })
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
e + "-" + I
|
|
120
|
+
) : r.type == "divider" ? /* @__PURE__ */ d(
|
|
121
|
+
p.Separator,
|
|
122
|
+
{
|
|
123
|
+
className: u(
|
|
124
|
+
t("dropdown-menu-divider"),
|
|
125
|
+
o == null ? void 0 : o.separator
|
|
126
|
+
)
|
|
127
|
+
},
|
|
128
|
+
e
|
|
129
|
+
) : r.type == "header" ? /* @__PURE__ */ d(
|
|
130
|
+
p.GroupLabel,
|
|
131
|
+
{
|
|
132
|
+
className: u(
|
|
133
|
+
t("dropdown-menu-header"),
|
|
134
|
+
o == null ? void 0 : o.groupLabel
|
|
135
|
+
),
|
|
136
|
+
children: /* @__PURE__ */ d("span", { children: r.title })
|
|
137
|
+
},
|
|
138
|
+
e
|
|
139
|
+
) : null)
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"group" + e
|
|
143
|
+
))
|
|
92
144
|
}
|
|
93
145
|
)
|
|
94
146
|
}
|
|
@@ -98,6 +150,6 @@ const S = ({
|
|
|
98
150
|
);
|
|
99
151
|
};
|
|
100
152
|
export {
|
|
101
|
-
|
|
153
|
+
J as DropdownMenu
|
|
102
154
|
};
|
|
103
155
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/DropdownMenu/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCls,\n clsx,\n useAntdCssVarClassname,\n parseAntdPlacement,\n} from \"../utils\";\nimport { Menu } from \"@base-ui-components/react/menu\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useRef } from \"react\";\nimport { useControlled } from \"@base-ui-components/react/utils\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport type DropdownMenuItemType =\n | {\n type: \"item\";\n label?: React.ReactNode;\n disabled?: boolean;\n icon?: React.ReactNode;\n key: React.Key;\n onClick?: React.HTMLAttributes<HTMLElement>[\"onClick\"];\n onMouseEnter?: React.HTMLAttributes<HTMLElement>[\"onMouseEnter\"];\n onMouseLeave?: React.HTMLAttributes<HTMLElement>[\"onMouseLeave\"];\n onMouseOver?: React.HTMLAttributes<HTMLElement>[\"onMouseOver\"];\n onMouseOut?: React.HTMLAttributes<HTMLElement>[\"onMouseOut\"];\n danger?: boolean;\n ref?: React.Ref<HTMLElement>;\n }\n | {\n type: \"divider\";\n }\n | {\n type: \"header\";\n title?: React.ReactNode;\n };\n\nexport interface DropdownMenuProps {\n items: DropdownMenuItemType[];\n children?: React.ComponentProps<typeof Menu.Trigger>[\"render\"];\n placement?: PopoverProps[\"placement\"];\n openOnHover?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\ninterface DropdownMenuGroup {\n label: React.ReactNode | null;\n items: DropdownMenuItemType[];\n}\n\nexport const DropdownMenu = ({\n children,\n items,\n placement,\n openOnHover,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n}: DropdownMenuProps) => {\n const [open, setOpen] = useControlled({\n controlled: outsideOpen,\n default: false,\n name: \"open\",\n });\n const onOpenChange = useCallback(\n (newValue: boolean) => {\n setOpen(newValue);\n outsideOnOpenChange?.(newValue);\n },\n [setOpen, outsideOnOpenChange]\n );\n const cls = useCls();\n const antdCssVarClassname = useAntdCssVarClassname();\n const headlessUIPlacement = parseAntdPlacement(placement);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const itemGroups = items.reduce<DropdownMenuGroup[]>((acc, current) => {\n // If no groups exist yet and current item is not a header, create default group\n if (acc.length === 0 && current.type !== \"header\") {\n acc.push({\n label: null,\n items: [],\n });\n }\n\n // If it's a header, create a new group\n if (current.type === \"header\") {\n acc.push({\n label: current.title,\n items: [],\n });\n }\n // If it's an item and we have at least one group, add it to the last group's items\n else if (\n (current.type === \"item\" || current.type === \"divider\") &&\n acc.length > 0\n ) {\n acc[acc.length - 1].items.push(current);\n }\n // Skip dividers\n return acc;\n }, []);\n\n return (\n <Menu.Root\n openOnHover={openOnHover}\n open={open}\n onOpenChange={onOpenChange}\n >\n <Menu.Trigger render={children} ref={buttonRef}></Menu.Trigger>\n <Menu.Portal>\n <Menu.Positioner\n side={headlessUIPlacement.placement}\n align={headlessUIPlacement.align}\n sideOffset={4}\n >\n <Menu.Popup\n className={clsx(cls(\"dropdown-menu\"), antdCssVarClassname)}\n >\n {itemGroups.map((group, i) => {\n return (\n <Menu.Group key={\"group\" + i}>\n {group.label && (\n <Menu.GroupLabel\n key={i}\n className={cls(\"dropdown-menu-header\")}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n )}\n {group.items.map((item, j) => {\n return item.type == \"item\" ? (\n <Menu.Item\n key={i + \"-\" + j}\n className={clsx(cls(\"dropdown-menu-item\"))}\n disabled={item.disabled}\n data-danger={item.danger}\n ref={item.ref}\n onClick={item.onClick}\n onMouseEnter={item.onMouseEnter}\n onMouseLeave={item.onMouseLeave}\n onMouseOver={item.onMouseOver}\n onMouseOut={item.onMouseOut}\n >\n {item.icon && (\n <span className={cls(\"dropdown-menu-item-icon\")}>\n {item.icon}\n </span>\n )}\n <span>{item.label}</span>\n </Menu.Item>\n ) : item.type == \"divider\" ? (\n <Menu.Separator\n key={i}\n className={cls(\"dropdown-menu-divider\")}\n ></Menu.Separator>\n ) : item.type == \"header\" ? (\n <Menu.GroupLabel\n key={i}\n className={cls(\"dropdown-menu-header\")}\n >\n <span>{item.title}</span>\n </Menu.GroupLabel>\n ) : null;\n })}\n </Menu.Group>\n );\n })}\n </Menu.Popup>\n </Menu.Positioner>\n </Menu.Portal>\n </Menu.Root>\n );\n};\n"],"names":["DropdownMenu","children","items","placement","openOnHover","outsideOpen","outsideOnOpenChange","open","setOpen","useControlled","onOpenChange","useCallback","newValue","cls","useCls","antdCssVarClassname","useAntdCssVarClassname","headlessUIPlacement","parseAntdPlacement","buttonRef","useRef","itemGroups","acc","current","jsxs","Menu","jsx","clsx","group","i","item","j"],"mappings":";;;;;;;AAqDO,MAAMA,IAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAMC;AAAA,EACN,cAAcC;AAChB,MAAyB;AACvB,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAc;AAAA,IACpC,YAAYJ;AAAA,IACZ,SAAS;AAAA,IACT,MAAM;AAAA,EAAA,CACP,GACKK,IAAeC;AAAA,IACnB,CAACC,MAAsB;AACrB,MAAAJ,EAAQI,CAAQ,GAChBN,KAAA,QAAAA,EAAsBM;AAAA,IACxB;AAAA,IACA,CAACJ,GAASF,CAAmB;AAAA,EAC/B,GACMO,IAAMC,EAAO,GACbC,IAAsBC,EAAuB,GAC7CC,IAAsBC,EAAmBf,CAAS,GAClDgB,IAAYC,EAA0B,IAAI,GAC1CC,IAAanB,EAAM,OAA4B,CAAC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,EAAK;AAAA,oBAAL;AAAA,sBAEC,WAAWE,EAAKd,EAAI,oBAAoB,CAAC;AAAA,sBACzC,UAAUiB,EAAK;AAAA,sBACf,eAAaA,EAAK;AAAA,sBAClB,KAAKA,EAAK;AAAA,sBACV,SAASA,EAAK;AAAA,sBACd,cAAcA,EAAK;AAAA,sBACnB,cAAcA,EAAK;AAAA,sBACnB,aAAaA,EAAK;AAAA,sBAClB,YAAYA,EAAK;AAAA,sBAEhB,UAAA;AAAA,wBAAKA,EAAA,0BACH,QAAK,EAAA,WAAWjB,EAAI,yBAAyB,GAC3C,YAAK,KACR,CAAA;AAAA,wBAEF,gBAAAa,EAAC,QAAM,EAAA,UAAAI,EAAK,MAAM,CAAA;AAAA,sBAAA;AAAA,oBAAA;AAAA,oBAhBbD,IAAI,MAAME;AAAA,kBAAA,IAkBfD,EAAK,QAAQ,YACf,gBAAAJ;AAAA,oBAACD,EAAK;AAAA,oBAAL;AAAA,sBAEC,WAAWZ,EAAI,uBAAuB;AAAA,oBAAA;AAAA,oBADjCgB;AAAA,kBAAA,IAGLC,EAAK,QAAQ,WACf,gBAAAJ;AAAA,oBAACD,EAAK;AAAA,oBAAL;AAAA,sBAEC,WAAWZ,EAAI,sBAAsB;AAAA,sBAErC,UAAA,gBAAAa,EAAC,QAAM,EAAA,UAAAI,EAAK,MAAM,CAAA;AAAA,oBAAA;AAAA,oBAHbD;AAAA,kBAAA,IAKL,IACL;AAAA,gBAAA,EAAA,GA3Cc,UAAUA,CA4C3B,CAEH;AAAA,cAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/DropdownMenu/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCls,\n clsx,\n useAntdCssVarClassname,\n parseAntdPlacement,\n} from \"../utils\";\nimport { Menu } from \"@base-ui-components/react/menu\";\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useRef } from \"react\";\nimport { useControlled } from \"@base-ui-components/react/utils\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport type DropdownMenuItemType =\n | {\n type: \"item\";\n label?: React.ReactNode;\n disabled?: boolean;\n icon?: React.ReactNode;\n key: React.Key;\n onClick?: React.HTMLAttributes<HTMLElement>[\"onClick\"];\n onMouseEnter?: React.HTMLAttributes<HTMLElement>[\"onMouseEnter\"];\n onMouseLeave?: React.HTMLAttributes<HTMLElement>[\"onMouseLeave\"];\n onMouseOver?: React.HTMLAttributes<HTMLElement>[\"onMouseOver\"];\n onMouseOut?: React.HTMLAttributes<HTMLElement>[\"onMouseOut\"];\n danger?: boolean;\n ref?: React.Ref<HTMLElement>;\n }\n | {\n type: \"divider\";\n }\n | {\n type: \"header\";\n title?: React.ReactNode;\n };\n\nexport interface DropdownMenuProps {\n /** Array of menu items to be displayed in the dropdown */\n items: DropdownMenuItemType[];\n /** Custom render function for the trigger element */\n children?: React.ComponentProps<typeof Menu.Trigger>[\"render\"];\n /**\n * Placement of the dropdown relative to the trigger element\n * @default \"bottomLeft\"\n */\n placement?: PopoverProps[\"placement\"];\n /**\n * Whether to open the dropdown on hover instead of click\n * @default false\n */\n openOnHover?: boolean;\n /**\n * Controlled open state of the dropdown\n */\n open?: boolean;\n /**\n * Callback fired when the dropdown open state changes\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Additional CSS class for the dropdown component\n */\n className?: string;\n /**\n * Custom class names for different parts of the dropdown\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n group?: string;\n groupLabel?: string;\n item?: string;\n itemIcon?: string;\n itemText?: string;\n separator?: string;\n positioner?: string;\n };\n /**\n * Custom render function for menu items\n */\n itemRender?: (\n item: DropdownMenuItemType,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n}\n\ninterface DropdownMenuGroup {\n label: React.ReactNode | null;\n items: DropdownMenuItemType[];\n}\n\nexport const DropdownMenu = ({\n children,\n items,\n placement,\n openOnHover,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n className,\n itemRender,\n classNames,\n}: DropdownMenuProps) => {\n const [open, setOpen] = useControlled({\n controlled: outsideOpen,\n default: false,\n name: \"open\",\n });\n const onOpenChange = useCallback(\n (newValue: boolean) => {\n setOpen(newValue);\n outsideOnOpenChange?.(newValue);\n },\n [setOpen, outsideOnOpenChange]\n );\n const cls = useCls();\n const antdCssVarClassname = useAntdCssVarClassname();\n const headlessUIPlacement = parseAntdPlacement(placement);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const itemGroups = items.reduce<DropdownMenuGroup[]>((acc, current) => {\n // If no groups exist yet and current item is not a header, create default group\n if (acc.length === 0 && current.type !== \"header\") {\n acc.push({\n label: null,\n items: [],\n });\n }\n\n // If it's a header, create a new group\n if (current.type === \"header\") {\n acc.push({\n label: current.title,\n items: [],\n });\n }\n // If it's an item and we have at least one group, add it to the last group's items\n else if (\n (current.type === \"item\" || current.type === \"divider\") &&\n acc.length > 0\n ) {\n acc[acc.length - 1].items.push(current);\n }\n // Skip dividers\n return acc;\n }, []);\n\n return (\n <Menu.Root\n openOnHover={openOnHover}\n open={open}\n onOpenChange={onOpenChange}\n >\n <Menu.Trigger\n render={children}\n ref={buttonRef}\n className={clsx(\n cls(\"dropdown-menu-trigger\"),\n classNames?.trigger,\n antdCssVarClassname\n )}\n ></Menu.Trigger>\n <Menu.Portal>\n <Menu.Positioner\n side={headlessUIPlacement.placement}\n align={headlessUIPlacement.align}\n sideOffset={4}\n className={clsx(cls(\"dropdown-menu-root\"), classNames?.root)}\n >\n <Menu.Popup\n className={clsx(\n cls(\"dropdown-menu\"),\n className,\n classNames?.popup,\n antdCssVarClassname\n )}\n >\n {itemGroups.map((group, i) => {\n return (\n <Menu.Group\n key={\"group\" + i}\n className={clsx(\n cls(\"dropdown-menu-group\"),\n classNames?.group\n )}\n >\n {group.label && (\n <Menu.GroupLabel\n key={i}\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Menu.GroupLabel>\n )}\n {group.items.map((item, j) => {\n return item.type == \"item\" ? (\n <Menu.Item\n key={i + \"-\" + j}\n className={clsx(\n cls(\"dropdown-menu-item\"),\n classNames?.item\n )}\n disabled={item.disabled}\n data-danger={item.danger}\n ref={item.ref}\n onClick={item.onClick}\n onMouseEnter={item.onMouseEnter}\n onMouseLeave={item.onMouseLeave}\n onMouseOver={item.onMouseOver}\n onMouseOut={item.onMouseOut}\n render={\n itemRender\n ? (itemProps) => itemRender(item, itemProps)\n : undefined\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>{item.label}</span>\n </Menu.Item>\n ) : item.type == \"divider\" ? (\n <Menu.Separator\n key={i}\n className={clsx(\n cls(\"dropdown-menu-divider\"),\n classNames?.separator\n )}\n ></Menu.Separator>\n ) : item.type == \"header\" ? (\n <Menu.GroupLabel\n key={i}\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{item.title}</span>\n </Menu.GroupLabel>\n ) : null;\n })}\n </Menu.Group>\n );\n })}\n </Menu.Popup>\n </Menu.Positioner>\n </Menu.Portal>\n </Menu.Root>\n );\n};\n"],"names":["DropdownMenu","children","items","placement","openOnHover","outsideOpen","outsideOnOpenChange","className","itemRender","classNames","open","setOpen","useControlled","onOpenChange","useCallback","newValue","cls","useCls","antdCssVarClassname","useAntdCssVarClassname","headlessUIPlacement","parseAntdPlacement","buttonRef","useRef","itemGroups","acc","current","jsxs","Menu","jsx","clsx","group","i","item","j","itemProps"],"mappings":";;;;;;;AA+FO,MAAMA,IAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAMC;AAAA,EACN,cAAcC;AAA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-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)}.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-item{padding:.375rem .75rem;border-radius:var(--ds-border-radius-sm);transition:all .3s var(--ds-motion-ease-out);cursor:pointer;display:flex;align-items:center}.ds-dropdown-menu-item:focus{outline:none}.ds-dropdown-menu-item:hover{background:var(--ds-control-item-bg-hover)}.ds-dropdown-menu-item:active,.ds-dropdown-menu-item:focus,.ds-dropdown-menu-item[data-focus]{background:var(--ds-control-item-bg-active)}.ds-dropdown-menu-item[data-disabled]{pointer-events:none;color:var(--ds-color-text-disabled)}.ds-dropdown-menu-item[data-danger]{color:var(--ds-color-error)}.ds-dropdown-menu-item[data-danger]:hover{background:var(--ds-color-error-bg)}.ds-dropdown-menu-item[data-danger]:active,.ds-dropdown-menu-item[data-danger]:focus,.ds-dropdown-menu-item[data-danger][data-focus]{background:var(--ds-color-error-bg-hover)}.ds-dropdown-menu-item-icon{display:flex;align-items:center;justify-content:center;margin-right:.5rem;font-size:1rem;color:var(--ds-color-icon)}[data-danger] .ds-dropdown-menu-item-icon{color:var(--ds-color-error)}.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}}
|
|
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)}.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-item{padding:.375rem .75rem;border-radius:var(--ds-border-radius-sm);transition:all .3s var(--ds-motion-ease-out);cursor:pointer;display:flex;align-items:center}.ds-dropdown-menu-item:focus{outline:none}.ds-dropdown-menu-item:hover{background:var(--ds-control-item-bg-hover)}.ds-dropdown-menu-item:active,.ds-dropdown-menu-item:focus,.ds-dropdown-menu-item[data-focus]{background:var(--ds-control-item-bg-active)}.ds-dropdown-menu-item[data-disabled]{pointer-events:none;color:var(--ds-color-text-disabled)}.ds-dropdown-menu-item[data-danger]{color:var(--ds-color-error)}.ds-dropdown-menu-item[data-danger]:hover{background:var(--ds-color-error-bg)}.ds-dropdown-menu-item[data-danger]:active,.ds-dropdown-menu-item[data-danger]:focus,.ds-dropdown-menu-item[data-danger][data-focus]{background:var(--ds-color-error-bg-hover)}.ds-dropdown-menu-item-icon{display:flex;align-items:center;justify-content:center;margin-right:.5rem;font-size:1rem;color:var(--ds-color-icon)}[data-danger] .ds-dropdown-menu-item-icon{color:var(--ds-color-error)}.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}}
|
|
@@ -1,175 +1,201 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Popover as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { X as
|
|
6
|
-
import { PopupPanelSize as
|
|
7
|
-
import { useResizable as
|
|
1
|
+
import { jsx as n, jsxs as i, Fragment as m } from "react/jsx-runtime";
|
|
2
|
+
import { Popover as p } from "@base-ui-components/react/popover";
|
|
3
|
+
import { useState as l, useCallback as k, useEffect as O, useMemo as a } from "react";
|
|
4
|
+
import N from "antd/es/flex";
|
|
5
|
+
import { X as s } from "@bioturing/assets";
|
|
6
|
+
import { PopupPanelSize as ee } from "./constants.js";
|
|
7
|
+
import { useResizable as te } from "react-use-resizable";
|
|
8
|
+
import ne from "merge-refs";
|
|
8
9
|
import './style.css';/* empty css */
|
|
9
|
-
import { useControlledState as
|
|
10
|
-
import { useCls as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
const
|
|
14
|
-
children:
|
|
15
|
-
placement:
|
|
16
|
-
openOnHover:
|
|
17
|
-
open:
|
|
18
|
-
onOpenChange:
|
|
19
|
-
content:
|
|
20
|
-
title:
|
|
21
|
-
trigger:
|
|
22
|
-
className:
|
|
23
|
-
anchor:
|
|
24
|
-
beforeCloseButton:
|
|
25
|
-
afterCloseButton:
|
|
26
|
-
afterTitle:
|
|
10
|
+
import { useControlledState as re } from "../hooks/useControlledState.js";
|
|
11
|
+
import { useCls as oe, useAntdCssVarClassname as pe, parseAntdPlacement as ie } from "../utils/antdUtils.js";
|
|
12
|
+
import { clsx as o } from "../utils/cn.js";
|
|
13
|
+
import { IconButton as de } from "../IconButton/component.js";
|
|
14
|
+
const be = ({
|
|
15
|
+
children: S,
|
|
16
|
+
placement: I,
|
|
17
|
+
openOnHover: V = !1,
|
|
18
|
+
open: D,
|
|
19
|
+
onOpenChange: W,
|
|
20
|
+
content: j,
|
|
21
|
+
title: f,
|
|
22
|
+
trigger: A = "click",
|
|
23
|
+
className: E,
|
|
24
|
+
anchor: F,
|
|
25
|
+
beforeCloseButton: P,
|
|
26
|
+
afterCloseButton: C,
|
|
27
|
+
afterTitle: h,
|
|
27
28
|
size: g = "medium",
|
|
28
|
-
footer:
|
|
29
|
-
defaultOpen:
|
|
30
|
-
resizable:
|
|
29
|
+
footer: d,
|
|
30
|
+
defaultOpen: $,
|
|
31
|
+
resizable: M = !1,
|
|
32
|
+
classNames: e
|
|
31
33
|
}) => {
|
|
32
|
-
const [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const [T, H] = re(
|
|
35
|
+
D,
|
|
36
|
+
W,
|
|
37
|
+
$ ?? !1
|
|
36
38
|
// Always provide a default value to prevent undefined
|
|
37
|
-
),
|
|
38
|
-
|
|
39
|
+
), t = oe(), y = pe(), b = ie(I), [c, U] = l(null), [X, q] = l(), [G, J] = l(), K = k((r) => {
|
|
40
|
+
U(r);
|
|
39
41
|
}, []);
|
|
40
|
-
|
|
41
|
-
if (!
|
|
42
|
-
const
|
|
43
|
-
for (const
|
|
44
|
-
|
|
42
|
+
O(() => {
|
|
43
|
+
if (!c) return;
|
|
44
|
+
const r = new ResizeObserver((R) => {
|
|
45
|
+
for (const u of R)
|
|
46
|
+
q(u.contentRect.width), J(u.contentRect.height);
|
|
45
47
|
});
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
+
return r.observe(c), () => {
|
|
49
|
+
r.disconnect();
|
|
48
50
|
};
|
|
49
|
-
}, [
|
|
50
|
-
const
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
|
|
51
|
+
}, [c]);
|
|
52
|
+
const w = a(() => /* @__PURE__ */ n(s, { size: 16 }), []), L = k(() => /* @__PURE__ */ i("div", { className: o(t("popup-panel-header"), e == null ? void 0 : e.header), children: [
|
|
53
|
+
/* @__PURE__ */ i(
|
|
54
|
+
N,
|
|
53
55
|
{
|
|
54
56
|
align: "center",
|
|
55
57
|
gap: 8,
|
|
56
|
-
className:
|
|
58
|
+
className: t("popup-panel-title-wrapper"),
|
|
57
59
|
children: [
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
|
|
60
|
+
/* @__PURE__ */ n(
|
|
61
|
+
p.Title,
|
|
60
62
|
{
|
|
61
|
-
render: /* @__PURE__ */
|
|
63
|
+
render: /* @__PURE__ */ n("div", { className: o(t("grow", "truncate"), e == null ? void 0 : e.title), children: f })
|
|
62
64
|
}
|
|
63
65
|
),
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
|
|
66
|
+
/* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
67
|
+
P,
|
|
68
|
+
/* @__PURE__ */ n(
|
|
69
|
+
p.Close,
|
|
68
70
|
{
|
|
69
|
-
render: /* @__PURE__ */
|
|
71
|
+
render: /* @__PURE__ */ n(de, { children: w })
|
|
70
72
|
}
|
|
71
73
|
),
|
|
72
|
-
|
|
74
|
+
C
|
|
73
75
|
] })
|
|
74
76
|
]
|
|
75
77
|
}
|
|
76
78
|
),
|
|
77
|
-
|
|
79
|
+
h || null
|
|
78
80
|
] }), [
|
|
81
|
+
C,
|
|
79
82
|
h,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
P,
|
|
84
|
+
t,
|
|
85
|
+
e == null ? void 0 : e.header,
|
|
86
|
+
e == null ? void 0 : e.title,
|
|
87
|
+
w,
|
|
88
|
+
f
|
|
89
|
+
]), [v, x] = l(!1), { getRootProps: Q, getHandleProps: z, rootRef: Y } = te({
|
|
90
|
+
initialWidth: X,
|
|
91
|
+
initialHeight: G,
|
|
92
|
+
onDragStart: () => x(!0),
|
|
93
|
+
onDragEnd: () => x(!1)
|
|
90
94
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, [
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
96
|
-
const {
|
|
97
|
-
|
|
98
|
-
}, K = (e, l) => {
|
|
99
|
-
if (!e.current) return;
|
|
100
|
-
const { widthDiff: s } = l;
|
|
101
|
-
e.current.style.left = `${parseInt(e.current.style.left || "0") - s}px`;
|
|
95
|
+
O(() => {
|
|
96
|
+
v ? document.body.style.userSelect = "none" : document.body.style.userSelect = "";
|
|
97
|
+
}, [v]);
|
|
98
|
+
const { ref: Z, ..._ } = Q(), B = (r, R) => {
|
|
99
|
+
if (!r.current) return;
|
|
100
|
+
const { widthDiff: u } = R;
|
|
101
|
+
r.current.style.left = `${parseInt(r.current.style.left || "0") - u}px`;
|
|
102
102
|
};
|
|
103
|
-
return /* @__PURE__ */
|
|
104
|
-
|
|
103
|
+
return /* @__PURE__ */ i(
|
|
104
|
+
p.Root,
|
|
105
105
|
{
|
|
106
|
-
openOnHover:
|
|
107
|
-
open:
|
|
108
|
-
onOpenChange:
|
|
109
|
-
v(e);
|
|
110
|
-
},
|
|
111
|
-
delay: 100,
|
|
106
|
+
openOnHover: A === "hover" ? !0 : V,
|
|
107
|
+
open: T,
|
|
108
|
+
onOpenChange: H,
|
|
112
109
|
children: [
|
|
113
|
-
/* @__PURE__ */
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
/* @__PURE__ */ n(
|
|
111
|
+
p.Trigger,
|
|
112
|
+
{
|
|
113
|
+
render: S,
|
|
114
|
+
className: o(t("popup-panel-trigger"), e == null ? void 0 : e.trigger)
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ n(p.Portal, { children: /* @__PURE__ */ n(
|
|
118
|
+
p.Positioner,
|
|
116
119
|
{
|
|
117
|
-
className:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
className: o(
|
|
121
|
+
t("popup-panel-root"),
|
|
122
|
+
e == null ? void 0 : e.root,
|
|
123
|
+
y
|
|
124
|
+
),
|
|
125
|
+
side: b.placement,
|
|
126
|
+
align: b.align,
|
|
120
127
|
sideOffset: 4,
|
|
121
|
-
anchor:
|
|
128
|
+
anchor: F,
|
|
122
129
|
style: {
|
|
123
|
-
"--size-width": g ?
|
|
130
|
+
"--size-width": g ? ee[g] : void 0
|
|
124
131
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
r.Popup,
|
|
132
|
+
children: /* @__PURE__ */ i(
|
|
133
|
+
p.Popup,
|
|
128
134
|
{
|
|
129
|
-
className:
|
|
130
|
-
|
|
131
|
-
|
|
135
|
+
className: o(
|
|
136
|
+
t("popup-panel"),
|
|
137
|
+
t(`popup-panel-size-${g}`),
|
|
138
|
+
E,
|
|
139
|
+
e == null ? void 0 : e.popup,
|
|
140
|
+
y
|
|
141
|
+
),
|
|
142
|
+
ref: ne(Z, K),
|
|
143
|
+
..._,
|
|
144
|
+
...v ? { "data-resizing": !0 } : {},
|
|
132
145
|
children: [
|
|
133
|
-
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
"div",
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
f && L(),
|
|
147
|
+
/* @__PURE__ */ n(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
className: o(t("popup-panel-content"), e == null ? void 0 : e.content),
|
|
151
|
+
children: /* @__PURE__ */ n("div", { className: t("popup-panel-content-inner"), children: j })
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
d && /* @__PURE__ */ n(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
className: o(t("popup-panel-footer"), e == null ? void 0 : e.footer),
|
|
158
|
+
children: typeof d == "function" ? d({ close: () => H(!1) }) : d
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
M && /* @__PURE__ */ i(m, { children: [
|
|
162
|
+
/* @__PURE__ */ n(
|
|
149
163
|
"div",
|
|
150
164
|
{
|
|
151
|
-
className:
|
|
152
|
-
|
|
165
|
+
className: o(
|
|
166
|
+
t("popup-panel-resize-handle"),
|
|
167
|
+
e == null ? void 0 : e.resizeHandle
|
|
168
|
+
),
|
|
169
|
+
"data-placement": "bottom-left",
|
|
170
|
+
...z({
|
|
153
171
|
lockHorizontal: !0
|
|
154
172
|
})
|
|
155
173
|
}
|
|
156
174
|
),
|
|
157
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ n(
|
|
158
176
|
"div",
|
|
159
177
|
{
|
|
160
|
-
className:
|
|
161
|
-
|
|
178
|
+
className: o(
|
|
179
|
+
t("popup-panel-resize-handle"),
|
|
180
|
+
e == null ? void 0 : e.resizeHandle
|
|
181
|
+
),
|
|
182
|
+
"data-placement": "top-left",
|
|
183
|
+
...z({
|
|
162
184
|
reverse: !0,
|
|
163
185
|
lockVertical: !0,
|
|
164
|
-
onResize: (
|
|
186
|
+
onResize: (r) => B(Y, r)
|
|
165
187
|
})
|
|
166
188
|
}
|
|
167
189
|
),
|
|
168
|
-
/* @__PURE__ */
|
|
190
|
+
/* @__PURE__ */ n(
|
|
169
191
|
"div",
|
|
170
192
|
{
|
|
171
|
-
className:
|
|
172
|
-
|
|
193
|
+
className: o(
|
|
194
|
+
t("popup-panel-resize-handle"),
|
|
195
|
+
e == null ? void 0 : e.resizeHandle
|
|
196
|
+
),
|
|
197
|
+
"data-placement": "top-right",
|
|
198
|
+
...z({
|
|
173
199
|
lockVertical: !0
|
|
174
200
|
})
|
|
175
201
|
}
|
|
@@ -185,6 +211,6 @@ const ze = ({
|
|
|
185
211
|
);
|
|
186
212
|
};
|
|
187
213
|
export {
|
|
188
|
-
|
|
214
|
+
be as PopupPanel
|
|
189
215
|
};
|
|
190
216
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/PopupPanel/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCls,\n clsx,\n useAntdCssVarClassname,\n parseAntdPlacement,\n} from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport Flex from \"antd/es/flex\";\nimport { IconButton } from \"../IconButton\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState } from \"../hooks\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n > {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: (open: boolean) => void;\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const antdCssVarClassname = useAntdCssVarClassname();\n const headlessUIPlacement = parseAntdPlacement(placement);\n const triggerRef = useRef<HTMLElement>(null);\n const [popupRef, setPopupRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const callbackRef = useCallback((node: HTMLDivElement) => {\n setPopupRef(node);\n }, []);\n useEffect(() => {\n if (!popupRef) return;\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setWidth(entry.contentRect.width);\n setHeight(entry.contentRect.height);\n }\n });\n observer.observe(popupRef);\n return () => {\n observer.disconnect();\n };\n }, [popupRef]);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n const renderTitle = useCallback(() => {\n return (\n <div className={cls(\"popup-panel-header\")}>\n <Flex\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={<div className={cls(\"grow\", \"truncate\")}>{title}</div>}\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Flex>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n defaultCloseIcon,\n title,\n ]);\n const [resizing, setResizing] = useState(false);\n const { getRootProps, getHandleProps, rootRef } = useResizable({\n initialWidth: width,\n initialHeight: height,\n onDragStart: () => setResizing(true),\n onDragEnd: () => setResizing(false),\n });\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n // Handle reverse handle change\n const onReverseHandleChangeVertical = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current) return;\n const { heightDiff } = values;\n parent.current.style.top = `${\n parseInt(parent.current.style.top || \"0\") - heightDiff\n }px`;\n };\n\n // Handle reverse handle change\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(newOpen) => {\n // Ensure we're properly handling the state change\n setOpen(newOpen);\n }}\n delay={100}\n >\n <Popover.Trigger render={children} ref={triggerRef}></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n className={cls(\"popup-panel-root\")}\n side={headlessUIPlacement.placement}\n align={headlessUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n ref={callbackRef}\n >\n <Popover.Popup\n className={clsx(cls(\"popup-panel\"), antdCssVarClassname, className)}\n {...getRootProps()}\n {...(resizing ? { \"data-resizing\": true } : {})}\n >\n {/* <div ref={popupRef}> */}\n {title && renderTitle()}\n <div className={cls(\"popup-panel-content\")}>\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div className={cls(\"popup-panel-footer\")}>\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n {resizable && (\n <>\n <div\n className={cls(\"resize-handle-top\")}\n {...getHandleProps({\n reverse: true,\n lockHorizontal: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n <div\n className={cls(\"resize-handle-bottom\")}\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n <div\n className={cls(\"resize-handle-left\")}\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n <div\n className={cls(\"resize-handle-right\")}\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n </>\n )}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","open","setOpen","useControlledState","cls","useCls","antdCssVarClassname","useAntdCssVarClassname","headlessUIPlacement","parseAntdPlacement","triggerRef","useRef","popupRef","setPopupRef","useState","width","setWidth","height","setHeight","callbackRef","useCallback","node","useEffect","observer","entries","entry","defaultCloseIcon","useMemo","jsx","X","renderTitle","jsxs","Flex","Popover","IconButton","resizing","setResizing","getRootProps","getHandleProps","rootRef","useResizable","onReverseHandleChangeVertical","parent","values","heightDiff","onReverseHandleChangeHorizontal","widthDiff","newOpen","PopupPanelSize","clsx","Fragment"],"mappings":";;;;;;;;;;;;AAkFO,MAAMA,KAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AACd,MAAuB;AAEf,QAAA,CAACC,GAAMC,CAAO,IAAIC;AAAA,IACtBhB;AAAA,IACAC;AAAA,IACAW,KAAe;AAAA;AAAA,EACjB,GAEMK,IAAMC,GAAO,GACbC,IAAsBC,GAAuB,GAC7CC,IAAsBC,GAAmBxB,CAAS,GAClDyB,IAAaC,EAAoB,IAAI,GACrC,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;AAAA,sBAAA;AAAA,wBACC,WAAWxB,EAAI,sBAAsB;AAAA,wBACpC,GAAGkC,EAAe;AAAA,0BACjB,gBAAgB;AAAA,wBACjB,CAAA;AAAA,sBAAA;AAAA,oBACH;AAAA,oBACA,gBAAAV;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACC,WAAWxB,EAAI,oBAAoB;AAAA,wBAClC,GAAGkC,EAAe;AAAA,0BACjB,SAAS;AAAA,0BACT,cAAc;AAAA,0BACd,UAAU,CAACK,MACTE,EAAgCN,GAASI,CAAM;AAAA,wBAClD,CAAA;AAAA,sBAAA;AAAA,oBACH;AAAA,oBACA,gBAAAf;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACC,WAAWxB,EAAI,qBAAqB;AAAA,wBACnC,GAAGkC,EAAe;AAAA,0BACjB,cAAc;AAAA,wBACf,CAAA;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBACH,EACF,CAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/PopupPanel/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCls,\n clsx,\n useAntdCssVarClassname,\n parseAntdPlacement,\n} from \"../utils\";\nimport { Popover } from \"@base-ui-components/react/popover\";\n\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport Flex from \"antd/es/flex\";\nimport { IconButton } from \"../IconButton\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState } from \"../hooks\";\nimport { useResizable, type MoveValues } from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n > {\n /** The trigger element that opens the popup panel */\n children?: React.ComponentProps<typeof Popover.Trigger>[\"render\"];\n /** Placement of the popup panel relative to its trigger */\n placement?: PopoverProps[\"placement\"];\n /** Whether to open the popup panel on hover */\n openOnHover?: boolean;\n /** Controls the open state of the popup panel */\n open?: boolean;\n /** Callback fired when the open state changes */\n onOpenChange?: (open: boolean) => void;\n /** Content to display inside the popup panel */\n content?: React.ReactNode;\n /** Title text or element to display in the panel header */\n title?: React.ReactNode;\n /** The event that triggers the popup panel */\n /**\n * @default \"click\"\n */\n trigger?: \"click\" | \"hover\";\n /** Custom anchor element for positioning the panel */\n anchor?: Popover.Positioner.Props[\"anchor\"];\n /** Content to display before the close button */\n beforeCloseButton?: React.ReactNode;\n /** Content to display after the close button */\n afterCloseButton?: React.ReactNode;\n /** Content to display after the title */\n afterTitle?: React.ReactNode;\n /**\n * Predefined sizes for the popup panel\n * - xsmall: 320px\n * - small: 400px\n * - medium: 480px (default)\n * - large: 640px\n * - xlarge: 840px\n * @default \"medium\" for default type, \"xsmall\" for other types\n */\n size?: keyof typeof PopupPanelSize;\n /**\n * Footer content for the popup panel\n * Can be a React node or a function that returns a React node\n */\n footer?:\n | React.ReactNode\n | ((props: { close: () => void }) => React.ReactNode);\n /**\n * Whether the panel should be open by default when uncontrolled\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Whether the panel should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Custom class names for different parts of the popup panel\n * @default {}\n */\n classNames?: {\n root?: string;\n trigger?: string;\n popup?: string;\n header?: string;\n title?: string;\n content?: string;\n footer?: string;\n resizeHandle?: string;\n };\n}\n\nexport const PopupPanel = ({\n children,\n placement,\n openOnHover = false,\n open: outsideOpen,\n onOpenChange: outsideOnOpenChange,\n content,\n title,\n trigger = \"click\",\n className,\n anchor,\n beforeCloseButton,\n afterCloseButton,\n afterTitle,\n size = \"medium\",\n footer,\n defaultOpen,\n resizable = false,\n classNames,\n}: PopupPanelProps) => {\n // Use controlled state with proper initialization to prevent switching between controlled/uncontrolled\n const [open, setOpen] = useControlledState(\n outsideOpen,\n outsideOnOpenChange,\n defaultOpen ?? false // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const antdCssVarClassname = useAntdCssVarClassname();\n const headlessUIPlacement = parseAntdPlacement(placement);\n // We don't need triggerRef since we're using callbackRef for the popup\n const [popupRef, setPopupRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const callbackRef = useCallback((node: HTMLDivElement) => {\n setPopupRef(node);\n }, []);\n useEffect(() => {\n if (!popupRef) return;\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n setWidth(entry.contentRect.width);\n setHeight(entry.contentRect.height);\n }\n });\n observer.observe(popupRef);\n return () => {\n observer.disconnect();\n };\n }, [popupRef]);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Flex\n align=\"center\"\n gap={8}\n className={cls(\"popup-panel-title-wrapper\")}\n >\n <Popover.Title\n render={\n <div className={clsx(cls(\"grow\", \"truncate\"), classNames?.title)}>\n {title}\n </div>\n }\n ></Popover.Title>\n <div className=\"flex items-center gap-2\">\n {beforeCloseButton}\n <Popover.Close\n render={<IconButton>{defaultCloseIcon}</IconButton>}\n />\n {afterCloseButton}\n </div>\n </Flex>\n {afterTitle ? afterTitle : null}\n </div>\n );\n }, [\n afterCloseButton,\n afterTitle,\n beforeCloseButton,\n cls,\n classNames?.header,\n classNames?.title,\n defaultCloseIcon,\n title,\n ]);\n const [resizing, setResizing] = useState(false);\n const { getRootProps, getHandleProps, rootRef } = useResizable({\n initialWidth: width,\n initialHeight: height,\n onDragStart: () => setResizing(true),\n onDragEnd: () => setResizing(false),\n });\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n const { ref: rootRefProp, ...rootPropsWithoutRef } = getRootProps();\n // Handle reverse handle change for vertical resizing\n // Currently not used but kept for future implementation\n const _onReverseHandleChangeVertical = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current) return;\n const { heightDiff } = values;\n parent.current.style.top = `${\n parseInt(parent.current.style.top || \"0\") - heightDiff\n }px`;\n };\n\n // Handle reverse handle change\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues\n ) => {\n if (!parent.current) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={setOpen}\n >\n <Popover.Trigger\n render={children}\n className={clsx(cls(\"popup-panel-trigger\"), classNames?.trigger)}\n ></Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n className={clsx(\n cls(\"popup-panel-root\"),\n classNames?.root,\n antdCssVarClassname\n )}\n side={headlessUIPlacement.placement}\n align={headlessUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup,\n antdCssVarClassname\n )}\n ref={mergeRefs(rootRefProp, callbackRef)}\n {...rootPropsWithoutRef}\n {...(resizing ? { \"data-resizing\": true } : {})}\n >\n {/* <div ref={popupRef}> */}\n {title && renderTitle()}\n <div\n className={clsx(cls(\"popup-panel-content\"), classNames?.content)}\n >\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div\n className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}\n >\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n {resizable && (\n <>\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left\"\n {...getHandleProps({\n reverse: true,\n lockVertical: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n <div\n className={clsx(\n cls(\"popup-panel-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n </>\n )}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["PopupPanel","children","placement","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","classNames","open","setOpen","useControlledState","cls","useCls","antdCssVarClassname","useAntdCssVarClassname","headlessUIPlacement","parseAntdPlacement","popupRef","setPopupRef","useState","width","setWidth","height","setHeight","callbackRef","useCallback","node","useEffect","observer","entries","entry","defaultCloseIcon","useMemo","jsx","X","renderTitle","jsxs","clsx","Flex","Popover","IconButton","resizing","setResizing","getRootProps","getHandleProps","rootRef","useResizable","rootRefProp","rootPropsWithoutRef","onReverseHandleChangeHorizontal","parent","values","widthDiff","PopupPanelSize","mergeRefs","Fragment"],"mappings":";;;;;;;;;;;;;AAiGO,MAAMA,KAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAMC;AAAA,EACN,cAAcC;AAAA,EACd,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAC;AAAA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,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-popup-panel{box-shadow:var(--ds-box-shadow-secondary);border-radius:var(--ds-border-radius);background:var(--ds-color-bg-elevated);list-style:none;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);width:min(var(--size-width),var(--available-width));max-width:var(--available-width);max-height:var(--available-height);height:max-content;display:flex;flex-direction:column}.ds-popup-panel[data-ending-style],.ds-popup-panel[data-starting-style]{transform:scale(.9);opacity:0}.ds-popup-panel:focus{outline:none}.ds-popup-panel-header{border-bottom:1px solid var(--ds-color-split);margin-bottom:0;padding:calc(var(--ds-popup-panel-padding) / 2) var(--ds-popup-panel-padding);flex:0}.ds-popup-panel-
|
|
1
|
+
@layer components{.ds-popup-panel-root{z-index:1030}.ds-popup-panel{box-shadow:var(--ds-box-shadow-secondary);border-radius:var(--ds-border-radius);background:var(--ds-color-bg-elevated);list-style:none;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);width:min(var(--size-width),var(--available-width));max-width:var(--available-width);max-height:var(--available-height);height:max-content;display:flex;flex-direction:column}.ds-popup-panel[data-ending-style],.ds-popup-panel[data-starting-style]{transform:scale(.9);opacity:0}.ds-popup-panel:focus{outline:none}.ds-popup-panel-header{border-bottom:1px solid var(--ds-color-split);margin-bottom:0;padding:calc(var(--ds-popup-panel-padding) / 2) var(--ds-popup-panel-padding);flex:0}.ds-popup-panel-title-wrapper{font-weight:500;font-size:var(--ds-font-size);line-height:var(--ds-line-height);color:var(--ds-color-text)}.ds-popup-panel-footer{border-top:1px solid var(--ds-color-split);margin-top:0;padding:calc(var(--ds-popup-panel-padding) / 2) var(--ds-popup-panel-padding);flex:0}.ds-popup-panel-content{display:flex;flex-direction:column;flex:1;overflow:auto}.ds-popup-panel-content .ds-popup-panel-content-inner{flex:1;padding:var(--ds-popup-panel-padding)}.ds-popup-panel-resize-handle{position:absolute;padding:.5rem;color:#fff;display:block}.ds-popup-panel-resize-handle[data-placement=top-left]{left:0;top:0;width:4px;height:100%;border-top-left-radius:.5rem;border-bottom-left-radius:.5rem;align-items:center}.ds-popup-panel-resize-handle[data-placement=top-right]{right:0;top:0;width:4px;height:100%;border-top-right-radius:.5rem;border-bottom-right-radius:.5rem;align-items:center}.ds-popup-panel-resize-handle[data-placement=bottom-left]{bottom:0;width:100%;height:4px;border-bottom-left-radius:.5rem;border-bottom-right-radius:.5rem;justify-content:center}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-scroll-area{display:flex;flex-direction:column;height:100%;min-height:0;flex:1}.ds-scroll-area .ds-scroll-area-viewport{flex-shrink:1;height:100%;max-height:100%;overflow:hidden;overscroll-behavior:contain}:is(.ds-scroll-area .ds-scroll-area-viewport):focus-visible{outline-width:2px;outline-offset:4px;outline-color:var(--ds-color-primary)}.ds-scroll-area .ds-scroll-area-scrollbar{padding:.
|
|
1
|
+
@layer components{.ds-scroll-area{display:flex;flex-direction:column;height:100%;min-height:0;flex:1}.ds-scroll-area .ds-scroll-area-viewport{flex-shrink:1;height:100%;max-height:100%;overflow:hidden;overscroll-behavior:contain}:is(.ds-scroll-area .ds-scroll-area-viewport):focus-visible{outline-width:2px;outline-offset:4px;outline-color:var(--ds-color-primary)}.ds-scroll-area .ds-scroll-area-scrollbar{padding:.125rem;display:flex;justify-content:center;background-color:transparent;opacity:0;transition-property:opacity;transition-delay:.1s}:is(.ds-scroll-area .ds-scroll-area-scrollbar) .ds-scroll-area-thumb{border-radius:9999px;background-color:var(--ds-color-bg-fill-tertiary);border:1px solid var(--ds-color-border)}[data-orientation=vertical]:is(.ds-scroll-area .ds-scroll-area-scrollbar){width:.625rem}[data-orientation=vertical]:is(.ds-scroll-area .ds-scroll-area-scrollbar) .ds-scroll-area-thumb{width:100%}[data-orientation=horizontal]:is(.ds-scroll-area .ds-scroll-area-scrollbar){width:100%;height:.625rem;flex-direction:column}[data-orientation=horizontal]:is(.ds-scroll-area .ds-scroll-area-scrollbar) .ds-scroll-area-thumb{height:100%}[data-hovering]:is(.ds-scroll-area .ds-scroll-area-scrollbar){opacity:1;transition-delay:0ms;transition-duration:.2s}[data-scrolling]:is(.ds-scroll-area .ds-scroll-area-scrollbar){opacity:1;transition-delay:0ms;transition-duration:.2s}}
|
package/dist/index.d.ts
CHANGED
|
@@ -917,7 +917,7 @@ export { DrawerProps }
|
|
|
917
917
|
|
|
918
918
|
export { Dropdown }
|
|
919
919
|
|
|
920
|
-
export declare const DropdownMenu: ({ children, items, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, }: DropdownMenuProps) => JSX.Element;
|
|
920
|
+
export declare const DropdownMenu: ({ children, items, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, className, itemRender, classNames, }: DropdownMenuProps) => JSX.Element;
|
|
921
921
|
|
|
922
922
|
export declare type DropdownMenuItemType = {
|
|
923
923
|
type: "item";
|
|
@@ -940,12 +940,52 @@ export declare type DropdownMenuItemType = {
|
|
|
940
940
|
};
|
|
941
941
|
|
|
942
942
|
export declare interface DropdownMenuProps {
|
|
943
|
+
/** Array of menu items to be displayed in the dropdown */
|
|
943
944
|
items: DropdownMenuItemType[];
|
|
945
|
+
/** Custom render function for the trigger element */
|
|
944
946
|
children?: React.ComponentProps<typeof Menu_2.Trigger>["render"];
|
|
947
|
+
/**
|
|
948
|
+
* Placement of the dropdown relative to the trigger element
|
|
949
|
+
* @default "bottomLeft"
|
|
950
|
+
*/
|
|
945
951
|
placement?: PopoverProps_2["placement"];
|
|
952
|
+
/**
|
|
953
|
+
* Whether to open the dropdown on hover instead of click
|
|
954
|
+
* @default false
|
|
955
|
+
*/
|
|
946
956
|
openOnHover?: boolean;
|
|
957
|
+
/**
|
|
958
|
+
* Controlled open state of the dropdown
|
|
959
|
+
*/
|
|
947
960
|
open?: boolean;
|
|
961
|
+
/**
|
|
962
|
+
* Callback fired when the dropdown open state changes
|
|
963
|
+
*/
|
|
948
964
|
onOpenChange?: (open: boolean) => void;
|
|
965
|
+
/**
|
|
966
|
+
* Additional CSS class for the dropdown component
|
|
967
|
+
*/
|
|
968
|
+
className?: string;
|
|
969
|
+
/**
|
|
970
|
+
* Custom class names for different parts of the dropdown
|
|
971
|
+
* @default {}
|
|
972
|
+
*/
|
|
973
|
+
classNames?: {
|
|
974
|
+
root?: string;
|
|
975
|
+
trigger?: string;
|
|
976
|
+
popup?: string;
|
|
977
|
+
group?: string;
|
|
978
|
+
groupLabel?: string;
|
|
979
|
+
item?: string;
|
|
980
|
+
itemIcon?: string;
|
|
981
|
+
itemText?: string;
|
|
982
|
+
separator?: string;
|
|
983
|
+
positioner?: string;
|
|
984
|
+
};
|
|
985
|
+
/**
|
|
986
|
+
* Custom render function for menu items
|
|
987
|
+
*/
|
|
988
|
+
itemRender?: (item: DropdownMenuItemType, props: React.HTMLAttributes<HTMLElement>) => React.ReactElement;
|
|
949
989
|
}
|
|
950
990
|
|
|
951
991
|
export { DropDownProps }
|
|
@@ -1299,7 +1339,7 @@ export declare interface PopoverProps extends PopoverProps_2 {
|
|
|
1299
1339
|
arrow?: PopoverProps_2["arrow"];
|
|
1300
1340
|
}
|
|
1301
1341
|
|
|
1302
|
-
export declare const PopupPanel: ({ children, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, content, title, trigger, className, anchor, beforeCloseButton, afterCloseButton, afterTitle, size, footer, defaultOpen, resizable, }: PopupPanelProps) => JSX.Element;
|
|
1342
|
+
export declare const PopupPanel: ({ children, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, content, title, trigger, className, anchor, beforeCloseButton, afterCloseButton, afterTitle, size, footer, defaultOpen, resizable, classNames, }: PopupPanelProps) => JSX.Element;
|
|
1303
1343
|
|
|
1304
1344
|
export declare interface PopupPanelProps extends Omit<React.ComponentPropsWithRef<"div">, "title" | "content" | "children"> {
|
|
1305
1345
|
/** The trigger element that opens the popup panel */
|
|
@@ -1356,6 +1396,20 @@ export declare interface PopupPanelProps extends Omit<React.ComponentPropsWithRe
|
|
|
1356
1396
|
* @default false
|
|
1357
1397
|
*/
|
|
1358
1398
|
resizable?: boolean;
|
|
1399
|
+
/**
|
|
1400
|
+
* Custom class names for different parts of the popup panel
|
|
1401
|
+
* @default {}
|
|
1402
|
+
*/
|
|
1403
|
+
classNames?: {
|
|
1404
|
+
root?: string;
|
|
1405
|
+
trigger?: string;
|
|
1406
|
+
popup?: string;
|
|
1407
|
+
header?: string;
|
|
1408
|
+
title?: string;
|
|
1409
|
+
content?: string;
|
|
1410
|
+
footer?: string;
|
|
1411
|
+
resizeHandle?: string;
|
|
1412
|
+
};
|
|
1359
1413
|
}
|
|
1360
1414
|
|
|
1361
1415
|
declare enum PopupPanelSize {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bioturing/components",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@base-ui-components/react": "1.0.0-alpha.8",
|
|
21
21
|
"@floating-ui/react": "^0.27.8",
|
|
22
22
|
"es-toolkit": "^1.37.2",
|
|
23
|
+
"merge-refs": "^2.0.0",
|
|
23
24
|
"prism-react-renderer": "^2.4.1",
|
|
24
25
|
"rc-select": "^14.16.7",
|
|
25
26
|
"rc-table": "^7.50.4",
|