@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.
Files changed (49) hide show
  1. package/dist/components/data-table/component.d.ts.map +1 -1
  2. package/dist/components/data-table/component.js +76 -71
  3. package/dist/components/data-table/component.js.map +1 -1
  4. package/dist/components/data-table/components/TablePagination.d.ts +1 -1
  5. package/dist/components/data-table/components/TablePagination.d.ts.map +1 -1
  6. package/dist/components/data-table/components/TablePagination.js +26 -23
  7. package/dist/components/data-table/components/TablePagination.js.map +1 -1
  8. package/dist/components/data-table/hooks.d.ts.map +1 -1
  9. package/dist/components/data-table/hooks.js +82 -82
  10. package/dist/components/data-table/hooks.js.map +1 -1
  11. package/dist/components/data-table/style.css +1 -1
  12. package/dist/components/empty/component.d.ts +0 -2
  13. package/dist/components/empty/component.d.ts.map +1 -1
  14. package/dist/components/empty/component.js +14 -35
  15. package/dist/components/empty/component.js.map +1 -1
  16. package/dist/components/empty/style.css +1 -1
  17. package/dist/components/hooks/useResizable.d.ts +50 -0
  18. package/dist/components/hooks/useResizable.d.ts.map +1 -0
  19. package/dist/components/hooks/useResizable.js +148 -0
  20. package/dist/components/hooks/useResizable.js.map +1 -0
  21. package/dist/components/index.d.ts +1 -0
  22. package/dist/components/index.d.ts.map +1 -1
  23. package/dist/components/popup-panel/component.d.ts.map +1 -1
  24. package/dist/components/popup-panel/component.js +119 -112
  25. package/dist/components/popup-panel/component.js.map +1 -1
  26. package/dist/components/popup-panel/utils.d.ts +10 -0
  27. package/dist/components/popup-panel/utils.d.ts.map +1 -0
  28. package/dist/components/popup-panel/utils.js +13 -0
  29. package/dist/components/popup-panel/utils.js.map +1 -0
  30. package/dist/components/resizable/component.d.ts +2 -8
  31. package/dist/components/resizable/component.d.ts.map +1 -1
  32. package/dist/components/resizable/component.js +250 -248
  33. package/dist/components/resizable/component.js.map +1 -1
  34. package/dist/components/window-portal/component.d.ts +24 -0
  35. package/dist/components/window-portal/component.d.ts.map +1 -0
  36. package/dist/components/window-portal/component.js +120 -0
  37. package/dist/components/window-portal/component.js.map +1 -0
  38. package/dist/components/window-portal/index.d.ts +3 -0
  39. package/dist/components/window-portal/index.d.ts.map +1 -0
  40. package/dist/components/window-portal/types.d.ts +77 -0
  41. package/dist/components/window-portal/types.d.ts.map +1 -0
  42. package/dist/index.js +139 -138
  43. package/dist/index.js.map +1 -1
  44. package/dist/metadata.d.ts +8 -0
  45. package/dist/metadata.d.ts.map +1 -1
  46. package/dist/metadata.js +18 -0
  47. package/dist/metadata.js.map +1 -1
  48. package/dist/stats.html +1 -1
  49. package/package.json +1 -1
@@ -1,256 +1,258 @@
1
1
  "use client";
2
- import { jsx as l } from "react/jsx-runtime";
3
- import A, { useState as H, useCallback as ee, useEffect as B, isValidElement as te } from "react";
4
- import { useResizable as re } from "react-use-resizable";
5
- import oe from "merge-refs";
6
- import { mergeProps as le } from "@base-ui-components/react";
2
+ import { jsx as i } from "react/jsx-runtime";
3
+ import Y, { forwardRef as Z, useState as b, useCallback as $, useEffect as C, isValidElement as K } from "react";
4
+ import { useResizable as A } from "../hooks/useResizable.js";
5
+ import ee from "merge-refs";
6
+ import { mergeProps as te } from "@base-ui-components/react";
7
7
  import './style.css';/* empty css */
8
- import { getReactElementProp as C } from "../utils/reactElement.js";
9
- import { useCls as ie } from "../utils/antdUtils.js";
10
- import { clsx as c, cn as se } from "../utils/cn.js";
11
- import { WithRenderProp as ne } from "../utils/WithRenderProp.js";
12
- const be = ({
13
- children: u,
14
- resizable: a = !1,
15
- handles: o = { bottom: !0, right: !0, left: !0, top: !0 },
16
- absolutePositioning: E = !1,
17
- classNames: i,
18
- className: D,
19
- style: S,
20
- resetKey: k,
21
- // Use Resizable Props
22
- maxHeight: I,
23
- maxWidth: _,
24
- minHeight: $,
25
- minWidth: j,
26
- lockHorizontal: q,
27
- lockVertical: F,
28
- onResize: G,
29
- onDragEnd: x,
30
- onDragStart: N,
31
- disabled: J,
32
- maintainAspectRatio: r = !1,
33
- interval: L,
34
- initialHeight: M,
35
- initialWidth: O,
36
- // other With Render Props
37
- ...Q
38
- }) => {
39
- const s = ie(), [d, T] = H(null), [g, z] = H(), [p, b] = H(), [v, V] = H(!1), U = ee(
40
- (e) => {
41
- if (T(e), e && !g && !p) {
42
- const t = e.getBoundingClientRect();
43
- t.width > 0 && t.height > 0 && r && (z(t.width), b(t.height));
44
- }
45
- },
46
- [g, p, r]
47
- );
48
- B(() => {
49
- if (k !== void 0 && d) {
50
- d.style.width = "", d.style.height = "";
51
- const e = d.getBoundingClientRect();
52
- e.width > 0 && e.height > 0 && (r ? (z(e.width), b(e.height)) : (z(void 0), b(void 0)));
53
- }
54
- }, [k, d, r]);
55
- const y = re({
56
- initialWidth: r ? g : O,
57
- initialHeight: r ? p : M,
58
- maxHeight: I,
59
- maxWidth: _,
60
- minHeight: $,
61
- minWidth: j,
62
- lockHorizontal: q,
63
- lockVertical: F,
64
- onResize: G,
65
- disabled: J,
66
- maintainAspectRatio: r,
67
- interval: L,
68
- onDragStart: (e) => {
69
- if (V(!0), d) {
70
- const t = d.getBoundingClientRect();
71
- t.width > 0 && !g && z(t.width), t.height > 0 && !p && b(t.height);
72
- }
73
- N && N(e);
74
- },
75
- onDragEnd: (e) => {
76
- V(!1), x && x(e);
77
- }
78
- }), W = te(u);
79
- B(() => {
80
- v ? document.body.style.userSelect = "none" : document.body.style.userSelect = "";
81
- }, [v]);
82
- const { ref: X, ...Y } = y.getRootProps(), n = y.getHandleProps, f = y.rootRef, R = (e, t) => {
83
- if (!e.current || !E) return;
84
- const { widthDiff: P } = t;
85
- e.current.style.left = `${parseInt(e.current.style.left || "0") - P}px`;
86
- }, w = (e, t) => {
87
- if (!e.current || !E) return;
88
- const { heightDiff: P } = t;
89
- e.current.style.top = `${parseInt(e.current.style.top || "0") - P}px`;
90
- }, Z = a ? [
91
- o.top && !r && /* @__PURE__ */ l(
92
- "div",
93
- {
94
- className: c(
95
- s("resizable-resize-handle"),
96
- i?.resizeHandle
97
- ),
98
- "data-placement": "top-center",
99
- ...n({
100
- reverse: !0,
101
- lockHorizontal: !0,
102
- onResize: (e) => w(f, e)
103
- })
104
- },
105
- "top"
106
- ),
107
- o.bottom && !r && /* @__PURE__ */ l(
108
- "div",
109
- {
110
- className: c(
111
- s("resizable-resize-handle"),
112
- i?.resizeHandle
113
- ),
114
- "data-placement": "bottom-left",
115
- ...n({
116
- lockHorizontal: !0
117
- })
118
- },
119
- "bottom"
120
- ),
121
- o.left && !r && /* @__PURE__ */ l(
122
- "div",
123
- {
124
- className: c(
125
- s("resizable-resize-handle"),
126
- i?.resizeHandle
127
- ),
128
- "data-placement": "top-left",
129
- ...n({
130
- reverse: !0,
131
- lockVertical: !0,
132
- onResize: (e) => R(f, e)
133
- })
134
- },
135
- "left"
136
- ),
137
- o.right && !r && /* @__PURE__ */ l(
138
- "div",
139
- {
140
- className: c(
141
- s("resizable-resize-handle"),
142
- i?.resizeHandle
143
- ),
144
- "data-placement": "top-right",
145
- ...n({
146
- lockVertical: !0
147
- })
148
- },
149
- "right"
150
- ),
151
- // For aspect ratio maintenance, add corner handles that can resize both dimensions
152
- o.right && o.bottom && /* @__PURE__ */ l(
153
- "div",
154
- {
155
- className: c(
156
- s("resizable-resize-handle"),
157
- i?.resizeHandle
158
- ),
159
- "data-placement": "bottom-right-corner",
160
- ...n({
161
- // No locks - allow both horizontal and vertical resizing
162
- })
163
- },
164
- "bottom-right-corner"
165
- ),
166
- r && o.left && o.bottom && /* @__PURE__ */ l(
167
- "div",
168
- {
169
- className: c(
170
- s("resizable-resize-handle"),
171
- i?.resizeHandle
172
- ),
173
- "data-placement": "bottom-left-corner",
174
- ...n({
175
- reverse: !0,
176
- onResize: (e) => R(f, e)
177
- })
8
+ import { getReactElementProp as v } from "../utils/reactElement.js";
9
+ import { useCls as re } from "../utils/antdUtils.js";
10
+ import { clsx as c, cn as oe } from "../utils/cn.js";
11
+ import { WithRenderProp as ie } from "../utils/WithRenderProp.js";
12
+ const pe = Z(
13
+ ({
14
+ children: m,
15
+ resizable: a = !1,
16
+ handles: t = { bottom: !0, right: !0, left: !0, top: !0 },
17
+ classNames: l,
18
+ className: N,
19
+ style: W,
20
+ resetKey: y,
21
+ // Use Resizable Props
22
+ maxHeight: B,
23
+ maxWidth: S,
24
+ minHeight: V,
25
+ minWidth: x,
26
+ lockHorizontal: D,
27
+ lockVertical: _,
28
+ onResize: j,
29
+ onDragEnd: P,
30
+ onDragStart: w,
31
+ disabled: q,
32
+ maintainAspectRatio: o = !1,
33
+ interval: F,
34
+ initialHeight: G,
35
+ initialWidth: I,
36
+ // other With Render Props
37
+ ...J
38
+ }, L) => {
39
+ const s = re(), [d, M] = b(null), [g, p] = b(), [u, z] = b(), [H, E] = b(!1), O = $(
40
+ (e) => {
41
+ if (M(e), e && !g && !u) {
42
+ const r = e.getBoundingClientRect();
43
+ r.width > 0 && r.height > 0 && o && (p(r.width), z(r.height));
44
+ }
178
45
  },
179
- "bottom-left-corner"
180
- ),
181
- r && o.right && o.top && /* @__PURE__ */ l(
182
- "div",
183
- {
184
- className: c(
185
- s("resizable-resize-handle"),
186
- i?.resizeHandle
187
- ),
188
- "data-placement": "top-right-corner",
189
- ...n({
190
- reverse: !0,
191
- onResize: (e) => w(f, e)
192
- })
46
+ [g, u, o]
47
+ );
48
+ C(() => {
49
+ if (y !== void 0 && d) {
50
+ d.style.width = "", d.style.height = "";
51
+ const e = d.getBoundingClientRect();
52
+ e.width > 0 && e.height > 0 && (o ? (p(e.width), z(e.height)) : (p(void 0), z(void 0)));
53
+ }
54
+ }, [y, d, o]);
55
+ const k = A({
56
+ initialWidth: o ? g : I,
57
+ initialHeight: o ? u : G,
58
+ maxHeight: B,
59
+ maxWidth: S,
60
+ minHeight: V,
61
+ minWidth: x,
62
+ lockHorizontal: D,
63
+ lockVertical: _,
64
+ onResize: j,
65
+ disabled: q,
66
+ maintainAspectRatio: o,
67
+ interval: F,
68
+ onDragStart: (e) => {
69
+ if (E(!0), d) {
70
+ const r = d.getBoundingClientRect();
71
+ r.width > 0 && !g && p(r.width), r.height > 0 && !u && z(r.height);
72
+ }
73
+ w && w(e);
193
74
  },
194
- "top-right-corner"
195
- ),
196
- o.left && o.top && /* @__PURE__ */ l(
197
- "div",
75
+ onDragEnd: (e) => {
76
+ E(!1), P && P(e);
77
+ }
78
+ }), R = K(m);
79
+ C(() => {
80
+ H ? document.body.style.userSelect = "none" : document.body.style.userSelect = "";
81
+ }, [H]);
82
+ const { ref: Q, ...T } = k.getRootProps(), n = k.getHandleProps, U = a ? [
83
+ t.top && !o && /* @__PURE__ */ i(
84
+ "div",
85
+ {
86
+ className: c(
87
+ s("resizable-resize-handle"),
88
+ l?.resizeHandle
89
+ ),
90
+ "data-placement": "top-center",
91
+ ...n({
92
+ reverse: !0,
93
+ lockHorizontal: !0
94
+ // onResize: (values) =>
95
+ // onReverseHandleChangeVertical(rootRef, values),
96
+ })
97
+ },
98
+ "top"
99
+ ),
100
+ t.bottom && !o && /* @__PURE__ */ i(
101
+ "div",
102
+ {
103
+ className: c(
104
+ s("resizable-resize-handle"),
105
+ l?.resizeHandle
106
+ ),
107
+ "data-placement": "bottom-left",
108
+ ...n({
109
+ lockHorizontal: !0
110
+ })
111
+ },
112
+ "bottom"
113
+ ),
114
+ t.left && !o && /* @__PURE__ */ i(
115
+ "div",
116
+ {
117
+ className: c(
118
+ s("resizable-resize-handle"),
119
+ l?.resizeHandle
120
+ ),
121
+ "data-placement": "top-left",
122
+ ...n({
123
+ reverse: !0,
124
+ lockVertical: !0
125
+ // onResize: (values) =>
126
+ // onReverseHandleChangeHorizontal(rootRef, values),
127
+ })
128
+ },
129
+ "left"
130
+ ),
131
+ t.right && !o && /* @__PURE__ */ i(
132
+ "div",
133
+ {
134
+ className: c(
135
+ s("resizable-resize-handle"),
136
+ l?.resizeHandle
137
+ ),
138
+ "data-placement": "top-right",
139
+ ...n({
140
+ lockVertical: !0
141
+ })
142
+ },
143
+ "right"
144
+ ),
145
+ t.right && t.bottom && /* @__PURE__ */ i(
146
+ "div",
147
+ {
148
+ className: c(
149
+ s("resizable-resize-handle"),
150
+ l?.resizeHandle
151
+ ),
152
+ "data-placement": "bottom-right-corner",
153
+ ...n({
154
+ // No locks - allow both horizontal and vertical resizing
155
+ corner: "bottom-right"
156
+ })
157
+ },
158
+ "bottom-right-corner"
159
+ ),
160
+ t.left && t.top && /* @__PURE__ */ i(
161
+ "div",
162
+ {
163
+ className: c(
164
+ s("resizable-resize-handle"),
165
+ l?.resizeHandle
166
+ ),
167
+ "data-placement": "top-left-corner",
168
+ ...n({
169
+ corner: "top-left"
170
+ // onResize: (values) => {
171
+ // onReverseHandleChangeHorizontal(rootRef, values);
172
+ // onReverseHandleChangeVertical(rootRef, values);
173
+ // },
174
+ })
175
+ },
176
+ "top-left-corner"
177
+ ),
178
+ t.right && t.top && /* @__PURE__ */ i(
179
+ "div",
180
+ {
181
+ className: c(
182
+ s("resizable-resize-handle"),
183
+ l?.resizeHandle
184
+ ),
185
+ "data-placement": "top-right-corner",
186
+ ...n({
187
+ corner: "top-right"
188
+ // onResize: (values) => {
189
+ // onReverseHandleChangeVertical(rootRef, values);
190
+ // },
191
+ })
192
+ },
193
+ "top-right-corner"
194
+ ),
195
+ t.left && t.bottom && /* @__PURE__ */ i(
196
+ "div",
197
+ {
198
+ className: c(
199
+ s("resizable-resize-handle"),
200
+ l?.resizeHandle
201
+ ),
202
+ "data-placement": "bottom-left-corner",
203
+ ...n({
204
+ corner: "bottom-left"
205
+ // onResize: (values) => {
206
+ // onReverseHandleChangeHorizontal(rootRef, values);
207
+ // onReverseHandleChangeVertical(rootRef, values);
208
+ // },
209
+ })
210
+ },
211
+ "bottom-left-corner"
212
+ )
213
+ ] : [], f = m, h = {
214
+ className: v(f, "className"),
215
+ style: v(f, "style"),
216
+ children: v(f, "children")
217
+ }, X = {
218
+ className: oe(
219
+ a && s("resizable"),
220
+ l?.root,
221
+ h.className,
222
+ N
223
+ ),
224
+ ref: ee(
225
+ a ? Q : void 0,
226
+ O,
227
+ // Always need this for dimension measurement
228
+ f?.ref,
229
+ L
230
+ ),
231
+ style: { ...h.style, ...W },
232
+ ...H ? { "data-resizing": !0 } : {},
233
+ ...a ? { "data-resizable": !0 } : {},
234
+ children: R ? [
235
+ ...Array.isArray(h.children) ? h.children : [h.children],
236
+ ...U.filter(Boolean)
237
+ ] : m
238
+ };
239
+ return /* @__PURE__ */ i(
240
+ ie,
198
241
  {
199
- className: c(
200
- s("resizable-resize-handle"),
201
- i?.resizeHandle
202
- ),
203
- "data-placement": "top-left-corner",
204
- ...n({
205
- reverse: !0,
206
- onResize: (e) => {
207
- R(f, e), w(f, e);
208
- }
209
- })
210
- },
211
- "top-left-corner"
212
- )
213
- ] : [], h = u, m = {
214
- className: C(h, "className"),
215
- style: C(h, "style"),
216
- children: C(h, "children")
217
- }, K = {
218
- className: se(
219
- a && s("resizable"),
220
- i?.root,
221
- m.className,
222
- D
223
- ),
224
- ref: oe(
225
- a ? X : void 0,
226
- U,
227
- // Always need this for dimension measurement
228
- h?.ref
229
- ),
230
- style: { ...m.style, ...S },
231
- ...v ? { "data-resizing": !0 } : {},
232
- ...a ? { "data-resizable": !0 } : {},
233
- children: W ? [
234
- ...Array.isArray(m.children) ? m.children : [m.children],
235
- ...Z.filter(Boolean)
236
- ] : u
237
- };
238
- return /* @__PURE__ */ l(
239
- ne,
240
- {
241
- render: (e) => {
242
- const t = le(
243
- e,
244
- K,
245
- a ? Y : {}
246
- );
247
- return W ? A.cloneElement(h, t) : /* @__PURE__ */ l("div", { ...t, children: u });
248
- },
249
- ...Q
250
- }
251
- );
252
- };
242
+ render: (e) => {
243
+ const r = te(
244
+ e,
245
+ X,
246
+ a ? T : {}
247
+ );
248
+ return R ? Y.cloneElement(f, r) : /* @__PURE__ */ i("div", { ...r, children: m });
249
+ },
250
+ ...J
251
+ }
252
+ );
253
+ }
254
+ );
253
255
  export {
254
- be as Resizable
256
+ pe as Resizable
255
257
  };
256
258
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/components/resizable/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { useCallback, useEffect, useState, isValidElement } from \"react\";\nimport {\n useResizable,\n type MoveValues,\n ResizableProps as UseResizableProps,\n} from \"react-use-resizable\";\nimport mergeRefs from \"merge-refs\";\nimport {\n useCls,\n clsx,\n WithRenderProp,\n WithRenderPropProps,\n cn,\n getReactElementProp,\n} from \"../utils\";\nimport { mergeProps } from \"@base-ui-components/react\";\n\nimport \"./style.css\";\nimport { on } from \"node:stream\";\n\nexport interface ResizableProps\n extends Omit<WithRenderPropProps, keyof UseResizableProps>,\n UseResizableProps {\n /**\n * Single React element child that will be enhanced with resize handles\n */\n children: React.ReactNode;\n /**\n * Whether the component should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Configure which resize handles to show\n * @default { bottom: true, right: true, left: true, top: true }\n */\n handles?: {\n bottom?: boolean;\n right?: boolean;\n left?: boolean;\n top?: boolean;\n };\n /**\n * Whether to use absolute positioning for left handle resizing\n * Set to true when used in absolutely positioned containers like PopupPanel\n * @default false\n */\n absolutePositioning?: boolean;\n /**\n * Custom class names for different parts of the resizable component\n */\n classNames?: {\n root?: string;\n resizeHandle?: string;\n };\n /**\n * Key to reset dimensions to current element size\n * When this value changes, the component will recalculate its dimensions\n * Similar to React's key prop pattern for forcing component resets\n */\n resetKey?: React.Key;\n /**\n * Maximum width the component can be resized to\n */\n maxWidth?: number;\n /**\n * Maximum height the component can be resized to\n */\n maxHeight?: number;\n /**\n * Minimum width the component can be resized to\n */\n minWidth?: number;\n /**\n * Minimum height the component can be resized to\n */\n minHeight?: number;\n /**\n * Callback fired during resize operations\n */\n onResize?: (values: MoveValues) => void;\n /**\n * Whether to maintain aspect ratio during resize\n * @default false\n */\n maintainAspectRatio?: boolean;\n}\n\nexport const Resizable = ({\n children,\n resizable = false,\n handles = { bottom: true, right: true, left: true, top: true },\n absolutePositioning = false,\n classNames,\n className: containerClassName,\n style: containerStyle,\n resetKey,\n\n // Use Resizable Props\n maxHeight,\n maxWidth,\n minHeight,\n minWidth,\n lockHorizontal,\n lockVertical,\n onResize,\n onDragEnd: onDragEndProp,\n onDragStart: onDragStartProp,\n disabled,\n maintainAspectRatio = false,\n interval,\n initialHeight: initialHeightProp,\n initialWidth: initialWidthProp,\n // other With Render Props\n ...rest\n}: ResizableProps) => {\n // Validate that children is a single React element\n // if (!isValidElement(children)) {\n // throw new Error(\n // \"Resizable component expects a single React element as children\"\n // );\n // }\n\n const cls = useCls();\n const [panelRef, setPanelRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const [resizing, setResizing] = useState(false);\n\n const callbackRef = useCallback(\n (node: HTMLDivElement) => {\n setPanelRef(node);\n\n // Get initial dimensions only once when ref is set\n // For aspect ratio maintenance, we need initial dimensions immediately\n // Otherwise, preserve natural width/height behavior\n if (node && !width && !height) {\n const rect = node.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // Need dimensions for aspect ratio calculation\n setWidth(rect.width);\n setHeight(rect.height);\n }\n // For non-aspect-ratio cases, don't set dimensions to preserve natural behavior\n }\n }\n },\n [width, height, maintainAspectRatio],\n );\n\n // Reset dimensions when resetKey changes\n useEffect(() => {\n if (resetKey !== undefined && panelRef) {\n // Clear the hook's inline styles to reset to natural size\n panelRef.style.width = \"\";\n panelRef.style.height = \"\";\n\n // Force a reflow to get natural dimensions\n const rect = panelRef.getBoundingClientRect();\n\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // For aspect ratio maintenance, re-measure and set dimensions\n setWidth(rect.width);\n setHeight(rect.height);\n } else {\n // Reset state to allow natural dimensions again\n setWidth(undefined);\n setHeight(undefined);\n }\n\n // Don't apply any explicit dimensions - let them remain natural\n // panelRef.style.width = `${rect.width}px`;\n // panelRef.style.height = `${rect.height}px`;\n }\n }\n }, [resetKey, panelRef, maintainAspectRatio]);\n\n // Initialize useResizable with current dimensions (or undefined if not ready)\n // For aspect ratio maintenance, we need initial dimensions\n // Otherwise, preserve natural width/height behavior until user starts resizing\n const resizableHook = useResizable({\n initialWidth: maintainAspectRatio ? width : initialWidthProp,\n initialHeight: maintainAspectRatio ? height : initialHeightProp,\n maxHeight,\n maxWidth,\n minHeight,\n minWidth,\n lockHorizontal,\n lockVertical,\n onResize,\n disabled,\n maintainAspectRatio,\n interval,\n onDragStart: (values) => {\n setResizing(true);\n // Capture natural dimensions when user starts resizing\n if (panelRef) {\n const rect = panelRef.getBoundingClientRect();\n if (rect.width > 0 && !width) {\n setWidth(rect.width);\n }\n if (rect.height > 0 && !height) {\n setHeight(rect.height);\n }\n }\n if (onDragStartProp) onDragStartProp(values);\n },\n onDragEnd: (values) => {\n setResizing(false);\n if (onDragEndProp) onDragEndProp(values);\n },\n });\n\n const isChildrenValidElement = isValidElement(children);\n\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n\n // Get resizable props - useResizable hook handles cases where dimensions aren't ready\n const { ref: rootRefProp, ...rootPropsWithoutRef } =\n resizableHook.getRootProps();\n const getHandleProps = resizableHook.getHandleProps;\n const rootRef = resizableHook.rootRef;\n\n // Handle reverse handle change for horizontal resizing (only for absolute positioning)\n const onReverseHandleChangeHorizontal = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues,\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { widthDiff } = values;\n parent.current.style.left = `${\n parseInt(parent.current.style.left || \"0\") - widthDiff\n }px`;\n };\n\n // Handle reverse handle change for vertical resizing (only for absolute positioning)\n const onReverseHandleChangeVertical = (\n parent: React.RefObject<HTMLDivElement>,\n values: MoveValues,\n ) => {\n if (!parent.current || !absolutePositioning) return;\n const { heightDiff } = values;\n parent.current.style.top = `${\n parseInt(parent.current.style.top || \"0\") - heightDiff\n }px`;\n };\n\n const resizeHandles = resizable\n ? [\n handles.top && !maintainAspectRatio && (\n <div\n key=\"top\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle,\n )}\n data-placement=\"top-center\"\n {...getHandleProps({\n reverse: true,\n lockHorizontal: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.bottom && !maintainAspectRatio && (\n <div\n key=\"bottom\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle,\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n ),\n handles.left && !maintainAspectRatio && (\n <div\n key=\"left\"\n className={clsx(\n cls(\"resizable-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 ),\n handles.right && !maintainAspectRatio && (\n <div\n key=\"right\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle,\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n ),\n // For aspect ratio maintenance, add corner handles that can resize both dimensions\n handles.right && handles.bottom && (\n <div\n key=\"bottom-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle,\n )}\n data-placement=\"bottom-right-corner\"\n {...getHandleProps({\n // No locks - allow both horizontal and vertical resizing\n })}\n />\n ),\n maintainAspectRatio && handles.left && handles.bottom && (\n <div\n key=\"bottom-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle,\n )}\n data-placement=\"bottom-left-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) =>\n onReverseHandleChangeHorizontal(rootRef, values),\n })}\n />\n ),\n maintainAspectRatio && handles.right && handles.top && (\n <div\n key=\"top-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle,\n )}\n data-placement=\"top-right-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) =>\n onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.left && handles.top && (\n <div\n key=\"top-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle,\n )}\n data-placement=\"top-left-corner\"\n {...getHandleProps({\n reverse: true,\n onResize: (values) => {\n onReverseHandleChangeHorizontal(rootRef, values);\n onReverseHandleChangeVertical(rootRef, values);\n },\n })}\n />\n ),\n ]\n : [];\n\n const childElement = children as React.ReactElement & {\n ref?: React.Ref<HTMLDivElement>;\n };\n\n const childElementProps = {\n className: getReactElementProp<string>(childElement, \"className\"),\n style: getReactElementProp<React.CSSProperties>(childElement, \"style\"),\n children: getReactElementProp<React.ReactNode>(childElement, \"children\"),\n ref: childElement.ref,\n };\n\n const childProps = {\n className: cn(\n resizable && cls(\"resizable\"),\n classNames?.root,\n childElementProps.className,\n containerClassName,\n ),\n ref: mergeRefs(\n resizable ? rootRefProp : undefined,\n callbackRef, // Always need this for dimension measurement\n childElement?.ref,\n ),\n style: { ...childElementProps.style, ...containerStyle },\n ...(resizing ? { \"data-resizing\": true } : {}),\n ...(resizable ? { \"data-resizable\": true } : {}),\n children: isChildrenValidElement\n ? [\n ...(Array.isArray(childElementProps.children)\n ? childElementProps.children\n : [childElementProps.children]),\n ...resizeHandles.filter(Boolean),\n ]\n : children,\n };\n\n return (\n <WithRenderProp\n render={(props) => {\n // Merge the props from WithRenderProp with our childProps\n const mergedProps = mergeProps(\n props,\n childProps,\n resizable ? rootPropsWithoutRef : {},\n );\n if (isChildrenValidElement) {\n return React.cloneElement(childElement, mergedProps);\n } else {\n return <div {...mergedProps}>{children}</div>;\n }\n }}\n {...rest}\n />\n );\n};\n"],"names":["Resizable","children","resizable","handles","absolutePositioning","classNames","containerClassName","containerStyle","resetKey","maxHeight","maxWidth","minHeight","minWidth","lockHorizontal","lockVertical","onResize","onDragEndProp","onDragStartProp","disabled","maintainAspectRatio","interval","initialHeightProp","initialWidthProp","rest","cls","useCls","panelRef","setPanelRef","useState","width","setWidth","height","setHeight","resizing","setResizing","callbackRef","useCallback","node","rect","useEffect","resizableHook","useResizable","values","isChildrenValidElement","isValidElement","rootRefProp","rootPropsWithoutRef","getHandleProps","rootRef","onReverseHandleChangeHorizontal","parent","widthDiff","onReverseHandleChangeVertical","heightDiff","resizeHandles","jsx","clsx","childElement","childElementProps","getReactElementProp","childProps","cn","mergeRefs","WithRenderProp","props","mergedProps","mergeProps","React"],"mappings":";;;;;;;;;;;AAyFO,MAAMA,KAAY,CAAC;AAAA,EACxB,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU,EAAE,QAAQ,IAAM,OAAO,IAAM,MAAM,IAAM,KAAK,GAAA;AAAA,EACxD,qBAAAC,IAAsB;AAAA,EACtB,YAAAC;AAAA,EACA,WAAWC;AAAA,EACX,OAAOC;AAAA,EACP,UAAAC;AAAA;AAAA,EAGA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAWC;AAAA,EACX,aAAaC;AAAA,EACb,UAAAC;AAAA,EACA,qBAAAC,IAAsB;AAAA,EACtB,UAAAC;AAAA,EACA,eAAeC;AAAA,EACf,cAAcC;AAAA;AAAA,EAEd,GAAGC;AACL,MAAsB;AAQpB,QAAMC,IAAMC,GAAA,GACN,CAACC,GAAUC,CAAW,IAAIC,EAAgC,IAAI,GAC9D,CAACC,GAAOC,CAAQ,IAAIF,EAAA,GACpB,CAACG,GAAQC,CAAS,IAAIJ,EAAA,GACtB,CAACK,GAAUC,CAAW,IAAIN,EAAS,EAAK,GAExCO,IAAcC;AAAA,IAClB,CAACC,MAAyB;AAMxB,UALAV,EAAYU,CAAI,GAKZA,KAAQ,CAACR,KAAS,CAACE,GAAQ;AAC7B,cAAMO,IAAOD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AA;AAAA,IAEhB,OAAO,EAAE,GAAGC,EAAkB,OAAO,GAAGnD,EAAA;AAAA,IACxC,GAAI0B,IAAW,EAAE,iBAAiB,GAAA,IAAS,CAAA;AAAA,IAC3C,GAAI/B,IAAY,EAAE,kBAAkB,GAAA,IAAS,CAAA;AAAA,IAC7C,UAAUyC,IACN;AAAA,MACE,GAAI,MAAM,QAAQe,EAAkB,QAAQ,IACxCA,EAAkB,WAClB,CAACA,EAAkB,QAAQ;AAAA,MAC/B,GAAGJ,EAAc,OAAO,OAAO;AAAA,IAAA,IAEjCrD;AAAA,EAAA;AAGN,SACE,gBAAAsD;AAAA,IAACQ;AAAA,IAAA;AAAA,MACC,QAAQ,CAACC,MAAU;AAEjB,cAAMC,IAAcC;AAAA,UAClBF;AAAA,UACAJ;AAAA,UACA1D,IAAY4C,IAAsB,CAAA;AAAA,QAAC;AAErC,eAAIH,IACKwB,EAAM,aAAaV,GAAcQ,CAAW,IAE5C,gBAAAV,EAAC,OAAA,EAAK,GAAGU,GAAc,UAAAhE,EAAA,CAAS;AAAA,MAE3C;AAAA,MACC,GAAGsB;AAAA,IAAA;AAAA,EAAA;AAGV;"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/components/resizable/component.tsx"],"sourcesContent":["\"use client\";\nimport React, {\n useCallback,\n useEffect,\n useState,\n isValidElement,\n forwardRef,\n} from \"react\";\nimport {\n useResizable,\n type MoveValues,\n ResizableProps as UseResizableProps,\n} from \"../hooks/useResizable\";\nimport mergeRefs from \"merge-refs\";\nimport {\n useCls,\n clsx,\n WithRenderProp,\n WithRenderPropProps,\n cn,\n getReactElementProp,\n} from \"../utils\";\nimport { mergeProps } from \"@base-ui-components/react\";\n\nimport \"./style.css\";\n// import { on } from \"node:stream\";\n\nexport interface ResizableProps\n extends Omit<WithRenderPropProps, keyof UseResizableProps>,\n UseResizableProps {\n /**\n * Single React element child that will be enhanced with resize handles\n */\n children: React.ReactNode;\n /**\n * Whether the component should be resizable\n * @default false\n */\n resizable?: boolean;\n /**\n * Configure which resize handles to show\n * @default { bottom: true, right: true, left: true, top: true }\n */\n handles?: {\n bottom?: boolean;\n right?: boolean;\n left?: boolean;\n top?: boolean;\n };\n // /**\n // * Whether to use absolute positioning for left handle resizing\n // * Set to true when used in absolutely positioned containers like PopupPanel\n // * @default false\n // */\n // absolutePositioning?: boolean;\n /**\n * Custom class names for different parts of the resizable component\n */\n classNames?: {\n root?: string;\n resizeHandle?: string;\n };\n /**\n * Key to reset dimensions to current element size\n * When this value changes, the component will recalculate its dimensions\n * Similar to React's key prop pattern for forcing component resets\n */\n resetKey?: React.Key;\n /**\n * Maximum width the component can be resized to\n */\n maxWidth?: number;\n /**\n * Maximum height the component can be resized to\n */\n maxHeight?: number;\n /**\n * Minimum width the component can be resized to\n */\n minWidth?: number;\n /**\n * Minimum height the component can be resized to\n */\n minHeight?: number;\n /**\n * Callback fired during resize operations\n */\n onResize?: (values: MoveValues) => void;\n /**\n * Whether to maintain aspect ratio during resize\n * @default false\n */\n maintainAspectRatio?: boolean;\n}\n\nexport const Resizable = forwardRef<HTMLDivElement, ResizableProps>(\n (\n {\n children,\n resizable = false,\n handles = { bottom: true, right: true, left: true, top: true },\n classNames,\n className: containerClassName,\n style: containerStyle,\n resetKey,\n\n // Use Resizable Props\n maxHeight,\n maxWidth,\n minHeight,\n minWidth,\n lockHorizontal,\n lockVertical,\n onResize,\n onDragEnd: onDragEndProp,\n onDragStart: onDragStartProp,\n disabled,\n maintainAspectRatio = false,\n interval,\n initialHeight: initialHeightProp,\n initialWidth: initialWidthProp,\n // other With Render Props\n ...rest\n },\n ref\n ) => {\n // Validate that children is a single React element\n // if (!isValidElement(children)) {\n // throw new Error(\n // \"Resizable component expects a single React element as children\"\n // );\n // }\n\n const cls = useCls();\n const [panelRef, setPanelRef] = useState<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number>();\n const [height, setHeight] = useState<number>();\n const [resizing, setResizing] = useState(false);\n\n const callbackRef = useCallback(\n (node: HTMLDivElement) => {\n setPanelRef(node);\n\n // Get initial dimensions only once when ref is set\n // For aspect ratio maintenance, we need initial dimensions immediately\n // Otherwise, preserve natural width/height behavior\n if (node && !width && !height) {\n const rect = node.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // Need dimensions for aspect ratio calculation\n setWidth(rect.width);\n setHeight(rect.height);\n }\n // For non-aspect-ratio cases, don't set dimensions to preserve natural behavior\n }\n }\n },\n [width, height, maintainAspectRatio]\n );\n\n // Reset dimensions when resetKey changes\n useEffect(() => {\n if (resetKey !== undefined && panelRef) {\n // Clear the hook's inline styles to reset to natural size\n panelRef.style.width = \"\";\n panelRef.style.height = \"\";\n\n // Force a reflow to get natural dimensions\n const rect = panelRef.getBoundingClientRect();\n\n if (rect.width > 0 && rect.height > 0) {\n if (maintainAspectRatio) {\n // For aspect ratio maintenance, re-measure and set dimensions\n setWidth(rect.width);\n setHeight(rect.height);\n } else {\n // Reset state to allow natural dimensions again\n setWidth(undefined);\n setHeight(undefined);\n }\n\n // Don't apply any explicit dimensions - let them remain natural\n // panelRef.style.width = `${rect.width}px`;\n // panelRef.style.height = `${rect.height}px`;\n }\n }\n }, [resetKey, panelRef, maintainAspectRatio]);\n\n // Initialize useResizable with current dimensions (or undefined if not ready)\n // For aspect ratio maintenance, we need initial dimensions\n // Otherwise, preserve natural width/height behavior until user starts resizing\n const resizableHook = useResizable({\n initialWidth: maintainAspectRatio ? width : initialWidthProp,\n initialHeight: maintainAspectRatio ? height : initialHeightProp,\n maxHeight,\n maxWidth,\n minHeight,\n minWidth,\n lockHorizontal,\n lockVertical,\n onResize,\n disabled,\n maintainAspectRatio,\n interval,\n onDragStart: (values) => {\n setResizing(true);\n // Capture natural dimensions when user starts resizing\n if (panelRef) {\n const rect = panelRef.getBoundingClientRect();\n if (rect.width > 0 && !width) {\n setWidth(rect.width);\n }\n if (rect.height > 0 && !height) {\n setHeight(rect.height);\n }\n }\n if (onDragStartProp) onDragStartProp(values);\n },\n onDragEnd: (values) => {\n setResizing(false);\n if (onDragEndProp) onDragEndProp(values);\n },\n });\n\n const isChildrenValidElement = isValidElement(children);\n\n useEffect(() => {\n if (resizing) {\n document.body.style.userSelect = \"none\";\n } else {\n document.body.style.userSelect = \"\";\n }\n }, [resizing]);\n\n // Get resizable props - useResizable hook handles cases where dimensions aren't ready\n const { ref: rootRefProp, ...rootPropsWithoutRef } =\n resizableHook.getRootProps();\n const getHandleProps = resizableHook.getHandleProps;\n\n // // Handle reverse handle change for horizontal resizing (only for absolute positioning)\n // const onReverseHandleChangeHorizontal = (\n // parent: React.RefObject<HTMLDivElement>,\n // values: MoveValues\n // ) => {\n // if (!parent.current || !absolutePositioning) return;\n // const { widthDiff } = values;\n // parent.current.style.left = `${\n // parseInt(parent.current.style.left || \"0\") - widthDiff\n // }px`;\n // };\n\n // // Handle reverse handle change for vertical resizing (only for absolute positioning)\n // const onReverseHandleChangeVertical = (\n // parent: React.RefObject<HTMLDivElement>,\n // values: MoveValues\n // ) => {\n // if (!parent.current || !absolutePositioning) return;\n // const { heightDiff } = values;\n // console.log({\n // parentStyleTop: parent.current.style.top,\n // computedStyleTop: window.getComputedStyle(parent.current).top,\n // });\n // parent.current.style.top = `${\n // parseInt(parent.current.style.top || \"0\") - heightDiff\n // }px`;\n // };\n\n const resizeHandles = resizable\n ? [\n handles.top && !maintainAspectRatio && (\n <div\n key=\"top\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-center\"\n {...getHandleProps({\n reverse: true,\n lockHorizontal: true,\n // onResize: (values) =>\n // onReverseHandleChangeVertical(rootRef, values),\n })}\n />\n ),\n handles.bottom && !maintainAspectRatio && (\n <div\n key=\"bottom\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left\"\n {...getHandleProps({\n lockHorizontal: true,\n })}\n />\n ),\n handles.left && !maintainAspectRatio && (\n <div\n key=\"left\"\n className={clsx(\n cls(\"resizable-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 ),\n handles.right && !maintainAspectRatio && (\n <div\n key=\"right\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right\"\n {...getHandleProps({\n lockVertical: true,\n })}\n />\n ),\n handles.right && handles.bottom && (\n <div\n key=\"bottom-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-right-corner\"\n {...getHandleProps({\n // No locks - allow both horizontal and vertical resizing\n corner: \"bottom-right\",\n })}\n />\n ),\n handles.left && handles.top && (\n <div\n key=\"top-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-left-corner\"\n {...getHandleProps({\n corner: \"top-left\",\n // onResize: (values) => {\n // onReverseHandleChangeHorizontal(rootRef, values);\n // onReverseHandleChangeVertical(rootRef, values);\n // },\n })}\n />\n ),\n handles.right && handles.top && (\n <div\n key=\"top-right-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"top-right-corner\"\n {...getHandleProps({\n corner: \"top-right\",\n // onResize: (values) => {\n // onReverseHandleChangeVertical(rootRef, values);\n // },\n })}\n />\n ),\n handles.left && handles.bottom && (\n <div\n key=\"bottom-left-corner\"\n className={clsx(\n cls(\"resizable-resize-handle\"),\n classNames?.resizeHandle\n )}\n data-placement=\"bottom-left-corner\"\n {...getHandleProps({\n corner: \"bottom-left\",\n // onResize: (values) => {\n // onReverseHandleChangeHorizontal(rootRef, values);\n // onReverseHandleChangeVertical(rootRef, values);\n // },\n })}\n />\n ),\n ]\n : [];\n\n const childElement = children as React.ReactElement & {\n ref?: React.Ref<HTMLDivElement>;\n };\n\n const childElementProps = {\n className: getReactElementProp<string>(childElement, \"className\"),\n style: getReactElementProp<React.CSSProperties>(childElement, \"style\"),\n children: getReactElementProp<React.ReactNode>(childElement, \"children\"),\n ref: childElement.ref,\n };\n\n const childProps = {\n className: cn(\n resizable && cls(\"resizable\"),\n classNames?.root,\n childElementProps.className,\n containerClassName\n ),\n ref: mergeRefs(\n resizable ? rootRefProp : undefined,\n callbackRef, // Always need this for dimension measurement\n childElement?.ref,\n ref\n ),\n style: { ...childElementProps.style, ...containerStyle },\n ...(resizing ? { \"data-resizing\": true } : {}),\n ...(resizable ? { \"data-resizable\": true } : {}),\n children: isChildrenValidElement\n ? [\n ...(Array.isArray(childElementProps.children)\n ? childElementProps.children\n : [childElementProps.children]),\n ...resizeHandles.filter(Boolean),\n ]\n : children,\n };\n\n return (\n <WithRenderProp\n render={(props) => {\n // Merge the props from WithRenderProp with our childProps\n const mergedProps = mergeProps(\n props,\n childProps,\n resizable ? rootPropsWithoutRef : {}\n );\n if (isChildrenValidElement) {\n return React.cloneElement(childElement, mergedProps);\n } else {\n return <div {...mergedProps}>{children}</div>;\n }\n }}\n {...rest}\n />\n );\n }\n);\n"],"names":["Resizable","forwardRef","children","resizable","handles","classNames","containerClassName","containerStyle","resetKey","maxHeight","maxWidth","minHeight","minWidth","lockHorizontal","lockVertical","onResize","onDragEndProp","onDragStartProp","disabled","maintainAspectRatio","interval","initialHeightProp","initialWidthProp","rest","ref","cls","useCls","panelRef","setPanelRef","useState","width","setWidth","height","setHeight","resizing","setResizing","callbackRef","useCallback","node","rect","useEffect","resizableHook","useResizable","values","isChildrenValidElement","isValidElement","rootRefProp","rootPropsWithoutRef","getHandleProps","resizeHandles","jsx","clsx","childElement","childElementProps","getReactElementProp","childProps","cn","mergeRefs","WithRenderProp","props","mergedProps","mergeProps","React"],"mappings":";;;;;;;;;;;AA+FO,MAAMA,KAAYC;AAAA,EACvB,CACE;AAAA,IACE,UAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,S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A,MAAA;AAAA,MAEF,KAAKmD;AAAAA,QACHtD,IAAY2C,IAAc;AAAA,QAC1BV;AAAA;AAAA,QACAgB,GAAc;AAAA,QACd5B;AAAA,MAAA;AAAA,MAEF,OAAO,EAAE,GAAG6B,EAAkB,OAAO,GAAG9C,EAAA;AAAA,MACxC,GAAI2B,IAAW,EAAE,iBAAiB,GAAA,IAAS,CAAA;AAAA,MAC3C,GAAI/B,IAAY,EAAE,kBAAkB,GAAA,IAAS,CAAA;AAAA,MAC7C,UAAUyC,IACN;AAAA,QACE,GAAI,MAAM,QAAQS,EAAkB,QAAQ,IACxCA,EAAkB,WAClB,CAACA,EAAkB,QAAQ;AAAA,QAC/B,GAAGJ,EAAc,OAAO,OAAO;AAAA,MAAA,IAEjC/C;AAAA,IAAA;AAGN,WACE,gBAAAgD;AAAA,MAACQ;AAAA,MAAA;AAAA,QACC,QAAQ,CAACC,MAAU;AAEjB,gBAAMC,IAAcC;AAAA,YAClBF;AAAA,YACAJ;AAAA,YACApD,IAAY4C,IAAsB,CAAA;AAAA,UAAC;AAErC,iBAAIH,IACKkB,EAAM,aAAaV,GAAcQ,CAAW,IAE5C,gBAAAV,EAAC,OAAA,EAAK,GAAGU,GAAc,UAAA1D,EAAA,CAAS;AAAA,QAE3C;AAAA,QACC,GAAGqB;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV;AACF;"}
@@ -0,0 +1,24 @@
1
+ import { WindowPortalProps } from './types';
2
+ /**
3
+ * WindowPortal - Renders content in a separate browser window
4
+ *
5
+ * This component creates a new browser window and renders its children inside it.
6
+ * It automatically copies parent window styles for consistent theming and handles
7
+ * cleanup when the component unmounts or the window is closed.
8
+ *
9
+ * **Performance Note**: Rapid state updates (e.g., text input) may have slight latency
10
+ * due to React reconciliation across different window contexts. This is expected behavior
11
+ * when using portals across window boundaries.
12
+ *
13
+ * **Theme Synchronization**: The component automatically syncs theme changes (light/dark mode)
14
+ * from the parent window to the popup window using a MutationObserver.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <WindowPortal width={800} height={600} title="My Window">
19
+ * <div>Content rendered in separate window</div>
20
+ * </WindowPortal>
21
+ * ```
22
+ */
23
+ export declare function WindowPortal({ children, width, height, left, top, title, copyStyles, onClose, windowFeatures, }: WindowPortalProps): import('react').ReactPortal;
24
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/window-portal/component.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAW,EACX,MAAY,EACZ,IAAU,EACV,GAAS,EACT,KAAU,EACV,UAAiB,EACjB,OAAO,EACP,cAAmB,GACpB,EAAE,iBAAiB,+BAiOnB"}