@bioturing/components 0.38.0 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/base-menu/index.js +3 -3
- package/dist/components/cmdk/index.d.ts +2 -2
- package/dist/components/combobox/component.js.map +1 -1
- package/dist/components/data-table/component.js +7 -7
- package/dist/components/data-table/component.js.map +1 -1
- package/dist/components/data-table/hooks.d.ts.map +1 -1
- package/dist/components/data-table/hooks.js +73 -61
- package/dist/components/data-table/hooks.js.map +1 -1
- package/dist/components/dropdown-menu/component.d.ts +4 -2
- package/dist/components/dropdown-menu/component.d.ts.map +1 -1
- package/dist/components/dropdown-menu/component.js +153 -154
- package/dist/components/dropdown-menu/component.js.map +1 -1
- package/dist/components/dropdown-menu/divider.js +6 -6
- package/dist/components/dropdown-menu/divider.js.map +1 -1
- package/dist/components/dropdown-menu/item.d.ts.map +1 -1
- package/dist/components/dropdown-menu/item.js +27 -26
- package/dist/components/dropdown-menu/item.js.map +1 -1
- package/dist/components/dropdown-menu/style.css +1 -1
- package/dist/components/dropdown-menu/types.d.ts +2 -2
- package/dist/components/dropdown-menu/types.d.ts.map +1 -1
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts.map +1 -1
- package/dist/components/dropdown-menu/useDropdownMenu.js +72 -68
- package/dist/components/dropdown-menu/useDropdownMenu.js.map +1 -1
- package/dist/components/popup-panel/component.d.ts +13 -1
- package/dist/components/popup-panel/component.d.ts.map +1 -1
- package/dist/components/popup-panel/component.js +102 -95
- package/dist/components/popup-panel/component.js.map +1 -1
- package/dist/components/toast/function.d.ts +8 -8
- package/dist/components/toast/function.d.ts.map +1 -1
- package/dist/components/toast/function.js.map +1 -1
- package/dist/components/tree/components.d.ts.map +1 -1
- package/dist/components/tree/components.js +50 -40
- package/dist/components/tree/components.js.map +1 -1
- package/dist/components/tree/style.css +1 -1
- package/dist/components/tree/types.d.ts +4 -0
- package/dist/components/tree/types.d.ts.map +1 -1
- package/dist/components/tree/useTreeCommon.d.ts +1 -0
- package/dist/components/tree/useTreeCommon.d.ts.map +1 -1
- package/dist/components/tree/useTreeCommon.js +21 -19
- package/dist/components/tree/useTreeCommon.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +4 -4
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useCallback as m, useMemo as
|
|
3
|
-
import { DropdownMenuItem as
|
|
4
|
-
import { DropdownMenuDivider as
|
|
5
|
-
import { Menu as
|
|
6
|
-
import { Command as L } from "../cmdk/index.js";
|
|
1
|
+
import { jsx as i, jsxs as w } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as m, useMemo as L } from "react";
|
|
3
|
+
import { DropdownMenuItem as I } from "./item.js";
|
|
4
|
+
import { DropdownMenuDivider as j } from "./divider.js";
|
|
5
|
+
import { Menu as v, Combobox as f } from "@base-ui-components/react";
|
|
7
6
|
import './style.css';/* empty css */
|
|
8
|
-
import { useCls as
|
|
9
|
-
import { reactNodeToString as
|
|
7
|
+
import { useCls as k } from "../utils/antdUtils.js";
|
|
8
|
+
import { reactNodeToString as x } from "../utils/reactToString.js";
|
|
10
9
|
import { clsx as d } from "../utils/cn.js";
|
|
11
|
-
const
|
|
12
|
-
items:
|
|
13
|
-
inCombobox:
|
|
10
|
+
const J = ({
|
|
11
|
+
items: s,
|
|
12
|
+
inCombobox: n = !1,
|
|
14
13
|
classNames: o = {},
|
|
15
|
-
selectedItemKeys:
|
|
16
|
-
keepOpenOnSelect:
|
|
17
|
-
showCheckbox:
|
|
18
|
-
getItemKeywords:
|
|
19
|
-
onOpenChange:
|
|
14
|
+
selectedItemKeys: h,
|
|
15
|
+
keepOpenOnSelect: a,
|
|
16
|
+
showCheckbox: G = !1,
|
|
17
|
+
getItemKeywords: b = (l) => [String(l.key), x(l.label)],
|
|
18
|
+
onOpenChange: g,
|
|
20
19
|
itemRender: y,
|
|
21
20
|
itemLabelRender: M
|
|
22
21
|
}) => {
|
|
23
|
-
const
|
|
24
|
-
(e, r,
|
|
25
|
-
|
|
22
|
+
const l = k(), p = m(
|
|
23
|
+
(e, r, t) => e.type === "item" ? /* @__PURE__ */ i(
|
|
24
|
+
I,
|
|
26
25
|
{
|
|
27
26
|
item: e,
|
|
28
|
-
inCombobox:
|
|
29
|
-
selected:
|
|
27
|
+
inCombobox: n,
|
|
28
|
+
selected: h?.includes(e.key),
|
|
30
29
|
afterSelect: () => {
|
|
31
|
-
|
|
30
|
+
a || g?.(!1);
|
|
32
31
|
},
|
|
33
32
|
itemRender: y,
|
|
34
|
-
showCheckbox:
|
|
35
|
-
getItemKeywords:
|
|
33
|
+
showCheckbox: G,
|
|
34
|
+
getItemKeywords: b,
|
|
36
35
|
itemLabelRender: M,
|
|
37
36
|
classNames: {
|
|
38
37
|
item: o.item,
|
|
@@ -40,85 +39,90 @@ const U = ({
|
|
|
40
39
|
itemSuffix: o.itemSuffix
|
|
41
40
|
}
|
|
42
41
|
},
|
|
43
|
-
r + "-" +
|
|
44
|
-
) : e.type === "divider" ? /* @__PURE__ */
|
|
45
|
-
|
|
42
|
+
r + "-" + t
|
|
43
|
+
) : e.type === "divider" ? /* @__PURE__ */ i(
|
|
44
|
+
j,
|
|
46
45
|
{
|
|
47
|
-
inCombobox:
|
|
46
|
+
inCombobox: n,
|
|
48
47
|
className: o?.divider
|
|
49
48
|
},
|
|
50
|
-
r + "-" +
|
|
49
|
+
r + "-" + t
|
|
51
50
|
) : null,
|
|
52
51
|
[
|
|
53
52
|
o,
|
|
54
53
|
y,
|
|
55
|
-
G,
|
|
56
|
-
u,
|
|
57
|
-
h,
|
|
58
|
-
s,
|
|
59
|
-
a,
|
|
60
54
|
g,
|
|
55
|
+
n,
|
|
56
|
+
a,
|
|
57
|
+
h,
|
|
58
|
+
G,
|
|
59
|
+
b,
|
|
61
60
|
M
|
|
62
61
|
]
|
|
63
|
-
),
|
|
64
|
-
(e, r) => /* @__PURE__ */
|
|
65
|
-
|
|
62
|
+
), D = m(
|
|
63
|
+
(e, r) => /* @__PURE__ */ w(
|
|
64
|
+
v.Group,
|
|
66
65
|
{
|
|
67
|
-
className: d(
|
|
66
|
+
className: d(l("dropdown-menu-group"), o?.group),
|
|
68
67
|
children: [
|
|
69
|
-
e.label && /* @__PURE__ */
|
|
70
|
-
|
|
68
|
+
e.label && /* @__PURE__ */ i(
|
|
69
|
+
v.GroupLabel,
|
|
71
70
|
{
|
|
72
71
|
className: d(
|
|
73
|
-
|
|
72
|
+
l("dropdown-menu-header"),
|
|
74
73
|
o?.groupLabel
|
|
75
74
|
),
|
|
76
|
-
children: /* @__PURE__ */
|
|
75
|
+
children: /* @__PURE__ */ i("span", { children: e.label })
|
|
77
76
|
}
|
|
78
77
|
),
|
|
79
|
-
e.items.map((
|
|
78
|
+
e.items.map((t, u) => p(t, r, u))
|
|
80
79
|
]
|
|
81
80
|
},
|
|
82
81
|
"group" + r
|
|
83
82
|
),
|
|
84
|
-
[
|
|
85
|
-
),
|
|
86
|
-
(e, r) => e.label ? /* @__PURE__ */
|
|
87
|
-
|
|
83
|
+
[l, o, p]
|
|
84
|
+
), S = m(
|
|
85
|
+
(e, r) => e.label ? /* @__PURE__ */ w(
|
|
86
|
+
f.Group,
|
|
88
87
|
{
|
|
89
|
-
className: d(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
className: d(l("dropdown-menu-group"), o?.group),
|
|
89
|
+
items: e.items,
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ i(
|
|
92
|
+
f.GroupLabel,
|
|
93
|
+
{
|
|
94
|
+
className: d(
|
|
95
|
+
l("dropdown-menu-header"),
|
|
96
|
+
o?.groupLabel
|
|
97
|
+
),
|
|
98
|
+
children: /* @__PURE__ */ i("span", { children: e.label })
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ i(f.Collection, { children: (t, u) => p(t, r, u) })
|
|
102
|
+
]
|
|
101
103
|
},
|
|
102
104
|
"group" + r
|
|
103
|
-
) : e.items.map((
|
|
104
|
-
[
|
|
105
|
+
) : e.items.map((t, u) => p(t, r, u)),
|
|
106
|
+
[l, o, p]
|
|
105
107
|
);
|
|
106
108
|
return {
|
|
107
|
-
itemGroups:
|
|
108
|
-
() =>
|
|
109
|
+
itemGroups: L(
|
|
110
|
+
() => s.reduce((e, r) => (e.length === 0 && r.type !== "header" && e.push({
|
|
109
111
|
label: null,
|
|
110
112
|
items: []
|
|
111
113
|
}), r.type === "header" ? e.push({
|
|
112
114
|
label: r.title,
|
|
113
115
|
items: []
|
|
114
|
-
}) : (r.type === "item" || r.type === "divider") && e.length > 0 && e[e.length - 1].items.push(
|
|
115
|
-
|
|
116
|
+
}) : (r.type === "item" || r.type === "divider") && e.length > 0 && e[e.length - 1].items.push({
|
|
117
|
+
...r
|
|
118
|
+
}), e), []),
|
|
119
|
+
[s]
|
|
116
120
|
),
|
|
117
|
-
renderMenuItem:
|
|
118
|
-
renderGroup:
|
|
121
|
+
renderMenuItem: p,
|
|
122
|
+
renderGroup: n ? S : D
|
|
119
123
|
};
|
|
120
124
|
};
|
|
121
125
|
export {
|
|
122
|
-
|
|
126
|
+
J as useDropdownMenu
|
|
123
127
|
};
|
|
124
128
|
//# sourceMappingURL=useDropdownMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDropdownMenu.js","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { DropdownMenuItemType, DropdownMenuGroup } from \"./types\";\nimport { DropdownMenuItem } from \"./item\";\nimport { DropdownMenuDivider } from \"./divider\";\nimport { reactNodeToString, clsx, useCls } from \"../utils\";\nimport { Menu } from \"@base-ui-components/react\";\
|
|
1
|
+
{"version":3,"file":"useDropdownMenu.js","sources":["../../../src/components/dropdown-menu/useDropdownMenu.tsx"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { DropdownMenuItemType, DropdownMenuGroup } from \"./types\";\nimport { DropdownMenuItem } from \"./item\";\nimport { DropdownMenuDivider } from \"./divider\";\nimport { reactNodeToString, clsx, useCls } from \"../utils\";\nimport { Combobox, Menu } from \"@base-ui-components/react\";\n\nimport \"./style.css\";\n\nexport interface UseDropdownMenuProps {\n /**\n * Callback function to handle the open state change of the dropdown menu.\n */\n onOpenChange?: (open: boolean) => void;\n items: DropdownMenuItemType[];\n inCombobox?: boolean;\n classNames?: {\n item?: string;\n itemIcon?: string;\n itemSuffix?: string;\n group?: string;\n groupLabel?: string;\n divider?: 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 * Custom render function for menu item labels\n */\n itemLabelRender?: (\n item: DropdownMenuItemType & { type: \"item\" },\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /**\n * Whether to keep the dropdown open when an item is selected\n * @default false\n */\n keepOpenOnSelect?: boolean;\n /**\n * Control the highlighted state of the menu item\n */\n highlightedItemKey?: React.Key;\n /**\n * Control the selected state of the menu item\n */\n selectedItemKeys?: React.Key[];\n /**\n * Whether to show checkbox\n * @default false\n */\n showCheckbox?: boolean;\n /**\n * Function to extract keywords from the item for search filtering\n * @default (item) => [String(item.key), reactNodeToString(item.label)]\n */\n getItemKeywords?: (item: DropdownMenuItemType & { type: \"item\" }) => string[];\n}\n\nexport const useDropdownMenu = ({\n items,\n inCombobox = false,\n classNames = {},\n selectedItemKeys,\n keepOpenOnSelect,\n showCheckbox = false,\n getItemKeywords = (item) => [String(item.key), reactNodeToString(item.label)],\n onOpenChange,\n itemRender,\n itemLabelRender,\n}: UseDropdownMenuProps) => {\n const cls = useCls();\n const renderMenuItem = useCallback(\n (item: DropdownMenuItemType, i: number, j: number) => {\n if (item.type === \"item\") {\n return (\n <DropdownMenuItem\n key={i + \"-\" + j}\n item={item}\n inCombobox={inCombobox}\n selected={selectedItemKeys?.includes(item.key)}\n afterSelect={() => {\n if (!keepOpenOnSelect) onOpenChange?.(false);\n }}\n itemRender={itemRender}\n showCheckbox={showCheckbox}\n getItemKeywords={getItemKeywords}\n itemLabelRender={itemLabelRender}\n classNames={{\n item: classNames.item,\n itemIcon: classNames.itemIcon,\n itemSuffix: classNames.itemSuffix,\n }}\n />\n );\n } else if (item.type === \"divider\") {\n return (\n <DropdownMenuDivider\n key={i + \"-\" + j}\n inCombobox={inCombobox}\n className={classNames?.divider}\n />\n );\n }\n return null;\n },\n [\n classNames,\n itemRender,\n onOpenChange,\n inCombobox,\n keepOpenOnSelect,\n selectedItemKeys,\n showCheckbox,\n getItemKeywords,\n itemLabelRender,\n ]\n );\n\n const renderGroup = useCallback(\n (group: DropdownMenuGroup, index: number) => (\n <Menu.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n >\n {group.label && (\n <Menu.GroupLabel\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) => renderMenuItem(item, index, j))}\n </Menu.Group>\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const renderGroupCombobox = useCallback(\n (group: DropdownMenuGroup, index: number) =>\n group.label ? (\n <Combobox.Group\n key={\"group\" + index}\n className={clsx(cls(\"dropdown-menu-group\"), classNames?.group)}\n items={group.items}\n >\n <Combobox.GroupLabel\n className={clsx(\n cls(\"dropdown-menu-header\"),\n classNames?.groupLabel\n )}\n >\n <span>{group.label}</span>\n </Combobox.GroupLabel>\n <Combobox.Collection>\n {(item, i) => renderMenuItem(item, index, i)}\n </Combobox.Collection>\n </Combobox.Group>\n ) : (\n group.items.map((item, j) => renderMenuItem(item, index, j))\n ),\n [cls, classNames, renderMenuItem]\n );\n\n const itemGroups = useMemo(\n () =>\n 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({\n ...current,\n });\n }\n // Skip dividers\n return acc;\n }, []),\n [items]\n );\n return {\n itemGroups,\n renderMenuItem,\n renderGroup: inCombobox ? renderGroupCombobox : renderGroup,\n };\n};\n"],"names":["useDropdownMenu","items","inCombobox","classNames","selectedItemKeys","keepOpenOnSelect","showCheckbox","getItemKeywords","item","reactNodeToString","onOpenChange","itemRender","itemLabelRender","cls","useCls","renderMenuItem","useCallback","i","j","jsx","DropdownMenuItem","DropdownMenuDivider","renderGroup","group","index","jsxs","Menu","clsx","renderGroupCombobox","Combobox","useMemo","acc","current"],"mappings":";;;;;;;;;AA+DO,MAAMA,IAAkB,CAAC;AAAA,EAC9B,OAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,YAAAC,IAAa,CAAA;AAAA,EACb,kBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,iBAAAC,IAAkB,CAACC,MAAS,CAAC,OAAOA,EAAK,GAAG,GAAGC,EAAkBD,EAAK,KAAK,CAAC;AAAA,EAC5E,cAAAE;AAAA,EACA,YAAAC;AAAA,EACA,iBAAAC;AACF,MAA4B;AAC1B,QAAMC,IAAMC,EAAA,GACNC,IAAiBC;AAAA,IACrB,CAACR,GAA4BS,GAAWC,MAClCV,EAAK,SAAS,SAEd,gBAAAW;AAAA,MAACC;AAAA,MAAA;AAAA,QAEC,MAAAZ;AAAA,QACA,YAAAN;AAAA,QACA,UAAUE,GAAkB,SAASI,EAAK,GAAG;AAAA,QAC7C,aAAa,MAAM;AACjB,UA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a0B,IAAsBN;AAAA,EAAA;AAEpD;"}
|
|
@@ -95,6 +95,18 @@ export interface PopupPanelProps extends Omit<React.ComponentPropsWithRef<"div">
|
|
|
95
95
|
* Callback function when the placement changes
|
|
96
96
|
*/
|
|
97
97
|
onPlacementChange?: (placement: PopoverProps["placement"]) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Props to pass to the positioner
|
|
100
|
+
*/
|
|
101
|
+
positionerProps?: Popover.Positioner.Props;
|
|
102
|
+
/**
|
|
103
|
+
* Props to pass to the trigger
|
|
104
|
+
*/
|
|
105
|
+
triggerProps?: Popover.Trigger.Props;
|
|
106
|
+
/**
|
|
107
|
+
* Props to pass to the portal
|
|
108
|
+
*/
|
|
109
|
+
portalProps?: Popover.Portal.Props;
|
|
98
110
|
}
|
|
99
|
-
export declare const PopupPanel: ({ children, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, content, title, trigger, className, anchor, beforeCloseButton, afterCloseButton, afterTitle, size, footer, defaultOpen, resizable, draggable, maintainAspectRatio, classNames, modal, closeOnClickOutside, onPlacementChange, ...rest }: PopupPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
111
|
+
export declare const PopupPanel: ({ children, placement, openOnHover, open: outsideOpen, onOpenChange: outsideOnOpenChange, content, title, trigger, className, anchor, beforeCloseButton, afterCloseButton, afterTitle, size, footer, defaultOpen, resizable, draggable, maintainAspectRatio, classNames, modal, closeOnClickOutside, onPlacementChange, positionerProps, triggerProps, portalProps, ...rest }: PopupPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
100
112
|
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/popup-panel/component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/popup-panel/component.tsx"],"names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AC,KAAK,CAAC;CACpC;AAED,eAAO,MAAM,UAAU,GAAI,+WA4BxB,eAAe,4CAkNjB,CAAC"}
|
|
@@ -1,86 +1,90 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e, jsxs as c } from "react/jsx-runtime";
|
|
3
3
|
import { Popover as a } from "@base-ui-components/react/popover";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { mergeProps as S } from "@base-ui-components/react";
|
|
5
|
+
import { X as re } from "@bioturing/assets";
|
|
6
|
+
import { useMemo as te, useRef as A, useState as x, useEffect as ne, useCallback as oe } from "react";
|
|
7
|
+
import { Stack as ie } from "../stack/index.js";
|
|
8
|
+
import { PopupPanelSize as ae } from "./constants.js";
|
|
8
9
|
import './style.css';/* empty css */
|
|
9
|
-
import { anchorToResizeHandles as
|
|
10
|
-
import { parseAntdPlacement as
|
|
11
|
-
import { useDraggable as
|
|
12
|
-
import { Resizable as
|
|
13
|
-
import { useControlledState as
|
|
14
|
-
import { useCls as
|
|
15
|
-
import { useTheme as
|
|
10
|
+
import { anchorToResizeHandles as pe } from "./utils.js";
|
|
11
|
+
import { parseAntdPlacement as se, buildAntdPlacement as le } from "../utils/placement.js";
|
|
12
|
+
import { useDraggable as ce } from "../hooks/useDraggable.js";
|
|
13
|
+
import { Resizable as ue } from "../resizable/component.js";
|
|
14
|
+
import { useControlledState as de } from "../hooks/useControlledState.js";
|
|
15
|
+
import { useCls as me } from "../utils/antdUtils.js";
|
|
16
|
+
import { useTheme as fe } from "../theme-provider/context/themeStore.js";
|
|
16
17
|
import { clsx as p } from "../utils/cn.js";
|
|
17
|
-
import { IconButton as
|
|
18
|
-
const
|
|
19
|
-
children:
|
|
20
|
-
placement:
|
|
21
|
-
openOnHover:
|
|
22
|
-
open:
|
|
23
|
-
onOpenChange:
|
|
24
|
-
content:
|
|
18
|
+
import { IconButton as ge } from "../icon-button/component.js";
|
|
19
|
+
const Ie = ({
|
|
20
|
+
children: z,
|
|
21
|
+
placement: H,
|
|
22
|
+
openOnHover: k = !1,
|
|
23
|
+
open: E,
|
|
24
|
+
onOpenChange: I,
|
|
25
|
+
content: K,
|
|
25
26
|
title: h,
|
|
26
|
-
trigger:
|
|
27
|
-
className:
|
|
28
|
-
anchor:
|
|
27
|
+
trigger: T = "click",
|
|
28
|
+
className: j,
|
|
29
|
+
anchor: M,
|
|
29
30
|
beforeCloseButton: N,
|
|
30
31
|
afterCloseButton: w,
|
|
31
32
|
afterTitle: b,
|
|
32
33
|
size: P = "medium",
|
|
33
34
|
footer: u,
|
|
34
|
-
defaultOpen:
|
|
35
|
+
defaultOpen: D = !1,
|
|
35
36
|
resizable: y = !1,
|
|
36
|
-
draggable:
|
|
37
|
-
maintainAspectRatio:
|
|
37
|
+
draggable: F = !1,
|
|
38
|
+
maintainAspectRatio: U = !1,
|
|
38
39
|
classNames: n,
|
|
39
|
-
modal:
|
|
40
|
-
closeOnClickOutside:
|
|
40
|
+
modal: V = !1,
|
|
41
|
+
closeOnClickOutside: X = !0,
|
|
41
42
|
onPlacementChange: v,
|
|
42
|
-
|
|
43
|
+
positionerProps: $ = {},
|
|
44
|
+
triggerProps: q = {},
|
|
45
|
+
portalProps: G = {},
|
|
46
|
+
...J
|
|
43
47
|
}) => {
|
|
44
|
-
const [R, C] =
|
|
45
|
-
k,
|
|
48
|
+
const [R, C] = de(
|
|
46
49
|
E,
|
|
47
|
-
|
|
50
|
+
I,
|
|
51
|
+
D
|
|
48
52
|
// Always provide a default value to prevent undefined
|
|
49
|
-
), r =
|
|
53
|
+
), r = me(), { className: L } = fe(), d = se(H), O = te(() => /* @__PURE__ */ e(re, { size: 16 }), []), m = A(d.side), f = A(d.align), [Q, W] = x(0), [l, Y] = x(
|
|
50
54
|
null
|
|
51
55
|
);
|
|
52
|
-
|
|
53
|
-
if (!
|
|
54
|
-
const i = new MutationObserver((
|
|
56
|
+
ne(() => {
|
|
57
|
+
if (!l || !R) return;
|
|
58
|
+
const i = new MutationObserver((s) => {
|
|
55
59
|
let g = !1;
|
|
56
|
-
if (
|
|
60
|
+
if (s.forEach((t) => {
|
|
57
61
|
if (t.type === "attributes" && t.attributeName === "data-side") {
|
|
58
|
-
const o =
|
|
59
|
-
o && o !==
|
|
62
|
+
const o = l.getAttribute(t.attributeName);
|
|
63
|
+
o && o !== m.current && (m.current = o, g = !0);
|
|
60
64
|
}
|
|
61
65
|
if (t.type === "attributes" && t.attributeName === "data-align") {
|
|
62
|
-
const o =
|
|
63
|
-
o && o !==
|
|
66
|
+
const o = l.getAttribute(t.attributeName);
|
|
67
|
+
o && o !== f.current && (f.current = o, g = !0);
|
|
64
68
|
}
|
|
65
69
|
}), g) {
|
|
66
|
-
const t =
|
|
67
|
-
side:
|
|
68
|
-
align:
|
|
70
|
+
const t = le({
|
|
71
|
+
side: m.current,
|
|
72
|
+
align: f.current
|
|
69
73
|
});
|
|
70
|
-
|
|
74
|
+
W((o) => o + 1), v && v(t);
|
|
71
75
|
}
|
|
72
76
|
});
|
|
73
|
-
return i.observe(
|
|
77
|
+
return i.observe(l, {
|
|
74
78
|
attributes: !0,
|
|
75
79
|
attributeFilter: ["data-side", "data-align"],
|
|
76
80
|
attributeOldValue: !0
|
|
77
81
|
}), () => {
|
|
78
82
|
i.disconnect();
|
|
79
83
|
};
|
|
80
|
-
}, [v, R,
|
|
81
|
-
const
|
|
84
|
+
}, [v, R, l]);
|
|
85
|
+
const Z = oe(() => /* @__PURE__ */ c("div", { className: p(r("popup-panel-header"), n?.header), children: [
|
|
82
86
|
/* @__PURE__ */ c(
|
|
83
|
-
|
|
87
|
+
ie,
|
|
84
88
|
{
|
|
85
89
|
align: "center",
|
|
86
90
|
gap: 8,
|
|
@@ -97,7 +101,7 @@ const Ae = ({
|
|
|
97
101
|
/* @__PURE__ */ e(
|
|
98
102
|
a.Close,
|
|
99
103
|
{
|
|
100
|
-
render: /* @__PURE__ */ e(
|
|
104
|
+
render: /* @__PURE__ */ e(ge, { children: O })
|
|
101
105
|
}
|
|
102
106
|
),
|
|
103
107
|
w
|
|
@@ -115,75 +119,78 @@ const Ae = ({
|
|
|
115
119
|
n?.title,
|
|
116
120
|
O,
|
|
117
121
|
h
|
|
118
|
-
]), { ref:
|
|
122
|
+
]), { ref: _ } = ce(F), B = /* @__PURE__ */ c(
|
|
119
123
|
a.Popup,
|
|
120
124
|
{
|
|
121
125
|
className: p(
|
|
122
126
|
r("popup-panel"),
|
|
123
127
|
r(`popup-panel-size-${P}`),
|
|
124
|
-
|
|
128
|
+
j,
|
|
125
129
|
n?.popup
|
|
126
130
|
),
|
|
127
|
-
ref:
|
|
131
|
+
ref: _,
|
|
128
132
|
children: [
|
|
129
|
-
h &&
|
|
130
|
-
/* @__PURE__ */ e("div", { className: p(r("popup-panel-content"), n?.content), children: /* @__PURE__ */ e("div", { className: r("popup-panel-content-inner"), children:
|
|
133
|
+
h && Z(),
|
|
134
|
+
/* @__PURE__ */ e("div", { className: p(r("popup-panel-content"), n?.content), children: /* @__PURE__ */ e("div", { className: r("popup-panel-content-inner"), children: K }) }),
|
|
131
135
|
u && /* @__PURE__ */ e("div", { className: p(r("popup-panel-footer"), n?.footer), children: typeof u == "function" ? u({ close: () => C(!1) }) : u })
|
|
132
136
|
]
|
|
133
137
|
}
|
|
134
|
-
)
|
|
138
|
+
), ee = {
|
|
139
|
+
ref: Y,
|
|
140
|
+
className: p(r("popup-panel-root"), L, n?.root),
|
|
141
|
+
side: d.side,
|
|
142
|
+
align: d.align,
|
|
143
|
+
sideOffset: 4,
|
|
144
|
+
anchor: M,
|
|
145
|
+
style: {
|
|
146
|
+
"--size-width": P ? ae[P] : void 0
|
|
147
|
+
},
|
|
148
|
+
render: ({ children: i, onDragEnd: s, onDragStart: g, ...t }) => y ? /* @__PURE__ */ e(
|
|
149
|
+
ue,
|
|
150
|
+
{
|
|
151
|
+
resizable: y,
|
|
152
|
+
resetKey: Q,
|
|
153
|
+
maintainAspectRatio: U,
|
|
154
|
+
classNames: {
|
|
155
|
+
resizeHandle: n?.resizeHandle
|
|
156
|
+
},
|
|
157
|
+
handles: pe(
|
|
158
|
+
m.current,
|
|
159
|
+
f.current
|
|
160
|
+
),
|
|
161
|
+
...t,
|
|
162
|
+
children: i
|
|
163
|
+
}
|
|
164
|
+
) : /* @__PURE__ */ e("div", { ...t, children: i })
|
|
165
|
+
};
|
|
135
166
|
return /* @__PURE__ */ c(
|
|
136
167
|
a.Root,
|
|
137
168
|
{
|
|
138
|
-
openOnHover: K === "hover" ? !0 : H,
|
|
139
169
|
open: R,
|
|
140
|
-
onOpenChange: (i,
|
|
141
|
-
(
|
|
170
|
+
onOpenChange: (i, s) => {
|
|
171
|
+
(s.reason === "outside-press" || s.reason === "focus-out") && !X || C(i, s);
|
|
142
172
|
},
|
|
143
|
-
modal:
|
|
144
|
-
...
|
|
173
|
+
modal: V,
|
|
174
|
+
...J,
|
|
145
175
|
children: [
|
|
146
176
|
/* @__PURE__ */ e(
|
|
147
177
|
a.Trigger,
|
|
148
178
|
{
|
|
149
|
-
|
|
150
|
-
|
|
179
|
+
...S(
|
|
180
|
+
{
|
|
181
|
+
render: z,
|
|
182
|
+
className: p(r("popup-panel-trigger"), n?.trigger),
|
|
183
|
+
openOnHover: T === "hover" ? !0 : k
|
|
184
|
+
},
|
|
185
|
+
q
|
|
186
|
+
)
|
|
151
187
|
}
|
|
152
188
|
),
|
|
153
|
-
/* @__PURE__ */ e(a.Portal, { children: /* @__PURE__ */ e(
|
|
189
|
+
/* @__PURE__ */ e(a.Portal, { ...G, children: /* @__PURE__ */ e(
|
|
154
190
|
a.Positioner,
|
|
155
191
|
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
r("popup-panel-root"),
|
|
159
|
-
$,
|
|
160
|
-
n?.root
|
|
161
|
-
),
|
|
162
|
-
side: d.side,
|
|
163
|
-
align: d.align,
|
|
164
|
-
sideOffset: 4,
|
|
165
|
-
anchor: j,
|
|
166
|
-
style: {
|
|
167
|
-
"--size-width": P ? re[P] : void 0
|
|
168
|
-
},
|
|
169
|
-
render: ({ children: i, onDragEnd: l, onDragStart: g, ...t }) => y ? /* @__PURE__ */ e(
|
|
170
|
-
ae,
|
|
171
|
-
{
|
|
172
|
-
resizable: y,
|
|
173
|
-
resetKey: q,
|
|
174
|
-
maintainAspectRatio: F,
|
|
175
|
-
classNames: {
|
|
176
|
-
resizeHandle: n?.resizeHandle
|
|
177
|
-
},
|
|
178
|
-
handles: te(
|
|
179
|
-
f.current,
|
|
180
|
-
m.current
|
|
181
|
-
),
|
|
182
|
-
...t,
|
|
183
|
-
children: i
|
|
184
|
-
}
|
|
185
|
-
) : /* @__PURE__ */ e("div", { ...t, children: i }),
|
|
186
|
-
children: W
|
|
192
|
+
...S(ee, $),
|
|
193
|
+
children: B
|
|
187
194
|
}
|
|
188
195
|
) })
|
|
189
196
|
]
|
|
@@ -191,6 +198,6 @@ const Ae = ({
|
|
|
191
198
|
);
|
|
192
199
|
};
|
|
193
200
|
export {
|
|
194
|
-
|
|
201
|
+
Ie as PopupPanel
|
|
195
202
|
};
|
|
196
203
|
//# sourceMappingURL=component.js.map
|