@alea-design/ui 0.5.1 → 0.6.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/dist/components/button/Button.d.ts +3 -1
- package/dist/components/button/Button.js +64 -63
- package/dist/components/card/Card.d.ts +6 -2
- package/dist/components/card/Card.js +20 -20
- package/dist/components/combobox/Autocomplete.d.ts +4 -0
- package/dist/components/combobox/Autocomplete.js +89 -87
- package/dist/components/command/CommandPalette.d.ts +10 -0
- package/dist/components/command/CommandPalette.js +82 -56
- package/dist/components/data/Data.d.ts +11 -7
- package/dist/components/data/Data.js +65 -55
- package/dist/components/date/Date.d.ts +16 -2
- package/dist/components/date/Date.js +80 -69
- package/dist/components/display/Display.d.ts +3 -1
- package/dist/components/display/Display.js +27 -27
- package/dist/components/display/Display2.d.ts +2 -2
- package/dist/components/display/Display2.js +28 -27
- package/dist/components/feedback/Feedback.d.ts +3 -1
- package/dist/components/feedback/Feedback.js +102 -102
- package/dist/components/feedback/PageSkeleton.d.ts +19 -0
- package/dist/components/feedback/PageSkeleton.js +58 -0
- package/dist/components/field/Field.d.ts +3 -1
- package/dist/components/field/Field.js +82 -82
- package/dist/components/filter/FilterBar.d.ts +5 -2
- package/dist/components/filter/FilterBar.js +97 -66
- package/dist/components/form/Form.d.ts +8 -2
- package/dist/components/form/Form.js +53 -40
- package/dist/components/icon/icon-names.d.ts +2 -2
- package/dist/components/icon/icon-names.js +4 -2
- package/dist/components/list/List.d.ts +6 -2
- package/dist/components/list/List.js +65 -62
- package/dist/components/list/Lists2.d.ts +4 -0
- package/dist/components/list/Lists2.js +35 -35
- package/dist/components/media/Media.d.ts +5 -1
- package/dist/components/media/Media.js +115 -113
- package/dist/components/more/More.d.ts +2 -2
- package/dist/components/more/More.js +46 -45
- package/dist/components/navigation/Navigation.d.ts +11 -5
- package/dist/components/navigation/Navigation.js +97 -80
- package/dist/components/navigation/Navigation2.d.ts +9 -3
- package/dist/components/navigation/Navigation2.js +208 -194
- package/dist/components/notification/NotificationCenter.js +70 -70
- package/dist/components/overlay/Drawer.d.ts +6 -1
- package/dist/components/overlay/Drawer.js +27 -25
- package/dist/components/overlay/Modal.d.ts +5 -0
- package/dist/components/overlay/Modal.js +16 -15
- package/dist/components/overlay/Overlay.d.ts +14 -1
- package/dist/components/overlay/Overlay.js +52 -50
- package/dist/components/overlay/Sheet.d.ts +2 -0
- package/dist/components/overlay/Sheet.js +30 -30
- package/dist/components/page/PageParts.d.ts +6 -2
- package/dist/components/page/PageParts.js +92 -84
- package/dist/components/select/Select.js +75 -70
- package/dist/components/settings/Settings.d.ts +29 -0
- package/dist/components/settings/Settings.js +31 -0
- package/dist/components/shell/AccountMenu.d.ts +20 -0
- package/dist/components/shell/AccountMenu.js +32 -0
- package/dist/components/shell/AppShell.d.ts +9 -2
- package/dist/components/shell/AppShell.js +37 -37
- package/dist/components/shell/AppSidebar.d.ts +9 -3
- package/dist/components/shell/AppSidebar.js +45 -39
- package/dist/components/table/Table.d.ts +18 -4
- package/dist/components/table/Table.js +70 -46
- package/dist/components/tabs/Tabs.js +105 -94
- package/dist/components/theme/Theme.d.ts +7 -4
- package/dist/components/theme/Theme.js +127 -130
- package/dist/components/upload/Upload.js +62 -54
- package/dist/css/base.css +1 -1
- package/dist/css/button.css +1 -1
- package/dist/css/card.css +1 -1
- package/dist/css/command.css +1 -1
- package/dist/css/data.css +1 -1
- package/dist/css/date.css +1 -1
- package/dist/css/display.css +1 -1
- package/dist/css/feedback.css +1 -1
- package/dist/css/field.css +1 -1
- package/dist/css/form.css +1 -1
- package/dist/css/groups.json +37 -21
- package/dist/css/list.css +1 -1
- package/dist/css/menu.css +1 -1
- package/dist/css/navigation.css +1 -1
- package/dist/css/notification.css +1 -1
- package/dist/css/overlay.css +1 -1
- package/dist/css/page.css +1 -1
- package/dist/css/select.css +1 -1
- package/dist/css/settings.css +1 -0
- package/dist/css/shell.css +1 -1
- package/dist/css/table.css +1 -1
- package/dist/css/tabs.css +1 -1
- package/dist/css/upload.css +1 -1
- package/dist/i18n/strings.d.ts +9 -0
- package/dist/i18n/strings.js +18 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +318 -306
- package/dist/styles.css +1 -1
- package/dist/utils/animateRows.d.ts +11 -0
- package/dist/utils/animateRows.js +23 -0
- package/dist/utils/decimal.d.ts +12 -0
- package/dist/utils/decimal.js +48 -0
- package/dist/utils/initialFocus.d.ts +6 -0
- package/dist/utils/initialFocus.js +24 -0
- package/dist/utils/refs.d.ts +2 -0
- package/dist/utils/refs.js +14 -6
- package/package.json +3 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
3
|
+
import { cx as m } from "../../utils/cx.js";
|
|
4
|
+
import { useStrings as w } from "../../i18n/strings.js";
|
|
5
|
+
import { Skeleton as i } from "./Feedback.js";
|
|
6
|
+
function S({ variant: s = "cards", header: o = !0, count: c, animation: p, "aria-label": g, isLoaded: k, children: x, className: d, ...h }) {
|
|
7
|
+
const u = w();
|
|
8
|
+
if (k) return /* @__PURE__ */ e("div", { ...h, className: m("alea-page-skeleton-loaded", d), children: /* @__PURE__ */ e("div", { className: "alea-skeleton-reveal", children: x }) });
|
|
9
|
+
const r = c ?? (s === "cards" ? 6 : 5), a = p, l = Array.from({ length: r }, (n, N) => N);
|
|
10
|
+
return /* @__PURE__ */ t("div", { ...h, className: m("alea-page-skeleton", d), "data-variant": s, "aria-busy": "true", children: [
|
|
11
|
+
/* @__PURE__ */ e("span", { role: "status", className: "alea-visually-hidden", children: g ?? u.loading }),
|
|
12
|
+
o && /* @__PURE__ */ t("div", { className: "alea-page-skeleton-head", "aria-hidden": "true", children: [
|
|
13
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "40%", height: "1.75rem", animation: a }),
|
|
14
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "60%", animation: a })
|
|
15
|
+
] }),
|
|
16
|
+
s === "cards" && /* @__PURE__ */ e("div", { className: "alea-page-skeleton-cards", "aria-hidden": "true", children: l.map((n) => /* @__PURE__ */ t("div", { className: "alea-page-skeleton-card", children: [
|
|
17
|
+
/* @__PURE__ */ e(i, { shape: "rect", height: "6rem", animation: a }),
|
|
18
|
+
/* @__PURE__ */ e(i, { shape: "text", lines: 2, animation: a })
|
|
19
|
+
] }, n)) }),
|
|
20
|
+
s === "table" && /* @__PURE__ */ t("div", { className: "alea-page-skeleton-table", "aria-hidden": "true", children: [
|
|
21
|
+
/* @__PURE__ */ t("div", { className: "alea-page-skeleton-row", "data-head": !0, children: [
|
|
22
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "20%", animation: a }),
|
|
23
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "30%", animation: a }),
|
|
24
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "15%", animation: a })
|
|
25
|
+
] }),
|
|
26
|
+
l.map((n) => /* @__PURE__ */ t("div", { className: "alea-page-skeleton-row", children: [
|
|
27
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "24%", animation: a }),
|
|
28
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "36%", animation: a }),
|
|
29
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "12%", animation: a })
|
|
30
|
+
] }, n))
|
|
31
|
+
] }),
|
|
32
|
+
s === "list" && /* @__PURE__ */ e("div", { className: "alea-page-skeleton-list", "aria-hidden": "true", children: l.map((n) => /* @__PURE__ */ t("div", { className: "alea-page-skeleton-item", children: [
|
|
33
|
+
/* @__PURE__ */ e(i, { shape: "circle", width: "2.5rem", animation: a }),
|
|
34
|
+
/* @__PURE__ */ t("div", { className: "alea-page-skeleton-lines", children: [
|
|
35
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "45%", animation: a }),
|
|
36
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "70%", animation: a })
|
|
37
|
+
] })
|
|
38
|
+
] }, n)) }),
|
|
39
|
+
s === "detail" && /* @__PURE__ */ t("div", { className: "alea-page-skeleton-detail", "aria-hidden": "true", children: [
|
|
40
|
+
/* @__PURE__ */ e(i, { shape: "rect", height: "12rem", animation: a }),
|
|
41
|
+
/* @__PURE__ */ e(i, { shape: "text", lines: Math.max(2, r - 2), animation: a }),
|
|
42
|
+
/* @__PURE__ */ t("div", { className: "alea-page-skeleton-split", children: [
|
|
43
|
+
/* @__PURE__ */ e(i, { shape: "rect", height: "5rem", animation: a }),
|
|
44
|
+
/* @__PURE__ */ e(i, { shape: "rect", height: "5rem", animation: a })
|
|
45
|
+
] })
|
|
46
|
+
] }),
|
|
47
|
+
s === "form" && /* @__PURE__ */ t("div", { className: "alea-page-skeleton-form", "aria-hidden": "true", children: [
|
|
48
|
+
l.map((n) => /* @__PURE__ */ t("div", { className: "alea-page-skeleton-field", children: [
|
|
49
|
+
/* @__PURE__ */ e(i, { shape: "text", width: "25%", animation: a }),
|
|
50
|
+
/* @__PURE__ */ e(i, { shape: "rect", height: "2.75rem", animation: a })
|
|
51
|
+
] }, n)),
|
|
52
|
+
/* @__PURE__ */ e(i, { shape: "rect", width: "8rem", height: "2.5rem", animation: a })
|
|
53
|
+
] })
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
S as PageSkeleton
|
|
58
|
+
};
|
|
@@ -116,11 +116,13 @@ export interface NumberFieldProps extends Omit<RACNumberFieldProps, 'children'>,
|
|
|
116
116
|
prefix?: ReactNode;
|
|
117
117
|
/** Icon or text after the value (a unit). */
|
|
118
118
|
suffix?: ReactNode;
|
|
119
|
+
/** Where the number sits in the field: center (default with the stepper on the sides), start (default otherwise) or end (amounts and currency, so the digits line up on the right in a column of fields). */
|
|
120
|
+
align?: 'start' | 'center' | 'end';
|
|
119
121
|
/** Shows a spinner at the end of the number while it is saved or checked. It takes no room, the field stays editable, and screen readers hear it as busy. */
|
|
120
122
|
isLoading?: boolean;
|
|
121
123
|
}
|
|
122
124
|
/** A number input with steppers, min, max, step and locale formatting (currency, percent, units). */
|
|
123
|
-
export declare function NumberField({ label, description, errorMessage, warningMessage, showOptional, size, variant, labelPosition, placeholder, showStepper, stepperPosition, prefix, suffix, isLoading, className, ...props }: NumberFieldProps): import("react").JSX.Element;
|
|
125
|
+
export declare function NumberField({ label, description, errorMessage, warningMessage, showOptional, size, variant, labelPosition, placeholder, showStepper, stepperPosition, prefix, suffix, align, isLoading, className, ...props }: NumberFieldProps): import("react").JSX.Element;
|
|
124
126
|
export interface InputGroupProps {
|
|
125
127
|
/** Fields, selects and buttons to join into one control, like an amount and its currency, or a search and its button. */
|
|
126
128
|
children: ReactNode;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e, jsxs as r, Fragment as j } from "react/jsx-runtime";
|
|
3
3
|
import { useState as O, useRef as Z } from "react";
|
|
4
|
-
import { Text as J, FieldError as K, Group as G, Label as Q, NumberField as W, Button as
|
|
4
|
+
import { Text as J, FieldError as K, Group as G, Label as Q, NumberField as W, Button as g, Input as k, SearchField as Y, TextField as L, TextArea as _ } from "react-aria-components";
|
|
5
5
|
import { Minus as M, Plus as ee, ChevronUp as ae, ChevronDown as le, EyeOff as ie, Eye as se, Search as te, X as U } from "lucide-react";
|
|
6
6
|
import { cx as $, withBase as A } from "../../utils/cx.js";
|
|
7
|
-
import { useStrings as
|
|
7
|
+
import { useStrings as w } from "../../i18n/strings.js";
|
|
8
8
|
import { useControlled as B } from "../../utils/controlled.js";
|
|
9
9
|
import { responsiveAttrs as re } from "../../utils/responsive.js";
|
|
10
10
|
import { Spinner as ne } from "../feedback/Spinner.js";
|
|
@@ -12,21 +12,21 @@ import { FieldSpinner as D, loadingAttrs as ce } from "./FieldLoading.js";
|
|
|
12
12
|
function de({ className: a, ...l }) {
|
|
13
13
|
return /* @__PURE__ */ e(Q, { ...l, className: $("alea-label", a) });
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function oe({ className: a, ...l }) {
|
|
16
16
|
return /* @__PURE__ */ e(J, { ...l, slot: "description", className: $("alea-description", a) });
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function ue({ className: a, ...l }) {
|
|
19
19
|
return /* @__PURE__ */ e(K, { ...l, className: $("alea-field-error", a) });
|
|
20
20
|
}
|
|
21
|
-
const R = (a, l, s, i,
|
|
21
|
+
const R = (a, l, s, i, u) => ({
|
|
22
22
|
...re("size", a, "md"),
|
|
23
23
|
"data-variant": l !== "outline" ? l : void 0,
|
|
24
24
|
"data-label-position": s !== "top" ? s : void 0,
|
|
25
25
|
"data-warning": i ? !0 : void 0,
|
|
26
|
-
...ce(
|
|
26
|
+
...ce(u)
|
|
27
27
|
});
|
|
28
28
|
function q({ label: a, showOptional: l, isRequired: s }) {
|
|
29
|
-
const i =
|
|
29
|
+
const i = w();
|
|
30
30
|
return a ? /* @__PURE__ */ r(de, { children: [
|
|
31
31
|
a,
|
|
32
32
|
s && /* @__PURE__ */ e("span", { className: "alea-label-required", "aria-hidden": "true", children: " *" }),
|
|
@@ -38,78 +38,78 @@ function q({ label: a, showOptional: l, isRequired: s }) {
|
|
|
38
38
|
] }) : null;
|
|
39
39
|
}
|
|
40
40
|
function E({ description: a, errorMessage: l, warningMessage: s, count: i }) {
|
|
41
|
-
const
|
|
41
|
+
const u = w(), n = (i == null ? void 0 : i.max) != null ? i.max - i.n : void 0;
|
|
42
42
|
return /* @__PURE__ */ r(j, { children: [
|
|
43
|
-
(a || s) && /* @__PURE__ */ r(
|
|
43
|
+
(a || s) && /* @__PURE__ */ r(oe, { children: [
|
|
44
44
|
a,
|
|
45
45
|
s && /* @__PURE__ */ e("span", { className: "alea-field-warning", children: s })
|
|
46
46
|
] }),
|
|
47
|
-
/* @__PURE__ */ e(
|
|
47
|
+
/* @__PURE__ */ e(ue, { children: l }),
|
|
48
48
|
i && /* @__PURE__ */ r("span", { className: "alea-field-count", "data-over": n != null && n < 0 ? !0 : void 0, children: [
|
|
49
49
|
/* @__PURE__ */ e("span", { "aria-hidden": "true", children: i.max != null ? `${i.n} / ${i.max}` : i.n }),
|
|
50
|
-
/* @__PURE__ */ e("span", { className: "alea-visually-hidden", "aria-live": "polite", children: n != null && n <= 10 ? n < 0 ?
|
|
50
|
+
/* @__PURE__ */ e("span", { className: "alea-visually-hidden", "aria-live": "polite", children: n != null && n <= 10 ? n < 0 ? u.overLimit(-n) : u.charactersLeft(n) : "" })
|
|
51
51
|
] })
|
|
52
52
|
] });
|
|
53
53
|
}
|
|
54
|
-
function me({ label: a, description: l, errorMessage: s, warningMessage: i, showOptional:
|
|
55
|
-
const H =
|
|
56
|
-
return /* @__PURE__ */ r(L, { ...
|
|
57
|
-
/* @__PURE__ */ e(q, { label: a, showOptional:
|
|
54
|
+
function me({ label: a, description: l, errorMessage: s, warningMessage: i, showOptional: u, size: n, variant: N = "outline", labelPosition: v = "top", placeholder: m, prefix: d, suffix: t, addonStart: h, addonEnd: o, isClearable: x, showCount: c, isLoading: p, min: b, max: F, step: z, className: f, value: S, defaultValue: T, onChange: X, ...y }) {
|
|
55
|
+
const H = w(), [C, V] = B(S, T ?? "", X), I = Z(null);
|
|
56
|
+
return /* @__PURE__ */ r(L, { ...y, value: C, onChange: V, className: A("alea-field", f), ...R(n, N, v, i, p), children: [
|
|
57
|
+
/* @__PURE__ */ e(q, { label: a, showOptional: u, isRequired: y.isRequired }),
|
|
58
58
|
/* @__PURE__ */ r("div", { className: "alea-input-wrap", children: [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/* @__PURE__ */ e(k, { ref: I, className: "alea-input", placeholder:
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
h && /* @__PURE__ */ e("span", { className: "alea-input-addon", "data-side": "start", children: h }),
|
|
60
|
+
d && /* @__PURE__ */ e("span", { className: "alea-input-affix", "data-side": "start", children: d }),
|
|
61
|
+
/* @__PURE__ */ e(k, { ref: I, className: "alea-input", placeholder: m, min: b, max: F, step: z, "aria-busy": p || void 0 }),
|
|
62
|
+
p && /* @__PURE__ */ e(D, {}),
|
|
63
|
+
x && C && !y.isDisabled && !y.isReadOnly && /* @__PURE__ */ e(g, { className: "alea-input-clear alea-focus-ring", "aria-label": H.clear, onPress: () => {
|
|
64
64
|
var P;
|
|
65
65
|
V(""), (P = I.current) == null || P.focus();
|
|
66
66
|
}, children: /* @__PURE__ */ e(U, { size: 14 }) }),
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
t && /* @__PURE__ */ e("span", { className: "alea-input-affix", "data-side": "end", children: t }),
|
|
68
|
+
o && /* @__PURE__ */ e("span", { className: "alea-input-addon", "data-side": "end", children: o })
|
|
69
69
|
] }),
|
|
70
|
-
/* @__PURE__ */ e(E, { description: l, errorMessage: s, warningMessage: i, count:
|
|
70
|
+
/* @__PURE__ */ e(E, { description: l, errorMessage: s, warningMessage: i, count: c ? { n: C.length, max: y.maxLength } : void 0 })
|
|
71
71
|
] });
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const [S, T] = B(b,
|
|
75
|
-
return /* @__PURE__ */ r(L, { ...
|
|
76
|
-
/* @__PURE__ */ e(q, { label: a, showOptional:
|
|
73
|
+
function we({ label: a, description: l, errorMessage: s, warningMessage: i, showOptional: u, size: n, variant: N = "outline", labelPosition: v = "top", placeholder: m, rows: d = 4, autoGrow: t, maxRows: h = 12, resize: o = "vertical", showCount: x, isLoading: c, className: p, value: b, defaultValue: F, onChange: z, ...f }) {
|
|
74
|
+
const [S, T] = B(b, F ?? "", z);
|
|
75
|
+
return /* @__PURE__ */ r(L, { ...f, value: S, onChange: T, className: A("alea-field", p), ...R(n, N, v, i, c), children: [
|
|
76
|
+
/* @__PURE__ */ e(q, { label: a, showOptional: u, isRequired: f.isRequired }),
|
|
77
77
|
/* @__PURE__ */ r("div", { className: "alea-input-wrap alea-textarea-wrap", children: [
|
|
78
78
|
/* @__PURE__ */ e(
|
|
79
79
|
_,
|
|
80
80
|
{
|
|
81
81
|
className: "alea-input alea-textarea",
|
|
82
|
-
placeholder:
|
|
83
|
-
rows:
|
|
84
|
-
"aria-busy":
|
|
85
|
-
"data-autogrow":
|
|
86
|
-
style: { resize:
|
|
82
|
+
placeholder: m,
|
|
83
|
+
rows: d,
|
|
84
|
+
"aria-busy": c || void 0,
|
|
85
|
+
"data-autogrow": t || void 0,
|
|
86
|
+
style: { resize: t ? "none" : o, ...t ? { fieldSizing: "content", minBlockSize: `calc(${d} * 1.5em + var(--alea-space-6))`, maxBlockSize: `calc(${h} * 1.5em + var(--alea-space-6))` } : {} }
|
|
87
87
|
}
|
|
88
88
|
),
|
|
89
|
-
|
|
89
|
+
c && /* @__PURE__ */ e(D, {})
|
|
90
90
|
] }),
|
|
91
|
-
/* @__PURE__ */ e(E, { description: l, errorMessage: s, warningMessage: i, count:
|
|
91
|
+
/* @__PURE__ */ e(E, { description: l, errorMessage: s, warningMessage: i, count: x ? { n: S.length, max: f.maxLength } : void 0 })
|
|
92
92
|
] });
|
|
93
93
|
}
|
|
94
|
-
function Se({ label: a, description: l, errorMessage: s, warningMessage: i, showOptional:
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
return /* @__PURE__ */ r(Y, { ...
|
|
99
|
-
|
|
100
|
-
}, className: A("alea-field alea-search-field",
|
|
101
|
-
/* @__PURE__ */ e(q, { label: a, showOptional:
|
|
94
|
+
function Se({ label: a, description: l, errorMessage: s, warningMessage: i, showOptional: u, size: n, variant: N = "outline", labelPosition: v = "top", placeholder: m, isLoading: d, shortcut: t, className: h, onClear: o, ...x }) {
|
|
95
|
+
const c = w();
|
|
96
|
+
m ?? (m = c.search);
|
|
97
|
+
const p = Z(""), [b, F] = O(null);
|
|
98
|
+
return /* @__PURE__ */ r(Y, { ...x, onClear: () => {
|
|
99
|
+
p.current.trim() && F({ id: Date.now(), words: p.current.split(/(\s+)/) }), p.current = "", o == null || o();
|
|
100
|
+
}, className: A("alea-field alea-search-field", h), ...R(n, N, v, i, d), children: [
|
|
101
|
+
/* @__PURE__ */ e(q, { label: a, showOptional: u, isRequired: x.isRequired }),
|
|
102
102
|
/* @__PURE__ */ r("div", { className: "alea-input-wrap", children: [
|
|
103
|
-
/* @__PURE__ */ e("span", { className: "alea-input-affix", "data-side": "start", "aria-hidden":
|
|
104
|
-
/* @__PURE__ */ e(k, { className: "alea-input", placeholder:
|
|
105
|
-
|
|
103
|
+
/* @__PURE__ */ e("span", { className: "alea-input-affix", "data-side": "start", "aria-hidden": d ? void 0 : !0, children: d ? /* @__PURE__ */ e(ne, { size: "sm", "aria-label": c.searching }) : /* @__PURE__ */ e(te, { size: 16 }) }),
|
|
104
|
+
/* @__PURE__ */ e(k, { className: "alea-input", placeholder: m, "aria-busy": d || void 0, onInput: (z) => {
|
|
105
|
+
p.current = z.target.value;
|
|
106
106
|
} }),
|
|
107
107
|
b && /* @__PURE__ */ e("span", { className: "alea-input-ghost", "aria-hidden": "true", onAnimationEnd: (z) => {
|
|
108
|
-
var
|
|
109
|
-
((
|
|
110
|
-
}, children: b.words.map((z,
|
|
111
|
-
|
|
112
|
-
/* @__PURE__ */ e(
|
|
108
|
+
var f;
|
|
109
|
+
((f = z.target.parentElement) == null ? void 0 : f.lastElementChild) === z.target && F(null);
|
|
110
|
+
}, children: b.words.map((z, f) => /* @__PURE__ */ e("span", { style: { "--alea-i": f }, children: z }, f)) }, b.id),
|
|
111
|
+
t && /* @__PURE__ */ e("kbd", { className: "alea-input-kbd", "aria-hidden": "true", children: t }),
|
|
112
|
+
/* @__PURE__ */ e(g, { className: "alea-input-clear alea-focus-ring", "aria-label": c.clearSearch, children: /* @__PURE__ */ e(U, { size: 14 }) })
|
|
113
113
|
] }),
|
|
114
114
|
/* @__PURE__ */ e(E, { description: l, errorMessage: s, warningMessage: i })
|
|
115
115
|
] });
|
|
@@ -118,22 +118,22 @@ function pe(a) {
|
|
|
118
118
|
let l = 0;
|
|
119
119
|
return a.length >= 8 && l++, a.length >= 12 && l++, /[a-z]/.test(a) && /[A-Z]/.test(a) && l++, /\d/.test(a) && l++, /[^A-Za-z0-9]/.test(a) && l++, l <= 1 ? 0 : l === 2 ? 1 : l === 3 ? 2 : 3;
|
|
120
120
|
}
|
|
121
|
-
function $e({ label: a, showStrength: l, strength: s = pe, value: i, defaultValue:
|
|
122
|
-
const
|
|
123
|
-
a ?? (a =
|
|
124
|
-
const [t,
|
|
121
|
+
function $e({ label: a, showStrength: l, strength: s = pe, value: i, defaultValue: u, onChange: n, description: N, ...v }) {
|
|
122
|
+
const m = w(), d = a !== void 0;
|
|
123
|
+
a ?? (a = m.password);
|
|
124
|
+
const [t, h] = O(!1), [o, x] = B(i, u ?? "", n), c = o ? s(o) : -1;
|
|
125
125
|
return /* @__PURE__ */ e(
|
|
126
126
|
me,
|
|
127
127
|
{
|
|
128
|
-
...
|
|
128
|
+
...v,
|
|
129
129
|
label: a,
|
|
130
|
-
value:
|
|
131
|
-
onChange:
|
|
130
|
+
value: o,
|
|
131
|
+
onChange: x,
|
|
132
132
|
type: t ? "text" : "password",
|
|
133
|
-
autoComplete:
|
|
134
|
-
description: l &&
|
|
135
|
-
|
|
136
|
-
/* @__PURE__ */ r("span", { className: "alea-strength", "data-score":
|
|
133
|
+
autoComplete: v.autoComplete || "current-password",
|
|
134
|
+
description: l && c >= 0 ? /* @__PURE__ */ r(j, { children: [
|
|
135
|
+
N,
|
|
136
|
+
/* @__PURE__ */ r("span", { className: "alea-strength", "data-score": c, children: [
|
|
137
137
|
/* @__PURE__ */ r("span", { className: "alea-strength-bars", "aria-hidden": "true", children: [
|
|
138
138
|
/* @__PURE__ */ e("i", {}),
|
|
139
139
|
/* @__PURE__ */ e("i", {}),
|
|
@@ -141,30 +141,30 @@ function $e({ label: a, showStrength: l, strength: s = pe, value: i, defaultValu
|
|
|
141
141
|
/* @__PURE__ */ e("i", {})
|
|
142
142
|
] }),
|
|
143
143
|
/* @__PURE__ */ r("span", { "aria-live": "polite", children: [
|
|
144
|
-
|
|
144
|
+
m.passwordStrength,
|
|
145
145
|
": ",
|
|
146
|
-
|
|
146
|
+
m.strengthLevels[c]
|
|
147
147
|
] })
|
|
148
148
|
] })
|
|
149
|
-
] }) :
|
|
150
|
-
suffix: /* @__PURE__ */ e(
|
|
149
|
+
] }) : N,
|
|
150
|
+
suffix: /* @__PURE__ */ e(g, { className: "alea-input-clear alea-focus-ring", "aria-label": (t ? m.hidePassword : m.showPassword) + (d && typeof a == "string" ? ` (${a})` : ""), "aria-pressed": t, onPress: () => h((p) => !p), children: t ? /* @__PURE__ */ e(ie, { size: 16 }) : /* @__PURE__ */ e(se, { size: 16 }) })
|
|
151
151
|
}
|
|
152
152
|
);
|
|
153
153
|
}
|
|
154
|
-
function Ae({ label: a, description: l, errorMessage: s, warningMessage: i, showOptional:
|
|
155
|
-
const
|
|
156
|
-
return /* @__PURE__ */ r(W, { ...
|
|
157
|
-
/* @__PURE__ */ e(q, { label: a, showOptional:
|
|
158
|
-
/* @__PURE__ */ r(G, { className: "alea-input-wrap alea-number", "data-stepper":
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
/* @__PURE__ */ e(k, { className: "alea-input", placeholder:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
/* @__PURE__ */ e(
|
|
167
|
-
/* @__PURE__ */ e(
|
|
154
|
+
function Ae({ label: a, description: l, errorMessage: s, warningMessage: i, showOptional: u, size: n, variant: N = "outline", labelPosition: v = "top", placeholder: m, showStepper: d = !0, stepperPosition: t = "sides", prefix: h, suffix: o, align: x, isLoading: c, className: p, ...b }) {
|
|
155
|
+
const F = d && t === "sides";
|
|
156
|
+
return /* @__PURE__ */ r(W, { ...b, className: A("alea-field", p), ...R(n, N, v, i, c), children: [
|
|
157
|
+
/* @__PURE__ */ e(q, { label: a, showOptional: u, isRequired: b.isRequired }),
|
|
158
|
+
/* @__PURE__ */ r(G, { className: "alea-input-wrap alea-number", "data-stepper": d ? t : void 0, "data-align": x, children: [
|
|
159
|
+
F && /* @__PURE__ */ e(g, { slot: "decrement", className: "alea-stepper alea-focus-ring", children: /* @__PURE__ */ e(M, { size: 14 }) }),
|
|
160
|
+
h && /* @__PURE__ */ e("span", { className: "alea-input-affix", "data-side": "start", children: h }),
|
|
161
|
+
/* @__PURE__ */ e(k, { className: "alea-input", placeholder: m, "aria-busy": c || void 0 }),
|
|
162
|
+
c && /* @__PURE__ */ e(D, {}),
|
|
163
|
+
o && /* @__PURE__ */ e("span", { className: "alea-input-affix", "data-side": "end", children: o }),
|
|
164
|
+
F && /* @__PURE__ */ e(g, { slot: "increment", className: "alea-stepper alea-focus-ring", children: /* @__PURE__ */ e(ee, { size: 14 }) }),
|
|
165
|
+
d && t === "end" && /* @__PURE__ */ r("span", { className: "alea-stepper-col", children: [
|
|
166
|
+
/* @__PURE__ */ e(g, { slot: "increment", className: "alea-stepper-mini alea-focus-ring", children: /* @__PURE__ */ e(ae, { size: 14 }) }),
|
|
167
|
+
/* @__PURE__ */ e(g, { slot: "decrement", className: "alea-stepper-mini alea-focus-ring", children: /* @__PURE__ */ e(le, { size: 14 }) })
|
|
168
168
|
] })
|
|
169
169
|
] }),
|
|
170
170
|
/* @__PURE__ */ e(E, { description: l, errorMessage: s, warningMessage: i })
|
|
@@ -174,14 +174,14 @@ function Re({ children: a, className: l, ...s }) {
|
|
|
174
174
|
return /* @__PURE__ */ e(G, { ...s, className: $("alea-input-group", l), children: a });
|
|
175
175
|
}
|
|
176
176
|
export {
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
oe as Description,
|
|
178
|
+
ue as FieldError,
|
|
179
179
|
Re as InputGroup,
|
|
180
180
|
de as Label,
|
|
181
181
|
Ae as NumberField,
|
|
182
182
|
$e as PasswordField,
|
|
183
183
|
Se as SearchField,
|
|
184
|
-
|
|
184
|
+
we as TextArea,
|
|
185
185
|
me as TextField,
|
|
186
186
|
pe as passwordScore
|
|
187
187
|
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type DateRangePreset } from '../date/Date.js';
|
|
2
3
|
/** A filter people can add: what it filters, and how they pick its value. */
|
|
3
4
|
export interface FilterDef {
|
|
4
5
|
id: string;
|
|
5
6
|
label: string;
|
|
6
|
-
/** select: one option; multi: several; text: contains; boolean: on or off. */
|
|
7
|
-
type: 'select' | 'multi' | 'text' | 'boolean';
|
|
7
|
+
/** select: one option; multi: several; text: contains; boolean: on or off; date-range: a start and end date, kept as ['2026-01-01', '2026-03-31'] (ISO, start then end). */
|
|
8
|
+
type: 'select' | 'multi' | 'text' | 'boolean' | 'date-range';
|
|
8
9
|
options?: Array<{
|
|
9
10
|
id: string;
|
|
10
11
|
label: string;
|
|
11
12
|
}>;
|
|
13
|
+
/** With type "date-range": shortcut buttons above the calendar (This month, Last quarter, your fiscal periods). You make them: the bar knows no calendar rules. */
|
|
14
|
+
presets?: DateRangePreset[];
|
|
12
15
|
icon?: ReactNode;
|
|
13
16
|
}
|
|
14
17
|
export type FilterValue = Record<string, string | string[] | boolean | undefined>;
|
|
@@ -1,96 +1,127 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { DialogTrigger as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
import { jsxs as m, jsx as a, Fragment as R } from "react/jsx-runtime";
|
|
3
|
+
import { useState as U } from "react";
|
|
4
|
+
import { useLocale as k, DialogTrigger as E, Button as j } from "react-aria-components";
|
|
5
|
+
import { DateFormatter as H, parseDate as N } from "@internationalized/date";
|
|
6
|
+
import { ChevronDown as X, X as q, Plus as w } from "lucide-react";
|
|
7
|
+
import { cx as G } from "../../utils/cx.js";
|
|
8
|
+
import { useControlled as J } from "../../utils/controlled.js";
|
|
9
|
+
import { Button as z } from "../button/Button.js";
|
|
10
|
+
import { SearchField as Q, TextField as W } from "../field/Field.js";
|
|
11
|
+
import { Switch as Y } from "../choice/Choice.js";
|
|
12
|
+
import { DropdownMenu as Z, MenuItem as _ } from "../menu/Menu.js";
|
|
13
|
+
import { Popover as V, PopoverDialog as ee } from "../overlay/Overlay.js";
|
|
14
|
+
import { ListBox as ae, SelectItem as le } from "../select/Select.js";
|
|
15
|
+
import { Tabs as ie, TabList as re, Tab as te } from "../tabs/Tabs.js";
|
|
16
|
+
import { RangeCalendar as ne } from "../date/Date.js";
|
|
17
|
+
import { useStrings as se } from "../../i18n/strings.js";
|
|
18
|
+
const v = (t) => Array.isArray(t) ? t.length > 0 : t !== void 0 && t !== "";
|
|
19
|
+
function I(t, n, S) {
|
|
20
|
+
if (t.type === "boolean") return n ? "✓" : "✕";
|
|
21
|
+
if (t.type === "text") return `“${n}”`;
|
|
22
|
+
if (t.type === "date-range") {
|
|
23
|
+
const [s, o] = Array.isArray(n) ? n : [];
|
|
24
|
+
if (!s || !o) return "";
|
|
25
|
+
try {
|
|
26
|
+
const d = new H(S, { dateStyle: "medium" });
|
|
27
|
+
return `${d.format(N(s).toDate("UTC"))} - ${d.format(N(o).toDate("UTC"))}`;
|
|
28
|
+
} catch {
|
|
29
|
+
return `${s} - ${o}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const h = (Array.isArray(n) ? n : [n]).map((s) => {
|
|
33
|
+
var o, d;
|
|
34
|
+
return ((d = (o = t.options) == null ? void 0 : o.find((A) => A.id === s)) == null ? void 0 : d.label) ?? s;
|
|
23
35
|
});
|
|
24
|
-
return
|
|
36
|
+
return h.length > 2 ? `${h.slice(0, 2).join(", ")} +${h.length - 2}` : h.join(", ");
|
|
25
37
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
const l = { ...
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
function Fe({ filters: t, value: n, defaultValue: S = {}, onChange: C, search: h, onSearchChange: s, searchPlaceholder: o, views: d, view: A, onViewChange: x, end: D, className: L, "aria-label": M }) {
|
|
39
|
+
const i = se(), { locale: $ } = k(), [c, P] = J(n, S, C), [f, u] = U(null), F = t.filter((e) => v(c[e.id]) || f === e.id), T = t.filter((e) => !F.includes(e)), b = (e, r) => {
|
|
40
|
+
const l = { ...c, [e]: r };
|
|
41
|
+
v(r) || delete l[e], P(l);
|
|
42
|
+
}, K = (e) => {
|
|
43
|
+
const r = c[e.id];
|
|
44
|
+
if (e.type === "boolean") return /* @__PURE__ */ a(Y, { isSelected: !!r, onChange: (l) => b(e.id, l), children: e.label });
|
|
45
|
+
if (e.type === "date-range") {
|
|
46
|
+
const [l, g] = Array.isArray(r) ? r : [];
|
|
47
|
+
let y = null;
|
|
48
|
+
try {
|
|
49
|
+
l && g && (y = { start: N(l), end: N(g) });
|
|
50
|
+
} catch {
|
|
51
|
+
y = null;
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ m("div", { className: "alea-filter-range", children: [
|
|
54
|
+
e.presets && e.presets.length > 0 && /* @__PURE__ */ a("div", { className: "alea-cal-presets", role: "group", "aria-label": i.dateRangePresets, children: e.presets.map((p, O) => /* @__PURE__ */ a(z, { size: "sm", variant: "soft", onPress: () => {
|
|
55
|
+
const B = p.range();
|
|
56
|
+
b(e.id, [B.start.toString(), B.end.toString()]), u(null);
|
|
57
|
+
}, children: p.label }, p.id ?? (typeof p.label == "string" ? p.label : O))) }),
|
|
58
|
+
/* @__PURE__ */ a(ne, { "aria-label": e.label, value: y, onChange: (p) => {
|
|
59
|
+
b(e.id, [p.start.toString(), p.end.toString()]), u(null);
|
|
60
|
+
} })
|
|
61
|
+
] });
|
|
62
|
+
}
|
|
63
|
+
return e.type === "text" ? /* @__PURE__ */ a(W, { "aria-label": e.label, autoFocus: !0, defaultValue: r ?? "", onChange: (l) => b(e.id, l), isClearable: !0, size: "sm" }) : /* @__PURE__ */ a(
|
|
64
|
+
ae,
|
|
34
65
|
{
|
|
35
66
|
"aria-label": e.label,
|
|
36
67
|
variant: "plain",
|
|
37
68
|
maxHeight: 260,
|
|
38
69
|
selectionMode: e.type === "multi" ? "multiple" : "single",
|
|
39
70
|
autoFocus: !0,
|
|
40
|
-
selectedKeys: Array.isArray(
|
|
71
|
+
selectedKeys: Array.isArray(r) ? r : r ? [r] : [],
|
|
41
72
|
onSelectionChange: (l) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
73
|
+
const g = l === "all" ? (e.options || []).map((y) => y.id) : [...l].map(String);
|
|
74
|
+
b(e.id, e.type === "multi" ? g : g[0]), e.type === "select" && u(null);
|
|
44
75
|
},
|
|
45
76
|
items: e.options,
|
|
46
|
-
children: (l) => /* @__PURE__ */
|
|
77
|
+
children: (l) => /* @__PURE__ */ a(le, { id: l.id, children: l.label })
|
|
47
78
|
}
|
|
48
79
|
);
|
|
49
80
|
};
|
|
50
|
-
return /* @__PURE__ */
|
|
51
|
-
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
-
e.icon && /* @__PURE__ */
|
|
58
|
-
/* @__PURE__ */
|
|
81
|
+
return /* @__PURE__ */ m("div", { className: G("alea-filterbar", L), role: "group", "aria-label": M ?? i.filters, children: [
|
|
82
|
+
d && d.length > 0 && /* @__PURE__ */ a(ie, { size: "sm", selectedKey: A, onSelectionChange: (e) => x == null ? void 0 : x(String(e)), children: /* @__PURE__ */ a(re, { "aria-label": i.views, children: d.map((e) => /* @__PURE__ */ a(te, { id: e.id, badge: e.count, children: e.label }, e.id)) }) }),
|
|
83
|
+
/* @__PURE__ */ m("div", { className: "alea-filterbar-row", children: [
|
|
84
|
+
s && /* @__PURE__ */ a(Q, { "aria-label": o ?? i.search, placeholder: o, size: "sm", value: h, onChange: s, className: "alea-filterbar-search" }),
|
|
85
|
+
/* @__PURE__ */ a("ul", { className: "alea-filterbar-chips", "aria-label": i.activeFilters, children: F.map((e) => /* @__PURE__ */ m("li", { className: "alea-filter-chip", "data-empty": !v(c[e.id]) || void 0, children: [
|
|
86
|
+
/* @__PURE__ */ m(E, { isOpen: f === e.id, onOpenChange: (r) => u(r ? e.id : null), children: [
|
|
87
|
+
/* @__PURE__ */ m(j, { className: "alea-filter-chip-main alea-focus-ring", children: [
|
|
88
|
+
e.icon && /* @__PURE__ */ a("span", { className: "alea-filter-chip-icon", "aria-hidden": "true", children: e.icon }),
|
|
89
|
+
/* @__PURE__ */ m("span", { className: "alea-filter-chip-label", children: [
|
|
59
90
|
e.label,
|
|
60
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ a("span", { className: "alea-visually-hidden", children: ": " })
|
|
61
92
|
] }),
|
|
62
|
-
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
] }) :
|
|
66
|
-
/* @__PURE__ */
|
|
93
|
+
v(c[e.id]) ? /* @__PURE__ */ a("span", { className: "alea-filter-chip-value", children: e.type === "boolean" ? /* @__PURE__ */ m(R, { children: [
|
|
94
|
+
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: I(e, c[e.id], $) }),
|
|
95
|
+
/* @__PURE__ */ a("span", { className: "alea-visually-hidden", children: c[e.id] ? i.on : i.off })
|
|
96
|
+
] }) : I(e, c[e.id], $) }) : /* @__PURE__ */ a("span", { className: "alea-visually-hidden", children: i.noValue }),
|
|
97
|
+
/* @__PURE__ */ m("span", { className: "alea-visually-hidden", children: [
|
|
67
98
|
". ",
|
|
68
|
-
|
|
99
|
+
i.edit
|
|
69
100
|
] }),
|
|
70
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ a(X, { size: 14, "aria-hidden": "true" })
|
|
71
102
|
] }),
|
|
72
|
-
/* @__PURE__ */
|
|
103
|
+
/* @__PURE__ */ a(V, { placement: "bottom start", className: "alea-popover alea-filter-popover", children: /* @__PURE__ */ a(ee, { title: e.label, children: K(e) }) })
|
|
73
104
|
] }),
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
|
|
76
|
-
}, children: /* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ a(j, { className: "alea-filter-chip-remove alea-focus-ring", "aria-label": i.removeItem(e.label), onPress: () => {
|
|
106
|
+
b(e.id, void 0), f === e.id && u(null);
|
|
107
|
+
}, children: /* @__PURE__ */ a(q, { size: 12, "aria-hidden": "true" }) })
|
|
77
108
|
] }, e.id)) }),
|
|
78
|
-
|
|
79
|
-
|
|
109
|
+
T.length > 0 && /* @__PURE__ */ a(
|
|
110
|
+
Z,
|
|
80
111
|
{
|
|
81
|
-
"aria-label":
|
|
82
|
-
trigger: /* @__PURE__ */
|
|
83
|
-
menuProps: { onAction: (e) =>
|
|
84
|
-
children:
|
|
112
|
+
"aria-label": i.addFilter,
|
|
113
|
+
trigger: /* @__PURE__ */ a(z, { size: "sm", variant: "dashed", iconStart: /* @__PURE__ */ a(w, {}), children: i.addFilter }),
|
|
114
|
+
menuProps: { onAction: (e) => u(String(e)) },
|
|
115
|
+
children: T.map((e) => /* @__PURE__ */ a(_, { id: e.id, icon: e.icon, children: e.label }, e.id))
|
|
85
116
|
}
|
|
86
117
|
),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}, children:
|
|
90
|
-
|
|
118
|
+
F.some((e) => v(c[e.id])) && /* @__PURE__ */ a(z, { size: "sm", variant: "text", onPress: () => {
|
|
119
|
+
P({}), u(null);
|
|
120
|
+
}, children: i.clearAll }),
|
|
121
|
+
D && /* @__PURE__ */ a("div", { className: "alea-filterbar-end", children: D })
|
|
91
122
|
] })
|
|
92
123
|
] });
|
|
93
124
|
}
|
|
94
125
|
export {
|
|
95
|
-
|
|
126
|
+
Fe as FilterBar
|
|
96
127
|
};
|