@bioturing/components 0.37.0 → 0.38.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.
- package/dist/components/data-table/component.d.ts.map +1 -1
- package/dist/components/data-table/component.js +76 -71
- package/dist/components/data-table/component.js.map +1 -1
- package/dist/components/data-table/components/TablePagination.d.ts +1 -1
- package/dist/components/data-table/components/TablePagination.d.ts.map +1 -1
- package/dist/components/data-table/components/TablePagination.js +26 -23
- package/dist/components/data-table/components/TablePagination.js.map +1 -1
- package/dist/components/data-table/hooks.d.ts.map +1 -1
- package/dist/components/data-table/hooks.js +82 -82
- package/dist/components/data-table/hooks.js.map +1 -1
- package/dist/components/data-table/style.css +1 -1
- package/dist/components/empty/component.d.ts +0 -2
- package/dist/components/empty/component.d.ts.map +1 -1
- package/dist/components/empty/component.js +14 -35
- package/dist/components/empty/component.js.map +1 -1
- package/dist/components/empty/style.css +1 -1
- package/dist/components/hooks/useResizable.d.ts +50 -0
- package/dist/components/hooks/useResizable.d.ts.map +1 -0
- package/dist/components/hooks/useResizable.js +148 -0
- package/dist/components/hooks/useResizable.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/popup-panel/component.d.ts.map +1 -1
- package/dist/components/popup-panel/component.js +119 -112
- package/dist/components/popup-panel/component.js.map +1 -1
- package/dist/components/popup-panel/utils.d.ts +10 -0
- package/dist/components/popup-panel/utils.d.ts.map +1 -0
- package/dist/components/popup-panel/utils.js +13 -0
- package/dist/components/popup-panel/utils.js.map +1 -0
- package/dist/components/resizable/component.d.ts +2 -8
- package/dist/components/resizable/component.d.ts.map +1 -1
- package/dist/components/resizable/component.js +250 -248
- package/dist/components/resizable/component.js.map +1 -1
- package/dist/components/window-portal/component.d.ts +24 -0
- package/dist/components/window-portal/component.d.ts.map +1 -0
- package/dist/components/window-portal/component.js +120 -0
- package/dist/components/window-portal/component.js.map +1 -0
- package/dist/components/window-portal/index.d.ts +3 -0
- package/dist/components/window-portal/index.d.ts.map +1 -0
- package/dist/components/window-portal/types.d.ts +77 -0
- package/dist/components/window-portal/types.d.ts.map +1 -0
- package/dist/index.js +139 -138
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +8 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +18 -0
- package/dist/metadata.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
|
@@ -1,182 +1,189 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
3
|
-
import { Popover as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { jsx as e, jsxs as c } from "react/jsx-runtime";
|
|
3
|
+
import { Popover as a } from "@base-ui-components/react/popover";
|
|
4
|
+
import { X as Y } from "@bioturing/assets";
|
|
5
|
+
import { useMemo as Z, useRef as S, useState as A, useEffect as _, useCallback as B } from "react";
|
|
6
|
+
import { Stack as ee } from "../stack/index.js";
|
|
7
|
+
import { PopupPanelSize as re } from "./constants.js";
|
|
8
8
|
import './style.css';/* empty css */
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { anchorToResizeHandles as te } from "./utils.js";
|
|
10
|
+
import { parseAntdPlacement as ne, buildAntdPlacement as oe } from "../utils/placement.js";
|
|
11
|
+
import { useDraggable as ie } from "../hooks/useDraggable.js";
|
|
12
|
+
import { Resizable as ae } from "../resizable/component.js";
|
|
12
13
|
import { useControlledState as pe } from "../hooks/useControlledState.js";
|
|
13
|
-
import { useCls as
|
|
14
|
+
import { useCls as le } from "../utils/antdUtils.js";
|
|
14
15
|
import { useTheme as se } from "../theme-provider/context/themeStore.js";
|
|
15
16
|
import { clsx as p } from "../utils/cn.js";
|
|
16
|
-
import { IconButton as
|
|
17
|
-
const
|
|
17
|
+
import { IconButton as ce } from "../icon-button/component.js";
|
|
18
|
+
const Ae = ({
|
|
18
19
|
children: x,
|
|
19
20
|
placement: z,
|
|
20
|
-
openOnHover:
|
|
21
|
-
open:
|
|
22
|
-
onOpenChange:
|
|
23
|
-
content:
|
|
24
|
-
title:
|
|
25
|
-
trigger:
|
|
26
|
-
className:
|
|
27
|
-
anchor:
|
|
28
|
-
beforeCloseButton:
|
|
29
|
-
afterCloseButton:
|
|
30
|
-
afterTitle:
|
|
31
|
-
size:
|
|
32
|
-
footer:
|
|
33
|
-
defaultOpen:
|
|
34
|
-
resizable:
|
|
35
|
-
draggable:
|
|
36
|
-
maintainAspectRatio:
|
|
37
|
-
classNames:
|
|
38
|
-
modal:
|
|
39
|
-
closeOnClickOutside:
|
|
40
|
-
onPlacementChange:
|
|
41
|
-
|
|
21
|
+
openOnHover: H = !1,
|
|
22
|
+
open: k,
|
|
23
|
+
onOpenChange: E,
|
|
24
|
+
content: I,
|
|
25
|
+
title: h,
|
|
26
|
+
trigger: K = "click",
|
|
27
|
+
className: T,
|
|
28
|
+
anchor: j,
|
|
29
|
+
beforeCloseButton: N,
|
|
30
|
+
afterCloseButton: w,
|
|
31
|
+
afterTitle: b,
|
|
32
|
+
size: P = "medium",
|
|
33
|
+
footer: u,
|
|
34
|
+
defaultOpen: M = !1,
|
|
35
|
+
resizable: y = !1,
|
|
36
|
+
draggable: D = !1,
|
|
37
|
+
maintainAspectRatio: F = !1,
|
|
38
|
+
classNames: n,
|
|
39
|
+
modal: U = !1,
|
|
40
|
+
closeOnClickOutside: V = !0,
|
|
41
|
+
onPlacementChange: v,
|
|
42
|
+
...X
|
|
42
43
|
}) => {
|
|
43
|
-
const [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const [R, C] = pe(
|
|
45
|
+
k,
|
|
46
|
+
E,
|
|
47
|
+
M
|
|
47
48
|
// Always provide a default value to prevent undefined
|
|
48
|
-
), r =
|
|
49
|
+
), r = le(), { className: $ } = se(), d = ne(z), O = Z(() => /* @__PURE__ */ e(Y, { size: 16 }), []), f = S(d.side), m = S(d.align), [q, G] = A(0), [s, J] = A(
|
|
50
|
+
null
|
|
51
|
+
);
|
|
49
52
|
_(() => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
n && n !== b.current && (b.current = n, v = !0);
|
|
53
|
+
if (!s || !R) return;
|
|
54
|
+
const i = new MutationObserver((l) => {
|
|
55
|
+
let g = !1;
|
|
56
|
+
if (l.forEach((t) => {
|
|
57
|
+
if (t.type === "attributes" && t.attributeName === "data-side") {
|
|
58
|
+
const o = s.getAttribute(t.attributeName);
|
|
59
|
+
o && o !== f.current && (f.current = o, g = !0);
|
|
58
60
|
}
|
|
59
|
-
if (
|
|
60
|
-
const
|
|
61
|
-
|
|
61
|
+
if (t.type === "attributes" && t.attributeName === "data-align") {
|
|
62
|
+
const o = s.getAttribute(t.attributeName);
|
|
63
|
+
o && o !== m.current && (m.current = o, g = !0);
|
|
62
64
|
}
|
|
63
|
-
}),
|
|
64
|
-
const
|
|
65
|
-
side:
|
|
66
|
-
align:
|
|
65
|
+
}), g) {
|
|
66
|
+
const t = oe({
|
|
67
|
+
side: f.current,
|
|
68
|
+
align: m.current
|
|
67
69
|
});
|
|
68
|
-
|
|
70
|
+
G((o) => o + 1), v && v(t);
|
|
69
71
|
}
|
|
70
72
|
});
|
|
71
|
-
return
|
|
73
|
+
return i.observe(s, {
|
|
72
74
|
attributes: !0,
|
|
73
75
|
attributeFilter: ["data-side", "data-align"],
|
|
74
76
|
attributeOldValue: !0
|
|
75
77
|
}), () => {
|
|
76
|
-
|
|
78
|
+
i.disconnect();
|
|
77
79
|
};
|
|
78
|
-
}, [
|
|
79
|
-
const L = B(() => /* @__PURE__ */
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
80
|
+
}, [v, R, s]);
|
|
81
|
+
const L = B(() => /* @__PURE__ */ c("div", { className: p(r("popup-panel-header"), n?.header), children: [
|
|
82
|
+
/* @__PURE__ */ c(
|
|
83
|
+
ee,
|
|
82
84
|
{
|
|
83
85
|
align: "center",
|
|
84
86
|
gap: 8,
|
|
85
87
|
className: r("popup-panel-title-wrapper"),
|
|
86
88
|
children: [
|
|
87
89
|
/* @__PURE__ */ e(
|
|
88
|
-
|
|
90
|
+
a.Title,
|
|
89
91
|
{
|
|
90
|
-
render: /* @__PURE__ */ e("div", { className: p(r("grow", "truncate"),
|
|
92
|
+
render: /* @__PURE__ */ e("div", { className: p(r("grow", "truncate"), n?.title), children: h })
|
|
91
93
|
}
|
|
92
94
|
),
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
|
|
95
|
+
/* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
|
|
96
|
+
N,
|
|
95
97
|
/* @__PURE__ */ e(
|
|
96
|
-
|
|
98
|
+
a.Close,
|
|
97
99
|
{
|
|
98
|
-
render: /* @__PURE__ */ e(
|
|
100
|
+
render: /* @__PURE__ */ e(ce, { children: O })
|
|
99
101
|
}
|
|
100
102
|
),
|
|
101
|
-
|
|
103
|
+
w
|
|
102
104
|
] })
|
|
103
105
|
]
|
|
104
106
|
}
|
|
105
107
|
),
|
|
106
|
-
|
|
108
|
+
b || null
|
|
107
109
|
] }), [
|
|
108
|
-
y,
|
|
109
|
-
f,
|
|
110
110
|
w,
|
|
111
|
+
b,
|
|
112
|
+
N,
|
|
111
113
|
r,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
]), { ref: Q } =
|
|
117
|
-
|
|
114
|
+
n?.header,
|
|
115
|
+
n?.title,
|
|
116
|
+
O,
|
|
117
|
+
h
|
|
118
|
+
]), { ref: Q } = ie(D), W = /* @__PURE__ */ c(
|
|
119
|
+
a.Popup,
|
|
118
120
|
{
|
|
119
121
|
className: p(
|
|
120
122
|
r("popup-panel"),
|
|
121
|
-
r(`popup-panel-size-${
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
r(`popup-panel-size-${P}`),
|
|
124
|
+
T,
|
|
125
|
+
n?.popup
|
|
124
126
|
),
|
|
125
127
|
ref: Q,
|
|
126
128
|
children: [
|
|
127
|
-
|
|
128
|
-
/* @__PURE__ */ e("div", { className: p(r("popup-panel-content"),
|
|
129
|
-
|
|
129
|
+
h && L(),
|
|
130
|
+
/* @__PURE__ */ e("div", { className: p(r("popup-panel-content"), n?.content), children: /* @__PURE__ */ e("div", { className: r("popup-panel-content-inner"), children: I }) }),
|
|
131
|
+
u && /* @__PURE__ */ e("div", { className: p(r("popup-panel-footer"), n?.footer), children: typeof u == "function" ? u({ close: () => C(!1) }) : u })
|
|
130
132
|
]
|
|
131
133
|
}
|
|
132
134
|
);
|
|
133
|
-
return /* @__PURE__ */
|
|
134
|
-
|
|
135
|
+
return /* @__PURE__ */ c(
|
|
136
|
+
a.Root,
|
|
135
137
|
{
|
|
136
|
-
openOnHover:
|
|
137
|
-
open:
|
|
138
|
-
onOpenChange: (
|
|
139
|
-
(
|
|
138
|
+
openOnHover: K === "hover" ? !0 : H,
|
|
139
|
+
open: R,
|
|
140
|
+
onOpenChange: (i, l) => {
|
|
141
|
+
(l.reason === "outside-press" || l.reason === "focus-out") && !V || C(i, l);
|
|
140
142
|
},
|
|
141
|
-
modal:
|
|
142
|
-
|
|
143
|
+
modal: U,
|
|
144
|
+
...X,
|
|
143
145
|
children: [
|
|
144
146
|
/* @__PURE__ */ e(
|
|
145
|
-
|
|
147
|
+
a.Trigger,
|
|
146
148
|
{
|
|
147
149
|
render: x,
|
|
148
|
-
className: p(r("popup-panel-trigger"),
|
|
150
|
+
className: p(r("popup-panel-trigger"), n?.trigger)
|
|
149
151
|
}
|
|
150
152
|
),
|
|
151
|
-
/* @__PURE__ */ e(
|
|
152
|
-
|
|
153
|
+
/* @__PURE__ */ e(a.Portal, { children: /* @__PURE__ */ e(
|
|
154
|
+
a.Positioner,
|
|
153
155
|
{
|
|
154
|
-
ref:
|
|
156
|
+
ref: J,
|
|
155
157
|
className: p(
|
|
156
158
|
r("popup-panel-root"),
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
$,
|
|
160
|
+
n?.root
|
|
159
161
|
),
|
|
160
|
-
side:
|
|
161
|
-
align:
|
|
162
|
+
side: d.side,
|
|
163
|
+
align: d.align,
|
|
162
164
|
sideOffset: 4,
|
|
163
|
-
anchor:
|
|
165
|
+
anchor: j,
|
|
164
166
|
style: {
|
|
165
|
-
"--size-width":
|
|
167
|
+
"--size-width": P ? re[P] : void 0
|
|
166
168
|
},
|
|
167
|
-
children:
|
|
168
|
-
|
|
169
|
+
render: ({ children: i, onDragEnd: l, onDragStart: g, ...t }) => y ? /* @__PURE__ */ e(
|
|
170
|
+
ae,
|
|
169
171
|
{
|
|
170
|
-
resizable:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
maintainAspectRatio: U,
|
|
172
|
+
resizable: y,
|
|
173
|
+
resetKey: q,
|
|
174
|
+
maintainAspectRatio: F,
|
|
174
175
|
classNames: {
|
|
175
|
-
resizeHandle:
|
|
176
|
+
resizeHandle: n?.resizeHandle
|
|
176
177
|
},
|
|
177
|
-
|
|
178
|
+
handles: te(
|
|
179
|
+
f.current,
|
|
180
|
+
m.current
|
|
181
|
+
),
|
|
182
|
+
...t,
|
|
183
|
+
children: i
|
|
178
184
|
}
|
|
179
|
-
) :
|
|
185
|
+
) : /* @__PURE__ */ e("div", { ...t, children: i }),
|
|
186
|
+
children: W
|
|
180
187
|
}
|
|
181
188
|
) })
|
|
182
189
|
]
|
|
@@ -184,6 +191,6 @@ const Re = ({
|
|
|
184
191
|
);
|
|
185
192
|
};
|
|
186
193
|
export {
|
|
187
|
-
|
|
194
|
+
Ae as PopupPanel
|
|
188
195
|
};
|
|
189
196
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n useCls,\n clsx,\n parseAntdPlacement,\n buildAntdPlacement,\n BaseUIPlacement,\n BaseUISide,\n BaseUIAlign,\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 { IconButton } from \"../icon-button\";\nimport { X } from \"@bioturing/assets\";\nimport { PopupPanelSize } from \"./constants\";\nimport { useControlledState, useDraggable } from \"../hooks\";\nimport { Resizable } from \"../resizable\";\nimport { Stack } from \"../stack\";\n\n// Import component-specific styles\nimport \"./style.css\";\nimport { useRef } from \"react\";\nimport { useTheme } from \"../theme-provider\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n >,\n Omit<Popover.Root.Props, \"children\"> {\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 * Whether the panel should be draggable\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether to maintain aspect ratio when resizing\n * Only applies when resizable is true\n * @default false\n */\n maintainAspectRatio?: 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 = false,\n resizable = false,\n draggable = false,\n maintainAspectRatio = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n onPlacementChange,\n ...rest\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 // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const { className: themeClassName } = useTheme();\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 const { ref: draggableRef } = useDraggable(draggable);\n\n const popup = (\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup\n )}\n ref={draggableRef}\n >\n {title && renderTitle()}\n <div className={clsx(cls(\"popup-panel-content\"), classNames?.content)}>\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}>\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n </Popover.Popup>\n );\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, eventDetails) => {\n if (\n (eventDetails.reason === \"outside-press\" ||\n eventDetails.reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(open, eventDetails);\n }}\n modal={modal}\n {...rest}\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(\n cls(\"popup-panel-root\"),\n themeClassName,\n classNames?.root\n )}\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\n resizable={resizable}\n absolutePositioning={true}\n resetKey={placementChangeKey}\n maintainAspectRatio={maintainAspectRatio}\n classNames={{\n resizeHandle: classNames?.resizeHandle,\n }}\n >\n {popup}\n </Resizable>\n ) : (\n popup\n )}\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","draggable","maintainAspectRatio","classNames","modal","closeOnClickOutside","onPlacementChange","rest","open","setOpen","useControlledState","cls","useCls","themeClassName","useTheme","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","draggableRef","useDraggable","popup","eventDetails","PopupPanelSize","Resizable"],"mappings":";;;;;;;;;;;;;;;;AA+HO,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,IAAc;AAAA,EACd,WAAAC,IAAY;AAAA,EACZ,WAAAC,IAAY;AAAA,EACZ,qBAAAC,IAAsB;AAAA,EACtB,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,qBAAAC,IAAsB;AAAA,EACtB,mBAAAC;AAAA,EACA,GAAGC;AACL,MAAuB;AAErB,QAAM,CAACC,GAAMC,CAAO,IAAIC;AAAA,IACtBvB;AAAA,IACAC;AAAA,IACAW;AAAA;AAAA,EAAA,GAGIY,IAAMC,GAAA,GACN,EAAE,WAAWC,EAAA,IAAmBC,GAAA,GAChCC,IAAkBC,GAAmB/B,CAAS,GAE9CgC,IAAmBC,EAAQ,MAAM,gBAAAC,EAACC,KAAE,MAAM,IAAI,GAAI,EAAE,GAEpDC,IAAgBC,EAAuB,IAAI,GAC3CC,IAAiBD,EAAmBP,EA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BACV,cAAcC,GAAY;AAAA,gBAAA;AAAA,gBAG3B,UAAA6C;AAAA,cAAA;AAAA,YAAA,IAGHA;AAAA,UAAA;AAAA,QAAA,EAEJ,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport { Popover } from \"@base-ui-components/react/popover\";\nimport {\n BaseUIAlign,\n BaseUISide,\n buildAntdPlacement,\n clsx,\n parseAntdPlacement,\n useCls,\n} from \"../utils\";\n\nimport { X } from \"@bioturing/assets\";\nimport { type PopoverProps } from \"antd/es/popover\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useControlledState, useDraggable } from \"../hooks\";\nimport { IconButton } from \"../icon-button\";\nimport { Resizable } from \"../resizable\";\nimport { Stack } from \"../stack\";\nimport { PopupPanelSize } from \"./constants\";\n\n// Import component-specific styles\nimport { useRef } from \"react\";\nimport { useTheme } from \"../theme-provider\";\nimport \"./style.css\";\nimport { anchorToResizeHandles } from \"./utils\";\n\nexport interface PopupPanelProps\n extends Omit<\n React.ComponentPropsWithRef<\"div\">,\n \"title\" | \"content\" | \"children\"\n >,\n Omit<Popover.Root.Props, \"children\"> {\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 * Whether the panel should be draggable\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether to maintain aspect ratio when resizing\n * Only applies when resizable is true\n * @default false\n */\n maintainAspectRatio?: 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 = false,\n resizable = false,\n draggable = false,\n maintainAspectRatio = false,\n classNames,\n modal = false,\n closeOnClickOutside = true,\n onPlacementChange,\n ...rest\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 // Always provide a default value to prevent undefined\n );\n\n const cls = useCls();\n const { className: themeClassName } = useTheme();\n const baseUIPlacement = parseAntdPlacement(placement);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\n\n // const positionerRef = useRef<HTMLDivElement>(null);\n\n const currentSideRef = useRef<BaseUISide>(baseUIPlacement.side);\n const currentAlignRef = useRef<BaseUIAlign>(baseUIPlacement.align);\n const [placementChangeKey, setPlacementChangeKey] = useState(0);\n const [positionerRef, setPositionerRef] = useState<HTMLDivElement | null>(\n null\n );\n\n useEffect(() => {\n if (!positionerRef || !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 mutations.forEach((mutation) => {\n if (\n mutation.type === \"attributes\" &&\n mutation.attributeName === \"data-side\"\n ) {\n const newSide = positionerRef.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 = positionerRef.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(positionerRef, {\n attributes: true,\n attributeFilter: [\"data-side\", \"data-align\"],\n attributeOldValue: true,\n });\n\n return () => {\n observer.disconnect();\n };\n }, [onPlacementChange, open, positionerRef]);\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 const { ref: draggableRef } = useDraggable(draggable);\n\n const popup = (\n <Popover.Popup\n className={clsx(\n cls(\"popup-panel\"),\n cls(`popup-panel-size-${size}`),\n className,\n classNames?.popup\n )}\n ref={draggableRef}\n >\n {title && renderTitle()}\n <div className={clsx(cls(\"popup-panel-content\"), classNames?.content)}>\n <div className={cls(\"popup-panel-content-inner\")}>{content}</div>\n </div>\n {footer && (\n <div className={clsx(cls(\"popup-panel-footer\"), classNames?.footer)}>\n {typeof footer === \"function\"\n ? footer({ close: () => setOpen(false) })\n : footer}\n </div>\n )}\n </Popover.Popup>\n );\n\n return (\n <Popover.Root\n openOnHover={trigger === \"hover\" ? true : openOnHover}\n open={open}\n onOpenChange={(open, eventDetails) => {\n if (\n (eventDetails.reason === \"outside-press\" ||\n eventDetails.reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(open, eventDetails);\n }}\n modal={modal}\n {...rest}\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={setPositionerRef}\n className={clsx(\n cls(\"popup-panel-root\"),\n themeClassName,\n classNames?.root\n )}\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 render={({ children, onDragEnd, onDragStart, ...props }) => {\n return resizable ? (\n <Resizable\n resizable={resizable}\n resetKey={placementChangeKey}\n maintainAspectRatio={maintainAspectRatio}\n classNames={{\n resizeHandle: classNames?.resizeHandle,\n }}\n handles={anchorToResizeHandles(\n currentSideRef.current,\n currentAlignRef.current\n )}\n {...props}\n >\n {children}\n </Resizable>\n ) : (\n <div {...props}>{children}</div>\n );\n }}\n >\n {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","draggable","maintainAspectRatio","classNames","modal","closeOnClickOutside","onPlacementChange","rest","open","setOpen","useControlledState","cls","useCls","themeClassName","useTheme","baseUIPlacement","parseAntdPlacement","defaultCloseIcon","useMemo","jsx","X","currentSideRef","useRef","currentAlignRef","placementChangeKey","setPlacementChangeKey","useState","positionerRef","setPositionerRef","useEffect","observer","mutations","hasPlacementChanged","mutation","newSide","newAlign","newPlacement","buildAntdPlacement","prev","renderTitle","useCallback","jsxs","clsx","Stack","Popover","IconButton","draggableRef","useDraggable","popup","eventDetails","PopupPanelSize","onDragEnd","onDragStart","props","Resizable","anchorToResizeHandles"],"mappings":";;;;;;;;;;;;;;;;;AA+HO,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,IAAc;AAAA,EACd,W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,EAAQ,QAAR,EACC,UAAA,gBAAAzB;AAAA,UAACyB,EAAQ;AAAA,UAAR;AAAA,YACC,KAAKhB;AAAA,YACL,WAAWc;AAAA,cACT/B,EAAI,kBAAkB;AAAA,cACtBE;AAAA,cACAV,GAAY;AAAA,YAAA;AAAA,YAEd,MAAMY,EAAgB;AAAA,YACtB,OAAOA,EAAgB;AAAA,YACvB,YAAY;AAAA,YACZ,QAAAtB;AAAA,YACA,OACE;AAAA,cACE,gBAAgBI,IAAOqD,GAAerD,CAAI,IAAI;AAAA,YAAA;AAAA,YAGlD,QAAQ,CAAC,EAAE,UAAAb,GAAU,WAAAmE,GAAW,aAAAC,GAAa,GAAGC,QACvCrD,IACL,gBAAAmB;AAAA,cAACmC;AAAA,cAAA;AAAA,gBACC,WAAAtD;AAAA,gBACA,UAAUwB;AAAA,gBACV,qBAAAtB;AAAA,gBACA,YAAY;AAAA,kBACV,cAAcC,GAAY;AAAA,gBAAA;AAAA,gBAE5B,SAASoD;AAAA,kBACPlC,EAAe;AAAA,kBACfE,EAAgB;AAAA,gBAAA;AAAA,gBAEjB,GAAG8B;AAAA,gBAEH,UAAArE;AAAAA,cAAA;AAAA,YAAA,IAGH,gBAAAmC,EAAC,OAAA,EAAK,GAAGkC,GAAQ,UAAArE,GAAS;AAAA,YAI7B,UAAAgE;AAAA,UAAA;AAAA,QAAA,EACH,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseUISide, BaseUIAlign } from '../utils/placement';
|
|
2
|
+
import { ResizableProps } from '../resizable';
|
|
3
|
+
/**
|
|
4
|
+
* Convert anchor position (side + align) to resize handles
|
|
5
|
+
* @param side - The side of the anchor (top, bottom, left, right)
|
|
6
|
+
* @param align - The alignment on that side (start, end, center)
|
|
7
|
+
* @returns Object with boolean flags for each resize handle
|
|
8
|
+
*/
|
|
9
|
+
export declare function anchorToResizeHandles(side: BaseUISide, align: BaseUIAlign): ResizableProps["handles"];
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/popup-panel/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,WAAW,GACjB,cAAc,CAAC,SAAS,CAAC,CAwB3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function r(t, e) {
|
|
2
|
+
const o = {
|
|
3
|
+
top: !1,
|
|
4
|
+
bottom: !1,
|
|
5
|
+
left: !1,
|
|
6
|
+
right: !1
|
|
7
|
+
};
|
|
8
|
+
return o[t] = !0, (e === "start" || e === "end") && (t === "top" || t === "bottom" ? o[e === "start" ? "right" : "left"] = !0 : (t === "left" || t === "right") && (o[e === "start" ? "bottom" : "top"] = !0)), o;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
r as anchorToResizeHandles
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/components/popup-panel/utils.ts"],"sourcesContent":["import { BaseUISide, BaseUIAlign } from \"../utils/placement\";\nimport { ResizableProps } from \"../resizable\";\n\n/**\n * Convert anchor position (side + align) to resize handles\n * @param side - The side of the anchor (top, bottom, left, right)\n * @param align - The alignment on that side (start, end, center)\n * @returns Object with boolean flags for each resize handle\n */\nexport function anchorToResizeHandles(\n side: BaseUISide,\n align: BaseUIAlign\n): ResizableProps[\"handles\"] {\n const handles: ResizableProps[\"handles\"] = {\n top: false,\n bottom: false,\n left: false,\n right: false,\n };\n\n // Set the opposite side to true (this is where resizing happens from)\n // Set the side to true\n handles[side] = true;\n\n // Set horizontal handles based on alignment\n if (align === \"start\" || align === \"end\") {\n if (side === \"top\" || side === \"bottom\") {\n // For top/bottom, start maps to right, end maps to left\n handles[align === \"start\" ? \"right\" : \"left\"] = true;\n } else if (side === \"left\" || side === \"right\") {\n // For left/right, start maps to bottom, end maps to top\n handles[align === \"start\" ? \"bottom\" : \"top\"] = true;\n }\n }\n\n return handles;\n}\n"],"names":["anchorToResizeHandles","side","align","handles"],"mappings":"AASO,SAASA,EACdC,GACAC,GAC2B;AAC3B,QAAMC,IAAqC;AAAA,IACzC,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAKT,SAAAA,EAAQF,CAAI,IAAI,KAGZC,MAAU,WAAWA,MAAU,WAC7BD,MAAS,SAASA,MAAS,WAE7BE,EAAQD,MAAU,UAAU,UAAU,MAAM,IAAI,MACvCD,MAAS,UAAUA,MAAS,aAErCE,EAAQD,MAAU,UAAU,WAAW,KAAK,IAAI,MAI7CC;AACT;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { MoveValues, ResizableProps as UseResizableProps } from '
|
|
2
|
+
import { MoveValues, ResizableProps as UseResizableProps } from '../hooks/useResizable';
|
|
3
3
|
import { WithRenderPropProps } from '../utils';
|
|
4
4
|
export interface ResizableProps extends Omit<WithRenderPropProps, keyof UseResizableProps>, UseResizableProps {
|
|
5
5
|
/**
|
|
@@ -21,12 +21,6 @@ export interface ResizableProps extends Omit<WithRenderPropProps, keyof UseResiz
|
|
|
21
21
|
left?: boolean;
|
|
22
22
|
top?: boolean;
|
|
23
23
|
};
|
|
24
|
-
/**
|
|
25
|
-
* Whether to use absolute positioning for left handle resizing
|
|
26
|
-
* Set to true when used in absolutely positioned containers like PopupPanel
|
|
27
|
-
* @default false
|
|
28
|
-
*/
|
|
29
|
-
absolutePositioning?: boolean;
|
|
30
24
|
/**
|
|
31
25
|
* Custom class names for different parts of the resizable component
|
|
32
26
|
*/
|
|
@@ -66,5 +60,5 @@ export interface ResizableProps extends Omit<WithRenderPropProps, keyof UseResiz
|
|
|
66
60
|
*/
|
|
67
61
|
maintainAspectRatio?: boolean;
|
|
68
62
|
}
|
|
69
|
-
export declare const Resizable:
|
|
63
|
+
export declare const Resizable: React.ForwardRefExoticComponent<ResizableProps & React.RefAttributes<HTMLDivElement>>;
|
|
70
64
|
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/resizable/component.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/resizable/component.tsx"],"names":[],"mappings":"AACA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,UAAU,EACf,cAAc,IAAI,iBAAiB,EACpC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAIL,mBAAmB,EAGpB,MAAM,UAAU,CAAC;AAGlB,OAAO,aAAa,CAAC;AAGrB,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,MAAM,iBAAiB,CAAC,EACxD,iBAAiB;IACnB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,CAAC;IAOF;;OAEG;IACH,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,eAAO,MAAM,SAAS,uFAoWrB,CAAC"}
|