@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,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as t, jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { u as v } from "./PravaProvider-0znpKV4G.js";
|
|
4
|
+
function h({
|
|
5
|
+
value: a,
|
|
6
|
+
min: r = 0,
|
|
7
|
+
max: e = 100,
|
|
8
|
+
label: n,
|
|
9
|
+
showValue: d = !1,
|
|
10
|
+
className: p,
|
|
11
|
+
style: l,
|
|
12
|
+
...c
|
|
13
|
+
}) {
|
|
14
|
+
if (!Number.isFinite(r) || !Number.isFinite(e) || e <= r)
|
|
15
|
+
throw new RangeError(
|
|
16
|
+
"Progress max must be a finite number greater than min."
|
|
17
|
+
);
|
|
18
|
+
if (a !== void 0 && !Number.isFinite(a))
|
|
19
|
+
throw new RangeError("Progress value must be a finite number.");
|
|
20
|
+
const o = a === void 0 ? void 0 : Math.min(e, Math.max(r, a)), s = o === void 0 ? void 0 : (o - r) / (e - r) * 100, { locale: m } = v();
|
|
21
|
+
return /* @__PURE__ */ t(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
...c,
|
|
25
|
+
className: ["prava-progress", p].filter(Boolean).join(" "),
|
|
26
|
+
role: "progressbar",
|
|
27
|
+
"aria-label": n,
|
|
28
|
+
"aria-valuemin": r,
|
|
29
|
+
"aria-valuemax": e,
|
|
30
|
+
"aria-valuenow": o,
|
|
31
|
+
style: {
|
|
32
|
+
...l,
|
|
33
|
+
...s === void 0 ? {} : { "--prava-progress-value": `${s}%` }
|
|
34
|
+
},
|
|
35
|
+
"data-indeterminate": a === void 0 ? "" : void 0,
|
|
36
|
+
children: [
|
|
37
|
+
d && /* @__PURE__ */ t("span", { className: "prava-progress__header", "aria-hidden": "true", children: [
|
|
38
|
+
/* @__PURE__ */ i("span", { children: n }),
|
|
39
|
+
s !== void 0 && /* @__PURE__ */ i("span", { className: "prava-progress__value", children: new Intl.NumberFormat(m, {
|
|
40
|
+
style: "percent",
|
|
41
|
+
maximumFractionDigits: 0
|
|
42
|
+
}).format(s / 100) })
|
|
43
|
+
] }),
|
|
44
|
+
/* @__PURE__ */ i("span", { className: "prava-progress__track", "aria-hidden": "true", children: /* @__PURE__ */ i("span", { className: "prava-progress__indicator" }) })
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
h as P
|
|
51
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as o, jsx as s } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as V, useId as E, createElement as T } from "react";
|
|
4
|
+
import { u as z } from "./PravaProvider-0znpKV4G.js";
|
|
5
|
+
import { b as A, u as D, C as H } from "./field-U1YinldE.js";
|
|
6
|
+
const P = V(
|
|
7
|
+
function(a, n) {
|
|
8
|
+
const {
|
|
9
|
+
label: c,
|
|
10
|
+
options: u,
|
|
11
|
+
name: t,
|
|
12
|
+
value: r,
|
|
13
|
+
defaultValue: d,
|
|
14
|
+
onChange: v,
|
|
15
|
+
onBlur: f,
|
|
16
|
+
onValueChange: m,
|
|
17
|
+
required: i = !1,
|
|
18
|
+
disabled: p,
|
|
19
|
+
orientation: b = "vertical",
|
|
20
|
+
description: g,
|
|
21
|
+
error: h,
|
|
22
|
+
invalid: C,
|
|
23
|
+
id: N,
|
|
24
|
+
className: _,
|
|
25
|
+
style: y,
|
|
26
|
+
ref: k
|
|
27
|
+
} = A(a, n), q = a.field && "value" in a.field, { messages: R } = z(), j = E(), l = D({
|
|
28
|
+
id: N,
|
|
29
|
+
description: g,
|
|
30
|
+
error: h,
|
|
31
|
+
invalid: C,
|
|
32
|
+
onBlur: f,
|
|
33
|
+
onChange: (e) => {
|
|
34
|
+
v?.(e), m?.(e.currentTarget.value);
|
|
35
|
+
}
|
|
36
|
+
}), {
|
|
37
|
+
id: x,
|
|
38
|
+
"aria-invalid": B,
|
|
39
|
+
"aria-describedby": I,
|
|
40
|
+
...F
|
|
41
|
+
} = l.controlProps;
|
|
42
|
+
return /* @__PURE__ */ o(
|
|
43
|
+
"fieldset",
|
|
44
|
+
{
|
|
45
|
+
id: x,
|
|
46
|
+
role: "radiogroup",
|
|
47
|
+
className: ["prava-field prava-radio-group", _].filter(Boolean).join(" "),
|
|
48
|
+
style: y,
|
|
49
|
+
disabled: p,
|
|
50
|
+
"aria-invalid": B,
|
|
51
|
+
"aria-required": i || void 0,
|
|
52
|
+
"aria-describedby": I,
|
|
53
|
+
"data-choice": "",
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ o("legend", { className: "prava-field__legend", children: [
|
|
56
|
+
c,
|
|
57
|
+
i && /* @__PURE__ */ s("span", { className: "prava-label__required", children: R.required })
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ s(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
className: "prava-radio-group__options",
|
|
63
|
+
"data-orientation": b,
|
|
64
|
+
children: u.map((e, G) => /* @__PURE__ */ T(
|
|
65
|
+
H,
|
|
66
|
+
{
|
|
67
|
+
...F,
|
|
68
|
+
key: e.value,
|
|
69
|
+
ref: q && G > 0 ? void 0 : k,
|
|
70
|
+
kind: "radio",
|
|
71
|
+
name: t ?? j,
|
|
72
|
+
value: e.value,
|
|
73
|
+
label: e.label,
|
|
74
|
+
disabled: e.disabled,
|
|
75
|
+
required: i,
|
|
76
|
+
checked: r === void 0 ? void 0 : r === e.value,
|
|
77
|
+
defaultChecked: d === void 0 ? void 0 : d === e.value
|
|
78
|
+
}
|
|
79
|
+
))
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
l.messages
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
export {
|
|
89
|
+
P as R
|
|
90
|
+
};
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as c, jsx as r, Fragment as ge } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as Ue, useMemo as be, useState as B, useRef as v, useCallback as S, useEffect as D } from "react";
|
|
4
|
+
import { b as We, u as Ge, o as _e, s as Qe, f as ye } from "./field-U1YinldE.js";
|
|
5
|
+
import { p as Je } from "./overlay-9zlvgpUZ.js";
|
|
6
|
+
import { u as Xe } from "./PravaProvider-0znpKV4G.js";
|
|
7
|
+
const Ye = 144, we = (l) => l == null || l === "" ? [] : Array.isArray(l) ? l.map(String) : [String(l)], te = (l) => Array.from(l.options).filter((d) => d.selected && d.value).map((d) => d.value), Ne = (l, d) => l.length === d.length && l.every((w, h) => w === d[h]), K = (l) => !("value" in l), re = (l) => l.searchText ?? (typeof l.label == "string" || typeof l.label == "number" ? String(l.label) : l.value), T = (l, d) => l.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").toLocaleLowerCase(d), Ze = () => /* @__PURE__ */ r("svg", { className: "prava-select__check", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ r("path", { d: "M3.5 8.5l3 3 6-7" }) });
|
|
8
|
+
function ea(l, d) {
|
|
9
|
+
const w = l.field, {
|
|
10
|
+
options: h,
|
|
11
|
+
label: le,
|
|
12
|
+
placeholder: xe,
|
|
13
|
+
size: ke = "md",
|
|
14
|
+
placement: L = "auto",
|
|
15
|
+
multiple: o = !1,
|
|
16
|
+
searchable: N = !1,
|
|
17
|
+
renderOption: ne,
|
|
18
|
+
name: Me,
|
|
19
|
+
form: Ee,
|
|
20
|
+
required: j,
|
|
21
|
+
disabled: C,
|
|
22
|
+
value: se,
|
|
23
|
+
defaultValue: Se,
|
|
24
|
+
onValueChange: ie,
|
|
25
|
+
onChange: Ce,
|
|
26
|
+
onBlur: Ie,
|
|
27
|
+
onInvalid: Re,
|
|
28
|
+
description: Be,
|
|
29
|
+
error: De,
|
|
30
|
+
invalid: Le,
|
|
31
|
+
id: ze,
|
|
32
|
+
className: Ae,
|
|
33
|
+
style: Oe,
|
|
34
|
+
ref: ce,
|
|
35
|
+
...z
|
|
36
|
+
} = We(
|
|
37
|
+
// Controller reads event.target.value, which holds only the first choice of a multiple select.
|
|
38
|
+
l.multiple && w && "value" in w ? {
|
|
39
|
+
...l,
|
|
40
|
+
field: {
|
|
41
|
+
...w,
|
|
42
|
+
onChange: (e) => w.onChange?.(te(e.target))
|
|
43
|
+
}
|
|
44
|
+
} : l,
|
|
45
|
+
d
|
|
46
|
+
), { messages: x, locale: m } = Xe(), oe = Ge({
|
|
47
|
+
id: ze,
|
|
48
|
+
description: Be,
|
|
49
|
+
error: De,
|
|
50
|
+
invalid: Le,
|
|
51
|
+
onBlur: Ie,
|
|
52
|
+
onChange: Ce,
|
|
53
|
+
onInvalid: Re,
|
|
54
|
+
"aria-describedby": z["aria-describedby"],
|
|
55
|
+
"aria-invalid": z["aria-invalid"]
|
|
56
|
+
}), {
|
|
57
|
+
id: I,
|
|
58
|
+
"aria-invalid": de,
|
|
59
|
+
"aria-describedby": Fe,
|
|
60
|
+
...$e
|
|
61
|
+
} = oe.controlProps, A = be(
|
|
62
|
+
() => h.flatMap((e) => K(e) ? [...e.options] : [e]),
|
|
63
|
+
[h]
|
|
64
|
+
), [qe, U] = B(() => we(Se)), s = se !== void 0 ? we(se) : qe, [i, ue] = B(!1), [W, Pe] = B(!1), [O, pe] = B(""), [u, k] = B(), G = v(null), Q = v(null), g = v(null), F = v(null), J = v(null), b = v(null), Ve = v({ text: "", at: 0 }), He = v(s), X = v(!1), $ = S(() => {
|
|
65
|
+
const e = b.current;
|
|
66
|
+
if (!e || X.current) return;
|
|
67
|
+
const a = te(e);
|
|
68
|
+
U((t) => Ne(t, a) ? t : a);
|
|
69
|
+
}, []);
|
|
70
|
+
D(() => {
|
|
71
|
+
const e = b.current;
|
|
72
|
+
if (!e) return;
|
|
73
|
+
const a = te(e);
|
|
74
|
+
if (!Ne(a, s)) {
|
|
75
|
+
if (X.current = !0, o)
|
|
76
|
+
for (const t of Array.from(e.options))
|
|
77
|
+
t.selected = s.includes(t.value);
|
|
78
|
+
else e.value = s[0] ?? "";
|
|
79
|
+
X.current = !1;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const Ke = S(
|
|
83
|
+
(e) => {
|
|
84
|
+
e && (b.current = e, _e(e, "value", $), Object.defineProperty(e, "focus", {
|
|
85
|
+
configurable: !0,
|
|
86
|
+
value: (a) => g.current?.focus(a)
|
|
87
|
+
})), Qe(ce, e);
|
|
88
|
+
},
|
|
89
|
+
[ce, $]
|
|
90
|
+
), fe = S(
|
|
91
|
+
(e) => {
|
|
92
|
+
e && _e(e, "selected", $);
|
|
93
|
+
},
|
|
94
|
+
[$]
|
|
95
|
+
), Y = be(() => {
|
|
96
|
+
if (!N || !O) return h;
|
|
97
|
+
const e = T(O, m), a = (t) => T(re(t), m).includes(e);
|
|
98
|
+
return h.flatMap((t) => {
|
|
99
|
+
if (!K(t)) return a(t) ? [t] : [];
|
|
100
|
+
const n = t.options.filter(a);
|
|
101
|
+
return n.length ? [{ ...t, options: n }] : [];
|
|
102
|
+
});
|
|
103
|
+
}, [h, O, N, m]), p = Y.flatMap((e) => K(e) ? [...e.options] : [e]).filter((e) => !e.disabled), q = (e) => `${I}-option-${A.findIndex((a) => a.value === e)}`, Z = S(() => {
|
|
104
|
+
const e = F.current, a = Q.current;
|
|
105
|
+
!e || !a || (e.style.minInlineSize = `${a.getBoundingClientRect().width}px`, e.style.minInlineSize = getComputedStyle(e).inlineSize);
|
|
106
|
+
}, []), M = S(() => {
|
|
107
|
+
const e = F.current, a = Q.current, t = e?.querySelector(".prava-select__list");
|
|
108
|
+
if (!e || !a || !t) return;
|
|
109
|
+
const n = parseFloat(getComputedStyle(t).maxBlockSize) || 1 / 0;
|
|
110
|
+
Je(
|
|
111
|
+
a,
|
|
112
|
+
e,
|
|
113
|
+
L === "auto" ? "bottom" : L,
|
|
114
|
+
"start",
|
|
115
|
+
{
|
|
116
|
+
gap: 4,
|
|
117
|
+
contentHeight: e.offsetHeight - t.offsetHeight + Math.min(t.scrollHeight, n),
|
|
118
|
+
minBlockRoom: Ye,
|
|
119
|
+
strict: L !== "auto"
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}, [L]), _ = S((e = !1) => {
|
|
123
|
+
ue(!1), pe(""), e && g.current?.focus();
|
|
124
|
+
}, []), ee = () => {
|
|
125
|
+
C || (g.current?.focus(), Pe(!0), ue(!0), k(
|
|
126
|
+
p.find((e) => s.includes(e.value))?.value ?? p[0]?.value
|
|
127
|
+
));
|
|
128
|
+
};
|
|
129
|
+
D(() => {
|
|
130
|
+
const e = F.current;
|
|
131
|
+
if (!e) return;
|
|
132
|
+
if (!i) {
|
|
133
|
+
e.matches?.(":popover-open") && e.hidePopover();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
e.showPopover?.(), Z(), M(), N && J.current?.focus();
|
|
137
|
+
const a = (f) => {
|
|
138
|
+
G.current?.contains(f.target) || _();
|
|
139
|
+
}, t = () => {
|
|
140
|
+
Z(), M();
|
|
141
|
+
}, n = (f) => {
|
|
142
|
+
e.contains(f.target) || M();
|
|
143
|
+
};
|
|
144
|
+
return window.addEventListener("resize", t), window.addEventListener("scroll", n, !0), document.addEventListener("pointerdown", a), () => {
|
|
145
|
+
window.removeEventListener("resize", t), window.removeEventListener("scroll", n, !0), document.removeEventListener("pointerdown", a);
|
|
146
|
+
};
|
|
147
|
+
}, [i, N, Z, M, _]), D(() => {
|
|
148
|
+
i && M();
|
|
149
|
+
}, [i, Y, s.length, M]), D(() => {
|
|
150
|
+
!i || u === void 0 || document.getElementById(q(u))?.scrollIntoView?.({ block: "nearest" });
|
|
151
|
+
}, [i, u]), D(() => {
|
|
152
|
+
const e = b.current?.form;
|
|
153
|
+
if (!e) return;
|
|
154
|
+
const a = () => U(He.current);
|
|
155
|
+
return e.addEventListener("reset", a), () => e.removeEventListener("reset", a);
|
|
156
|
+
}, []);
|
|
157
|
+
const P = (e) => {
|
|
158
|
+
const a = b.current;
|
|
159
|
+
if (!a) return;
|
|
160
|
+
if (o)
|
|
161
|
+
for (const n of Array.from(a.options))
|
|
162
|
+
n.selected = e.includes(n.value);
|
|
163
|
+
else a.value = e[0] ?? "";
|
|
164
|
+
U(e), a.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
165
|
+
const t = e.flatMap((n) => A.filter((f) => f.value === n));
|
|
166
|
+
o ? ie?.(
|
|
167
|
+
e,
|
|
168
|
+
t
|
|
169
|
+
) : t[0] && ie?.(
|
|
170
|
+
e[0],
|
|
171
|
+
t[0]
|
|
172
|
+
);
|
|
173
|
+
}, ae = (e) => {
|
|
174
|
+
if (!e.disabled) {
|
|
175
|
+
if (!o) {
|
|
176
|
+
P([e.value]), _(!0);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
P(
|
|
180
|
+
s.includes(e.value) ? s.filter((a) => a !== e.value) : [...s, e.value]
|
|
181
|
+
), k(e.value);
|
|
182
|
+
}
|
|
183
|
+
}, E = (e) => {
|
|
184
|
+
const a = p[Math.max(0, Math.min(e, p.length - 1))];
|
|
185
|
+
a && k(a.value);
|
|
186
|
+
}, ve = (e) => {
|
|
187
|
+
const a = Date.now(), t = Ve.current;
|
|
188
|
+
t.text = a - t.at > 500 ? e : t.text + e, t.at = a;
|
|
189
|
+
const n = T(t.text, m), f = p.find(
|
|
190
|
+
(H) => T(re(H), m).startsWith(n)
|
|
191
|
+
);
|
|
192
|
+
f && k(f.value);
|
|
193
|
+
}, Te = (e) => {
|
|
194
|
+
const a = e.target === J.current, t = e.key.length === 1 && e.key !== " " && !e.ctrlKey && !e.metaKey && !e.altKey;
|
|
195
|
+
if (!i) {
|
|
196
|
+
["ArrowDown", "ArrowUp", "Enter", " "].includes(e.key) ? (e.preventDefault(), ee()) : t ? (ee(), ve(e.key)) : e.key === "Backspace" && o && s.length && P(s.slice(0, -1));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const n = p.findIndex((y) => y.value === u), H = {
|
|
200
|
+
ArrowDown: () => E(n + 1),
|
|
201
|
+
ArrowUp: () => E(n - 1),
|
|
202
|
+
PageDown: () => E(n + 10),
|
|
203
|
+
PageUp: () => E(n - 10),
|
|
204
|
+
Enter: () => {
|
|
205
|
+
const y = p[n];
|
|
206
|
+
y && ae(y);
|
|
207
|
+
},
|
|
208
|
+
Escape: () => _(!0),
|
|
209
|
+
...!a && {
|
|
210
|
+
Home: () => E(0),
|
|
211
|
+
End: () => E(p.length - 1),
|
|
212
|
+
" ": () => {
|
|
213
|
+
const y = p[n];
|
|
214
|
+
y && ae(y);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}[e.key];
|
|
218
|
+
H ? (e.preventDefault(), e.stopPropagation(), H()) : e.key === "Tab" ? _() : t && !a && ve(e.key);
|
|
219
|
+
}, je = (e) => {
|
|
220
|
+
e.target !== b.current && (G.current?.contains(e.relatedTarget) || (_(), b.current?.dispatchEvent(
|
|
221
|
+
new FocusEvent("focusout", { bubbles: !0 })
|
|
222
|
+
)));
|
|
223
|
+
}, he = s.flatMap(
|
|
224
|
+
(e) => A.filter((a) => a.value === e)
|
|
225
|
+
), V = o ? void 0 : he[0], R = `${I}-list`, me = (e) => {
|
|
226
|
+
const a = s.includes(e.value);
|
|
227
|
+
return /* @__PURE__ */ c(
|
|
228
|
+
"div",
|
|
229
|
+
{
|
|
230
|
+
id: q(e.value),
|
|
231
|
+
role: "option",
|
|
232
|
+
className: "prava-select__option",
|
|
233
|
+
"aria-selected": a,
|
|
234
|
+
"aria-disabled": e.disabled || void 0,
|
|
235
|
+
"data-active": u === e.value || void 0,
|
|
236
|
+
onMouseDown: (t) => t.preventDefault(),
|
|
237
|
+
onMouseMove: () => {
|
|
238
|
+
!e.disabled && u !== e.value && k(e.value);
|
|
239
|
+
},
|
|
240
|
+
onClick: () => ae(e),
|
|
241
|
+
children: [
|
|
242
|
+
e.icon != null && /* @__PURE__ */ r("span", { className: "prava-select__icon", "aria-hidden": "true", children: e.icon }),
|
|
243
|
+
/* @__PURE__ */ r("span", { className: "prava-select__text", children: ne ? ne(e, { selected: a }) : /* @__PURE__ */ c(ge, { children: [
|
|
244
|
+
/* @__PURE__ */ r("span", { children: e.label }),
|
|
245
|
+
e.description != null && /* @__PURE__ */ r("span", { className: "prava-select__description", children: e.description })
|
|
246
|
+
] }) }),
|
|
247
|
+
/* @__PURE__ */ r(Ze, {})
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
e.value
|
|
251
|
+
);
|
|
252
|
+
};
|
|
253
|
+
return /* @__PURE__ */ c("span", { className: "prava-field", children: [
|
|
254
|
+
le != null && /* @__PURE__ */ c("label", { className: "prava-field__legend", htmlFor: I, children: [
|
|
255
|
+
le,
|
|
256
|
+
j && /* @__PURE__ */ r("span", { className: "prava-label__required", children: x.required })
|
|
257
|
+
] }),
|
|
258
|
+
/* @__PURE__ */ c(
|
|
259
|
+
"div",
|
|
260
|
+
{
|
|
261
|
+
ref: G,
|
|
262
|
+
className: "prava-select__root",
|
|
263
|
+
onBlur: je,
|
|
264
|
+
onKeyDown: Te,
|
|
265
|
+
onKeyUp: (e) => {
|
|
266
|
+
e.key === " " && e.target === g.current && e.preventDefault();
|
|
267
|
+
},
|
|
268
|
+
children: [
|
|
269
|
+
/* @__PURE__ */ c(
|
|
270
|
+
"div",
|
|
271
|
+
{
|
|
272
|
+
ref: Q,
|
|
273
|
+
className: ["prava-control prava-select", Ae].filter(Boolean).join(" "),
|
|
274
|
+
style: Oe,
|
|
275
|
+
"data-size": ke,
|
|
276
|
+
"data-open": i || void 0,
|
|
277
|
+
"data-invalid": de,
|
|
278
|
+
"data-disabled": C || void 0,
|
|
279
|
+
onClick: (e) => {
|
|
280
|
+
e.target === e.currentTarget && g.current?.click();
|
|
281
|
+
},
|
|
282
|
+
children: [
|
|
283
|
+
o && he.map((e) => /* @__PURE__ */ c("span", { className: "prava-select__chip", children: [
|
|
284
|
+
e.icon != null && /* @__PURE__ */ r("span", { className: "prava-select__icon", "aria-hidden": "true", children: e.icon }),
|
|
285
|
+
/* @__PURE__ */ r("span", { className: "prava-select__chip-label", children: e.label }),
|
|
286
|
+
/* @__PURE__ */ r(
|
|
287
|
+
"button",
|
|
288
|
+
{
|
|
289
|
+
type: "button",
|
|
290
|
+
tabIndex: -1,
|
|
291
|
+
disabled: C,
|
|
292
|
+
className: "prava-select__chip-remove",
|
|
293
|
+
"aria-label": ye(
|
|
294
|
+
x.removeOption,
|
|
295
|
+
{ label: re(e) },
|
|
296
|
+
m
|
|
297
|
+
),
|
|
298
|
+
onMouseDown: (a) => a.preventDefault(),
|
|
299
|
+
onClick: () => P(s.filter((a) => a !== e.value)),
|
|
300
|
+
children: /* @__PURE__ */ r("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ r("path", { d: "M4.5 4.5l7 7m0-7l-7 7" }) })
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] }, e.value)),
|
|
304
|
+
/* @__PURE__ */ r(
|
|
305
|
+
"button",
|
|
306
|
+
{
|
|
307
|
+
...z,
|
|
308
|
+
ref: g,
|
|
309
|
+
id: I,
|
|
310
|
+
type: "button",
|
|
311
|
+
role: "combobox",
|
|
312
|
+
disabled: C,
|
|
313
|
+
className: "prava-select__trigger",
|
|
314
|
+
"aria-haspopup": "listbox",
|
|
315
|
+
"aria-expanded": i,
|
|
316
|
+
"aria-controls": R,
|
|
317
|
+
"aria-invalid": de,
|
|
318
|
+
"aria-describedby": Fe,
|
|
319
|
+
"aria-required": j || z["aria-required"],
|
|
320
|
+
"aria-activedescendant": i && !N && u !== void 0 ? q(u) : void 0,
|
|
321
|
+
onClick: () => i ? _() : ee(),
|
|
322
|
+
children: V ? /* @__PURE__ */ c(ge, { children: [
|
|
323
|
+
V.icon != null && /* @__PURE__ */ r("span", { className: "prava-select__icon", "aria-hidden": "true", children: V.icon }),
|
|
324
|
+
/* @__PURE__ */ r("span", { className: "prava-select__value", children: V.label })
|
|
325
|
+
] }) : o && s.length ? /* @__PURE__ */ r("span", { className: "prava-select__sr-only", children: ye(
|
|
326
|
+
x.selectedCount,
|
|
327
|
+
{ count: s.length },
|
|
328
|
+
m
|
|
329
|
+
) }) : /* @__PURE__ */ r("span", { className: "prava-select__placeholder", children: xe })
|
|
330
|
+
}
|
|
331
|
+
),
|
|
332
|
+
/* @__PURE__ */ r(
|
|
333
|
+
"svg",
|
|
334
|
+
{
|
|
335
|
+
className: "prava-select__chevron",
|
|
336
|
+
viewBox: "0 0 16 16",
|
|
337
|
+
"aria-hidden": "true",
|
|
338
|
+
onClick: () => g.current?.click(),
|
|
339
|
+
children: /* @__PURE__ */ r("path", { d: "M4.5 6.25 8 9.75l3.5-3.5" })
|
|
340
|
+
}
|
|
341
|
+
)
|
|
342
|
+
]
|
|
343
|
+
}
|
|
344
|
+
),
|
|
345
|
+
/* @__PURE__ */ c(
|
|
346
|
+
"select",
|
|
347
|
+
{
|
|
348
|
+
...$e,
|
|
349
|
+
ref: Ke,
|
|
350
|
+
hidden: !0,
|
|
351
|
+
tabIndex: -1,
|
|
352
|
+
multiple: o,
|
|
353
|
+
name: Me,
|
|
354
|
+
form: Ee,
|
|
355
|
+
required: j,
|
|
356
|
+
disabled: C,
|
|
357
|
+
defaultValue: o ? s : s[0] ?? "",
|
|
358
|
+
children: [
|
|
359
|
+
!o && /* @__PURE__ */ r("option", { value: "", ref: fe }),
|
|
360
|
+
A.map((e) => /* @__PURE__ */ r(
|
|
361
|
+
"option",
|
|
362
|
+
{
|
|
363
|
+
ref: fe,
|
|
364
|
+
value: e.value,
|
|
365
|
+
disabled: e.disabled
|
|
366
|
+
},
|
|
367
|
+
e.value
|
|
368
|
+
))
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
),
|
|
372
|
+
/* @__PURE__ */ c(
|
|
373
|
+
"div",
|
|
374
|
+
{
|
|
375
|
+
ref: F,
|
|
376
|
+
popover: "manual",
|
|
377
|
+
className: "prava-select__popup",
|
|
378
|
+
"data-open": i || void 0,
|
|
379
|
+
children: [
|
|
380
|
+
W && N && /* @__PURE__ */ c("div", { className: "prava-select__search", children: [
|
|
381
|
+
/* @__PURE__ */ c("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: [
|
|
382
|
+
/* @__PURE__ */ r("circle", { cx: "7", cy: "7", r: "4.5" }),
|
|
383
|
+
/* @__PURE__ */ r("path", { d: "M10.5 10.5 13.5 13.5" })
|
|
384
|
+
] }),
|
|
385
|
+
/* @__PURE__ */ r(
|
|
386
|
+
"input",
|
|
387
|
+
{
|
|
388
|
+
ref: J,
|
|
389
|
+
type: "text",
|
|
390
|
+
role: "combobox",
|
|
391
|
+
className: "prava-select__search-input",
|
|
392
|
+
value: O,
|
|
393
|
+
placeholder: x.search,
|
|
394
|
+
"aria-label": x.search,
|
|
395
|
+
"aria-autocomplete": "list",
|
|
396
|
+
"aria-expanded": i,
|
|
397
|
+
"aria-controls": R,
|
|
398
|
+
"aria-activedescendant": i && u !== void 0 ? q(u) : void 0,
|
|
399
|
+
onChange: (e) => {
|
|
400
|
+
pe(e.target.value), k(void 0);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
)
|
|
404
|
+
] }),
|
|
405
|
+
/* @__PURE__ */ c(
|
|
406
|
+
"div",
|
|
407
|
+
{
|
|
408
|
+
id: R,
|
|
409
|
+
role: "listbox",
|
|
410
|
+
className: "prava-select__list",
|
|
411
|
+
"aria-labelledby": I,
|
|
412
|
+
"aria-multiselectable": o || void 0,
|
|
413
|
+
children: [
|
|
414
|
+
W && Y.map(
|
|
415
|
+
(e, a) => K(e) ? /* @__PURE__ */ c(
|
|
416
|
+
"div",
|
|
417
|
+
{
|
|
418
|
+
role: "group",
|
|
419
|
+
"aria-labelledby": `${R}-group-${a}`,
|
|
420
|
+
children: [
|
|
421
|
+
/* @__PURE__ */ r(
|
|
422
|
+
"div",
|
|
423
|
+
{
|
|
424
|
+
id: `${R}-group-${a}`,
|
|
425
|
+
className: "prava-select__group-label",
|
|
426
|
+
children: e.label
|
|
427
|
+
}
|
|
428
|
+
),
|
|
429
|
+
e.options.map(me)
|
|
430
|
+
]
|
|
431
|
+
},
|
|
432
|
+
a
|
|
433
|
+
) : me(e)
|
|
434
|
+
),
|
|
435
|
+
W && p.length === 0 && /* @__PURE__ */ r("div", { className: "prava-select__empty", role: "status", children: x.noResults })
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
)
|
|
439
|
+
]
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
]
|
|
443
|
+
}
|
|
444
|
+
),
|
|
445
|
+
oe.messages
|
|
446
|
+
] });
|
|
447
|
+
}
|
|
448
|
+
const sa = Ue(ea);
|
|
449
|
+
export {
|
|
450
|
+
sa as S
|
|
451
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
function n({
|
|
4
|
+
orientation: r = "horizontal",
|
|
5
|
+
decorative: a = !0,
|
|
6
|
+
className: o,
|
|
7
|
+
...i
|
|
8
|
+
}) {
|
|
9
|
+
return /* @__PURE__ */ t(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
...i,
|
|
13
|
+
className: ["prava-separator", o].filter(Boolean).join(" "),
|
|
14
|
+
"data-orientation": r,
|
|
15
|
+
role: a ? void 0 : "separator",
|
|
16
|
+
"aria-hidden": a ? !0 : void 0,
|
|
17
|
+
"aria-orientation": a ? void 0 : r
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
n as S
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
3
|
+
function i({
|
|
4
|
+
shape: e = "rect",
|
|
5
|
+
className: a,
|
|
6
|
+
style: t,
|
|
7
|
+
...r
|
|
8
|
+
}) {
|
|
9
|
+
return /* @__PURE__ */ o(
|
|
10
|
+
"span",
|
|
11
|
+
{
|
|
12
|
+
...r,
|
|
13
|
+
className: ["prava-skeleton", a].filter(Boolean).join(" "),
|
|
14
|
+
"data-shape": e,
|
|
15
|
+
"aria-hidden": "true",
|
|
16
|
+
style: {
|
|
17
|
+
...t,
|
|
18
|
+
...e === "circle" ? { aspectRatio: "1 / 1" } : {}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
i as S
|
|
25
|
+
};
|