@versini/ui-panel 2.0.9 → 2.2.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/README.md +44 -1
- package/dist/components/Panel/Panel.js +228 -224
- package/dist/index.d.ts +9 -1
- package/dist/index.js +3 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
1
|
# @versini/ui-panel
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@versini/ui-panel)
|
|
4
|
+
|
|
5
|
+
> An accessible React slide-out panel component built with TypeScript and TailwindCSS.
|
|
6
|
+
|
|
7
|
+
The Panel component provides slide-out panels and drawers with focus management, keyboard navigation, and customizable positioning.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Features](#features)
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Usage](#usage)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @versini/ui-panel
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
> **Note**: This component requires TailwindCSS and the `@versini/ui-styles` plugin for proper styling. See the [root README](../../README.md#tailwindcss-setup) for complete setup instructions.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { Panel } from "@versini/ui-panel";
|
|
28
|
+
import { useState } from "react";
|
|
29
|
+
|
|
30
|
+
function App() {
|
|
31
|
+
const [open, setOpen] = useState(false);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<button onClick={() => setOpen(true)}>Open Panel</button>
|
|
36
|
+
<Panel
|
|
37
|
+
title="Panel Title"
|
|
38
|
+
open={open}
|
|
39
|
+
onOpenChange={setOpen}
|
|
40
|
+
>
|
|
41
|
+
Panel content goes here.
|
|
42
|
+
</Panel>
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
1
|
+
import { jsx as l, jsxs as L, Fragment as J } from "react/jsx-runtime";
|
|
2
|
+
import * as h from "react";
|
|
3
|
+
import F, { useRef as N, useLayoutEffect as Y, useEffect as B, useState as K, useMemo as Q, useCallback as ue, useId as Z } from "react";
|
|
4
4
|
import n from "clsx";
|
|
5
5
|
import { useFloating as me, useClick as ge, useDismiss as he, useRole as fe, useInteractions as be, useMergeRefs as ve, FloatingPortal as ye, FloatingOverlay as pe, FloatingFocusManager as ke } from "@floating-ui/react";
|
|
6
|
-
const
|
|
6
|
+
const H = "av-messagebox", R = "av-panel", q = "av-button", V = "icon", ee = "button", z = "link", we = ({
|
|
7
7
|
type: e,
|
|
8
8
|
size: t,
|
|
9
9
|
labelRight: r,
|
|
10
10
|
labelLeft: a,
|
|
11
|
-
align:
|
|
12
|
-
animated:
|
|
11
|
+
align: i,
|
|
12
|
+
animated: o
|
|
13
13
|
}) => {
|
|
14
|
-
const c = "max-h-8 py-0 px-2",
|
|
14
|
+
const c = "max-h-8 py-0 px-2", d = "max-h-9 h-8 px-3", s = "max-h-12 py-2 px-4";
|
|
15
15
|
switch (e) {
|
|
16
16
|
case ee:
|
|
17
|
-
case
|
|
17
|
+
case z:
|
|
18
18
|
return n({
|
|
19
19
|
[c]: t === "small",
|
|
20
|
-
[
|
|
20
|
+
[d]: t === "medium",
|
|
21
21
|
[s]: t === "large"
|
|
22
22
|
});
|
|
23
|
-
case
|
|
23
|
+
case V:
|
|
24
24
|
return n("flex items-center", {
|
|
25
|
-
"justify-center":
|
|
26
|
-
"justify-start":
|
|
27
|
-
"justify-end":
|
|
28
|
-
"h-6 w-6 p-0": t === "small" && !
|
|
29
|
-
"h-6 px-2": t === "small" && !
|
|
30
|
-
"h-8 w-8 p-1": t === "medium" && !
|
|
31
|
-
"h-8 px-3": t === "medium" && !
|
|
32
|
-
"h-12 w-12 p-2": t === "large" && !
|
|
33
|
-
"h-12 px-4": t === "large" && !
|
|
34
|
-
"h-6 py-0": t === "small" &&
|
|
35
|
-
"h-6": t === "small" &&
|
|
36
|
-
"h-8 py-1": t === "medium" &&
|
|
37
|
-
"h-8": t === "medium" &&
|
|
38
|
-
"h-12 py-2": t === "large" &&
|
|
39
|
-
"h-12": t === "large" &&
|
|
25
|
+
"justify-center": i === "center",
|
|
26
|
+
"justify-start": i === "left",
|
|
27
|
+
"justify-end": i === "right",
|
|
28
|
+
"h-6 w-6 p-0": t === "small" && !o && !(r || a),
|
|
29
|
+
"h-6 px-2": t === "small" && !o && (r || a),
|
|
30
|
+
"h-8 w-8 p-1": t === "medium" && !o && !(r || a),
|
|
31
|
+
"h-8 px-3": t === "medium" && !o && (r || a),
|
|
32
|
+
"h-12 w-12 p-2": t === "large" && !o && !(r || a),
|
|
33
|
+
"h-12 px-4": t === "large" && !o && (r || a),
|
|
34
|
+
"h-6 py-0": t === "small" && o && !(r || a),
|
|
35
|
+
"h-6": t === "small" && o && (r || a),
|
|
36
|
+
"h-8 py-1": t === "medium" && o && !(r || a),
|
|
37
|
+
"h-8": t === "medium" && o && (r || a),
|
|
38
|
+
"h-12 py-2": t === "large" && o && !(r || a),
|
|
39
|
+
"h-12": t === "large" && o && (r || a)
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
},
|
|
42
|
+
}, xe = ({
|
|
43
43
|
type: e,
|
|
44
44
|
size: t,
|
|
45
45
|
labelRight: r,
|
|
46
46
|
labelLeft: a
|
|
47
47
|
}) => {
|
|
48
|
-
const
|
|
48
|
+
const i = "text-sm font-medium", o = "text-base font-medium", c = "text-lg font-medium";
|
|
49
49
|
switch (e) {
|
|
50
50
|
case ee:
|
|
51
|
-
case
|
|
51
|
+
case z:
|
|
52
52
|
return n({
|
|
53
|
-
"text-center": e ===
|
|
54
|
-
[
|
|
55
|
-
[
|
|
53
|
+
"text-center": e === z,
|
|
54
|
+
[i]: t === "small",
|
|
55
|
+
[o]: t === "medium",
|
|
56
56
|
[c]: t === "large"
|
|
57
57
|
});
|
|
58
|
-
case
|
|
58
|
+
case V:
|
|
59
59
|
return n({
|
|
60
|
-
[
|
|
61
|
-
[
|
|
60
|
+
[i]: t === "small" && (r || a),
|
|
61
|
+
[o]: t === "medium" && (r || a),
|
|
62
62
|
[c]: t === "large" && (r || a)
|
|
63
63
|
});
|
|
64
64
|
}
|
|
@@ -252,69 +252,68 @@ const Y = "av-messagebox", H = "av-panel", W = "av-button", F = "icon", ee = "bu
|
|
|
252
252
|
className: t,
|
|
253
253
|
raw: r,
|
|
254
254
|
mode: a,
|
|
255
|
-
focusMode:
|
|
256
|
-
disabled:
|
|
255
|
+
focusMode: i,
|
|
256
|
+
disabled: o,
|
|
257
257
|
fullWidth: c,
|
|
258
|
-
size:
|
|
258
|
+
size: d,
|
|
259
259
|
noBorder: s,
|
|
260
260
|
labelRight: g,
|
|
261
|
-
labelLeft:
|
|
262
|
-
noBackground:
|
|
263
|
-
variant:
|
|
264
|
-
truncate:
|
|
265
|
-
align:
|
|
266
|
-
radius:
|
|
267
|
-
animated:
|
|
268
|
-
}) => (
|
|
269
|
-
|
|
261
|
+
labelLeft: v,
|
|
262
|
+
noBackground: u,
|
|
263
|
+
variant: m,
|
|
264
|
+
truncate: f,
|
|
265
|
+
align: b,
|
|
266
|
+
radius: x,
|
|
267
|
+
animated: I
|
|
268
|
+
}) => (m || (m = "primary"), r ? n(q, t) : n(
|
|
269
|
+
q,
|
|
270
270
|
Ie({
|
|
271
271
|
mode: a,
|
|
272
|
-
variant:
|
|
273
|
-
noBackground:
|
|
274
|
-
truncate:
|
|
272
|
+
variant: m,
|
|
273
|
+
noBackground: u,
|
|
274
|
+
truncate: f
|
|
275
275
|
}),
|
|
276
|
-
_e({ mode: a, noBackground:
|
|
277
|
-
Ne({ radius:
|
|
278
|
-
|
|
276
|
+
_e({ mode: a, noBackground: u, variant: m }),
|
|
277
|
+
Ne({ radius: x }),
|
|
278
|
+
we({
|
|
279
279
|
type: e,
|
|
280
|
-
size:
|
|
280
|
+
size: d,
|
|
281
281
|
labelRight: g,
|
|
282
|
-
labelLeft:
|
|
283
|
-
align:
|
|
284
|
-
animated:
|
|
282
|
+
labelLeft: v,
|
|
283
|
+
align: b,
|
|
284
|
+
animated: I
|
|
285
285
|
}),
|
|
286
|
-
|
|
287
|
-
Be({ mode: a, variant:
|
|
288
|
-
Se({ focusMode:
|
|
289
|
-
Ee({ mode: a, variant:
|
|
290
|
-
Ce({ mode: a, variant:
|
|
286
|
+
xe({ type: e, size: d, labelRight: g, labelLeft: v }),
|
|
287
|
+
Be({ mode: a, variant: m, noBorder: s }),
|
|
288
|
+
Se({ focusMode: i }),
|
|
289
|
+
Ee({ mode: a, variant: m, disabled: o }),
|
|
290
|
+
Ce({ mode: a, variant: m, disabled: o }),
|
|
291
291
|
{
|
|
292
292
|
"w-full": c,
|
|
293
|
-
"disabled:cursor-not-allowed disabled:opacity-50":
|
|
293
|
+
"disabled:cursor-not-allowed disabled:opacity-50": o
|
|
294
294
|
},
|
|
295
295
|
n({
|
|
296
|
-
"transition-[width] duration-300 ease-in":
|
|
296
|
+
"transition-[width] duration-300 ease-in": I
|
|
297
297
|
}),
|
|
298
298
|
t
|
|
299
299
|
)), Le = (e, t, r) => {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const { onClick: r, noInternalClick: a = !1, ...o } = e;
|
|
300
|
+
!t && (!document.activeElement || document.activeElement !== e.currentTarget) && typeof e?.currentTarget?.focus == "function" && e.currentTarget.focus(), typeof r == "function" && r(e);
|
|
301
|
+
}, re = F.forwardRef((e, t) => {
|
|
302
|
+
const { onClick: r, noInternalClick: a = !1, ...i } = e;
|
|
304
303
|
return /* @__PURE__ */ l(
|
|
305
304
|
"button",
|
|
306
305
|
{
|
|
307
306
|
ref: t,
|
|
308
|
-
onClick: (
|
|
309
|
-
Le(
|
|
307
|
+
onClick: (o) => {
|
|
308
|
+
Le(o, a, r);
|
|
310
309
|
},
|
|
311
|
-
...
|
|
310
|
+
...i
|
|
312
311
|
}
|
|
313
312
|
);
|
|
314
313
|
});
|
|
315
314
|
re.displayName = "BaseButton";
|
|
316
315
|
function Oe() {
|
|
317
|
-
const e =
|
|
316
|
+
const e = N(!1);
|
|
318
317
|
return B(() => (e.current = !0, () => {
|
|
319
318
|
e.current = !1;
|
|
320
319
|
}), []), ue(() => e.current, []);
|
|
@@ -338,92 +337,92 @@ const Pe = {
|
|
|
338
337
|
right: 0
|
|
339
338
|
};
|
|
340
339
|
function D(e) {
|
|
341
|
-
const t = Oe(), r =
|
|
342
|
-
const s =
|
|
340
|
+
const t = Oe(), r = N(0), a = N(null), [i, o] = K(Pe), c = Q(() => typeof ResizeObserver > "u" ? null : new ResizeObserver((d) => {
|
|
341
|
+
const s = d[0];
|
|
343
342
|
s && (cancelAnimationFrame(r.current), r.current = requestAnimationFrame(() => {
|
|
344
|
-
a.current && t() &&
|
|
343
|
+
a.current && t() && o(s.contentRect);
|
|
345
344
|
}));
|
|
346
345
|
}), [t]);
|
|
347
|
-
return B(() => (a.current &&
|
|
348
|
-
c
|
|
349
|
-
}), [c, e]), [a,
|
|
346
|
+
return B(() => (a.current && c?.observe(a.current, e), () => {
|
|
347
|
+
c?.disconnect(), r.current && cancelAnimationFrame(r.current);
|
|
348
|
+
}), [c, e]), [a, i];
|
|
350
349
|
}
|
|
351
|
-
const
|
|
350
|
+
const M = {
|
|
352
351
|
small: 24,
|
|
353
352
|
// w-6
|
|
354
353
|
medium: 32,
|
|
355
354
|
// w-8
|
|
356
355
|
large: 48
|
|
357
356
|
// w-12
|
|
358
|
-
},
|
|
359
|
-
small:
|
|
357
|
+
}, $e = {
|
|
358
|
+
small: 16,
|
|
360
359
|
// px-2 x 2
|
|
361
|
-
medium:
|
|
360
|
+
medium: 24,
|
|
362
361
|
// px-3 x 2
|
|
363
|
-
large:
|
|
362
|
+
large: 32
|
|
364
363
|
// px-4 x 2
|
|
365
|
-
},
|
|
364
|
+
}, De = 2, ze = 300, U = F.forwardRef(
|
|
366
365
|
({
|
|
367
366
|
children: e,
|
|
368
367
|
disabled: t = !1,
|
|
369
368
|
mode: r = "system",
|
|
370
369
|
focusMode: a = "system",
|
|
371
|
-
fullWidth:
|
|
372
|
-
className:
|
|
370
|
+
fullWidth: i = !1,
|
|
371
|
+
className: o,
|
|
373
372
|
type: c = "button",
|
|
374
|
-
raw:
|
|
373
|
+
raw: d = !1,
|
|
375
374
|
noBorder: s = !1,
|
|
376
375
|
"aria-label": g,
|
|
377
|
-
label:
|
|
378
|
-
size:
|
|
379
|
-
labelRight:
|
|
380
|
-
labelLeft:
|
|
381
|
-
noBackground:
|
|
382
|
-
align:
|
|
383
|
-
radius:
|
|
376
|
+
label: v,
|
|
377
|
+
size: u = "medium",
|
|
378
|
+
labelRight: m,
|
|
379
|
+
labelLeft: f,
|
|
380
|
+
noBackground: b = !1,
|
|
381
|
+
align: x = "center",
|
|
382
|
+
radius: I = "large",
|
|
384
383
|
variant: ae = "primary",
|
|
385
384
|
iconClassName: ie,
|
|
386
|
-
animated:
|
|
385
|
+
animated: k = !1,
|
|
387
386
|
...oe
|
|
388
387
|
}, ne) => {
|
|
389
388
|
const le = Te({
|
|
390
|
-
type:
|
|
389
|
+
type: V,
|
|
391
390
|
mode: r,
|
|
392
391
|
focusMode: a,
|
|
393
|
-
fullWidth:
|
|
392
|
+
fullWidth: i,
|
|
394
393
|
disabled: t,
|
|
395
|
-
raw:
|
|
396
|
-
className:
|
|
394
|
+
raw: d,
|
|
395
|
+
className: o,
|
|
397
396
|
noBorder: s,
|
|
398
|
-
size:
|
|
399
|
-
labelRight:
|
|
400
|
-
labelLeft:
|
|
401
|
-
noBackground:
|
|
402
|
-
align:
|
|
403
|
-
radius:
|
|
397
|
+
size: u,
|
|
398
|
+
labelRight: m,
|
|
399
|
+
labelLeft: f,
|
|
400
|
+
noBackground: b,
|
|
401
|
+
align: x,
|
|
402
|
+
radius: I,
|
|
404
403
|
variant: ae,
|
|
405
|
-
animated:
|
|
406
|
-
}), ce = Re({ mode: r, raw:
|
|
407
|
-
return
|
|
408
|
-
S && S.current &&
|
|
409
|
-
}, [
|
|
410
|
-
if (
|
|
411
|
-
let
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}, ze * 0.8))),
|
|
404
|
+
animated: k
|
|
405
|
+
}), ce = Re({ mode: r, raw: d, iconClassName: ie }), j = Me({ animated: k }), se = "flex items-center justify-center relative w-full h-full overflow-hidden", [y, A] = D(), [p, P] = D(), [S, G] = D(), $ = N(0), w = N(null), E = N(null), de = Ae([ne, w]);
|
|
406
|
+
return Y(() => {
|
|
407
|
+
S && S.current && k && ($.current = G.width + $e[u] + (s ? 0 : De), w.current && !w.current.style.width && (w.current.style.width = `${M[u]}px`));
|
|
408
|
+
}, [G, S, u, s, k]), Y(() => {
|
|
409
|
+
if (w && w.current && k) {
|
|
410
|
+
let C = M[u];
|
|
411
|
+
m && y && A.width > 0 ? C = A.width + $.current : f && p && P.width > 0 && (C = P.width + $.current), E.current && clearTimeout(E.current), C !== parseInt(w.current.style.width || "0", 10) && (y.current && (y.current.style.opacity = "0"), p.current && (p.current.style.opacity = "0"), w.current.style.width = `${C}px`, C > M[u] && (E.current = setTimeout(() => {
|
|
412
|
+
y.current && m && (y.current.style.opacity = "1"), p.current && f && (p.current.style.opacity = "1"), E.current = null;
|
|
413
|
+
}, ze * 0.8))), C === M[u] && (y.current && (y.current.style.opacity = "0"), p.current && (p.current.style.opacity = "0"));
|
|
415
414
|
}
|
|
416
415
|
}, [
|
|
417
|
-
O,
|
|
418
|
-
d,
|
|
419
|
-
v,
|
|
420
416
|
A,
|
|
421
|
-
h,
|
|
422
|
-
y,
|
|
423
417
|
m,
|
|
424
|
-
|
|
418
|
+
y,
|
|
419
|
+
P,
|
|
420
|
+
f,
|
|
421
|
+
p,
|
|
422
|
+
u,
|
|
423
|
+
k
|
|
425
424
|
]), B(() => () => {
|
|
426
|
-
|
|
425
|
+
E.current && clearTimeout(E.current);
|
|
427
426
|
}, []), /* @__PURE__ */ l(
|
|
428
427
|
re,
|
|
429
428
|
{
|
|
@@ -431,50 +430,50 @@ const R = {
|
|
|
431
430
|
className: le,
|
|
432
431
|
disabled: t,
|
|
433
432
|
type: c,
|
|
434
|
-
"aria-label": g ||
|
|
433
|
+
"aria-label": g || v,
|
|
435
434
|
...oe,
|
|
436
|
-
children: /* @__PURE__ */
|
|
435
|
+
children: /* @__PURE__ */ L("div", { className: se, children: [
|
|
437
436
|
/* @__PURE__ */ l(
|
|
438
|
-
|
|
437
|
+
X,
|
|
439
438
|
{
|
|
440
|
-
label:
|
|
441
|
-
labelRef:
|
|
442
|
-
labelClass:
|
|
439
|
+
label: f,
|
|
440
|
+
labelRef: p,
|
|
441
|
+
labelClass: j,
|
|
443
442
|
labelInnerClass: "pr-2",
|
|
444
|
-
initiallyHidden:
|
|
443
|
+
initiallyHidden: k
|
|
445
444
|
}
|
|
446
445
|
),
|
|
447
446
|
/* @__PURE__ */ l("span", { ref: S, className: ce, children: e }),
|
|
448
447
|
/* @__PURE__ */ l(
|
|
449
|
-
|
|
448
|
+
X,
|
|
450
449
|
{
|
|
451
|
-
label:
|
|
452
|
-
labelRef:
|
|
453
|
-
labelClass:
|
|
450
|
+
label: m,
|
|
451
|
+
labelRef: y,
|
|
452
|
+
labelClass: j,
|
|
454
453
|
labelInnerClass: "pl-2",
|
|
455
|
-
initiallyHidden:
|
|
454
|
+
initiallyHidden: k
|
|
456
455
|
}
|
|
457
456
|
)
|
|
458
457
|
] })
|
|
459
458
|
}
|
|
460
459
|
);
|
|
461
460
|
}
|
|
462
|
-
),
|
|
461
|
+
), X = ({
|
|
463
462
|
labelRef: e,
|
|
464
463
|
labelClass: t,
|
|
465
464
|
label: r,
|
|
466
465
|
labelInnerClass: a,
|
|
467
|
-
initiallyHidden:
|
|
466
|
+
initiallyHidden: i = !1
|
|
468
467
|
}) => /* @__PURE__ */ l(
|
|
469
468
|
"span",
|
|
470
469
|
{
|
|
471
470
|
ref: e,
|
|
472
471
|
className: t,
|
|
473
|
-
style:
|
|
472
|
+
style: i ? { opacity: 0 } : void 0,
|
|
474
473
|
children: r && /* @__PURE__ */ l("span", { className: a, children: r })
|
|
475
474
|
}
|
|
476
475
|
);
|
|
477
|
-
|
|
476
|
+
U.displayName = "ButtonIcon";
|
|
478
477
|
/*!
|
|
479
478
|
@versini/ui-button v6.0.9
|
|
480
479
|
© 2025 gizmette.com
|
|
@@ -482,20 +481,20 @@ V.displayName = "ButtonIcon";
|
|
|
482
481
|
try {
|
|
483
482
|
window.__VERSINI_UI_BUTTON__ || (window.__VERSINI_UI_BUTTON__ = {
|
|
484
483
|
version: "6.0.9",
|
|
485
|
-
buildTime: "
|
|
484
|
+
buildTime: "08/04/2025 12:23 PM EDT",
|
|
486
485
|
homepage: "https://github.com/aversini/ui-components",
|
|
487
486
|
license: "MIT"
|
|
488
487
|
});
|
|
489
488
|
} catch {
|
|
490
489
|
}
|
|
491
|
-
const Fe =
|
|
490
|
+
const Fe = F.forwardRef(
|
|
492
491
|
({
|
|
493
492
|
children: e,
|
|
494
493
|
mode: t = "system",
|
|
495
494
|
className: r,
|
|
496
495
|
active: a = !1,
|
|
497
|
-
...
|
|
498
|
-
},
|
|
496
|
+
...i
|
|
497
|
+
}, o) => {
|
|
499
498
|
const c = a ? n(
|
|
500
499
|
"relative",
|
|
501
500
|
"focus-within:static",
|
|
@@ -514,13 +513,13 @@ const Fe = z.forwardRef(
|
|
|
514
513
|
}
|
|
515
514
|
) : "";
|
|
516
515
|
return /* @__PURE__ */ l("div", { className: c, children: /* @__PURE__ */ l(
|
|
517
|
-
|
|
516
|
+
U,
|
|
518
517
|
{
|
|
519
518
|
className: n("justify-center", r),
|
|
520
|
-
ref:
|
|
519
|
+
ref: o,
|
|
521
520
|
mode: t,
|
|
522
521
|
radius: "small",
|
|
523
|
-
...
|
|
522
|
+
...i,
|
|
524
523
|
children: e
|
|
525
524
|
}
|
|
526
525
|
) });
|
|
@@ -532,26 +531,26 @@ const Ve = ({
|
|
|
532
531
|
fill: t,
|
|
533
532
|
viewBox: r,
|
|
534
533
|
className: a,
|
|
535
|
-
defaultViewBox:
|
|
536
|
-
size:
|
|
534
|
+
defaultViewBox: i,
|
|
535
|
+
size: o,
|
|
537
536
|
title: c,
|
|
538
|
-
semantic:
|
|
537
|
+
semantic: d = !1,
|
|
539
538
|
...s
|
|
540
539
|
}) => {
|
|
541
|
-
const g = n(
|
|
542
|
-
return /* @__PURE__ */ l(J, { children: /* @__PURE__ */
|
|
540
|
+
const g = n(o, a);
|
|
541
|
+
return /* @__PURE__ */ l(J, { children: /* @__PURE__ */ L(
|
|
543
542
|
"svg",
|
|
544
543
|
{
|
|
545
544
|
xmlns: "http://www.w3.org/2000/svg",
|
|
546
545
|
className: g,
|
|
547
|
-
viewBox: r ||
|
|
546
|
+
viewBox: r || i,
|
|
548
547
|
fill: t || "currentColor",
|
|
549
548
|
role: "img",
|
|
550
|
-
"aria-hidden": !
|
|
549
|
+
"aria-hidden": !d,
|
|
551
550
|
focusable: !1,
|
|
552
551
|
...s,
|
|
553
552
|
children: [
|
|
554
|
-
c &&
|
|
553
|
+
c && d && /* @__PURE__ */ l("title", { children: c }),
|
|
555
554
|
e
|
|
556
555
|
]
|
|
557
556
|
}
|
|
@@ -575,7 +574,7 @@ const Ue = ({
|
|
|
575
574
|
viewBox: t,
|
|
576
575
|
title: r,
|
|
577
576
|
monotone: a,
|
|
578
|
-
...
|
|
577
|
+
...i
|
|
579
578
|
}) => /* @__PURE__ */ l(
|
|
580
579
|
Ve,
|
|
581
580
|
{
|
|
@@ -584,7 +583,7 @@ const Ue = ({
|
|
|
584
583
|
viewBox: t,
|
|
585
584
|
className: e,
|
|
586
585
|
title: r || "Close",
|
|
587
|
-
...
|
|
586
|
+
...i,
|
|
588
587
|
children: /* @__PURE__ */ l(
|
|
589
588
|
"path",
|
|
590
589
|
{
|
|
@@ -607,37 +606,37 @@ try {
|
|
|
607
606
|
});
|
|
608
607
|
} catch {
|
|
609
608
|
}
|
|
610
|
-
const te =
|
|
609
|
+
const te = h.createContext(null);
|
|
611
610
|
function je({
|
|
612
611
|
initialOpen: e = !1,
|
|
613
612
|
open: t,
|
|
614
613
|
onOpenChange: r
|
|
615
614
|
} = {}) {
|
|
616
|
-
const [a,
|
|
615
|
+
const [a, i] = h.useState(e), [o, c] = h.useState(), [d, s] = h.useState(), g = t ?? a, v = r ?? i, u = me({
|
|
617
616
|
open: g,
|
|
618
|
-
onOpenChange:
|
|
619
|
-
}),
|
|
617
|
+
onOpenChange: v
|
|
618
|
+
}), m = u.context, f = ge(m, {
|
|
620
619
|
enabled: t == null
|
|
621
|
-
}),
|
|
620
|
+
}), b = he(m, {
|
|
622
621
|
outsidePress: !1,
|
|
623
622
|
outsidePressEvent: "mousedown"
|
|
624
|
-
}),
|
|
625
|
-
return
|
|
623
|
+
}), x = fe(m), I = be([f, b, x]);
|
|
624
|
+
return h.useMemo(
|
|
626
625
|
() => ({
|
|
627
626
|
open: g,
|
|
628
|
-
setOpen:
|
|
629
|
-
...
|
|
630
|
-
...
|
|
631
|
-
labelId:
|
|
632
|
-
descriptionId:
|
|
627
|
+
setOpen: v,
|
|
628
|
+
...I,
|
|
629
|
+
...u,
|
|
630
|
+
labelId: o,
|
|
631
|
+
descriptionId: d,
|
|
633
632
|
setLabelId: c,
|
|
634
633
|
setDescriptionId: s
|
|
635
634
|
}),
|
|
636
|
-
[g,
|
|
635
|
+
[g, v, I, u, o, d]
|
|
637
636
|
);
|
|
638
637
|
}
|
|
639
|
-
const
|
|
640
|
-
const e =
|
|
638
|
+
const O = () => {
|
|
639
|
+
const e = h.useContext(te);
|
|
641
640
|
if (e == null)
|
|
642
641
|
throw new Error("Modal components must be wrapped in <Modal />");
|
|
643
642
|
return e;
|
|
@@ -649,36 +648,36 @@ function Ge({
|
|
|
649
648
|
const r = je(t);
|
|
650
649
|
return /* @__PURE__ */ l(te.Provider, { value: r, children: e });
|
|
651
650
|
}
|
|
652
|
-
const Ye =
|
|
653
|
-
const { context: r, ...a } =
|
|
651
|
+
const Ye = h.forwardRef(function(e, t) {
|
|
652
|
+
const { context: r, ...a } = O(), i = ve([a.refs.setFloating, t]);
|
|
654
653
|
if (!r.open)
|
|
655
654
|
return null;
|
|
656
|
-
const { overlayBackground:
|
|
657
|
-
[`${
|
|
658
|
-
"bg-black sm:bg-black/[.8]": !
|
|
655
|
+
const { overlayBackground: o, ...c } = e, d = n("grid place-items-center", {
|
|
656
|
+
[`${o}`]: o,
|
|
657
|
+
"bg-black sm:bg-black/[.8]": !o
|
|
659
658
|
});
|
|
660
|
-
return /* @__PURE__ */ l(ye, { children: /* @__PURE__ */ l(pe, { className:
|
|
659
|
+
return /* @__PURE__ */ l(ye, { children: /* @__PURE__ */ l(pe, { className: d, lockScroll: !0, children: /* @__PURE__ */ l(ke, { context: r, children: /* @__PURE__ */ l(
|
|
661
660
|
"div",
|
|
662
661
|
{
|
|
663
|
-
ref:
|
|
662
|
+
ref: i,
|
|
664
663
|
"aria-labelledby": a.labelId,
|
|
665
664
|
"aria-describedby": a.descriptionId,
|
|
666
665
|
...a.getFloatingProps(c),
|
|
667
666
|
children: c.children
|
|
668
667
|
}
|
|
669
668
|
) }) }) });
|
|
670
|
-
}), He =
|
|
671
|
-
const { setLabelId: a } =
|
|
672
|
-
return
|
|
673
|
-
}),
|
|
674
|
-
const { setDescriptionId: a } =
|
|
675
|
-
return
|
|
676
|
-
}),
|
|
677
|
-
const { setOpen: r } =
|
|
678
|
-
return /* @__PURE__ */ l("div", { className:
|
|
669
|
+
}), He = h.forwardRef(function({ children: e, ...t }, r) {
|
|
670
|
+
const { setLabelId: a } = O(), i = Z();
|
|
671
|
+
return h.useLayoutEffect(() => (a(i), () => a(void 0)), [i, a]), /* @__PURE__ */ l("h1", { ...t, ref: r, id: i, children: e });
|
|
672
|
+
}), qe = h.forwardRef(function({ children: e, ...t }, r) {
|
|
673
|
+
const { setDescriptionId: a } = O(), i = Z();
|
|
674
|
+
return h.useLayoutEffect(() => (a(i), () => a(void 0)), [i, a]), /* @__PURE__ */ l("div", { ...t, ref: r, id: i, children: e });
|
|
675
|
+
}), Xe = h.forwardRef(function(e, t) {
|
|
676
|
+
const { setOpen: r } = O(), { trigger: a, className: i, ...o } = e, c = h.useCallback(() => r(!1), [r]);
|
|
677
|
+
return /* @__PURE__ */ l("div", { className: i, children: h.cloneElement(a, {
|
|
679
678
|
ref: t,
|
|
680
679
|
onClick: c,
|
|
681
|
-
...
|
|
680
|
+
...o
|
|
682
681
|
}) });
|
|
683
682
|
});
|
|
684
683
|
/*!
|
|
@@ -688,67 +687,72 @@ const Ye = f.forwardRef(function(e, t) {
|
|
|
688
687
|
try {
|
|
689
688
|
window.__VERSINI_UI_MODAL__ || (window.__VERSINI_UI_MODAL__ = {
|
|
690
689
|
version: "2.0.5",
|
|
691
|
-
buildTime: "
|
|
690
|
+
buildTime: "08/04/2025 12:23 PM EDT",
|
|
692
691
|
homepage: "https://github.com/aversini/ui-components",
|
|
693
692
|
license: "MIT"
|
|
694
693
|
});
|
|
695
694
|
} catch {
|
|
696
695
|
}
|
|
697
|
-
const
|
|
696
|
+
const _ = "panel", T = "messagebox", We = ({
|
|
698
697
|
className: e,
|
|
699
698
|
kind: t,
|
|
700
699
|
borderMode: r,
|
|
701
|
-
animation: a
|
|
700
|
+
animation: a,
|
|
701
|
+
maxWidth: i = "medium"
|
|
702
702
|
}) => ({
|
|
703
703
|
main: n("prose prose-lighter flex flex-col bg-surface-medium", {
|
|
704
704
|
"duration-200 ease-out": a,
|
|
705
|
-
[`${
|
|
706
|
-
[`${
|
|
707
|
-
[`${
|
|
708
|
-
[`${
|
|
705
|
+
[`${R} max-h-full sm:max-h-[95%] min-h-full sm:min-h-[10rem] sm:rounded-lg sm:border-2`]: t === _,
|
|
706
|
+
[`${R} w-full sm:w-[95%] md:max-w-2xl`]: t === _ && !e && i === "small",
|
|
707
|
+
[`${R} w-full sm:w-[95%] md:max-w-3xl`]: t === _ && !e && i === "medium",
|
|
708
|
+
[`${R} w-full sm:w-[95%] md:max-w-4xl`]: t === _ && !e && i === "large",
|
|
709
|
+
[`${H} rounded-lg border-2`]: t === T,
|
|
710
|
+
[`${H} w-[95%] sm:w-[50%] md:max-w-2xl`]: t === T && !e,
|
|
709
711
|
[`${e}`]: !!e,
|
|
710
|
-
"sm:border-border-dark": r === "dark" && t ===
|
|
711
|
-
"sm:border-border-accent": r === "light" && t ===
|
|
712
|
-
"border-border-dark": r === "dark" && t ===
|
|
713
|
-
"border-border-accent": r === "light" && t ===
|
|
712
|
+
"sm:border-border-dark": r === "dark" && t === _,
|
|
713
|
+
"sm:border-border-accent": r === "light" && t === _,
|
|
714
|
+
"border-border-dark": r === "dark" && t === T,
|
|
715
|
+
"border-border-accent": r === "light" && t === T
|
|
714
716
|
}),
|
|
715
717
|
content: "flex flex-col py-2 sm:py-4 sm:px-4 px-2 overflow-y-auto",
|
|
716
718
|
footer: "flex grow flex-col sm:p-4 p-2",
|
|
717
719
|
header: "sm:p-4 mb-0 p-2",
|
|
718
720
|
close: "sm:p-4 p-2"
|
|
719
|
-
}), Je = "slide",
|
|
721
|
+
}), Je = "slide", W = "fade", rr = ({
|
|
720
722
|
open: e,
|
|
721
723
|
onOpenChange: t,
|
|
722
724
|
title: r,
|
|
723
725
|
children: a,
|
|
724
|
-
footer:
|
|
725
|
-
borderMode:
|
|
726
|
-
kind: c =
|
|
727
|
-
className:
|
|
726
|
+
footer: i,
|
|
727
|
+
borderMode: o = "light",
|
|
728
|
+
kind: c = _,
|
|
729
|
+
className: d,
|
|
728
730
|
animation: s = !1,
|
|
729
|
-
animationType: g = Je
|
|
731
|
+
animationType: g = Je,
|
|
732
|
+
maxWidth: v = "medium"
|
|
730
733
|
}) => {
|
|
731
|
-
const
|
|
732
|
-
s ? g ===
|
|
734
|
+
const u = N(""), [m, f] = K(
|
|
735
|
+
s ? g === W ? { opacity: 0 } : {
|
|
733
736
|
transform: "translateY(-100vh)"
|
|
734
737
|
} : {}
|
|
735
|
-
),
|
|
736
|
-
className:
|
|
738
|
+
), b = We({
|
|
739
|
+
className: d,
|
|
737
740
|
kind: c,
|
|
738
|
-
borderMode:
|
|
739
|
-
animation: s
|
|
741
|
+
borderMode: o,
|
|
742
|
+
animation: s,
|
|
743
|
+
maxWidth: v
|
|
740
744
|
});
|
|
741
|
-
return B(() => (e && (
|
|
742
|
-
e && (document.title =
|
|
745
|
+
return B(() => (e && (u.current = document.title, document.title = `${r} | ${u.current}`), () => {
|
|
746
|
+
e && (document.title = u.current);
|
|
743
747
|
}), [r, e]), B(() => {
|
|
744
748
|
if (s && e) {
|
|
745
|
-
|
|
746
|
-
s ? g ===
|
|
749
|
+
f(
|
|
750
|
+
s ? g === W ? { opacity: 0 } : {
|
|
747
751
|
transform: "translateY(-666vh)"
|
|
748
752
|
} : {}
|
|
749
753
|
);
|
|
750
754
|
const x = setTimeout(() => {
|
|
751
|
-
|
|
755
|
+
f(
|
|
752
756
|
s ? g === "fade" ? { opacity: 1 } : {
|
|
753
757
|
transform: "translateY(0)"
|
|
754
758
|
} : {}
|
|
@@ -756,14 +760,14 @@ const C = "panel", M = "messagebox", Xe = ({
|
|
|
756
760
|
}, 100);
|
|
757
761
|
return () => clearTimeout(x);
|
|
758
762
|
}
|
|
759
|
-
}, [e, s, g]), /* @__PURE__ */ l(J, { children: e && /* @__PURE__ */ l(Ge, { open: e, onOpenChange: t, children: /* @__PURE__ */
|
|
760
|
-
/* @__PURE__ */
|
|
763
|
+
}, [e, s, g]), /* @__PURE__ */ l(J, { children: e && /* @__PURE__ */ l(Ge, { open: e, onOpenChange: t, children: /* @__PURE__ */ L(Ye, { className: b.main, style: m, children: [
|
|
764
|
+
/* @__PURE__ */ L("div", { className: "flex flex-row-reverse items-center justify-between", children: [
|
|
761
765
|
/* @__PURE__ */ l(
|
|
762
|
-
|
|
766
|
+
Xe,
|
|
763
767
|
{
|
|
764
|
-
className:
|
|
768
|
+
className: b.close,
|
|
765
769
|
trigger: /* @__PURE__ */ l(
|
|
766
|
-
|
|
770
|
+
U,
|
|
767
771
|
{
|
|
768
772
|
mode: "dark",
|
|
769
773
|
focusMode: "light",
|
|
@@ -774,14 +778,14 @@ const C = "panel", M = "messagebox", Xe = ({
|
|
|
774
778
|
)
|
|
775
779
|
}
|
|
776
780
|
),
|
|
777
|
-
/* @__PURE__ */ l(He, { className:
|
|
781
|
+
/* @__PURE__ */ l(He, { className: b.header, children: r })
|
|
778
782
|
] }),
|
|
779
|
-
/* @__PURE__ */ l(
|
|
780
|
-
|
|
783
|
+
/* @__PURE__ */ l(qe, { className: b.content, children: a }),
|
|
784
|
+
i && /* @__PURE__ */ l("div", { className: b.footer, children: i })
|
|
781
785
|
] }) }) });
|
|
782
786
|
};
|
|
783
787
|
export {
|
|
784
|
-
|
|
785
|
-
|
|
788
|
+
H as MESSAGEBOX_CLASSNAME,
|
|
789
|
+
R as PANEL_CLASSNAME,
|
|
786
790
|
rr as Panel
|
|
787
791
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -48,8 +48,16 @@ type PanelProps = {
|
|
|
48
48
|
* @default "slide"
|
|
49
49
|
*/
|
|
50
50
|
animationType?: "slide" | "fade";
|
|
51
|
+
/**
|
|
52
|
+
* The maximum width of the Panel when kind is "panel".
|
|
53
|
+
* NOTE: This only applies to panels, not messageboxes.
|
|
54
|
+
* NOTE: The max-width only takes effect at the medium breakpoint and above (768px+).
|
|
55
|
+
* At smaller viewports, the panel will take the full screen width.
|
|
56
|
+
* @default "medium"
|
|
57
|
+
*/
|
|
58
|
+
maxWidth?: "small" | "medium" | "large";
|
|
51
59
|
};
|
|
52
60
|
|
|
53
|
-
declare const Panel: ({ open, onOpenChange, title, children, footer, borderMode, kind, className, animation, animationType, }: PanelProps) => react_jsx_runtime.JSX.Element;
|
|
61
|
+
declare const Panel: ({ open, onOpenChange, title, children, footer, borderMode, kind, className, animation, animationType, maxWidth, }: PanelProps) => react_jsx_runtime.JSX.Element;
|
|
54
62
|
|
|
55
63
|
export { MESSAGEBOX_CLASSNAME, PANEL_CLASSNAME, Panel };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { MESSAGEBOX_CLASSNAME as o, PANEL_CLASSNAME as E, Panel as n } from "./components/Panel/Panel.js";
|
|
2
2
|
/*!
|
|
3
|
-
@versini/ui-panel v2.0
|
|
3
|
+
@versini/ui-panel v2.2.0
|
|
4
4
|
© 2025 gizmette.com
|
|
5
5
|
*/
|
|
6
6
|
try {
|
|
7
7
|
window.__VERSINI_UI_PANEL__ || (window.__VERSINI_UI_PANEL__ = {
|
|
8
|
-
version: "2.0
|
|
9
|
-
buildTime: "
|
|
8
|
+
version: "2.2.0",
|
|
9
|
+
buildTime: "08/04/2025 12:23 PM EDT",
|
|
10
10
|
homepage: "https://github.com/aversini/ui-components",
|
|
11
11
|
license: "MIT"
|
|
12
12
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-panel",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dev:types": "tsup --watch src",
|
|
28
28
|
"dev": "npm-run-all clean --parallel dev:js dev:types",
|
|
29
29
|
"lint": "biome lint src",
|
|
30
|
+
"lint:fix": "biome check src --write --no-errors-on-unmatched",
|
|
30
31
|
"prettier": "biome check --write --no-errors-on-unmatched",
|
|
31
32
|
"start": "static-server dist --port 5173",
|
|
32
33
|
"test:coverage:ui": "vitest --coverage --ui",
|
|
@@ -52,5 +53,5 @@
|
|
|
52
53
|
"sideEffects": [
|
|
53
54
|
"**/*.css"
|
|
54
55
|
],
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "14d53d66c2f014604b12f5e3ef0bb8708c996c21"
|
|
56
57
|
}
|