@bioturing/components 0.42.0 → 0.43.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/button/component.d.ts.map +1 -1
- package/dist/components/button/component.js +41 -34
- package/dist/components/button/component.js.map +1 -1
- package/dist/components/button/style.css +1 -1
- package/dist/components/combobox/component.d.ts.map +1 -1
- package/dist/components/combobox/component.js +136 -126
- package/dist/components/combobox/component.js.map +1 -1
- package/dist/components/command-palette/component.d.ts +7 -0
- package/dist/components/command-palette/component.d.ts.map +1 -1
- package/dist/components/command-palette/component.js +35 -33
- package/dist/components/command-palette/component.js.map +1 -1
- package/dist/components/dropdown-menu/component.d.ts +8 -1
- package/dist/components/dropdown-menu/component.d.ts.map +1 -1
- package/dist/components/dropdown-menu/component.js +165 -141
- package/dist/components/dropdown-menu/component.js.map +1 -1
- package/dist/components/dropdown-menu/style.css +1 -1
- package/dist/components/ds-root/component.d.ts +6 -1
- package/dist/components/ds-root/component.d.ts.map +1 -1
- package/dist/components/ds-root/component.js +15 -14
- package/dist/components/ds-root/component.js.map +1 -1
- package/dist/components/form/style.css +1 -1
- package/dist/components/hooks/index.d.ts +0 -1
- package/dist/components/hooks/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/label-with-help/component.d.ts +20 -0
- package/dist/components/label-with-help/component.d.ts.map +1 -0
- package/dist/components/label-with-help/component.js +39 -0
- package/dist/components/label-with-help/component.js.map +1 -0
- package/dist/components/label-with-help/index.d.ts +2 -0
- package/dist/components/label-with-help/index.d.ts.map +1 -0
- package/dist/components/label-with-help/style.css +1 -0
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/Modal.js +157 -133
- package/dist/components/modal/Modal.js.map +1 -1
- package/dist/components/popup-panel/component.d.ts +2 -111
- package/dist/components/popup-panel/component.d.ts.map +1 -1
- package/dist/components/popup-panel/component.js +253 -139
- package/dist/components/popup-panel/component.js.map +1 -1
- package/dist/components/popup-panel/constants.d.ts +1 -0
- package/dist/components/popup-panel/constants.d.ts.map +1 -1
- package/dist/components/popup-panel/constants.js +2 -0
- package/dist/components/popup-panel/constants.js.map +1 -1
- package/dist/components/popup-panel/index.d.ts +1 -0
- package/dist/components/popup-panel/index.d.ts.map +1 -1
- package/dist/components/popup-panel/types.d.ts +124 -0
- package/dist/components/popup-panel/types.d.ts.map +1 -0
- package/dist/components/popup-panel/utils.d.ts +1 -1
- package/dist/components/popup-panel/utils.d.ts.map +1 -1
- package/dist/components/popup-panel/utils.js +5 -5
- package/dist/components/popup-panel/utils.js.map +1 -1
- package/dist/components/resizable/component.d.ts.map +1 -1
- package/dist/components/resizable/component.js +28 -28
- package/dist/components/resizable/component.js.map +1 -1
- package/dist/components/select/component.d.ts.map +1 -1
- package/dist/components/select/component.js +130 -120
- package/dist/components/select/component.js.map +1 -1
- package/dist/components/toast/component.d.ts +2 -2
- package/dist/components/toast/component.d.ts.map +1 -1
- package/dist/components/toast/component.js +14 -20
- package/dist/components/toast/component.js.map +1 -1
- package/dist/components/toast/function.d.ts +7 -8
- package/dist/components/toast/function.d.ts.map +1 -1
- package/dist/components/toast/function.js.map +1 -1
- package/dist/components/toast/style.css +1 -1
- package/dist/components/toast/types.d.ts +4 -0
- package/dist/components/toast/types.d.ts.map +1 -1
- package/dist/components/utils/placement.d.ts +9 -2
- package/dist/components/utils/placement.d.ts.map +1 -1
- package/dist/components/utils/placement.js +29 -18
- package/dist/components/utils/placement.js.map +1 -1
- package/dist/components/utils/reactElement.d.ts +2 -0
- package/dist/components/utils/reactElement.d.ts.map +1 -1
- package/dist/components/utils/reactElement.js +10 -2
- package/dist/components/utils/reactElement.js.map +1 -1
- package/dist/components/utils/renderProp.d.ts.map +1 -1
- package/dist/components/utils/renderProp.js +9 -8
- package/dist/components/utils/renderProp.js.map +1 -1
- package/dist/index.js +191 -189
- package/dist/metadata.d.ts +8 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +15 -0
- package/dist/metadata.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +2 -2
- package/dist/components/hooks/useBaseUIPlacement.d.ts +0 -64
- package/dist/components/hooks/useBaseUIPlacement.d.ts.map +0 -1
- package/dist/components/hooks/useBaseUIPlacement.js +0 -61
- package/dist/components/hooks/useBaseUIPlacement.js.map +0 -1
|
@@ -1,186 +1,300 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as r, jsxs as
|
|
3
|
-
import { Popover as
|
|
4
|
-
import { mergeProps as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { jsx as r, jsxs as s, Fragment as ue } from "react/jsx-runtime";
|
|
3
|
+
import { Popover as d } from "@base-ui/react/popover";
|
|
4
|
+
import { mergeProps as G } from "@base-ui/react";
|
|
5
|
+
import { useStableCallback as se } from "@base-ui/utils/useStableCallback";
|
|
6
|
+
import { X as de } from "@bioturing/assets";
|
|
7
|
+
import { useState as ae, useMemo as u, useCallback as Q, useRef as me, useEffect as ge } from "react";
|
|
8
|
+
import { Stack as he } from "../stack/index.js";
|
|
9
|
+
import { PopupPanelSize as Oe, DEFAULT_SIDE_OFFSET as be } from "./constants.js";
|
|
9
10
|
import './style.css';/* empty css */
|
|
10
|
-
import { anchorToResizeHandles as
|
|
11
|
-
import { useDraggable as
|
|
12
|
-
import { Resizable as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
11
|
+
import { anchorToResizeHandles as Ee } from "./utils.js";
|
|
12
|
+
import { useDraggable as Se } from "../hooks/useDraggable.js";
|
|
13
|
+
import { Resizable as Pe } from "../resizable/component.js";
|
|
14
|
+
import { parseAntdPlacement as Re, buildAntdPlacement as ve } from "../utils/placement.js";
|
|
15
|
+
import { useControlledState as ye } from "../hooks/useControlledState.js";
|
|
16
|
+
import { useCls as Te } from "../utils/antdUtils.js";
|
|
17
|
+
import { useTheme as ke } from "../theme-provider/context/themeStore.js";
|
|
18
|
+
import { clsx as a } from "../utils/cn.js";
|
|
19
|
+
import { IconButton as Ce } from "../icon-button/component.js";
|
|
20
|
+
const D = {};
|
|
21
|
+
function V({
|
|
22
|
+
side: m,
|
|
23
|
+
align: P,
|
|
24
|
+
onPlacementChange: g
|
|
25
|
+
}) {
|
|
26
|
+
const R = me(void 0);
|
|
27
|
+
return ge(() => {
|
|
28
|
+
const h = ve({
|
|
29
|
+
side: m,
|
|
30
|
+
align: P
|
|
31
|
+
});
|
|
32
|
+
h !== R.current && (R.current = h, g?.(h));
|
|
33
|
+
}, [m, P, g]), null;
|
|
34
|
+
}
|
|
35
|
+
const Ye = ({
|
|
36
|
+
children: m,
|
|
37
|
+
placement: P,
|
|
38
|
+
openOnHover: g = !1,
|
|
39
|
+
open: R,
|
|
40
|
+
onOpenChange: h,
|
|
41
|
+
content: w,
|
|
42
|
+
title: v,
|
|
43
|
+
trigger: H = "click",
|
|
44
|
+
className: I,
|
|
45
|
+
anchor: n,
|
|
46
|
+
beforeCloseButton: z,
|
|
47
|
+
afterCloseButton: M,
|
|
48
|
+
afterTitle: T,
|
|
49
|
+
size: O = "medium",
|
|
50
|
+
footer: b,
|
|
51
|
+
defaultOpen: W = !1,
|
|
52
|
+
resizable: k = !1,
|
|
53
|
+
draggable: Z = !1,
|
|
54
|
+
maintainAspectRatio: $ = !1,
|
|
40
55
|
classNames: e,
|
|
41
|
-
modal:
|
|
42
|
-
closeOnClickOutside:
|
|
43
|
-
onPlacementChange:
|
|
44
|
-
positionerProps:
|
|
45
|
-
triggerProps:
|
|
46
|
-
portalProps:
|
|
47
|
-
|
|
56
|
+
modal: N = !1,
|
|
57
|
+
closeOnClickOutside: ee = !0,
|
|
58
|
+
onPlacementChange: C,
|
|
59
|
+
positionerProps: p = D,
|
|
60
|
+
triggerProps: te = D,
|
|
61
|
+
portalProps: re = D,
|
|
62
|
+
offsetFrom: E,
|
|
63
|
+
nativeButton: j = !0,
|
|
64
|
+
...ne
|
|
48
65
|
}) => {
|
|
49
|
-
const [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
const [oe, x] = ye(
|
|
67
|
+
R,
|
|
68
|
+
h,
|
|
69
|
+
W
|
|
53
70
|
// Always provide a default value to prevent undefined
|
|
54
|
-
),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}),
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
), t = Te(), { className: A } = ke(), y = Re(P), [K, U] = ae(null), _ = u(() => {
|
|
72
|
+
if (n instanceof Element) return n;
|
|
73
|
+
if (n != null && "current" in n) return n.current;
|
|
74
|
+
if (typeof n == "function") {
|
|
75
|
+
const o = n();
|
|
76
|
+
return o instanceof Element ? o : null;
|
|
77
|
+
}
|
|
78
|
+
return K;
|
|
79
|
+
}, [n, K]), B = u(() => {
|
|
80
|
+
if (typeof p.sideOffset == "function")
|
|
81
|
+
return p.sideOffset;
|
|
82
|
+
const o = typeof p.sideOffset == "number" ? p.sideOffset : 0, l = be + o;
|
|
83
|
+
return E ? ({ side: q }) => {
|
|
84
|
+
const S = E.current;
|
|
85
|
+
if (!S || !_) return l;
|
|
86
|
+
const i = S.getBoundingClientRect(), c = _.getBoundingClientRect();
|
|
87
|
+
let f;
|
|
88
|
+
switch (q) {
|
|
89
|
+
case "bottom":
|
|
90
|
+
f = i.bottom - c.bottom;
|
|
91
|
+
break;
|
|
92
|
+
case "top":
|
|
93
|
+
f = c.top - i.top;
|
|
94
|
+
break;
|
|
95
|
+
case "right":
|
|
96
|
+
f = i.right - c.right;
|
|
97
|
+
break;
|
|
98
|
+
case "left":
|
|
99
|
+
f = c.left - i.left;
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
f = 0;
|
|
103
|
+
}
|
|
104
|
+
return Math.max(0, f) + l;
|
|
105
|
+
} : l;
|
|
106
|
+
}, [E, _, p.sideOffset]), F = u(() => /* @__PURE__ */ r(de, { size: 16 }), []), J = Q(() => /* @__PURE__ */ s("div", { className: a(t("popup-panel-header"), e?.header), children: [
|
|
107
|
+
/* @__PURE__ */ s(
|
|
108
|
+
he,
|
|
65
109
|
{
|
|
66
110
|
align: "center",
|
|
67
111
|
gap: 8,
|
|
68
|
-
className:
|
|
112
|
+
className: t("popup-panel-title-wrapper"),
|
|
69
113
|
children: [
|
|
70
114
|
/* @__PURE__ */ r(
|
|
71
|
-
|
|
115
|
+
d.Title,
|
|
72
116
|
{
|
|
73
|
-
render: /* @__PURE__ */ r("div", { className:
|
|
117
|
+
render: /* @__PURE__ */ r("div", { className: a(t("grow", "truncate"), e?.title), children: v })
|
|
74
118
|
}
|
|
75
119
|
),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
120
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
121
|
+
z,
|
|
78
122
|
/* @__PURE__ */ r(
|
|
79
|
-
|
|
123
|
+
d.Close,
|
|
80
124
|
{
|
|
81
|
-
render: /* @__PURE__ */ r(
|
|
125
|
+
render: /* @__PURE__ */ r(Ce, { children: F })
|
|
82
126
|
}
|
|
83
127
|
),
|
|
84
|
-
|
|
128
|
+
M
|
|
85
129
|
] })
|
|
86
130
|
]
|
|
87
131
|
}
|
|
88
132
|
),
|
|
89
|
-
|
|
133
|
+
T || null
|
|
90
134
|
] }), [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
135
|
+
M,
|
|
136
|
+
T,
|
|
137
|
+
z,
|
|
138
|
+
t,
|
|
95
139
|
e?.header,
|
|
96
140
|
e?.title,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
]), { ref:
|
|
100
|
-
() => /* @__PURE__ */
|
|
101
|
-
|
|
141
|
+
F,
|
|
142
|
+
v
|
|
143
|
+
]), { ref: L } = Se(Z), le = u(
|
|
144
|
+
() => /* @__PURE__ */ s(
|
|
145
|
+
d.Popup,
|
|
102
146
|
{
|
|
103
|
-
className:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
147
|
+
className: a(
|
|
148
|
+
t("popup-panel"),
|
|
149
|
+
t(`popup-panel-size-${O}`),
|
|
150
|
+
I,
|
|
107
151
|
e?.popup
|
|
108
152
|
),
|
|
109
|
-
ref:
|
|
153
|
+
ref: L,
|
|
110
154
|
children: [
|
|
111
|
-
|
|
112
|
-
/* @__PURE__ */ r("div", { className:
|
|
113
|
-
|
|
155
|
+
v && J(),
|
|
156
|
+
/* @__PURE__ */ r("div", { className: a(t("popup-panel-content"), e?.content), children: /* @__PURE__ */ r("div", { className: t("popup-panel-content-inner"), children: w }) }),
|
|
157
|
+
b && /* @__PURE__ */ r("div", { className: a(t("popup-panel-footer"), e?.footer), children: typeof b == "function" ? b({ close: () => x(!1) }) : b })
|
|
114
158
|
]
|
|
115
159
|
}
|
|
116
160
|
),
|
|
117
161
|
[
|
|
118
|
-
|
|
162
|
+
I,
|
|
119
163
|
e?.content,
|
|
120
164
|
e?.footer,
|
|
121
165
|
e?.popup,
|
|
122
|
-
|
|
123
|
-
|
|
166
|
+
t,
|
|
167
|
+
w,
|
|
168
|
+
L,
|
|
169
|
+
b,
|
|
170
|
+
J,
|
|
124
171
|
x,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
u,
|
|
128
|
-
a,
|
|
129
|
-
l
|
|
172
|
+
O,
|
|
173
|
+
v
|
|
130
174
|
]
|
|
131
|
-
),
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
175
|
+
), X = Q(
|
|
176
|
+
({
|
|
177
|
+
children: o,
|
|
178
|
+
onDragEnd: l,
|
|
179
|
+
onDragStart: q,
|
|
180
|
+
...S
|
|
181
|
+
}, { side: i, align: c }) => {
|
|
182
|
+
const f = `${i}-${c}`;
|
|
183
|
+
return k ? /* @__PURE__ */ s(ue, { children: [
|
|
184
|
+
/* @__PURE__ */ r(
|
|
185
|
+
V,
|
|
186
|
+
{
|
|
187
|
+
side: i,
|
|
188
|
+
align: c,
|
|
189
|
+
onPlacementChange: C
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ r(
|
|
193
|
+
Pe,
|
|
194
|
+
{
|
|
195
|
+
resizable: k,
|
|
196
|
+
resetKey: f,
|
|
197
|
+
maintainAspectRatio: $,
|
|
198
|
+
classNames: {
|
|
199
|
+
resizeHandle: e?.resizeHandle
|
|
200
|
+
},
|
|
201
|
+
handles: Ee(i),
|
|
202
|
+
...S,
|
|
203
|
+
children: o
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
] }) : /* @__PURE__ */ s("div", { ...S, children: [
|
|
207
|
+
/* @__PURE__ */ r(
|
|
208
|
+
V,
|
|
209
|
+
{
|
|
210
|
+
side: i,
|
|
211
|
+
align: c,
|
|
212
|
+
onPlacementChange: C
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
o
|
|
216
|
+
] });
|
|
140
217
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
218
|
+
[
|
|
219
|
+
k,
|
|
220
|
+
$,
|
|
221
|
+
e?.resizeHandle,
|
|
222
|
+
C
|
|
223
|
+
]
|
|
224
|
+
), Y = u(
|
|
225
|
+
() => ({
|
|
226
|
+
"--size-width": O ? Oe[O] : void 0
|
|
227
|
+
}),
|
|
228
|
+
[O]
|
|
229
|
+
), ie = u(
|
|
230
|
+
() => ({
|
|
231
|
+
className: a(
|
|
232
|
+
t("popup-panel-root"),
|
|
233
|
+
A,
|
|
234
|
+
e?.root
|
|
235
|
+
),
|
|
236
|
+
side: y.side,
|
|
237
|
+
align: y.align,
|
|
238
|
+
sideOffset: B,
|
|
239
|
+
anchor: n,
|
|
240
|
+
style: Y,
|
|
241
|
+
render: X
|
|
242
|
+
}),
|
|
243
|
+
[
|
|
244
|
+
t,
|
|
245
|
+
A,
|
|
246
|
+
e?.root,
|
|
247
|
+
y.side,
|
|
248
|
+
y.align,
|
|
249
|
+
B,
|
|
250
|
+
n,
|
|
251
|
+
Y,
|
|
252
|
+
X
|
|
253
|
+
]
|
|
254
|
+
), pe = u(
|
|
255
|
+
() => E ? (({ sideOffset: o, ...l }) => l)(p) : p,
|
|
256
|
+
[E, p]
|
|
257
|
+
), ce = se(
|
|
258
|
+
(o, l) => {
|
|
259
|
+
(l.reason === "outside-press" || l.reason === "focus-out") && !ee || x(o, l);
|
|
260
|
+
}
|
|
261
|
+
), fe = u(
|
|
262
|
+
() => ({
|
|
263
|
+
ref: U,
|
|
264
|
+
render: m,
|
|
265
|
+
nativeButton: j,
|
|
266
|
+
className: a(t("popup-panel-trigger"), e?.trigger),
|
|
267
|
+
openOnHover: H === "hover" ? !0 : g
|
|
268
|
+
}),
|
|
269
|
+
[
|
|
270
|
+
U,
|
|
271
|
+
m,
|
|
272
|
+
j,
|
|
273
|
+
t,
|
|
274
|
+
e?.trigger,
|
|
275
|
+
H,
|
|
276
|
+
g
|
|
277
|
+
]
|
|
278
|
+
);
|
|
279
|
+
return /* @__PURE__ */ s(
|
|
280
|
+
d.Root,
|
|
158
281
|
{
|
|
159
|
-
open:
|
|
160
|
-
onOpenChange:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
modal: D,
|
|
164
|
-
...B,
|
|
282
|
+
open: oe,
|
|
283
|
+
onOpenChange: ce,
|
|
284
|
+
modal: N,
|
|
285
|
+
...ne,
|
|
165
286
|
children: [
|
|
166
287
|
/* @__PURE__ */ r(
|
|
167
|
-
|
|
288
|
+
d.Trigger,
|
|
168
289
|
{
|
|
169
|
-
...
|
|
170
|
-
{
|
|
171
|
-
render: H,
|
|
172
|
-
className: p(o("popup-panel-trigger"), e?.trigger),
|
|
173
|
-
openOnHover: A === "hover" ? !0 : b
|
|
174
|
-
},
|
|
175
|
-
$
|
|
176
|
-
)
|
|
290
|
+
...G(fe, te)
|
|
177
291
|
}
|
|
178
292
|
),
|
|
179
|
-
/* @__PURE__ */ r(
|
|
180
|
-
|
|
293
|
+
/* @__PURE__ */ r(d.Portal, { ...re, children: /* @__PURE__ */ r(
|
|
294
|
+
d.Positioner,
|
|
181
295
|
{
|
|
182
|
-
...
|
|
183
|
-
children:
|
|
296
|
+
...G(ie, pe),
|
|
297
|
+
children: le
|
|
184
298
|
}
|
|
185
299
|
) })
|
|
186
300
|
]
|
|
@@ -188,6 +302,6 @@ const we = ({
|
|
|
188
302
|
);
|
|
189
303
|
};
|
|
190
304
|
export {
|
|
191
|
-
|
|
305
|
+
Ye as PopupPanel
|
|
192
306
|
};
|
|
193
307
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/popup-panel/component.tsx"],"sourcesContent":["\"use client\";\nimport { Popover } from \"@base-ui/react/popover\";\nimport { clsx, parseAntdPlacement, useCls } from \"../utils\";\n\nimport { mergeProps } from \"@base-ui/react\";\nimport { X } from \"@bioturing/assets\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { useControlledState, useDraggable, useBaseUIPlacement } 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 { useTheme } from \"../theme-provider\";\nimport \"./style.css\";\nimport { anchorToResizeHandles } from \"./utils\";\n\nexport type PopupPanelPlacement =\n | \"top\"\n | \"left\"\n | \"right\"\n | \"bottom\"\n | \"topLeft\"\n | \"topRight\"\n | \"bottomLeft\"\n | \"bottomRight\"\n | \"leftTop\"\n | \"leftBottom\"\n | \"rightTop\"\n | \"rightBottom\";\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?: PopupPanelPlacement;\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: PopupPanelPlacement) => void;\n /**\n * Props to pass to the positioner\n */\n positionerProps?: Popover.Positioner.Props;\n /**\n * Props to pass to the trigger\n */\n triggerProps?: Popover.Trigger.Props;\n /**\n * Props to pass to the portal\n */\n portalProps?: Popover.Portal.Props;\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 positionerProps = {},\n triggerProps = {},\n portalProps = {},\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, setPositionerRef] = useState<HTMLDivElement | null>(\n null\n );\n\n // Track Base UI placement changes\n const { currentSide, currentAlign, placementChangeKey } = useBaseUIPlacement({\n positionerRef,\n open,\n initialSide: baseUIPlacement.side,\n initialAlign: baseUIPlacement.align,\n onPlacementChange,\n });\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 = useMemo(\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={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 className,\n classNames?.content,\n classNames?.footer,\n classNames?.popup,\n cls,\n content,\n draggableRef,\n footer,\n renderTitle,\n setOpen,\n size,\n title,\n ]\n );\n\n const defaultPositionerProps = {\n ref: setPositionerRef,\n className: clsx(cls(\"popup-panel-root\"), themeClassName, classNames?.root),\n side: baseUIPlacement.side,\n align: baseUIPlacement.align,\n sideOffset: 4,\n anchor,\n style: {\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n } as React.CSSProperties,\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(currentSide, currentAlign)}\n {...props}\n >\n {children}\n </Resizable>\n ) : (\n <div {...props}>{children}</div>\n );\n },\n };\n\n return (\n <Popover.Root\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 {...mergeProps(\n {\n render: children,\n className: clsx(cls(\"popup-panel-trigger\"), classNames?.trigger),\n openOnHover: trigger === \"hover\" ? true : openOnHover,\n },\n triggerProps\n )}\n ></Popover.Trigger>\n <Popover.Portal {...portalProps}>\n <Popover.Positioner\n {...mergeProps(defaultPositionerProps, positionerProps)}\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","positionerProps","triggerProps","portalProps","rest","open","setOpen","useControlledState","cls","useCls","themeClassName","useTheme","baseUIPlacement","parseAntdPlacement","defaultCloseIcon","useMemo","jsx","X","positionerRef","setPositionerRef","useState","currentSide","currentAlign","placementChangeKey","useBaseUIPlacement","renderTitle","useCallback","jsxs","clsx","Stack","Popover","IconButton","draggableRef","useDraggable","popup","defaultPositionerProps","PopupPanelSize","onDragEnd","onDragStart","props","Resizable","anchorToResizeHandles","eventDetails","mergeProps"],"mappings":";;;;;;;;;;;;;;;;;;;AAiJO,MAAMA,KAAa,CAAC;AAA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MqC,MAAiB;AACpC,SACGA,EAAa,WAAW,mBACvBA,EAAa,WAAW,gBAC1B,CAAC3C,KAGHO,EAAQD,GAAMqC,CAAY;AAAA,MAC5B;AAAA,MACA,OAAA5C;AAAA,MACC,GAAGM;AAAA,MAEJ,UAAA;AAAA,QAAA,gBAAAY;AAAA,UAACc,EAAQ;AAAA,UAAR;AAAA,YACE,GAAGa;AAAA,cACF;AAAA,gBACE,QAAQjE;AAAA,gBACR,WAAWkD,EAAKpB,EAAI,qBAAqB,GAAGX,GAAY,OAAO;AAAA,gBAC/D,aAAaZ,MAAY,UAAU,KAAOL;AAAA,cAAA;AAAA,cAE5CsB;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,QAEF,gBAAAc,EAACc,EAAQ,QAAR,EAAgB,GAAG3B,GAClB,UAAA,gBAAAa;AAAA,UAACc,EAAQ;AAAA,UAAR;AAAA,YACE,GAAGa,EAAWR,GAAwBlC,CAAe;AAAA,YAErD,UAAAiC;AAAA,UAAA;AAAA,QAAA,EACH,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/react/popover\";\nimport { buildAntdPlacement, clsx, parseAntdPlacement, useCls } from \"../utils\";\n\nimport { mergeProps } from \"@base-ui/react\";\nimport { useStableCallback } from \"@base-ui/utils/useStableCallback\";\nimport { X } from \"@bioturing/assets\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useControlledState, useDraggable } from \"../hooks\";\nimport { IconButton } from \"../icon-button\";\nimport { Resizable } from \"../resizable\";\nimport { Stack } from \"../stack\";\nimport { DEFAULT_SIDE_OFFSET, PopupPanelSize } from \"./constants\";\nimport { PopupPanelProps } from \"./types\";\n\n// Import component-specific styles\nimport { useTheme } from \"../theme-provider\";\nimport \"./style.css\";\nimport { anchorToResizeHandles } from \"./utils\";\n\n// Stable empty objects to avoid creating new references on every render\nconst EMPTY_OBJECT = {} as const;\n\ninterface PlacementStateSyncProps {\n side: Popover.Positioner.State[\"side\"];\n align: Popover.Positioner.State[\"align\"];\n onPlacementChange?: (\n placement: NonNullable<PopupPanelProps[\"placement\"]>,\n ) => void;\n}\n\nfunction PlacementStateSync({\n side,\n align,\n onPlacementChange,\n}: PlacementStateSyncProps) {\n const lastPlacementRef = useRef<\n NonNullable<PopupPanelProps[\"placement\"]> | undefined\n >(undefined);\n\n useEffect(() => {\n const placement = buildAntdPlacement({\n side,\n align,\n }) as NonNullable<PopupPanelProps[\"placement\"]>;\n if (placement === lastPlacementRef.current) return;\n lastPlacementRef.current = placement;\n onPlacementChange?.(placement);\n }, [side, align, onPlacementChange]);\n\n return null;\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 positionerProps = EMPTY_OBJECT,\n triggerProps = EMPTY_OBJECT,\n portalProps = EMPTY_OBJECT,\n offsetFrom,\n nativeButton = true,\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 [triggerEl, setTriggerEl] = useState<HTMLElement | null>(null);\n\n // Resolve the anchor element from the various anchor prop types\n const anchorEl = useMemo(() => {\n if (anchor instanceof Element) return anchor;\n if (anchor != null && \"current\" in anchor) return anchor.current;\n if (typeof anchor === \"function\") {\n const result = anchor();\n return result instanceof Element ? result : null;\n }\n return triggerEl;\n }, [anchor, triggerEl]);\n\n // Compute sideOffset: incorporate user sideOffset, and when offsetFrom is\n // provided, add the distance from the anchor to the offsetFrom element\n const resolvedSideOffset = useMemo(() => {\n // If user provides a function, let them fully control the offset\n if (typeof positionerProps.sideOffset === \"function\")\n return positionerProps.sideOffset;\n\n const userSideOffset =\n typeof positionerProps.sideOffset === \"number\"\n ? positionerProps.sideOffset\n : 0;\n const baseOffset = DEFAULT_SIDE_OFFSET + userSideOffset;\n\n if (!offsetFrom) return baseOffset;\n\n return ({ side }: { side: string }) => {\n const offsetFromEl = offsetFrom.current;\n if (!offsetFromEl || !anchorEl) return baseOffset;\n\n const offsetRect = offsetFromEl.getBoundingClientRect();\n const anchorRect = anchorEl.getBoundingClientRect();\n\n let distance: number;\n switch (side) {\n case \"bottom\":\n distance = offsetRect.bottom - anchorRect.bottom;\n break;\n case \"top\":\n distance = anchorRect.top - offsetRect.top;\n break;\n case \"right\":\n distance = offsetRect.right - anchorRect.right;\n break;\n case \"left\":\n distance = anchorRect.left - offsetRect.left;\n break;\n default:\n distance = 0;\n }\n\n return Math.max(0, distance) + baseOffset;\n };\n }, [offsetFrom, anchorEl, positionerProps.sideOffset]);\n\n const defaultCloseIcon = useMemo(() => <X size={16} />, []);\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 = useMemo(\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={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 className,\n classNames?.content,\n classNames?.footer,\n classNames?.popup,\n cls,\n content,\n draggableRef,\n footer,\n renderTitle,\n setOpen,\n size,\n title,\n ],\n );\n\n // Positioner render function — useCallback keeps the reference stable when deps\n // don't change. Cannot use useStableCallback here because render props are\n // called during React's render phase, not in effects/event handlers.\n const positionerRender = useCallback(\n (\n {\n children,\n onDragEnd: _onDragEnd,\n onDragStart: _onDragStart,\n ...props\n }: React.ComponentProps<\"div\">,\n { side, align }: Popover.Positioner.State,\n ) => {\n const placementKey = `${side}-${align}`;\n return resizable ? (\n <>\n <PlacementStateSync\n side={side}\n align={align}\n onPlacementChange={onPlacementChange}\n />\n <Resizable\n resizable={resizable}\n resetKey={placementKey}\n maintainAspectRatio={maintainAspectRatio}\n classNames={{\n resizeHandle: classNames?.resizeHandle,\n }}\n handles={anchorToResizeHandles(side, align)}\n {...props}\n >\n {children}\n </Resizable>\n </>\n ) : (\n <div {...props}>\n <PlacementStateSync\n side={side}\n align={align}\n onPlacementChange={onPlacementChange}\n />\n {children}\n </div>\n );\n },\n [\n resizable,\n maintainAspectRatio,\n classNames?.resizeHandle,\n onPlacementChange,\n ],\n );\n\n const positionerStyle = useMemo(\n () =>\n ({\n \"--size-width\": size ? PopupPanelSize[size] : undefined,\n }) as React.CSSProperties,\n [size],\n );\n\n const defaultPositionerProps = useMemo(\n () => ({\n className: clsx(\n cls(\"popup-panel-root\"),\n themeClassName,\n classNames?.root,\n ),\n side: baseUIPlacement.side,\n align: baseUIPlacement.align,\n sideOffset: resolvedSideOffset,\n anchor,\n style: positionerStyle,\n render: positionerRender,\n }),\n [\n cls,\n themeClassName,\n classNames?.root,\n baseUIPlacement.side,\n baseUIPlacement.align,\n resolvedSideOffset,\n anchor,\n positionerStyle,\n positionerRender,\n ],\n );\n\n // Strip sideOffset from positionerProps when offsetFrom is active,\n // since we've already incorporated it into resolvedSideOffset\n const finalPositionerProps = useMemo(\n () =>\n offsetFrom\n ? (({ sideOffset: _, ...rest }) => rest)(positionerProps)\n : positionerProps,\n [offsetFrom, positionerProps],\n );\n\n // Stable onOpenChange handler to avoid recreating on every render\n const handleOpenChange = useStableCallback(\n (nextOpen: boolean, eventDetails: Popover.Root.ChangeEventDetails) => {\n if (\n (eventDetails.reason === \"outside-press\" ||\n eventDetails.reason === \"focus-out\") &&\n !closeOnClickOutside\n )\n return;\n setOpen(nextOpen, eventDetails);\n },\n );\n\n const defaultTriggerProps = useMemo(\n () => ({\n ref: setTriggerEl,\n render: children,\n nativeButton,\n className: clsx(cls(\"popup-panel-trigger\"), classNames?.trigger),\n openOnHover: trigger === \"hover\" ? true : openOnHover,\n }),\n [\n setTriggerEl,\n children,\n nativeButton,\n cls,\n classNames?.trigger,\n trigger,\n openOnHover,\n ],\n );\n\n return (\n <Popover.Root\n open={open}\n onOpenChange={handleOpenChange}\n modal={modal}\n {...rest}\n >\n <Popover.Trigger\n {...mergeProps(defaultTriggerProps, triggerProps)}\n ></Popover.Trigger>\n <Popover.Portal {...portalProps}>\n <Popover.Positioner\n {...mergeProps(defaultPositionerProps, finalPositionerProps)}\n >\n {popup}\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n"],"names":["EMPTY_OBJECT","PlacementStateSync","side","align","onPlacementChange","lastPlacementRef","useRef","useEffect","placement","buildAntdPlacement","PopupPanel","children","openOnHover","outsideOpen","outsideOnOpenChange","content","title","trigger","className","anchor","beforeCloseButton","afterCloseButton","afterTitle","size","footer","defaultOpen","resizable","draggable","maintainAspectRatio","classNames","modal","closeOnClickOutside","positionerProps","triggerProps","portalProps","offsetFrom","nativeButton","rest","open","setOpen","useControlledState","cls","useCls","themeClassName","useTheme","baseUIPlacement","parseAntdPlacement","triggerEl","setTriggerEl","useState","anchorEl","useMemo","result","resolvedSideOffset","userSideOffset","baseOffset","DEFAULT_SIDE_OFFSET","offsetFromEl","offsetRect","anchorRect","distance","defaultCloseIcon","jsx","X","renderTitle","useCallback","jsxs","clsx","Stack","Popover","IconButton","draggableRef","useDraggable","popup","positionerRender","_onDragEnd","_onDragStart","props","placementKey","Fragment","Resizable","anchorToResizeHandles","positionerStyle","PopupPanelSize","defaultPositionerProps","finalPositionerProps","_","handleOpenChange","useStableCallback","nextOpen","eventDetails","defaultTriggerProps","mergeProps"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,MAAMA,IAAe,CAAA;AAUrB,SAASC,EAAmB;AAAA,EAC1B,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,mBAAAC;AACF,GAA4B;AAC1B,QAAMC,IAAmBC,GAEvB,MAAS;AAEX,SAAAC,GAAU,MAAM;AACd,UAAMC,IAAYC,GAAmB;AAAA,MACnC,MAAAP;AAAA,MACA,OAAAC;AAAA,IAAA,CACD;AACD,IAAIK,MAAcH,EAAiB,YACnCA,EAAiB,UAAUG,GAC3BJ,IAAoBI,CAAS;AAAA,EAC/B,GAAG,CAACN,GAAMC,GAAOC,CAAiB,CAAC,GAE5B;AACT;AAEO,MAAMM,KAAa,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,WAAAH;AAAA,EACA,aAAAI,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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AAA4B;AAAA,UAACO,EAAQ;AAAA,UAAR;AAAA,YACE,GAAGuB,EAAWR,IAAwBC,EAAoB;AAAA,YAE1D,UAAAZ;AAAA,UAAA;AAAA,QAAA,EACH,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/popup-panel/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/popup-panel/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAGrC,oBAAY,cAAc;IACxB,MAAM,UAAU;IAChB,KAAK,UAAU;IACf,MAAM,UAAU;IAChB,KAAK,UAAU;IACf,MAAM,UAAU;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../src/components/popup-panel/constants.ts"],"sourcesContent":["// Size map for predefined modal sizes\nexport enum PopupPanelSize {\n xsmall = \"320px\",\n small = \"400px\",\n medium = \"480px\",\n large = \"640px\",\n xlarge = \"840px\",\n}\n"],"names":["PopupPanelSize"],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../src/components/popup-panel/constants.ts"],"sourcesContent":["export const DEFAULT_SIDE_OFFSET = 4;\n\n// Size map for predefined modal sizes\nexport enum PopupPanelSize {\n xsmall = \"320px\",\n small = \"400px\",\n medium = \"480px\",\n large = \"640px\",\n xlarge = \"840px\",\n}\n"],"names":["DEFAULT_SIDE_OFFSET","PopupPanelSize"],"mappings":"AAAO,MAAMA,IAAsB;AAG5B,IAAKC,sBAAAA,OACVA,EAAA,SAAS,SACTA,EAAA,QAAQ,SACRA,EAAA,SAAS,SACTA,EAAA,QAAQ,SACRA,EAAA,SAAS,SALCA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/popup-panel/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/popup-panel/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|