@pravalabs/ui 0.0.0-stage → 1.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +142 -2
- package/dist/Accordion-CVRdRha1.js +107 -0
- package/dist/Alert-Bxv6CGPj.js +54 -0
- package/dist/Avatar-DUw9xBQ-.js +49 -0
- package/dist/Badge-cupXlWce.js +37 -0
- package/dist/Button-vjrnnaM_.js +65 -0
- package/dist/Card-BJNdpGjM.js +44 -0
- package/dist/Checkbox-BQtcnwwC.js +60 -0
- package/dist/Container-DO8bd1tv.js +19 -0
- package/dist/Dialog-D3-sT_1Z.js +147 -0
- package/dist/Drawer-BRzJmvQx.js +21 -0
- package/dist/DropdownMenu-CFa2vgXi.js +137 -0
- package/dist/FormField-CoC946w9.js +61 -0
- package/dist/Grid-vTrChm2w.js +31 -0
- package/dist/Input-B97l8Dj0.js +82 -0
- package/dist/Label-DYOFzyEM.js +25 -0
- package/dist/Popover-C9Vgtm3q.js +81 -0
- package/dist/PravaProvider-0znpKV4G.js +59 -0
- package/dist/Progress-_Hz8dxM4.js +51 -0
- package/dist/RadioGroup-CvdV80Pg.js +90 -0
- package/dist/Select-_urp2aA_.js +451 -0
- package/dist/Separator-MnFbL0eH.js +23 -0
- package/dist/Skeleton-CyjiU8o1.js +25 -0
- package/dist/Spinner-Da7h4BDn.js +77 -0
- package/dist/Stack-DNtmh6BN.js +30 -0
- package/dist/Switch-Cp-wriw6.js +50 -0
- package/dist/Tabs-C0SRJSv1.js +158 -0
- package/dist/Textarea-D0fNA7sQ.js +69 -0
- package/dist/Toast-7qJXHzEb.js +110 -0
- package/dist/Tooltip-CyW8YfU9.js +57 -0
- package/dist/accordion.js +8 -0
- package/dist/alert.js +7 -0
- package/dist/avatar.js +7 -0
- package/dist/badge.js +7 -0
- package/dist/button.js +7 -0
- package/dist/card.js +10 -0
- package/dist/checkbox.js +8 -0
- package/dist/components/accordion/Accordion.d.ts +42 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/alert/Alert.d.ts +35 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/avatar/Avatar.d.ts +16 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/badge/Badge.d.ts +22 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/button/Button.d.ts +50 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/card/Card.d.ts +49 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/checkbox/Checkbox.d.ts +23 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/container/Container.d.ts +22 -0
- package/dist/components/container/index.d.ts +2 -0
- package/dist/components/dialog/Dialog.d.ts +89 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/drawer/Drawer.d.ts +46 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.ts +59 -0
- package/dist/components/dropdown-menu/index.d.ts +2 -0
- package/dist/components/field/field.d.ts +87 -0
- package/dist/components/form-field/FormField.d.ts +41 -0
- package/dist/components/form-field/index.d.ts +2 -0
- package/dist/components/grid/Grid.d.ts +36 -0
- package/dist/components/grid/index.d.ts +2 -0
- package/dist/components/input/Input.d.ts +35 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/label/Label.d.ts +15 -0
- package/dist/components/label/index.d.ts +2 -0
- package/dist/components/popover/Popover.d.ts +35 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/progress/Progress.d.ts +15 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/provider/PravaProvider.d.ts +69 -0
- package/dist/components/provider/index.d.ts +2 -0
- package/dist/components/radio-group/RadioGroup.d.ts +58 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/select/Select.d.ts +76 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/separator/Separator.d.ts +9 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/skeleton/Skeleton.d.ts +7 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/spinner/Spinner.d.ts +15 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/stack/Stack.d.ts +38 -0
- package/dist/components/stack/index.d.ts +2 -0
- package/dist/components/switch/Switch.d.ts +19 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/tabs/Tabs.d.ts +69 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/textarea/Textarea.d.ts +26 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/toast/Toast.d.ts +55 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/tooltip/Tooltip.d.ts +22 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/container.js +7 -0
- package/dist/dialog.js +8 -0
- package/dist/drawer.js +8 -0
- package/dist/dropdown-menu.js +8 -0
- package/dist/field-U1YinldE.js +152 -0
- package/dist/form-field.js +8 -0
- package/dist/grid.js +7 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +29 -0
- package/dist/input.js +8 -0
- package/dist/internal/overlay.d.ts +39 -0
- package/dist/internal/useControllable.d.ts +2 -0
- package/dist/label.js +8 -0
- package/dist/overlay-9zlvgpUZ.js +121 -0
- package/dist/popover.js +8 -0
- package/dist/progress.js +7 -0
- package/dist/provider.js +7 -0
- package/dist/radio-group.js +8 -0
- package/dist/select.js +8 -0
- package/dist/separator.js +7 -0
- package/dist/skeleton.js +7 -0
- package/dist/spinner.js +7 -0
- package/dist/stack.js +7 -0
- package/dist/styles/components/accordion.css +1 -0
- package/dist/styles/components/alert.css +1 -0
- package/dist/styles/components/avatar.css +1 -0
- package/dist/styles/components/badge.css +1 -0
- package/dist/styles/components/button.css +1 -0
- package/dist/styles/components/card.css +1 -0
- package/dist/styles/components/checkbox.css +1 -0
- package/dist/styles/components/container.css +1 -0
- package/dist/styles/components/dialog.css +1 -0
- package/dist/styles/components/drawer.css +1 -0
- package/dist/styles/components/dropdown-menu.css +1 -0
- package/dist/styles/components/field.css +1 -0
- package/dist/styles/components/floating.css +1 -0
- package/dist/styles/components/form-field.css +1 -0
- package/dist/styles/components/grid.css +1 -0
- package/dist/styles/components/input.css +1 -0
- package/dist/styles/components/label.css +1 -0
- package/dist/styles/components/popover.css +1 -0
- package/dist/styles/components/progress.css +1 -0
- package/dist/styles/components/provider.css +1 -0
- package/dist/styles/components/radio-group.css +1 -0
- package/dist/styles/components/select.css +1 -0
- package/dist/styles/components/separator.css +1 -0
- package/dist/styles/components/skeleton.css +1 -0
- package/dist/styles/components/spinner.css +1 -0
- package/dist/styles/components/stack.css +1 -0
- package/dist/styles/components/switch.css +1 -0
- package/dist/styles/components/tabs.css +1 -0
- package/dist/styles/components/textarea.css +1 -0
- package/dist/styles/components/toast.css +1 -0
- package/dist/styles/components/tooltip.css +1 -0
- package/dist/styles.css +1 -0
- package/dist/switch.js +8 -0
- package/dist/tabs.js +10 -0
- package/dist/textarea.js +8 -0
- package/dist/toast.js +9 -0
- package/dist/tokens.css +192 -0
- package/dist/tooltip.js +8 -0
- package/dist/useControllable-C2Te1pSd.js +14 -0
- package/package.json +223 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as n, jsxs as a } from "react/jsx-runtime";
|
|
3
|
+
function u() {
|
|
4
|
+
return /* @__PURE__ */ a(
|
|
5
|
+
"svg",
|
|
6
|
+
{
|
|
7
|
+
className: "prava-spinner__indicator",
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
"aria-hidden": "true",
|
|
10
|
+
children: [
|
|
11
|
+
/* @__PURE__ */ n("circle", { className: "prava-spinner__track", cx: "12", cy: "12", r: "9" }),
|
|
12
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "9" })
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
function l() {
|
|
18
|
+
return /* @__PURE__ */ a("span", { className: "prava-spinner__dots", "aria-hidden": "true", children: [
|
|
19
|
+
/* @__PURE__ */ n("span", {}),
|
|
20
|
+
/* @__PURE__ */ n("span", {}),
|
|
21
|
+
/* @__PURE__ */ n("span", {})
|
|
22
|
+
] });
|
|
23
|
+
}
|
|
24
|
+
function _() {
|
|
25
|
+
return /* @__PURE__ */ a("span", { className: "prava-spinner__bars", "aria-hidden": "true", children: [
|
|
26
|
+
/* @__PURE__ */ n("span", {}),
|
|
27
|
+
/* @__PURE__ */ n("span", {}),
|
|
28
|
+
/* @__PURE__ */ n("span", {})
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
function h() {
|
|
32
|
+
return /* @__PURE__ */ n("span", { className: "prava-spinner__pulse", "aria-hidden": "true" });
|
|
33
|
+
}
|
|
34
|
+
function m() {
|
|
35
|
+
return /* @__PURE__ */ a("span", { className: "prava-spinner__bounce", "aria-hidden": "true", children: [
|
|
36
|
+
/* @__PURE__ */ n("span", {}),
|
|
37
|
+
/* @__PURE__ */ n("span", {}),
|
|
38
|
+
/* @__PURE__ */ n("span", {})
|
|
39
|
+
] });
|
|
40
|
+
}
|
|
41
|
+
const v = {
|
|
42
|
+
spinner: u,
|
|
43
|
+
dots: l,
|
|
44
|
+
bars: _,
|
|
45
|
+
pulse: h,
|
|
46
|
+
bounce: m
|
|
47
|
+
};
|
|
48
|
+
function N({
|
|
49
|
+
label: r,
|
|
50
|
+
size: i = "md",
|
|
51
|
+
variant: e = "spinner",
|
|
52
|
+
tone: p = "primary",
|
|
53
|
+
color: s,
|
|
54
|
+
className: t,
|
|
55
|
+
style: c,
|
|
56
|
+
...d
|
|
57
|
+
}) {
|
|
58
|
+
const o = v[e];
|
|
59
|
+
return /* @__PURE__ */ n(
|
|
60
|
+
"span",
|
|
61
|
+
{
|
|
62
|
+
...d,
|
|
63
|
+
style: { ...c, ...s ? { color: s } : {} },
|
|
64
|
+
className: ["prava-spinner", t].filter(Boolean).join(" "),
|
|
65
|
+
"data-size": i,
|
|
66
|
+
"data-variant": e,
|
|
67
|
+
"data-tone": p,
|
|
68
|
+
role: r ? "status" : void 0,
|
|
69
|
+
"aria-label": r,
|
|
70
|
+
"aria-hidden": r ? void 0 : !0,
|
|
71
|
+
children: /* @__PURE__ */ n(o, {})
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
N as S
|
|
77
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as f } from "react";
|
|
4
|
+
const v = f(function({
|
|
5
|
+
orientation: a = "vertical",
|
|
6
|
+
gap: t = 4,
|
|
7
|
+
align: o,
|
|
8
|
+
justify: r,
|
|
9
|
+
wrap: i,
|
|
10
|
+
as: n = "div",
|
|
11
|
+
className: d,
|
|
12
|
+
...e
|
|
13
|
+
}, s) {
|
|
14
|
+
return /* @__PURE__ */ c(
|
|
15
|
+
n,
|
|
16
|
+
{
|
|
17
|
+
...e,
|
|
18
|
+
ref: s,
|
|
19
|
+
className: ["prava-stack", d].filter(Boolean).join(" "),
|
|
20
|
+
"data-orientation": a,
|
|
21
|
+
"data-gap": t,
|
|
22
|
+
"data-align": o,
|
|
23
|
+
"data-justify": r,
|
|
24
|
+
"data-wrap": i || void 0
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
export {
|
|
29
|
+
v as S
|
|
30
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as h, jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as b } from "react";
|
|
4
|
+
import { b as u, u as v, C as w } from "./field-U1YinldE.js";
|
|
5
|
+
const j = b(
|
|
6
|
+
function(a, e) {
|
|
7
|
+
const {
|
|
8
|
+
label: s,
|
|
9
|
+
description: o,
|
|
10
|
+
error: d,
|
|
11
|
+
invalid: n,
|
|
12
|
+
id: c,
|
|
13
|
+
onBlur: t,
|
|
14
|
+
onChange: l,
|
|
15
|
+
onInvalid: p,
|
|
16
|
+
ref: f,
|
|
17
|
+
...i
|
|
18
|
+
} = u(
|
|
19
|
+
a,
|
|
20
|
+
e,
|
|
21
|
+
"checked"
|
|
22
|
+
), r = v({
|
|
23
|
+
id: c,
|
|
24
|
+
description: o,
|
|
25
|
+
error: d,
|
|
26
|
+
invalid: n,
|
|
27
|
+
onBlur: t,
|
|
28
|
+
onChange: l,
|
|
29
|
+
onInvalid: p,
|
|
30
|
+
"aria-describedby": i["aria-describedby"],
|
|
31
|
+
"aria-invalid": i["aria-invalid"]
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ h("span", { className: "prava-field", "data-choice": "switch", children: [
|
|
34
|
+
/* @__PURE__ */ m(
|
|
35
|
+
w,
|
|
36
|
+
{
|
|
37
|
+
...i,
|
|
38
|
+
...r.controlProps,
|
|
39
|
+
ref: f,
|
|
40
|
+
kind: "switch",
|
|
41
|
+
label: s
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
r.messages
|
|
45
|
+
] });
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
export {
|
|
49
|
+
j as S
|
|
50
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as R, jsx as y } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as x, useEffect as I, useId as j, useContext as k, createContext as B } from "react";
|
|
4
|
+
import { u as N } from "./useControllable-C2Te1pSd.js";
|
|
5
|
+
const C = B(null), g = () => {
|
|
6
|
+
const e = k(C);
|
|
7
|
+
if (!e) throw new Error("Tab parts must be inside <Tabs>.");
|
|
8
|
+
return e;
|
|
9
|
+
}, _ = (e, r) => `${e}-tab-${encodeURIComponent(r)}`, A = (e, r) => `${e}-panel-${encodeURIComponent(r)}`;
|
|
10
|
+
function D({
|
|
11
|
+
value: e,
|
|
12
|
+
defaultValue: r,
|
|
13
|
+
onValueChange: c,
|
|
14
|
+
activation: o = "automatic",
|
|
15
|
+
orientation: f = "horizontal",
|
|
16
|
+
className: b,
|
|
17
|
+
...i
|
|
18
|
+
}) {
|
|
19
|
+
const [s, d] = N(
|
|
20
|
+
e,
|
|
21
|
+
r ?? "",
|
|
22
|
+
c
|
|
23
|
+
), v = j();
|
|
24
|
+
return /* @__PURE__ */ y(
|
|
25
|
+
C.Provider,
|
|
26
|
+
{
|
|
27
|
+
value: { value: s, setValue: d, activation: o, orientation: f, id: v },
|
|
28
|
+
children: /* @__PURE__ */ y(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
...i,
|
|
32
|
+
className: ["prava-tabs", b].filter(Boolean).join(" "),
|
|
33
|
+
"data-orientation": f
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function P({
|
|
40
|
+
className: e,
|
|
41
|
+
children: r,
|
|
42
|
+
onKeyDown: c,
|
|
43
|
+
...o
|
|
44
|
+
}) {
|
|
45
|
+
const { value: f, setValue: b, activation: i, orientation: s } = g(), d = x(null), v = x(null), T = x(!1);
|
|
46
|
+
I(() => {
|
|
47
|
+
const t = d.current, a = v.current;
|
|
48
|
+
if (!t || !a) return;
|
|
49
|
+
const p = () => {
|
|
50
|
+
const u = t.querySelector('[aria-selected="true"]');
|
|
51
|
+
if (a.hidden = !u, !u) return;
|
|
52
|
+
const m = t.getBoundingClientRect(), n = u.getBoundingClientRect(), l = t.offsetWidth / m.width || 1;
|
|
53
|
+
if (s === "horizontal") {
|
|
54
|
+
const w = (n.left - m.left) * l + t.scrollLeft;
|
|
55
|
+
a.style.translate = `${w}px 0`, a.style.scale = `${n.width * l} 1`;
|
|
56
|
+
} else {
|
|
57
|
+
const w = (n.top - m.top) * l + t.scrollTop;
|
|
58
|
+
a.style.translate = `0 ${w}px`, a.style.scale = `1 ${n.height * l}`;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
T.current && (a.dataset.ready = ""), T.current = !0, p();
|
|
62
|
+
const h = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(p);
|
|
63
|
+
return h?.observe(t), t.querySelectorAll('[role="tab"]').forEach((u) => h?.observe(u)), () => {
|
|
64
|
+
h?.disconnect();
|
|
65
|
+
};
|
|
66
|
+
}, [f, s]);
|
|
67
|
+
const $ = (t) => {
|
|
68
|
+
if (c?.(t), t.defaultPrevented) return;
|
|
69
|
+
const a = Array.from(
|
|
70
|
+
t.currentTarget.querySelectorAll(
|
|
71
|
+
'[role="tab"]:not(:disabled)'
|
|
72
|
+
)
|
|
73
|
+
), p = a.indexOf(document.activeElement), h = getComputedStyle(t.currentTarget).direction === "rtl", [u, m] = s === "vertical" ? ["ArrowUp", "ArrowDown"] : h ? ["ArrowRight", "ArrowLeft"] : ["ArrowLeft", "ArrowRight"];
|
|
74
|
+
let n;
|
|
75
|
+
if (t.key === m) n = p + 1;
|
|
76
|
+
else if (t.key === u) n = p - 1;
|
|
77
|
+
else if (t.key === "Home") n = 0;
|
|
78
|
+
else if (t.key === "End") n = a.length - 1;
|
|
79
|
+
else return;
|
|
80
|
+
t.preventDefault();
|
|
81
|
+
const l = a[(n + a.length) % a.length];
|
|
82
|
+
l?.focus(), l && i === "automatic" && l.dataset.value !== void 0 && b(l.dataset.value);
|
|
83
|
+
};
|
|
84
|
+
return /* @__PURE__ */ R(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
...o,
|
|
88
|
+
ref: d,
|
|
89
|
+
role: "tablist",
|
|
90
|
+
"aria-orientation": s,
|
|
91
|
+
className: ["prava-tabs__list", e].filter(Boolean).join(" "),
|
|
92
|
+
onKeyDown: $,
|
|
93
|
+
children: [
|
|
94
|
+
r,
|
|
95
|
+
/* @__PURE__ */ y(
|
|
96
|
+
"span",
|
|
97
|
+
{
|
|
98
|
+
ref: v,
|
|
99
|
+
className: "prava-tabs__indicator",
|
|
100
|
+
"aria-hidden": "true"
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
function S({
|
|
108
|
+
value: e,
|
|
109
|
+
icon: r,
|
|
110
|
+
className: c,
|
|
111
|
+
children: o,
|
|
112
|
+
onClick: f,
|
|
113
|
+
...b
|
|
114
|
+
}) {
|
|
115
|
+
const i = g(), s = i.value === e;
|
|
116
|
+
return /* @__PURE__ */ R(
|
|
117
|
+
"button",
|
|
118
|
+
{
|
|
119
|
+
...b,
|
|
120
|
+
type: "button",
|
|
121
|
+
role: "tab",
|
|
122
|
+
id: _(i.id, e),
|
|
123
|
+
"aria-selected": s,
|
|
124
|
+
"aria-controls": A(i.id, e),
|
|
125
|
+
tabIndex: s ? 0 : -1,
|
|
126
|
+
"data-value": e,
|
|
127
|
+
className: ["prava-tabs__tab", c].filter(Boolean).join(" "),
|
|
128
|
+
onClick: (d) => {
|
|
129
|
+
f?.(d), d.defaultPrevented || i.setValue(e);
|
|
130
|
+
},
|
|
131
|
+
children: [
|
|
132
|
+
r != null && /* @__PURE__ */ y("span", { className: "prava-tabs__icon", "aria-hidden": "true", children: r }),
|
|
133
|
+
o
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function q({ value: e, className: r, ...c }) {
|
|
139
|
+
const o = g();
|
|
140
|
+
return /* @__PURE__ */ y(
|
|
141
|
+
"div",
|
|
142
|
+
{
|
|
143
|
+
tabIndex: 0,
|
|
144
|
+
...c,
|
|
145
|
+
role: "tabpanel",
|
|
146
|
+
id: A(o.id, e),
|
|
147
|
+
"aria-labelledby": _(o.id, e),
|
|
148
|
+
hidden: o.value !== e,
|
|
149
|
+
className: ["prava-tabs__panel", r].filter(Boolean).join(" ")
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
export {
|
|
154
|
+
S as T,
|
|
155
|
+
P as a,
|
|
156
|
+
q as b,
|
|
157
|
+
D as c
|
|
158
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as S, jsx as T } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as j, useRef as k, useCallback as f, useEffect as w } from "react";
|
|
4
|
+
import { b as H, u as N, o as P, s as F } from "./field-U1YinldE.js";
|
|
5
|
+
const d = (t) => `calc(${t} * 1lh + 1rem + 2px)`, M = j(
|
|
6
|
+
function(m, p) {
|
|
7
|
+
const {
|
|
8
|
+
invalid: u,
|
|
9
|
+
description: h,
|
|
10
|
+
error: g,
|
|
11
|
+
rows: r = 3,
|
|
12
|
+
maxRows: i = 12,
|
|
13
|
+
resize: x = "none",
|
|
14
|
+
id: v,
|
|
15
|
+
className: b,
|
|
16
|
+
style: y,
|
|
17
|
+
value: n,
|
|
18
|
+
onBlur: z,
|
|
19
|
+
onChange: C,
|
|
20
|
+
onInvalid: R,
|
|
21
|
+
ref: l,
|
|
22
|
+
...s
|
|
23
|
+
} = H(m, p), o = N({
|
|
24
|
+
id: v,
|
|
25
|
+
description: h,
|
|
26
|
+
error: g,
|
|
27
|
+
invalid: u,
|
|
28
|
+
onBlur: z,
|
|
29
|
+
onChange: C,
|
|
30
|
+
onInvalid: R,
|
|
31
|
+
"aria-describedby": s["aria-describedby"],
|
|
32
|
+
"aria-invalid": s["aria-invalid"]
|
|
33
|
+
}), c = k(null), a = f(() => {
|
|
34
|
+
const e = c.current;
|
|
35
|
+
!e || globalThis.CSS?.supports?.("field-sizing", "content") || (e.style.height = "auto", e.style.height = `${e.scrollHeight + e.offsetHeight - e.clientHeight}px`);
|
|
36
|
+
}, []), B = f(
|
|
37
|
+
(e) => {
|
|
38
|
+
e && (c.current = e, P(e, "value", a)), F(l, e);
|
|
39
|
+
},
|
|
40
|
+
[l, a]
|
|
41
|
+
);
|
|
42
|
+
return w(a, [a, n, r, i]), /* @__PURE__ */ S("span", { className: "prava-field", children: [
|
|
43
|
+
/* @__PURE__ */ T(
|
|
44
|
+
"textarea",
|
|
45
|
+
{
|
|
46
|
+
...s,
|
|
47
|
+
...o.controlProps,
|
|
48
|
+
ref: B,
|
|
49
|
+
rows: r,
|
|
50
|
+
value: n,
|
|
51
|
+
onChange: (e) => {
|
|
52
|
+
o.controlProps.onChange(e), a();
|
|
53
|
+
},
|
|
54
|
+
className: ["prava-control prava-textarea", b].filter(Boolean).join(" "),
|
|
55
|
+
"data-resize": x,
|
|
56
|
+
style: {
|
|
57
|
+
minBlockSize: d(r),
|
|
58
|
+
maxBlockSize: d(Math.max(r, i)),
|
|
59
|
+
...y
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
o.messages
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
export {
|
|
68
|
+
M as T
|
|
69
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as _, Fragment as w, jsx as a } from "react/jsx-runtime";
|
|
3
|
+
import { useSyncExternalStore as x, useRef as v, useState as f, useEffect as u } from "react";
|
|
4
|
+
import { u as S } from "./overlay-9zlvgpUZ.js";
|
|
5
|
+
import { u as I } from "./PravaProvider-0znpKV4G.js";
|
|
6
|
+
import { A as j } from "./Alert-Bxv6CGPj.js";
|
|
7
|
+
let i = [], D = 0;
|
|
8
|
+
const m = /* @__PURE__ */ new Set(), h = (e) => {
|
|
9
|
+
i = e, m.forEach((n) => n());
|
|
10
|
+
}, F = (e) => (m.add(e), () => m.delete(e)), L = () => i, A = [], B = () => A;
|
|
11
|
+
function q(e) {
|
|
12
|
+
const n = e.id ?? `prava-toast-${++D}`, s = { ...e, id: n, open: !0 };
|
|
13
|
+
return h(
|
|
14
|
+
i.some((o) => o.id === n) ? i.map((o) => o.id === n ? s : o) : [...i, s]
|
|
15
|
+
), n;
|
|
16
|
+
}
|
|
17
|
+
function y(e) {
|
|
18
|
+
h(
|
|
19
|
+
i.map(
|
|
20
|
+
(n) => e === void 0 || n.id === e ? { ...n, open: !1 } : n
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const H = ({ duration: e, tone: n, action: s }) => e ?? (n === "danger" ? 1 / 0 : s != null ? 1e4 : 5e3);
|
|
25
|
+
function C({ item: e, paused: n }) {
|
|
26
|
+
const s = v(null), o = H(e), r = v(o), d = S(e.open, s);
|
|
27
|
+
return u(() => {
|
|
28
|
+
r.current = o;
|
|
29
|
+
}, [e, o]), u(() => {
|
|
30
|
+
if (n || !e.open || r.current === 1 / 0) return;
|
|
31
|
+
const l = Date.now(), p = setTimeout(() => y(e.id), r.current);
|
|
32
|
+
return () => {
|
|
33
|
+
clearTimeout(p), r.current -= Date.now() - l;
|
|
34
|
+
};
|
|
35
|
+
}, [n, e]), u(() => {
|
|
36
|
+
d || h(i.filter((l) => l.id !== e.id));
|
|
37
|
+
}, [d, e.id]), /* @__PURE__ */ a(
|
|
38
|
+
"li",
|
|
39
|
+
{
|
|
40
|
+
ref: s,
|
|
41
|
+
className: "prava-toast",
|
|
42
|
+
"data-open": e.open ? "" : void 0,
|
|
43
|
+
children: /* @__PURE__ */ a("div", { className: "prava-toast__clip", children: /* @__PURE__ */ a(
|
|
44
|
+
j,
|
|
45
|
+
{
|
|
46
|
+
role: "group",
|
|
47
|
+
tone: e.tone,
|
|
48
|
+
title: e.title,
|
|
49
|
+
action: e.action,
|
|
50
|
+
onDismiss: () => y(e.id),
|
|
51
|
+
children: e.description
|
|
52
|
+
}
|
|
53
|
+
) })
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
function z({
|
|
58
|
+
placement: e = "bottom-end",
|
|
59
|
+
className: n,
|
|
60
|
+
...s
|
|
61
|
+
}) {
|
|
62
|
+
const { messages: o } = I(), r = x(F, L, B), d = v(null), [l, p] = f(!1), [E, g] = f(!1), [N, P] = f(!1);
|
|
63
|
+
u(() => {
|
|
64
|
+
const t = () => P(document.hidden);
|
|
65
|
+
return document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t);
|
|
66
|
+
}, []);
|
|
67
|
+
const b = r.length;
|
|
68
|
+
u(() => {
|
|
69
|
+
const t = d.current;
|
|
70
|
+
t && (t.matches?.(":popover-open") && t.hidePopover(), b > 0 && t.showPopover?.());
|
|
71
|
+
}, [b]);
|
|
72
|
+
const T = (t) => r.filter((c) => c.open && c.tone === "danger" === t).map((c) => /* @__PURE__ */ _("div", { children: [
|
|
73
|
+
c.title,
|
|
74
|
+
" ",
|
|
75
|
+
c.description
|
|
76
|
+
] }, c.id));
|
|
77
|
+
return /* @__PURE__ */ _(w, { children: [
|
|
78
|
+
/* @__PURE__ */ a("div", { role: "status", className: "prava-toaster__announce", children: T(!1) }),
|
|
79
|
+
/* @__PURE__ */ a("div", { role: "alert", className: "prava-toaster__announce", children: T(!0) }),
|
|
80
|
+
/* @__PURE__ */ a(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
role: "region",
|
|
84
|
+
"aria-label": o.notifications,
|
|
85
|
+
...s,
|
|
86
|
+
ref: d,
|
|
87
|
+
popover: "manual",
|
|
88
|
+
className: ["prava-toaster", n].filter(Boolean).join(" "),
|
|
89
|
+
"data-placement": e,
|
|
90
|
+
onPointerEnter: () => p(!0),
|
|
91
|
+
onPointerLeave: () => p(!1),
|
|
92
|
+
onFocus: () => g(!0),
|
|
93
|
+
onBlur: () => g(!1),
|
|
94
|
+
children: /* @__PURE__ */ a("ol", { className: "prava-toaster__list", children: r.map((t) => /* @__PURE__ */ a(
|
|
95
|
+
C,
|
|
96
|
+
{
|
|
97
|
+
item: t,
|
|
98
|
+
paused: l || E || N
|
|
99
|
+
},
|
|
100
|
+
t.id
|
|
101
|
+
)) })
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
] });
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
z as T,
|
|
108
|
+
y as d,
|
|
109
|
+
q as t
|
|
110
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as b, jsx as E } from "react/jsx-runtime";
|
|
3
|
+
import { useState as P, useRef as a, useId as D, useCallback as l, useEffect as j } from "react";
|
|
4
|
+
import { a as x, b as I, c as k } from "./overlay-9zlvgpUZ.js";
|
|
5
|
+
const B = 100;
|
|
6
|
+
function w({
|
|
7
|
+
content: p,
|
|
8
|
+
children: f,
|
|
9
|
+
delay: m = 400,
|
|
10
|
+
placement: d = "top",
|
|
11
|
+
className: T,
|
|
12
|
+
id: g,
|
|
13
|
+
...v
|
|
14
|
+
}) {
|
|
15
|
+
const [t, r] = P(!1), n = a(null), i = a(null), o = a(void 0), h = D(), u = g ?? h, c = l((e, y) => {
|
|
16
|
+
clearTimeout(o.current), o.current = setTimeout(() => r(e), y);
|
|
17
|
+
}, []), s = l(() => {
|
|
18
|
+
clearTimeout(o.current), r(!1);
|
|
19
|
+
}, []);
|
|
20
|
+
return j(() => () => clearTimeout(o.current), []), x(t, n, i, d, "center"), I(t, n, s), /* @__PURE__ */ b("span", { ref: n, className: "prava-floating-root", ...{
|
|
21
|
+
onPointerEnter: (e) => {
|
|
22
|
+
e.pointerType === "mouse" && c(!0, t ? 0 : m);
|
|
23
|
+
},
|
|
24
|
+
onPointerLeave: (e) => {
|
|
25
|
+
e.pointerType === "mouse" && c(!1, B);
|
|
26
|
+
},
|
|
27
|
+
// Touch has no hover: a tap shows it, and a press elsewhere hides it.
|
|
28
|
+
onPointerUp: (e) => {
|
|
29
|
+
e.pointerType !== "mouse" && (clearTimeout(o.current), r(!0));
|
|
30
|
+
},
|
|
31
|
+
onFocus: (e) => {
|
|
32
|
+
e.target.matches?.(":focus-visible") && (clearTimeout(o.current), r(!0));
|
|
33
|
+
},
|
|
34
|
+
onBlur: s,
|
|
35
|
+
onKeyDown: (e) => {
|
|
36
|
+
e.key !== "Escape" || !t || (e.preventDefault(), e.stopPropagation(), s());
|
|
37
|
+
}
|
|
38
|
+
}, children: [
|
|
39
|
+
k(f, { "aria-describedby": u }),
|
|
40
|
+
/* @__PURE__ */ E(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
...v,
|
|
44
|
+
ref: i,
|
|
45
|
+
id: u,
|
|
46
|
+
role: "tooltip",
|
|
47
|
+
popover: "manual",
|
|
48
|
+
className: ["prava-floating prava-tooltip", T].filter(Boolean).join(" "),
|
|
49
|
+
"data-open": t ? "" : void 0,
|
|
50
|
+
children: p
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
] });
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
w as T
|
|
57
|
+
};
|
package/dist/alert.js
ADDED
package/dist/avatar.js
ADDED
package/dist/badge.js
ADDED
package/dist/button.js
ADDED
package/dist/card.js
ADDED
package/dist/checkbox.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type AccordionProps = Omit<HTMLAttributes<HTMLDivElement>, "defaultValue"> & {
|
|
3
|
+
/** Lets several items stay open. By default, opening one closes the others. */
|
|
4
|
+
multiple?: boolean;
|
|
5
|
+
/** Open item values when controlled. */
|
|
6
|
+
value?: readonly string[];
|
|
7
|
+
/** Initially open item values when uncontrolled. */
|
|
8
|
+
defaultValue?: readonly string[];
|
|
9
|
+
/** Called with every open value after a change. */
|
|
10
|
+
onValueChange?: (value: string[]) => void;
|
|
11
|
+
/** Heading level of each item, to fit the page's outline. */
|
|
12
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Discloses related content. Up and Down, Home and End move between headers.
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { Accordion, AccordionItem } from '@pravalabs/ui/accordion';
|
|
19
|
+
*
|
|
20
|
+
* <Accordion defaultValue={['billing']}>
|
|
21
|
+
* <AccordionItem value="billing" title="Billing">Invoices are sent monthly.</AccordionItem>
|
|
22
|
+
* <AccordionItem value="security" title="Security">Data is encrypted at rest.</AccordionItem>
|
|
23
|
+
* </Accordion>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function Accordion({ multiple, value, defaultValue, onValueChange, headingLevel, className, onKeyDown, ...props }: AccordionProps): import("react").JSX.Element;
|
|
27
|
+
export type AccordionItemProps = Omit<HTMLAttributes<HTMLDivElement>, "title"> & {
|
|
28
|
+
/** Identifies the item in `value`. Keep it stable across languages. */
|
|
29
|
+
value: string;
|
|
30
|
+
/** Text of the header button. */
|
|
31
|
+
title: ReactNode;
|
|
32
|
+
/** Stops the header from toggling; the panel keeps its current state. */
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* One header and its panel. A closed panel is hidden from keyboard and screen readers.
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <AccordionItem value="billing" title="Billing">Invoices are sent monthly.</AccordionItem>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function AccordionItem({ value, title, disabled, className, children, ...props }: AccordionItemProps): import("react").JSX.Element;
|