@bioturing/components 0.26.2 → 0.27.0

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.
Files changed (37) hide show
  1. package/dist/components/choice-list/component.js +24 -21
  2. package/dist/components/choice-list/component.js.map +1 -1
  3. package/dist/components/cmdk/index.js.map +1 -1
  4. package/dist/components/dropdown-menu/component.js +16 -15
  5. package/dist/components/dropdown-menu/component.js.map +1 -1
  6. package/dist/components/popup-panel/component.js +142 -164
  7. package/dist/components/popup-panel/component.js.map +1 -1
  8. package/dist/components/popup-panel/style.css +1 -1
  9. package/dist/components/resizable/component.js +171 -0
  10. package/dist/components/resizable/component.js.map +1 -0
  11. package/dist/components/resizable/style.css +1 -0
  12. package/dist/components/segmented/component.js +3 -3
  13. package/dist/components/segmented/component.js.map +1 -1
  14. package/dist/components/spin/component.js +9 -8
  15. package/dist/components/spin/component.js.map +1 -1
  16. package/dist/components/splitter/splitter-panel.js +27 -44
  17. package/dist/components/splitter/splitter-panel.js.map +1 -1
  18. package/dist/components/splitter/splitter.js +94 -93
  19. package/dist/components/splitter/splitter.js.map +1 -1
  20. package/dist/components/splitter/useSizes.js +86 -0
  21. package/dist/components/splitter/useSizes.js.map +1 -0
  22. package/dist/components/upload/dragger.js +19 -10
  23. package/dist/components/upload/dragger.js.map +1 -1
  24. package/dist/components/upload/item.js +21 -18
  25. package/dist/components/upload/item.js.map +1 -1
  26. package/dist/components/utils/antdUtils.js +18 -56
  27. package/dist/components/utils/antdUtils.js.map +1 -1
  28. package/dist/components/utils/placement.js +58 -0
  29. package/dist/components/utils/placement.js.map +1 -0
  30. package/dist/components/utils/reactElement.js +5 -0
  31. package/dist/components/utils/reactElement.js.map +1 -0
  32. package/dist/index.d.ts +162 -16
  33. package/dist/index.js +164 -158
  34. package/dist/index.js.map +1 -1
  35. package/dist/metadata.js +22 -2
  36. package/dist/metadata.js.map +1 -1
  37. package/package.json +1 -1
@@ -1,208 +1,186 @@
1
1
  "use client";
2
- import { jsx as o, jsxs as d, Fragment as a } from "react/jsx-runtime";
3
- import { Popover as i } from "@base-ui-components/react/popover";
4
- import { useState as f, useCallback as C, useEffect as O, useMemo as N } from "react";
5
- import s from "antd/es/flex";
6
- import { X as ee } from "@bioturing/assets";
7
- import { PopupPanelSize as te } from "./constants.js";
8
- import { useResizable as oe } from "react-use-resizable";
9
- import ne from "merge-refs";
2
+ import { jsx as t, jsxs as f } from "react/jsx-runtime";
3
+ import { Popover as o } from "@base-ui-components/react/popover";
4
+ import { useMemo as L, useRef as C, useState as Q, useEffect as W, useCallback as Y } from "react";
5
+ import { X as Z } from "@bioturing/assets";
6
+ import { PopupPanelSize as _ } from "./constants.js";
7
+ import { Stack as B } from "../stack/index.js";
10
8
  import './style.css';/* empty css */
11
- import { useControlledState as re } from "../hooks/useControlledState.js";
12
- import { useCls as pe, parseAntdPlacement as ie } from "../utils/antdUtils.js";
13
- import { clsx as r } from "../utils/cn.js";
14
- import { IconButton as de } from "../icon-button/component.js";
15
- const we = ({
16
- children: S,
9
+ import { parseAntdPlacement as m, buildAntdPlacement as a } from "../utils/placement.js";
10
+ import { Resizable as N } from "../resizable/component.js";
11
+ import { useControlledState as s } from "../hooks/useControlledState.js";
12
+ import { useCls as ee } from "../utils/antdUtils.js";
13
+ import { clsx as p } from "../utils/cn.js";
14
+ import { IconButton as te } from "../icon-button/component.js";
15
+ const ve = ({
16
+ children: H,
17
17
  placement: I,
18
- openOnHover: D = !1,
19
- open: W,
20
- onOpenChange: j,
21
- content: E,
18
+ openOnHover: K = !1,
19
+ open: j,
20
+ onOpenChange: E,
21
+ content: M,
22
22
  title: h,
23
23
  trigger: F = "click",
24
- className: V,
25
- anchor: $,
26
- beforeCloseButton: P,
27
- afterCloseButton: H,
28
- afterTitle: c,
29
- size: g = "medium",
24
+ className: T,
25
+ anchor: U,
26
+ beforeCloseButton: R,
27
+ afterCloseButton: S,
28
+ afterTitle: b,
29
+ size: v = "medium",
30
30
  footer: l,
31
- defaultOpen: A,
32
- resizable: y = !1,
31
+ defaultOpen: V,
32
+ resizable: X = !1,
33
33
  classNames: e,
34
- modal: M = !1,
35
- closeOnClickOutside: T = !0
34
+ modal: $ = !1,
35
+ closeOnClickOutside: q = !0,
36
+ onPlacementChange: P
36
37
  }) => {
37
- const [U, b] = re(
38
- W,
38
+ const [w, x] = s(
39
39
  j,
40
- A ?? !1
40
+ E,
41
+ V ?? !1
41
42
  // Always provide a default value to prevent undefined
42
- ), t = pe(), w = ie(I), [v, X] = f(null), [q, G] = f(), [J, K] = f(), L = C((n) => {
43
- X(n);
44
- }, []);
45
- O(() => {
46
- if (!v) return;
47
- const n = new ResizeObserver((u) => {
48
- for (const p of u)
49
- G(p.contentRect.width), K(p.contentRect.height);
43
+ ), r = ee(), c = m(I), z = L(() => /* @__PURE__ */ t(Z, { size: 16 }), []), k = C(null), y = C(c.side), O = C(c.align), [D, G] = Q(0);
44
+ W(() => {
45
+ const u = k.current;
46
+ if (!u || !w) return;
47
+ const g = new MutationObserver((d) => {
48
+ let A = !1;
49
+ if (d.forEach((i) => {
50
+ if (i.type === "attributes" && i.attributeName === "data-side") {
51
+ const n = u.getAttribute(i.attributeName);
52
+ n && n !== y.current && (y.current = n, A = !0);
53
+ }
54
+ if (i.type === "attributes" && i.attributeName === "data-align") {
55
+ const n = u.getAttribute(i.attributeName);
56
+ n && n !== O.current && (O.current = n, A = !0);
57
+ }
58
+ }), A) {
59
+ const i = a({
60
+ side: y.current,
61
+ align: O.current
62
+ });
63
+ G((n) => n + 1), P && P(i);
64
+ }
50
65
  });
51
- return n.observe(v), () => {
52
- n.disconnect();
66
+ return g.observe(u, {
67
+ attributes: !0,
68
+ attributeFilter: ["data-side", "data-align"],
69
+ attributeOldValue: !0
70
+ }), () => {
71
+ g.disconnect();
53
72
  };
54
- }, [v]);
55
- const x = N(() => /* @__PURE__ */ o(ee, { size: 16 }), []), Q = C(() => /* @__PURE__ */ d("div", { className: r(t("popup-panel-header"), e == null ? void 0 : e.header), children: [
56
- /* @__PURE__ */ d(
57
- s,
73
+ }, [P, w]);
74
+ const J = Y(() => /* @__PURE__ */ f("div", { className: p(r("popup-panel-header"), e == null ? void 0 : e.header), children: [
75
+ /* @__PURE__ */ f(
76
+ B,
58
77
  {
59
78
  align: "center",
60
79
  gap: 8,
61
- className: t("popup-panel-title-wrapper"),
80
+ className: r("popup-panel-title-wrapper"),
62
81
  children: [
63
- /* @__PURE__ */ o(
64
- i.Title,
82
+ /* @__PURE__ */ t(
83
+ o.Title,
65
84
  {
66
- render: /* @__PURE__ */ o("div", { className: r(t("grow", "truncate"), e == null ? void 0 : e.title), children: h })
85
+ render: /* @__PURE__ */ t("div", { className: p(r("grow", "truncate"), e == null ? void 0 : e.title), children: h })
67
86
  }
68
87
  ),
69
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
70
- P,
71
- /* @__PURE__ */ o(
72
- i.Close,
88
+ /* @__PURE__ */ f("div", { className: "flex items-center gap-2", children: [
89
+ R,
90
+ /* @__PURE__ */ t(
91
+ o.Close,
73
92
  {
74
- render: /* @__PURE__ */ o(de, { children: x })
93
+ render: /* @__PURE__ */ t(te, { children: z })
75
94
  }
76
95
  ),
77
- H
96
+ S
78
97
  ] })
79
98
  ]
80
99
  }
81
100
  ),
82
- c || null
101
+ b || null
83
102
  ] }), [
84
- H,
85
- c,
86
- P,
87
- t,
103
+ S,
104
+ b,
105
+ R,
106
+ r,
88
107
  e == null ? void 0 : e.header,
89
108
  e == null ? void 0 : e.title,
90
- x,
109
+ z,
91
110
  h
92
- ]), [R, k] = f(!1), { getRootProps: Y, getHandleProps: z, rootRef: Z } = oe({
93
- initialWidth: q,
94
- initialHeight: J,
95
- onDragStart: () => k(!0),
96
- onDragEnd: () => k(!1)
97
- });
98
- O(() => {
99
- R ? document.body.style.userSelect = "none" : document.body.style.userSelect = "";
100
- }, [R]);
101
- const { ref: _, ...B } = Y(), m = (n, u) => {
102
- if (!n.current) return;
103
- const { widthDiff: p } = u;
104
- n.current.style.left = `${parseInt(n.current.style.left || "0") - p}px`;
105
- };
106
- return /* @__PURE__ */ d(
107
- i.Root,
111
+ ]);
112
+ return /* @__PURE__ */ f(
113
+ o.Root,
108
114
  {
109
- openOnHover: F === "hover" ? !0 : D,
110
- open: U,
111
- onOpenChange: (n, u, p) => {
112
- (p === "outside-press" || p === "focus-out") && !T || b(n, u, p);
115
+ openOnHover: F === "hover" ? !0 : K,
116
+ open: w,
117
+ onOpenChange: (u, g, d) => {
118
+ (d === "outside-press" || d === "focus-out") && !q || x(u, g, d);
113
119
  },
114
- modal: M,
120
+ modal: $,
115
121
  children: [
116
- /* @__PURE__ */ o(
117
- i.Trigger,
122
+ /* @__PURE__ */ t(
123
+ o.Trigger,
118
124
  {
119
- render: S,
120
- className: r(t("popup-panel-trigger"), e == null ? void 0 : e.trigger)
125
+ render: H,
126
+ className: p(r("popup-panel-trigger"), e == null ? void 0 : e.trigger)
121
127
  }
122
128
  ),
123
- /* @__PURE__ */ o(i.Portal, { children: /* @__PURE__ */ o(
124
- i.Positioner,
129
+ /* @__PURE__ */ t(o.Portal, { children: /* @__PURE__ */ t(
130
+ o.Positioner,
125
131
  {
126
- className: r(t("popup-panel-root"), e == null ? void 0 : e.root),
127
- side: w.placement,
128
- align: w.align,
132
+ ref: k,
133
+ className: p(r("popup-panel-root"), e == null ? void 0 : e.root),
134
+ side: c.side,
135
+ align: c.align,
129
136
  sideOffset: 4,
130
- anchor: $,
137
+ anchor: U,
131
138
  style: {
132
- "--size-width": g ? te[g] : void 0
139
+ "--size-width": v ? _[v] : void 0
133
140
  },
134
- children: /* @__PURE__ */ d(
135
- i.Popup,
141
+ children: /* @__PURE__ */ t(
142
+ N,
136
143
  {
137
- className: r(
138
- t("popup-panel"),
139
- t(`popup-panel-size-${g}`),
140
- V,
141
- e == null ? void 0 : e.popup
142
- ),
143
- ref: ne(_, L),
144
- ...y ? B : {},
145
- ...R ? { "data-resizing": !0 } : {},
146
- children: [
147
- h && Q(),
148
- /* @__PURE__ */ o(
149
- "div",
150
- {
151
- className: r(t("popup-panel-content"), e == null ? void 0 : e.content),
152
- children: /* @__PURE__ */ o("div", { className: t("popup-panel-content-inner"), children: E })
153
- }
154
- ),
155
- l && /* @__PURE__ */ o(
156
- "div",
157
- {
158
- className: r(t("popup-panel-footer"), e == null ? void 0 : e.footer),
159
- children: typeof l == "function" ? l({ close: () => b(!1) }) : l
160
- }
161
- ),
162
- y && /* @__PURE__ */ d(a, { children: [
163
- /* @__PURE__ */ o(
164
- "div",
165
- {
166
- className: r(
167
- t("popup-panel-resize-handle"),
168
- e == null ? void 0 : e.resizeHandle
169
- ),
170
- "data-placement": "bottom-left",
171
- ...z({
172
- lockHorizontal: !0
173
- })
174
- }
175
- ),
176
- /* @__PURE__ */ o(
177
- "div",
178
- {
179
- className: r(
180
- t("popup-panel-resize-handle"),
181
- e == null ? void 0 : e.resizeHandle
182
- ),
183
- "data-placement": "top-left",
184
- ...z({
185
- reverse: !0,
186
- lockVertical: !0,
187
- onResize: (n) => m(Z, n)
188
- })
189
- }
144
+ resizable: X,
145
+ absolutePositioning: !0,
146
+ resetKey: D,
147
+ classNames: {
148
+ resizeHandle: e == null ? void 0 : e.resizeHandle
149
+ },
150
+ children: /* @__PURE__ */ f(
151
+ o.Popup,
152
+ {
153
+ className: p(
154
+ r("popup-panel"),
155
+ r(`popup-panel-size-${v}`),
156
+ T,
157
+ e == null ? void 0 : e.popup
190
158
  ),
191
- /* @__PURE__ */ o(
192
- "div",
193
- {
194
- className: r(
195
- t("popup-panel-resize-handle"),
196
- e == null ? void 0 : e.resizeHandle
197
- ),
198
- "data-placement": "top-right",
199
- ...z({
200
- lockVertical: !0
201
- })
202
- }
203
- )
204
- ] })
205
- ]
159
+ children: [
160
+ h && J(),
161
+ /* @__PURE__ */ t(
162
+ "div",
163
+ {
164
+ className: p(
165
+ r("popup-panel-content"),
166
+ e == null ? void 0 : e.content
167
+ ),
168
+ children: /* @__PURE__ */ t("div", { className: r("popup-panel-content-inner"), children: M })
169
+ }
170
+ ),
171
+ l && /* @__PURE__ */ t(
172
+ "div",
173
+ {
174
+ className: p(
175
+ r("popup-panel-footer"),
176
+ e == null ? void 0 : e.footer
177
+ ),
178
+ children: typeof l == "function" ? l({ close: () => x(!1) }) : l
179
+ }
180
+ )
181
+ ]
182
+ }
183
+ )
206
184
  }
207
185
  )
208
186
  }
@@ -212,6 +190,6 @@ const we = ({
212
190
  );
213
191
  };
214
192
  export {
215
- we as PopupPanel
193
+ ve as PopupPanel
216
194
  };
217
195
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls, clsx, parseAntdPlacement } 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 \"../icon-button\";\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?: Popover.Root.Props[\"onOpenChange\"];\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 * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\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 modal = false,\n closeOnClickOutside = true,\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 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={(open, event, reason) => {\n if (\n (reason === \"outside-press\" || reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(open, event, reason);\n }}\n modal={modal}\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(cls(\"popup-panel-root\"), classNames?.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 >\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup\n )}\n ref={mergeRefs(rootRefProp, callbackRef)}\n // resizable props\n {...(resizable ? 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","modal","closeOnClickOutside","open","setOpen","useControlledState","cls","useCls","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","event","reason","PopupPanelSize","mergeRefs","Fragment"],"mappings":";;;;;;;;;;;;;;AAsGO,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;AAAA,EACZ,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,qBAAAC,IAAsB;AACxB,MAAuB;AAEf,QAAA,CAACC,GAAMC,CAAO,IAAIC;AAAA,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AAA;AAAA,YAAA;AAAA,UAEJ;AAAA,QAAA,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport { useCls, clsx, parseAntdPlacement, buildAntdPlacement, BaseUIPlacement, BaseUISide, BaseUIAlign } 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 { IconButton } from \"../icon-button\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState } from \"../hooks\";\nimport { Resizable } from \"../resizable\";\nimport { Stack } from \"../stack\";\n\n// Import component-specific styles\nimport \"./style.css\";\nimport { useRef } from \"react\";\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?: Popover.Root.Props[\"onOpenChange\"];\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 * Whether to close the panel when clicking outside\n * @default true\n */\n closeOnClickOutside?: boolean;\n /**\n * Whether to use modal mode\n * @default false\n */\n modal?: Popover.Root.Props[\"modal\"];\n /**\n * Callback function when the placement changes\n */\n onPlacementChange?: (placement: PopoverProps[\"placement\"]) => void;\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 modal = false,\n closeOnClickOutside = true,\n onPlacementChange,\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 baseUIPlacement = parseAntdPlacement(placement);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n\n const positionerRef = useRef<HTMLDivElement>(null);\n const currentSideRef = useRef<BaseUISide>(baseUIPlacement.side);\n const currentAlignRef = useRef<BaseUIAlign>(baseUIPlacement.align);\n const [placementChangeKey, setPlacementChangeKey] = useState(0);\n\n useEffect(() => {\n const positioner = positionerRef.current;\n if (!positioner || !open) return; // Only observe when popup is open\n\n // Create MutationObserver to watch for data-side changes\n const observer = new MutationObserver((mutations) => {\n let hasPlacementChanged = false;\n \n mutations.forEach((mutation) => {\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-side\"\n ) {\n const newSide = positioner.getAttribute(mutation.attributeName);\n if (newSide && newSide !== currentSideRef.current) {\n currentSideRef.current = newSide as BaseUISide;\n hasPlacementChanged = true;\n }\n }\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-align\"\n ) {\n const newAlign = positioner.getAttribute(mutation.attributeName);\n if (newAlign && newAlign !== currentAlignRef.current) {\n currentAlignRef.current = newAlign as BaseUIAlign;\n hasPlacementChanged = true;\n }\n }\n });\n\n // Only trigger callbacks if placement actually changed\n if (hasPlacementChanged) {\n const newPlacement = buildAntdPlacement({\n side: currentSideRef.current,\n align: currentAlignRef.current\n });\n \n // Trigger resizable dimensions reset when placement changes\n setPlacementChangeKey(prev => prev + 1);\n \n if (onPlacementChange) {\n onPlacementChange(newPlacement);\n }\n }\n });\n\n // Start observing\n observer.observe(positioner, {\n attributes: true,\n attributeFilter: [\"data-side\", \"data-align\"],\n attributeOldValue: true,\n });\n\n return () => {\n observer.disconnect();\n };\n }, [onPlacementChange, open]);\n\n const renderTitle = useCallback(() => {\n return (\n <div className={clsx(cls(\"popup-panel-header\"), classNames?.header)}>\n <Stack\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 </Stack>\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\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, event, reason) => {\n if (\n (reason === \"outside-press\" || reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(open, event, reason);\n }}\n modal={modal}\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 ref={positionerRef}\n className={clsx(cls(\"popup-panel-root\"), classNames?.root)}\n side={baseUIPlacement.side}\n align={baseUIPlacement.align}\n sideOffset={4}\n anchor={anchor}\n style={\n {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties\n }\n >\n <Resizable\n resizable={resizable}\n absolutePositioning={true}\n resetKey={placementChangeKey}\n classNames={{\n resizeHandle: classNames?.resizeHandle,\n }}\n >\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup\n )}\n >\n {title && renderTitle()}\n <div\n className={clsx(\n cls(\"popup-panel-content\"),\n classNames?.content\n )}\n >\n <div className={cls(\"popup-panel-content-inner\")}>\n {content}\n </div>\n </div>\n {footer && (\n <div\n className={clsx(\n cls(\"popup-panel-footer\"),\n classNames?.footer\n )}\n >\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n </Popover.Popup>\n </Resizable>\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","modal","closeOnClickOutside","onPlacementChange","open","setOpen","useControlledState","cls","useCls","baseUIPlacement","parseAntdPlacement","defaultCloseIcon","useMemo","jsx","X","positionerRef","useRef","currentSideRef","currentAlignRef","placementChangeKey","setPlacementChangeKey","useState","useEffect","positioner","observer","mutations","hasPlacementChanged","mutation","newSide","newAlign","newPlacement","buildAntdPlacement","prev","renderTitle","useCallback","jsxs","clsx","Stack","Popover","IconButton","event","reason","PopupPanelSize","Resizable"],"mappings":";;;;;;;;;;;;;;AA0GO,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;AAAA,EACZ,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,qBAAAC,IAAsB;AAAA,EACtB,mBAAAC;AACF,MAAuB;AAEf,QAAA,CAACC,GAAMC,CAAO,IAAIC;AAAA,IACtBpB;AAAA,IACAC;AAAA,IACAW,KAAe;AAAA;AAAA,EACjB,GAEMS,IAAMC,GAAO,GACbC,IAAkBC,EAAmB1B,CAAS,GAE9C2B,IAAmBC,EAAQ,MAAM,gBAAAC,EAACC,KAAE,MAAM,IAAI,GAAI,EAAE,GAEpDC,IAAgBC,EAAuB,IAAI,GAC3CC,IAAiBD,EAAmBP,EAAgB,IAAI,GACxDS,IAAkBF,EAAoBP,EAAgB,KAAK,GAC3D,CAACU,GAAoBC,CAAqB,IAAIC,EAAS,CAAC;AAE9D,EAAAC,EAAU,MAAM;AACd,UAAMC,IAAaR,EAAc;AAC7B,QAAA,CAACQ,KAAc,CAACnB,EAAM;AAG1B,UAAMoB,IAAW,IAAI,iBAAiB,CAACC,MAAc;AACnD,UAAIC,IAAsB;AA0B1B,UAxBUD,EAAA,QAAQ,CAACE,MAAa;AAC9B,YACEA,EAAS,SAAS,gBAClBA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 -1 +1 @@
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
+ @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)}}
@@ -0,0 +1,171 @@
1
+ "use client";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ import O, { useState as p, useCallback as Q, useEffect as C, isValidElement as T } from "react";
4
+ import { useResizable as U } from "react-use-resizable";
5
+ import X from "merge-refs";
6
+ import { mergeProps as Y } from "@base-ui-components/react";
7
+ import './style.css';/* empty css */
8
+ import { getReactElementProp as y } from "../utils/reactElement.js";
9
+ import { useCls as Z } from "../utils/antdUtils.js";
10
+ import { clsx as u, cn as _ } from "../utils/cn.js";
11
+ import { WithRenderProp as K } from "../utils/WithRenderProp.js";
12
+ const he = ({
13
+ children: f,
14
+ resizable: d = !1,
15
+ handles: h = { bottom: !0, right: !0, left: !0, top: !0 },
16
+ absolutePositioning: H = !1,
17
+ classNames: t,
18
+ className: E,
19
+ style: V,
20
+ resetKey: b,
21
+ maxWidth: D,
22
+ maxHeight: S,
23
+ minWidth: W,
24
+ minHeight: $,
25
+ onResize: B,
26
+ maintainAspectRatio: A = !1,
27
+ ...N
28
+ }) => {
29
+ const l = Z(), [i, I] = p(null), [g, v] = p(), [a, P] = p(), [z, w] = p(!1), j = Q(
30
+ (e) => {
31
+ if (I(e), e && !g && !a) {
32
+ const r = e.getBoundingClientRect();
33
+ r.width > 0 && r.height > 0 && (v(r.width), P(r.height));
34
+ }
35
+ },
36
+ [g, a]
37
+ );
38
+ C(() => {
39
+ if (b !== void 0 && i) {
40
+ i.style.width = "", i.style.height = "";
41
+ const e = i.getBoundingClientRect();
42
+ e.width > 0 && e.height > 0 && (v(e.width), P(e.height), i.style.width = `${e.width}px`, i.style.height = `${e.height}px`);
43
+ }
44
+ }, [b, i]);
45
+ const m = U({
46
+ initialWidth: g,
47
+ initialHeight: a,
48
+ maxWidth: D,
49
+ maxHeight: S,
50
+ minWidth: W,
51
+ minHeight: $,
52
+ onResize: B,
53
+ maintainAspectRatio: A,
54
+ onDragStart: () => w(!0),
55
+ onDragEnd: () => w(!1)
56
+ }), k = T(f);
57
+ C(() => {
58
+ z ? document.body.style.userSelect = "none" : document.body.style.userSelect = "";
59
+ }, [z]);
60
+ const { ref: q, ...F } = m.getRootProps(), s = m.getHandleProps, x = m.rootRef, G = (e, r) => {
61
+ if (!e.current || !H) return;
62
+ const { widthDiff: R } = r;
63
+ e.current.style.left = `${parseInt(e.current.style.left || "0") - R}px`;
64
+ }, J = (e, r) => {
65
+ if (!e.current || !H) return;
66
+ const { heightDiff: R } = r;
67
+ e.current.style.top = `${parseInt(e.current.style.top || "0") - R}px`;
68
+ }, L = d ? [
69
+ h.top && /* @__PURE__ */ n(
70
+ "div",
71
+ {
72
+ className: u(
73
+ l("resizable-resize-handle"),
74
+ t == null ? void 0 : t.resizeHandle
75
+ ),
76
+ "data-placement": "top-center",
77
+ ...s({
78
+ reverse: !0,
79
+ lockHorizontal: !0,
80
+ onResize: (e) => J(x, e)
81
+ })
82
+ },
83
+ "top"
84
+ ),
85
+ h.bottom && /* @__PURE__ */ n(
86
+ "div",
87
+ {
88
+ className: u(
89
+ l("resizable-resize-handle"),
90
+ t == null ? void 0 : t.resizeHandle
91
+ ),
92
+ "data-placement": "bottom-left",
93
+ ...s({
94
+ lockHorizontal: !0
95
+ })
96
+ },
97
+ "bottom"
98
+ ),
99
+ h.left && /* @__PURE__ */ n(
100
+ "div",
101
+ {
102
+ className: u(
103
+ l("resizable-resize-handle"),
104
+ t == null ? void 0 : t.resizeHandle
105
+ ),
106
+ "data-placement": "top-left",
107
+ ...s({
108
+ reverse: !0,
109
+ lockVertical: !0,
110
+ onResize: (e) => G(x, e)
111
+ })
112
+ },
113
+ "left"
114
+ ),
115
+ h.right && /* @__PURE__ */ n(
116
+ "div",
117
+ {
118
+ className: u(
119
+ l("resizable-resize-handle"),
120
+ t == null ? void 0 : t.resizeHandle
121
+ ),
122
+ "data-placement": "top-right",
123
+ ...s({
124
+ lockVertical: !0
125
+ })
126
+ },
127
+ "right"
128
+ )
129
+ ] : [], o = f, c = {
130
+ className: y(o, "className"),
131
+ style: y(o, "style"),
132
+ children: y(o, "children"),
133
+ ref: o.ref
134
+ }, M = {
135
+ className: _(
136
+ d && l("resizable"),
137
+ t == null ? void 0 : t.root,
138
+ c.className,
139
+ E
140
+ ),
141
+ ref: X(
142
+ d ? q : void 0,
143
+ j,
144
+ // Always need this for dimension measurement
145
+ o == null ? void 0 : o.ref
146
+ ),
147
+ style: { ...c.style, ...V },
148
+ ...z ? { "data-resizing": !0 } : {},
149
+ children: k ? [
150
+ ...Array.isArray(c.children) ? c.children : [c.children],
151
+ ...L.filter(Boolean)
152
+ ] : f
153
+ };
154
+ return /* @__PURE__ */ n(
155
+ K,
156
+ {
157
+ render: (e) => {
158
+ const r = Y(
159
+ e,
160
+ M,
161
+ d ? F : {}
162
+ );
163
+ return k ? O.cloneElement(o, r) : /* @__PURE__ */ n("div", { ...r, children: f });
164
+ }
165
+ }
166
+ );
167
+ };
168
+ export {
169
+ he as Resizable
170
+ };
171
+ //# sourceMappingURL=component.js.map