@bioturing/components 0.15.2 → 0.15.4
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/components/Table/component.js +81 -49
- package/dist/components/Table/component.js.map +1 -1
- package/dist/components/Table/style.css +1 -1
- package/dist/components/utils/antdUtils.js +31 -28
- package/dist/components/utils/antdUtils.js.map +1 -1
- package/dist/index.d.ts +67 -3
- 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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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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A;AAAA,EACF;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.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
|
+
@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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AAgB;AAAA,0BAChB,UAAU,CAACK,MACTF,EAA8BF,GAASI,CAAM;AAAA,wBAChD,CAAA;AAAA,sBAAA;AAAA,oBACH;AAAA,oBACA,gBAAAf;AAAA,sBAAC;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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AA,wBACA,kBAAe;AAAA,wBACd,GAAGqC,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 +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}}
|
|
@@ -1,68 +1,100 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { Empty as
|
|
1
|
+
import { jsx as e, jsxs as g, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
+
import t from "antd/es/table";
|
|
3
|
+
import { FunnelIcon as h, CaretUpIcon as p, CaretDownIcon as E } from "@bioturing/assets";
|
|
4
|
+
import { Empty as w } from "../Empty/component.js";
|
|
5
|
+
import { forwardRef as x, useState as j, useRef as A, useEffect as U, useCallback as M } from "react";
|
|
5
6
|
import './style.css';/* empty css */
|
|
6
|
-
import { useCls as
|
|
7
|
-
const
|
|
8
|
-
columns:
|
|
9
|
-
locale:
|
|
10
|
-
emptyDescription:
|
|
11
|
-
loading:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
import { useCls as R } from "../utils/antdUtils.js";
|
|
8
|
+
const D = ({
|
|
9
|
+
columns: f,
|
|
10
|
+
locale: N,
|
|
11
|
+
emptyDescription: C,
|
|
12
|
+
loading: l,
|
|
13
|
+
virtual: i,
|
|
14
|
+
scroll: I = {},
|
|
15
|
+
...b
|
|
16
|
+
}, r) => {
|
|
17
|
+
const c = R(), [L, d] = j(
|
|
18
|
+
i ? {} : {
|
|
19
|
+
x: "fit-content",
|
|
20
|
+
y: "fit-content"
|
|
21
|
+
}
|
|
22
|
+
), s = A(null);
|
|
23
|
+
U(() => {
|
|
24
|
+
var u;
|
|
25
|
+
if (!s.current) return;
|
|
26
|
+
const n = (u = s.current) == null ? void 0 : u.nativeElement.querySelector(
|
|
27
|
+
"." + c("table-tbody")
|
|
28
|
+
), o = new ResizeObserver((S) => {
|
|
29
|
+
for (const m of S)
|
|
30
|
+
m.target && d({
|
|
31
|
+
y: m.target.clientHeight,
|
|
32
|
+
x: m.target.clientWidth
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
return n && i && o.observe(n), () => {
|
|
36
|
+
n && i && o.disconnect();
|
|
37
|
+
};
|
|
38
|
+
}, [i, c]);
|
|
39
|
+
const T = f ? f.map((n) => ({
|
|
40
|
+
sortIcon: ({ sortOrder: o }) => /* @__PURE__ */ e(
|
|
17
41
|
"span",
|
|
18
42
|
{
|
|
19
|
-
className:
|
|
43
|
+
className: c(
|
|
20
44
|
"table-column-sort-icon",
|
|
21
45
|
o ? `table-column-sort-icon-${o}` : "table-column-sort-icon-none"
|
|
22
46
|
),
|
|
23
|
-
children: o ? o === "ascend" ? /* @__PURE__ */
|
|
24
|
-
/* @__PURE__ */
|
|
47
|
+
children: o ? o === "ascend" ? /* @__PURE__ */ e(p, { weight: "fill" }) : /* @__PURE__ */ e(E, { weight: "fill" }) : /* @__PURE__ */ g(_, { children: [
|
|
48
|
+
/* @__PURE__ */ e(p, { weight: "fill" }),
|
|
25
49
|
" ",
|
|
26
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ e(E, { weight: "fill" })
|
|
27
51
|
] })
|
|
28
52
|
}
|
|
29
53
|
),
|
|
30
|
-
filterIcon: (o) => /* @__PURE__ */
|
|
31
|
-
...
|
|
32
|
-
})) : void 0,
|
|
33
|
-
emptyText: /* @__PURE__ */
|
|
34
|
-
...
|
|
54
|
+
filterIcon: (o) => /* @__PURE__ */ e("span", { className: c("table-column-filter-icon"), children: /* @__PURE__ */ e(h, { weight: "fill" }) }),
|
|
55
|
+
...n
|
|
56
|
+
})) : void 0, y = {
|
|
57
|
+
emptyText: /* @__PURE__ */ e(w, { description: C }),
|
|
58
|
+
...N
|
|
35
59
|
};
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
spinning:
|
|
39
|
-
indicator: /* @__PURE__ */
|
|
40
|
-
} : typeof
|
|
60
|
+
let a;
|
|
61
|
+
typeof l == "boolean" ? a = {
|
|
62
|
+
spinning: l,
|
|
63
|
+
indicator: /* @__PURE__ */ e("span", { className: c("spin-loader") })
|
|
64
|
+
} : typeof l == "object" && (a = {
|
|
41
65
|
spinning: !0,
|
|
42
|
-
indicator: /* @__PURE__ */
|
|
43
|
-
...
|
|
44
|
-
})
|
|
45
|
-
|
|
66
|
+
indicator: /* @__PURE__ */ e("span", { className: c("spin-loader") }),
|
|
67
|
+
...l
|
|
68
|
+
});
|
|
69
|
+
const O = M(
|
|
70
|
+
(n) => {
|
|
71
|
+
n && (typeof r == "function" && r(n), r && typeof r == "object" && "current" in r && (r.current = n), s.current = n);
|
|
72
|
+
},
|
|
73
|
+
[r]
|
|
74
|
+
);
|
|
75
|
+
return /* @__PURE__ */ e(
|
|
76
|
+
t,
|
|
46
77
|
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
78
|
+
ref: O,
|
|
79
|
+
columns: T,
|
|
80
|
+
loading: a,
|
|
81
|
+
locale: y,
|
|
82
|
+
virtual: i,
|
|
83
|
+
scroll: { ...L, ...I },
|
|
84
|
+
...b
|
|
52
85
|
}
|
|
53
86
|
);
|
|
54
|
-
},
|
|
55
|
-
Column:
|
|
56
|
-
ColumnGroup:
|
|
57
|
-
SELECTION_COLUMN:
|
|
58
|
-
EXPAND_COLUMN:
|
|
59
|
-
SELECTION_ALL:
|
|
60
|
-
SELECTION_INVERT:
|
|
61
|
-
SELECTION_NONE:
|
|
62
|
-
Summary:
|
|
87
|
+
}, P = x(D), v = Object.assign(P, {
|
|
88
|
+
Column: t.Column,
|
|
89
|
+
ColumnGroup: t.ColumnGroup,
|
|
90
|
+
SELECTION_COLUMN: t.SELECTION_COLUMN,
|
|
91
|
+
EXPAND_COLUMN: t.EXPAND_COLUMN,
|
|
92
|
+
SELECTION_ALL: t.SELECTION_ALL,
|
|
93
|
+
SELECTION_INVERT: t.SELECTION_INVERT,
|
|
94
|
+
SELECTION_NONE: t.SELECTION_NONE,
|
|
95
|
+
Summary: t.Summary
|
|
63
96
|
});
|
|
64
97
|
export {
|
|
65
|
-
|
|
66
|
-
y as default
|
|
98
|
+
v as Table
|
|
67
99
|
};
|
|
68
100
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/Table/component.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/Table/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n default as AntTable,\n type ColumnType,\n type TableProps as AntTableProps,\n type TableRef,\n} from \"antd/es/table\";\nimport { CaretDownIcon, CaretUpIcon, FunnelIcon } from \"@bioturing/assets\";\nimport { useCls } from \"../utils\";\nimport Empty from \"../Empty/component\";\nimport { SpinProps } from \"antd/es/spin\";\nimport {\n useState,\n useEffect,\n forwardRef,\n Ref,\n ForwardedRef,\n useCallback,\n useRef,\n} from \"react\";\n\n// Import component-specific styles\nimport \"./style.css\";\n\n// Define interface with all the generic type parameters from AntTable without any\nexport interface TableProps<RecordType extends object = object>\n extends AntTableProps<RecordType> {\n /**\n * Add empty description for the table\n */\n emptyDescription?: React.ReactNode;\n /**\n * Table ref\n */\n tableRef?: React.Ref<HTMLDivElement>;\n}\n\n// Simple wrapper component with proper generics\nconst InnerInternalTable = <RecordType extends object = object>(\n {\n columns,\n locale,\n emptyDescription,\n loading,\n virtual,\n scroll: scrollProp = {},\n ...rest\n }: TableProps<RecordType>,\n ref: Ref<TableRef>\n) => {\n const cls = useCls();\n const [scroll, setScroll] = useState<TableProps[\"scroll\"]>(\n virtual\n ? {}\n : {\n x: \"fit-content\",\n y: \"fit-content\",\n }\n );\n\n const innerRef = useRef<TableRef>(null);\n\n useEffect(() => {\n if (!innerRef.current) return;\n const tbody = innerRef.current?.nativeElement.querySelector(\n \".\" + cls(\"table-tbody\")\n ) as HTMLElement;\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n if (entry.target) {\n setScroll({\n y: entry.target.clientHeight,\n x: entry.target.clientWidth,\n });\n }\n }\n });\n if (tbody && virtual) {\n resizeObserver.observe(tbody);\n }\n\n return () => {\n if (tbody && virtual) {\n resizeObserver.disconnect();\n }\n };\n }, [virtual, cls]);\n const modifiedColumns = columns\n ? columns.map((column: ColumnType<RecordType>): ColumnType<RecordType> => {\n return {\n sortIcon: ({ sortOrder }) => {\n return (\n <span\n className={cls(\n \"table-column-sort-icon\",\n sortOrder\n ? `table-column-sort-icon-${sortOrder}`\n : `table-column-sort-icon-none`\n )}\n >\n {!sortOrder ? (\n <>\n <CaretUpIcon weight=\"fill\" />{\" \"}\n <CaretDownIcon weight=\"fill\" />\n </>\n ) : sortOrder === \"ascend\" ? (\n <CaretUpIcon weight=\"fill\" />\n ) : (\n <CaretDownIcon weight=\"fill\" />\n )}\n </span>\n );\n },\n filterIcon: (_filtered) => {\n return (\n <span className={cls(\"table-column-filter-icon\")}>\n <FunnelIcon weight=\"fill\" />\n </span>\n );\n },\n ...column,\n };\n })\n : undefined;\n const modifiedLocale = {\n emptyText: <Empty description={emptyDescription} />,\n ...locale,\n };\n let spinProps: SpinProps | undefined;\n if (typeof loading === \"boolean\") {\n spinProps = {\n spinning: loading,\n indicator: <span className={cls(\"spin-loader\")} />,\n };\n } else if (typeof loading === \"object\") {\n spinProps = {\n spinning: true,\n indicator: <span className={cls(\"spin-loader\")} />,\n ...loading,\n };\n }\n const callbackRef = useCallback(\n (tableRef: TableRef) => {\n if (tableRef) {\n if (typeof ref === \"function\") {\n ref(tableRef);\n }\n if (ref && typeof ref === \"object\" && \"current\" in ref) {\n ref.current = tableRef;\n }\n innerRef.current = tableRef;\n }\n },\n [ref]\n );\n\n return (\n <AntTable\n ref={callbackRef}\n columns={modifiedColumns}\n loading={spinProps}\n locale={modifiedLocale}\n virtual={virtual}\n scroll={{ ...scroll, ...scrollProp }}\n {...rest}\n />\n );\n};\n\nconst InternalTable = forwardRef(InnerInternalTable) as <\n RecordType extends object = object\n>(\n props: TableProps<RecordType> & { ref?: ForwardedRef<TableRef> }\n) => ReturnType<typeof InnerInternalTable>;\n\n// Create the final component with all static properties\nexport const Table = Object.assign(InternalTable, {\n Column: AntTable.Column,\n ColumnGroup: AntTable.ColumnGroup,\n SELECTION_COLUMN: AntTable.SELECTION_COLUMN,\n EXPAND_COLUMN: AntTable.EXPAND_COLUMN,\n SELECTION_ALL: AntTable.SELECTION_ALL,\n SELECTION_INVERT: AntTable.SELECTION_INVERT,\n SELECTION_NONE: AntTable.SELECTION_NONE,\n Summary: AntTable.Summary,\n}) as typeof InternalTable & {\n Column: typeof AntTable.Column;\n ColumnGroup: typeof AntTable.ColumnGroup;\n SELECTION_COLUMN: typeof AntTable.SELECTION_COLUMN;\n EXPAND_COLUMN: typeof AntTable.EXPAND_COLUMN;\n SELECTION_ALL: typeof AntTable.SELECTION_ALL;\n SELECTION_INVERT: typeof AntTable.SELECTION_INVERT;\n SELECTION_NONE: typeof AntTable.SELECTION_NONE;\n Summary: typeof AntTable.Summary;\n};\n"],"names":["InnerInternalTable","columns","locale","emptyDescription","loading","virtual","scrollProp","rest","ref","cls","useCls","scroll","setScroll","useState","innerRef","useRef","useEffect","tbody","_a","resizeObserver","entries","entry","modifiedColumns","column","sortOrder","jsx","CaretUpIcon","CaretDownIcon","jsxs","Fragment","_filtered","FunnelIcon","modifiedLocale","Empty","spinProps","callbackRef","useCallback","tableRef","AntTable","InternalTable","forwardRef","Table"],"mappings":";;;;;;;AAsCA,MAAMA,IAAqB,CACzB;AAAA,EACE,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAQC,IAAa,CAAC;AAAA,EACtB,GAAGC;AACL,GACAC,MACG;AACH,QAAMC,IAAMC,EAAO,GACb,CAACC,GAAQC,CAAS,IAAIC;AAAA,IAC1BR,IACI,CAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,IAAA;AAAA,EAEX,GAEMS,IAAWC,EAAiB,IAAI;AAEtC,EAAAC,EAAU,MAAM;;AACV,QAAA,CAACF,EAAS,QAAS;AACjB,UAAAG,KAAQC,IAAAJ,EAAS,YAAT,gBAAAI,EAAkB,cAAc;AAAA,MAC5C,MAAMT,EAAI,aAAa;AAAA,OAEnBU,IAAiB,IAAI,eAAe,CAACC,MAAY;AACrD,iBAAWC,KAASD;AAClB,QAAIC,EAAM,UACET,EAAA;AAAA,UACR,GAAGS,EAAM,OAAO;AAAA,UAChB,GAAGA,EAAM,OAAO;AAAA,QAAA,CACjB;AAAA,IAEL,CACD;AACD,WAAIJ,KAASZ,KACXc,EAAe,QAAQF,CAAK,GAGvB,MAAM;AACX,MAAIA,KAASZ,KACXc,EAAe,WAAW;AAAA,IAE9B;AAAA,EAAA,GACC,CAACd,GAASI,CAAG,CAAC;AACjB,QAAMa,IAAkBrB,IACpBA,EAAQ,IAAI,CAACsB,OACJ;AAAA,IACL,UAAU,CAAC,EAAE,WAAAC,QAET,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWhB;AAAA,UACT;AAAA,UACAe,IACI,0BAA0BA,CAAS,KACnC;AAAA,QACN;AAAA,QAEC,UAACA,IAKEA,MAAc,WACf,gBAAAC,EAAAC,GAAA,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AAA,MACT,SAASY;AAAA,MACT,QAAQF;AAAA,MACR,SAAA3B;AAAA,MACA,QAAQ,EAAE,GAAGM,GAAQ,GAAGL,EAAW;AAAA,MAClC,GAAGC;AAAA,IAAA;AAAA,EACN;AAEJ,GAEMgC,IAAgBC,EAAWxC,CAAkB,GAOtCyC,IAAQ,OAAO,OAAOF,GAAe;AAAA,EAChD,QAAQD,EAAS;AAAA,EACjB,aAAaA,EAAS;AAAA,EACtB,kBAAkBA,EAAS;AAAA,EAC3B,eAAeA,EAAS;AAAA,EACxB,eAAeA,EAAS;AAAA,EACxB,kBAAkBA,EAAS;AAAA,EAC3B,gBAAgBA,EAAS;AAAA,EACzB,SAASA,EAAS;AACpB,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ds-table-column-sort-icon{display:flex;flex-direction:column}.ds-table-column-sort-icon svg{color:var(--ds-color-text-disabled);font-size:1rem}:is(.ds-table-column-sort-icon svg):hover{color:var(--ds-color-text-secondary)}.ds-table-column-sort-icon.ds-table-column-sort-icon-none svg{font-size:.75rem}.ds-table-column-sort-icon.ds-table-column-sort-icon-none>svg:first-child{margin-bottom:-2px}.ds-table-column-sort-icon.ds-table-column-sort-icon-none>svg:last-child{margin-top:-2px}.ds-table-column-filter-icon{display:flex;flex-direction:column}.ds-table-column-filter-icon svg{color:var(--ds-color-text-disabled);font-size:.875rem}:is(.ds-table-column-filter-icon svg):hover{color:var(--ds-color-text-secondary)}.ds-table-column-filter-icon.ds-table-column-filter-icon-active svg{color:var(--ds-color-primary)}.ds-table-wrapper .ds-table-ping-left .ds-table-cell-fix-left-first:after,.ds-table-wrapper .ds-table-ping-left .ds-table-cell-fix-left-last:after{box-shadow:inset 10px 0 8px -8px var(--ds-color-table-fixed-column-shadow)}.ds-table-wrapper .ds-table-ping-right .ds-table-cell-fix-right-first:after,.ds-table-wrapper .ds-table-ping-right .ds-table-cell-fix-right-last:after{box-shadow:inset -10px 0 8px -8px var(--ds-color-table-fixed-column-shadow)}.ds-table-wrapper .ds-table-ping-right:not(.ds-table-has-fix-right) .ds-table-container:after{box-shadow:inset -10px 0 8px -8px var(--ds-color-table-fixed-column-shadow)}.ds-table-wrapper .ds-table-ping-left:not(.ds-table-has-fix-left) .ds-table-container:before{box-shadow:inset 10px 0 8px -8px var(--ds-color-table-fixed-column-shadow)}.ds-table-wrapper{display:flex;flex-direction:column}.ds-table-wrapper .ds-spin-nested-loading,.ds-table-wrapper .ds-spin-container{display:flex;flex-direction:column;flex-shrink:1;flex-grow:1;min-height:0}:is(.ds-table-wrapper .ds-spin-container) .ds-table{flex-shrink:1;flex-grow:1;min-height:0}.ds-table{display:flex;flex-direction:column}.ds-table-container{flex-shrink:1;min-height:0;display:flex;flex-direction:column}.ds-table-header{flex-shrink:0}.ds-table-body{flex-shrink:1}}
|
|
1
|
+
@layer components{.ds-table-column-sort-icon{display:flex;flex-direction:column}.ds-table-column-sort-icon svg{color:var(--ds-color-text-disabled);font-size:1rem}:is(.ds-table-column-sort-icon svg):hover{color:var(--ds-color-text-secondary)}.ds-table-column-sort-icon.ds-table-column-sort-icon-none svg{font-size:.75rem}.ds-table-column-sort-icon.ds-table-column-sort-icon-none>svg:first-child{margin-bottom:-2px}.ds-table-column-sort-icon.ds-table-column-sort-icon-none>svg:last-child{margin-top:-2px}.ds-table-column-filter-icon{display:flex;flex-direction:column}.ds-table-column-filter-icon svg{color:var(--ds-color-text-disabled);font-size:.875rem}:is(.ds-table-column-filter-icon svg):hover{color:var(--ds-color-text-secondary)}.ds-table-column-filter-icon.ds-table-column-filter-icon-active svg{color:var(--ds-color-primary)}.ds-table-wrapper .ds-table-ping-left .ds-table-cell-fix-left-first:after,.ds-table-wrapper .ds-table-ping-left .ds-table-cell-fix-left-last:after{box-shadow:inset 10px 0 8px -8px var(--ds-color-table-fixed-column-shadow)}.ds-table-wrapper .ds-table-ping-right .ds-table-cell-fix-right-first:after,.ds-table-wrapper .ds-table-ping-right .ds-table-cell-fix-right-last:after{box-shadow:inset -10px 0 8px -8px var(--ds-color-table-fixed-column-shadow)}.ds-table-wrapper .ds-table-ping-right:not(.ds-table-has-fix-right) .ds-table-container:after{box-shadow:inset -10px 0 8px -8px var(--ds-color-table-fixed-column-shadow)}.ds-table-wrapper .ds-table-ping-left:not(.ds-table-has-fix-left) .ds-table-container:before{box-shadow:inset 10px 0 8px -8px var(--ds-color-table-fixed-column-shadow)}.ds-table-wrapper{display:flex;flex-direction:column}.ds-table-wrapper .ds-spin-nested-loading,.ds-table-wrapper .ds-spin-container{display:flex;flex-direction:column;flex-shrink:1;flex-grow:1;min-height:0}:is(.ds-table-wrapper .ds-spin-container) .ds-table{flex-shrink:1;flex-grow:1;min-height:0}.ds-table{display:flex;flex-direction:column}.ds-table-container{flex-shrink:1;min-height:0;display:flex;flex-direction:column}.ds-table-header{flex-shrink:0}.ds-table-body{flex-shrink:1;min-height:0;min-width:0}}
|
|
@@ -1,58 +1,61 @@
|
|
|
1
1
|
import n from "antd/es/config-provider";
|
|
2
|
-
import
|
|
3
|
-
import { useContext as i } from "react";
|
|
4
|
-
import { cx as
|
|
5
|
-
const
|
|
6
|
-
const { getPrefixCls:
|
|
7
|
-
return { getPrefixCls:
|
|
2
|
+
import c from "antd/es/theme/useToken";
|
|
3
|
+
import { useContext as i, useCallback as a } from "react";
|
|
4
|
+
import { cx as l } from "./cn.js";
|
|
5
|
+
const b = () => {
|
|
6
|
+
const { getPrefixCls: s } = i(n.ConfigContext);
|
|
7
|
+
return { getPrefixCls: s };
|
|
8
8
|
}, g = () => {
|
|
9
9
|
var t;
|
|
10
|
-
return (t =
|
|
11
|
-
},
|
|
12
|
-
const { getPrefixCls:
|
|
13
|
-
return (
|
|
10
|
+
return (t = c()[4]) == null ? void 0 : t.key;
|
|
11
|
+
}, k = () => {
|
|
12
|
+
const { getPrefixCls: s } = i(n.ConfigContext);
|
|
13
|
+
return a(
|
|
14
|
+
(...e) => l(...e).map((o) => s(o)).join(" "),
|
|
15
|
+
[s]
|
|
16
|
+
);
|
|
14
17
|
};
|
|
15
|
-
function f(
|
|
18
|
+
function f(s) {
|
|
16
19
|
const t = [];
|
|
17
20
|
let e = "";
|
|
18
|
-
for (const
|
|
19
|
-
|
|
20
|
-
return e && t.push(e), t.length > 0 ? t : [
|
|
21
|
+
for (const o of s)
|
|
22
|
+
o >= "A" && o <= "Z" ? (e && t.push(e), e = o.toLowerCase()) : e += o;
|
|
23
|
+
return e && t.push(e), t.length > 0 ? t : [s];
|
|
21
24
|
}
|
|
22
|
-
const h = (
|
|
23
|
-
const [t, e] = f(
|
|
24
|
-
let
|
|
25
|
+
const h = (s = "bottomLeft") => {
|
|
26
|
+
const [t, e] = f(s);
|
|
27
|
+
let o, r = "center";
|
|
25
28
|
if (t === "top" || t === "bottom") {
|
|
26
|
-
if (
|
|
29
|
+
if (o = t, e)
|
|
27
30
|
switch (e) {
|
|
28
31
|
case "left":
|
|
29
|
-
|
|
32
|
+
r = "start";
|
|
30
33
|
break;
|
|
31
34
|
case "right":
|
|
32
|
-
|
|
35
|
+
r = "end";
|
|
33
36
|
break;
|
|
34
37
|
}
|
|
35
38
|
} else if (t === "left" || t === "right") {
|
|
36
|
-
if (
|
|
39
|
+
if (o = t, e)
|
|
37
40
|
switch (e) {
|
|
38
41
|
case "top":
|
|
39
|
-
|
|
42
|
+
r = "start";
|
|
40
43
|
break;
|
|
41
44
|
case "bottom":
|
|
42
|
-
|
|
45
|
+
r = "end";
|
|
43
46
|
break;
|
|
44
47
|
}
|
|
45
48
|
} else
|
|
46
|
-
|
|
49
|
+
o = "bottom";
|
|
47
50
|
return {
|
|
48
|
-
placement:
|
|
49
|
-
align:
|
|
51
|
+
placement: o,
|
|
52
|
+
align: r
|
|
50
53
|
};
|
|
51
54
|
};
|
|
52
55
|
export {
|
|
53
56
|
h as parseAntdPlacement,
|
|
54
57
|
g as useAntdCssVarClassname,
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
k as useCls,
|
|
59
|
+
b as useGetPrefixCls
|
|
57
60
|
};
|
|
58
61
|
//# sourceMappingURL=antdUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antdUtils.js","sources":["../../../src/components/utils/antdUtils.ts"],"sourcesContent":["\"use client\";\nimport { default as ConfigProvider } from \"antd/es/config-provider\";\nimport useToken from \"antd/es/theme/useToken\";\nimport { useContext } from \"react\";\nimport type { ClassValue } from \"./types\";\nimport { cx } from \"./cn\";\nimport { PopoverProps } from \"antd/es/popover\";\n\nexport const useGetPrefixCls = () => {\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n return { getPrefixCls };\n};\n\n/**\n *\n * @returns the antd classname providing css variables\n */\nexport const useAntdCssVarClassname = () => {\n const token = useToken();\n return token[4]?.key;\n};\n\nexport const useCls = () => {\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n
|
|
1
|
+
{"version":3,"file":"antdUtils.js","sources":["../../../src/components/utils/antdUtils.ts"],"sourcesContent":["\"use client\";\nimport { default as ConfigProvider } from \"antd/es/config-provider\";\nimport useToken from \"antd/es/theme/useToken\";\nimport { useCallback, useContext } from \"react\";\nimport type { ClassValue } from \"./types\";\nimport { cx } from \"./cn\";\nimport { PopoverProps } from \"antd/es/popover\";\n\nexport const useGetPrefixCls = () => {\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n return { getPrefixCls };\n};\n\n/**\n *\n * @returns the antd classname providing css variables\n */\nexport const useAntdCssVarClassname = () => {\n const token = useToken();\n return token[4]?.key;\n};\n\nexport const useCls = () => {\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const cls = useCallback(\n (...args: ClassValue[]) => {\n return cx(...args)\n .map((cls) => getPrefixCls(cls))\n .join(\" \");\n },\n [getPrefixCls]\n );\n return cls;\n};\n\nfunction splitCamelCase(text: string): string[] {\n const result: string[] = [];\n let currentWord = \"\";\n\n for (const char of text) {\n if (char >= \"A\" && char <= \"Z\") {\n if (currentWord) {\n result.push(currentWord);\n }\n currentWord = char.toLowerCase();\n } else {\n currentWord += char;\n }\n }\n\n if (currentWord) {\n result.push(currentWord);\n }\n\n return result.length > 0 ? result : [text];\n}\n\nexport const parseAntdPlacement = (\n placement: PopoverProps[\"placement\"] = \"bottomLeft\"\n): {\n placement: \"top\" | \"bottom\" | \"left\" | \"right\";\n align: \"start\" | \"end\" | \"center\";\n} => {\n const [position1, position2] = splitCamelCase(placement);\n\n // Determine primary placement\n let primaryPlacement: \"top\" | \"bottom\" | \"left\" | \"right\";\n let align: \"start\" | \"end\" | \"center\" = \"center\";\n\n // First check if it's a vertical or horizontal primary placement\n if (position1 === \"top\" || position1 === \"bottom\") {\n primaryPlacement = position1;\n if (position2) {\n switch (position2) {\n case \"left\":\n align = \"start\";\n break;\n case \"right\":\n align = \"end\";\n break;\n // \"top\" or \"bottom\" as second position is invalid, defaults to center\n }\n }\n } else if (position1 === \"left\" || position1 === \"right\") {\n primaryPlacement = position1;\n if (position2) {\n switch (position2) {\n case \"top\":\n align = \"start\";\n break;\n case \"bottom\":\n align = \"end\";\n break;\n // \"left\" or \"right\" as second position is invalid, defaults to center\n }\n }\n } else {\n // Fallback for invalid placement\n primaryPlacement = \"bottom\";\n }\n\n return {\n placement: primaryPlacement,\n align,\n };\n};\n"],"names":["useGetPrefixCls","getPrefixCls","useContext","ConfigProvider","useAntdCssVarClassname","_a","useToken","useCls","useCallback","args","cx","cls","splitCamelCase","text","result","currentWord","char","parseAntdPlacement","placement","position1","position2","primaryPlacement","align"],"mappings":";;;;AAQO,MAAMA,IAAkB,MAAM;AACnC,QAAM,EAAE,cAAAC,EAAiB,IAAAC,EAAWC,EAAe,aAAa;AAChE,SAAO,EAAE,cAAAF,EAAa;AACxB,GAMaG,IAAyB,MAAM;;AAEnC,UAAAC,IADOC,EAAS,EACV,CAAC,MAAP,gBAAAD,EAAU;AACnB,GAEaE,IAAS,MAAM;AAC1B,QAAM,EAAE,cAAAN,EAAiB,IAAAC,EAAWC,EAAe,aAAa;AASzD,SARKK;AAAA,IACV,IAAIC,MACKC,EAAG,GAAGD,CAAI,EACd,IAAI,CAACE,MAAQV,EAAaU,CAAG,CAAC,EAC9B,KAAK,GAAG;AAAA,IAEb,CAACV,CAAY;AAAA,EACf;AAEF;AAEA,SAASW,EAAeC,GAAwB;AAC9C,QAAMC,IAAmB,CAAC;AAC1B,MAAIC,IAAc;AAElB,aAAWC,KAAQH;AACb,IAAAG,KAAQ,OAAOA,KAAQ,OACrBD,KACFD,EAAO,KAAKC,CAAW,GAEzBA,IAAcC,EAAK,YAAY,KAEhBD,KAAAC;AAInB,SAAID,KACFD,EAAO,KAAKC,CAAW,GAGlBD,EAAO,SAAS,IAAIA,IAAS,CAACD,CAAI;AAC3C;AAEa,MAAAI,IAAqB,CAChCC,IAAuC,iBAIpC;AACH,QAAM,CAACC,GAAWC,CAAS,IAAIR,EAAeM,CAAS;AAGnD,MAAAG,GACAC,IAAoC;AAGpC,MAAAH,MAAc,SAASA,MAAc;AAEvC,QADmBE,IAAAF,GACfC;AACF,cAAQA,GAAW;AAAA,QACjB,KAAK;AACK,UAAAE,IAAA;AACR;AAAA,QACF,KAAK;AACK,UAAAA,IAAA;AACR;AAAA,MAAA;AAAA,aAIGH,MAAc,UAAUA,MAAc;AAE/C,QADmBE,IAAAF,GACfC;AACF,cAAQA,GAAW;AAAA,QACjB,KAAK;AACK,UAAAE,IAAA;AACR;AAAA,QACF,KAAK;AACK,UAAAA,IAAA;AACR;AAAA,MAAA;AAAA;AAMa,IAAAD,IAAA;AAGd,SAAA;AAAA,IACL,WAAWA;AAAA,IACX,OAAAC;AAAA,EACF;AACF;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -160,6 +160,7 @@ import { RcFile } from 'antd/es/upload';
|
|
|
160
160
|
import * as React_2 from 'react';
|
|
161
161
|
import { ReactElement } from 'react';
|
|
162
162
|
import { ReactNode } from 'react';
|
|
163
|
+
import { Ref } from 'react';
|
|
163
164
|
import { RefAttributes } from 'react';
|
|
164
165
|
import { RefObject } from 'react';
|
|
165
166
|
import { RefSelectProps } from 'antd';
|
|
@@ -200,6 +201,7 @@ import { TableColumnType } from 'antd';
|
|
|
200
201
|
import { TablePaginationConfig } from 'antd';
|
|
201
202
|
import { TableProps } from 'antd';
|
|
202
203
|
import { TableProps as TableProps_3 } from 'antd/es/table';
|
|
204
|
+
import { TableRef } from 'antd/es/table';
|
|
203
205
|
import { TabPaneProps } from 'antd';
|
|
204
206
|
import { Tabs } from 'antd';
|
|
205
207
|
import { TabsProps } from 'antd';
|
|
@@ -917,7 +919,7 @@ export { DrawerProps }
|
|
|
917
919
|
|
|
918
920
|
export { Dropdown }
|
|
919
921
|
|
|
920
|
-
export declare const DropdownMenu: ({ children, items, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, }: DropdownMenuProps) => JSX.Element;
|
|
922
|
+
export declare const DropdownMenu: ({ children, items, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, className, itemRender, classNames, }: DropdownMenuProps) => JSX.Element;
|
|
921
923
|
|
|
922
924
|
export declare type DropdownMenuItemType = {
|
|
923
925
|
type: "item";
|
|
@@ -940,12 +942,52 @@ export declare type DropdownMenuItemType = {
|
|
|
940
942
|
};
|
|
941
943
|
|
|
942
944
|
export declare interface DropdownMenuProps {
|
|
945
|
+
/** Array of menu items to be displayed in the dropdown */
|
|
943
946
|
items: DropdownMenuItemType[];
|
|
947
|
+
/** Custom render function for the trigger element */
|
|
944
948
|
children?: React.ComponentProps<typeof Menu_2.Trigger>["render"];
|
|
949
|
+
/**
|
|
950
|
+
* Placement of the dropdown relative to the trigger element
|
|
951
|
+
* @default "bottomLeft"
|
|
952
|
+
*/
|
|
945
953
|
placement?: PopoverProps_2["placement"];
|
|
954
|
+
/**
|
|
955
|
+
* Whether to open the dropdown on hover instead of click
|
|
956
|
+
* @default false
|
|
957
|
+
*/
|
|
946
958
|
openOnHover?: boolean;
|
|
959
|
+
/**
|
|
960
|
+
* Controlled open state of the dropdown
|
|
961
|
+
*/
|
|
947
962
|
open?: boolean;
|
|
963
|
+
/**
|
|
964
|
+
* Callback fired when the dropdown open state changes
|
|
965
|
+
*/
|
|
948
966
|
onOpenChange?: (open: boolean) => void;
|
|
967
|
+
/**
|
|
968
|
+
* Additional CSS class for the dropdown component
|
|
969
|
+
*/
|
|
970
|
+
className?: string;
|
|
971
|
+
/**
|
|
972
|
+
* Custom class names for different parts of the dropdown
|
|
973
|
+
* @default {}
|
|
974
|
+
*/
|
|
975
|
+
classNames?: {
|
|
976
|
+
root?: string;
|
|
977
|
+
trigger?: string;
|
|
978
|
+
popup?: string;
|
|
979
|
+
group?: string;
|
|
980
|
+
groupLabel?: string;
|
|
981
|
+
item?: string;
|
|
982
|
+
itemIcon?: string;
|
|
983
|
+
itemText?: string;
|
|
984
|
+
separator?: string;
|
|
985
|
+
positioner?: string;
|
|
986
|
+
};
|
|
987
|
+
/**
|
|
988
|
+
* Custom render function for menu items
|
|
989
|
+
*/
|
|
990
|
+
itemRender?: (item: DropdownMenuItemType, props: React.HTMLAttributes<HTMLElement>) => React.ReactElement;
|
|
949
991
|
}
|
|
950
992
|
|
|
951
993
|
export { DropDownProps }
|
|
@@ -1067,6 +1109,8 @@ declare type IconButtonOwnProps<E extends ElementType = ElementType> = WithHrefP
|
|
|
1067
1109
|
|
|
1068
1110
|
export declare type IconButtonProps<E extends ElementType = "button"> = IconButtonOwnProps<E> & Omit<ComponentPropsWithoutRef<E>, keyof IconButtonOwnProps<E>>;
|
|
1069
1111
|
|
|
1112
|
+
declare const InnerInternalTable: <RecordType extends object = object>({ columns, locale, emptyDescription, loading, virtual, scroll: scrollProp, ...rest }: TableProps_2<RecordType>, ref: Ref<TableRef>) => JSX.Element;
|
|
1113
|
+
|
|
1070
1114
|
declare function InnerToast({ toast, }: {
|
|
1071
1115
|
toast: Toast_2.Root.ToastObject<ToastData>;
|
|
1072
1116
|
}): JSX.Element;
|
|
@@ -1100,7 +1144,9 @@ export declare interface InputProps extends InputProps_2 {
|
|
|
1100
1144
|
declare interface InternalFormProps<Values = any> extends React_2.ComponentProps<typeof default_8<Values>> {
|
|
1101
1145
|
}
|
|
1102
1146
|
|
|
1103
|
-
declare const InternalTable: <RecordType extends object = object>(
|
|
1147
|
+
declare const InternalTable: <RecordType extends object = object>(props: TableProps_2<RecordType> & {
|
|
1148
|
+
ref?: ForwardedRef<TableRef>;
|
|
1149
|
+
}) => ReturnType<typeof InnerInternalTable>;
|
|
1104
1150
|
|
|
1105
1151
|
declare type IntrinsicElement = keyof JSX_2.IntrinsicElements | JSXElementConstructor<any>;
|
|
1106
1152
|
|
|
@@ -1299,7 +1345,7 @@ export declare interface PopoverProps extends PopoverProps_2 {
|
|
|
1299
1345
|
arrow?: PopoverProps_2["arrow"];
|
|
1300
1346
|
}
|
|
1301
1347
|
|
|
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;
|
|
1348
|
+
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
1349
|
|
|
1304
1350
|
export declare interface PopupPanelProps extends Omit<React.ComponentPropsWithRef<"div">, "title" | "content" | "children"> {
|
|
1305
1351
|
/** The trigger element that opens the popup panel */
|
|
@@ -1356,6 +1402,20 @@ export declare interface PopupPanelProps extends Omit<React.ComponentPropsWithRe
|
|
|
1356
1402
|
* @default false
|
|
1357
1403
|
*/
|
|
1358
1404
|
resizable?: boolean;
|
|
1405
|
+
/**
|
|
1406
|
+
* Custom class names for different parts of the popup panel
|
|
1407
|
+
* @default {}
|
|
1408
|
+
*/
|
|
1409
|
+
classNames?: {
|
|
1410
|
+
root?: string;
|
|
1411
|
+
trigger?: string;
|
|
1412
|
+
popup?: string;
|
|
1413
|
+
header?: string;
|
|
1414
|
+
title?: string;
|
|
1415
|
+
content?: string;
|
|
1416
|
+
footer?: string;
|
|
1417
|
+
resizeHandle?: string;
|
|
1418
|
+
};
|
|
1359
1419
|
}
|
|
1360
1420
|
|
|
1361
1421
|
declare enum PopupPanelSize {
|
|
@@ -2108,6 +2168,10 @@ declare interface TableProps_2<RecordType extends object = object> extends Table
|
|
|
2108
2168
|
* Add empty description for the table
|
|
2109
2169
|
*/
|
|
2110
2170
|
emptyDescription?: React.ReactNode;
|
|
2171
|
+
/**
|
|
2172
|
+
* Table ref
|
|
2173
|
+
*/
|
|
2174
|
+
tableRef?: React.Ref<HTMLDivElement>;
|
|
2111
2175
|
}
|
|
2112
2176
|
|
|
2113
2177
|
export { TabPaneProps }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bioturing/components",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
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",
|