@alea-design/ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/components/accordion/Accordion.js +29 -0
- package/dist/components/ai/AI.d.ts +5 -1
- package/dist/components/ai/AI.js +187 -0
- package/dist/components/app/AppParts.d.ts +16 -4
- package/dist/components/app/AppParts.js +134 -0
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.js +137 -0
- package/dist/components/button/Groups.d.ts +1 -1
- package/dist/components/button/Groups.js +112 -0
- package/dist/components/card/Card.d.ts +3 -2
- package/dist/components/card/Card.js +47 -0
- package/dist/components/chat/Chat.d.ts +4 -2
- package/dist/components/chat/Chat.js +275 -0
- package/dist/components/choice/Choice.js +69 -0
- package/dist/components/color/Color.d.ts +3 -3
- package/dist/components/color/Color.js +98 -0
- package/dist/components/combobox/Autocomplete.d.ts +5 -5
- package/dist/components/combobox/Autocomplete.js +126 -0
- package/dist/components/combobox/ComboBox.d.ts +4 -4
- package/dist/components/combobox/ComboBox.js +112 -0
- package/dist/components/combobox/Highlight.js +50 -0
- package/dist/components/command/CommandPalette.d.ts +10 -3
- package/dist/components/command/CommandPalette.js +56 -0
- package/dist/components/content/Content.d.ts +1 -1
- package/dist/components/content/Content.js +125 -0
- package/dist/components/data/Data.js +79 -0
- package/dist/components/date/Date.js +109 -0
- package/dist/components/display/Display.d.ts +5 -3
- package/dist/components/display/Display.js +89 -0
- package/dist/components/display/Display2.d.ts +3 -1
- package/dist/components/display/Display2.js +75 -0
- package/dist/components/emoji/EmojiPicker.js +52 -0
- package/dist/components/emoji/emoji-data.js +27 -0
- package/dist/components/extras/CodeSteps.d.ts +1 -0
- package/dist/components/extras/CodeSteps.js +19 -0
- package/dist/components/extras/Extras.d.ts +1 -1
- package/dist/components/extras/Extras.js +116 -0
- package/dist/components/feedback/Feedback.d.ts +11 -8
- package/dist/components/feedback/Feedback.js +185 -0
- package/dist/components/feedback/Spinner.js +18 -0
- package/dist/components/feedback/Status.d.ts +6 -2
- package/dist/components/feedback/Status.js +48 -0
- package/dist/components/field/Field.d.ts +1 -1
- package/dist/components/field/Field.js +187 -0
- package/dist/components/field/FieldLoading.d.ts +1 -1
- package/dist/components/field/FieldLoading.js +18 -0
- package/dist/components/filter/FilterBar.js +96 -0
- package/dist/components/form/Form.d.ts +5 -5
- package/dist/components/form/Form.js +53 -0
- package/dist/components/icon/Icon.d.ts +2 -2
- package/dist/components/icon/Icon.js +66 -0
- package/dist/components/icon/icon-cells.js +39 -0
- package/dist/components/icon/icon-contexts.d.ts +1 -1
- package/dist/components/icon/icon-contexts.js +38 -0
- package/dist/components/icon/icon-names.d.ts +1 -1
- package/dist/components/icon/icon-names.js +376 -0
- package/dist/components/layout/Bento.d.ts +1 -1
- package/dist/components/layout/Bento.js +38 -0
- package/dist/components/layout/Layout.d.ts +1 -1
- package/dist/components/layout/Layout.js +54 -0
- package/dist/components/layout/Layout2.d.ts +36 -6
- package/dist/components/layout/Layout2.js +105 -0
- package/dist/components/layout/Layout3.js +35 -0
- package/dist/components/layout/Responsive.d.ts +1 -1
- package/dist/components/layout/Responsive.js +32 -0
- package/dist/components/list/List.d.ts +3 -2
- package/dist/components/list/List.js +82 -0
- package/dist/components/list/Lists2.d.ts +6 -4
- package/dist/components/list/Lists2.js +60 -0
- package/dist/components/media/Media.d.ts +8 -4
- package/dist/components/media/Media.js +188 -0
- package/dist/components/menu/Menu.d.ts +23 -12
- package/dist/components/menu/Menu.js +68 -0
- package/dist/components/more/More.d.ts +7 -7
- package/dist/components/more/More.js +182 -0
- package/dist/components/navigation/Navbar.d.ts +1 -1
- package/dist/components/navigation/Navbar.js +27 -0
- package/dist/components/navigation/Navigation.js +121 -0
- package/dist/components/navigation/Navigation2.d.ts +6 -2
- package/dist/components/navigation/Navigation2.js +355 -0
- package/dist/components/overlay/Drawer.d.ts +11 -6
- package/dist/components/overlay/Drawer.js +39 -0
- package/dist/components/overlay/Modal.d.ts +6 -3
- package/dist/components/overlay/Modal.js +27 -0
- package/dist/components/overlay/Overlay.d.ts +14 -9
- package/dist/components/overlay/Overlay.js +76 -0
- package/dist/components/overlay/Sheet.d.ts +11 -5
- package/dist/components/overlay/Sheet.js +52 -0
- package/dist/components/page/Page.d.ts +5 -5
- package/dist/components/page/Page.js +132 -0
- package/dist/components/page/PageParts.d.ts +5 -5
- package/dist/components/page/PageParts.js +109 -0
- package/dist/components/picker/Picker.d.ts +11 -11
- package/dist/components/picker/Picker.js +294 -0
- package/dist/components/picker/Wheel.js +132 -0
- package/dist/components/rating/Rating.d.ts +2 -1
- package/dist/components/rating/Rating.js +66 -0
- package/dist/components/select/Select.d.ts +8 -6
- package/dist/components/select/Select.js +146 -0
- package/dist/components/shell/AppShell.d.ts +3 -3
- package/dist/components/shell/AppShell.js +56 -0
- package/dist/components/shell/AppSidebar.d.ts +5 -5
- package/dist/components/shell/AppSidebar.js +62 -0
- package/dist/components/slider/Slider.d.ts +2 -1
- package/dist/components/slider/Slider.js +36 -0
- package/dist/components/surface/Surface.d.ts +16 -0
- package/dist/components/surface/Surface.js +7 -0
- package/dist/components/table/Table.d.ts +4 -3
- package/dist/components/table/Table.js +58 -0
- package/dist/components/tabs/Tabs.d.ts +1 -0
- package/dist/components/tabs/Tabs.js +120 -0
- package/dist/components/theme/Theme.d.ts +11 -6
- package/dist/components/theme/Theme.js +186 -0
- package/dist/components/theme/lens.js +104 -0
- package/dist/components/tree/Tree.js +303 -0
- package/dist/components/typography/Typography.js +43 -0
- package/dist/components/upload/Upload.js +71 -0
- package/dist/components/work/Ops.js +24 -0
- package/dist/components/work/Work.d.ts +4 -2
- package/dist/components/work/Work.js +241 -0
- package/dist/css/accordion.css +1 -0
- package/dist/css/ai.css +1 -0
- package/dist/css/app.css +1 -0
- package/dist/css/base.css +1 -0
- package/dist/css/button.css +1 -0
- package/dist/css/card.css +1 -0
- package/dist/css/chat.css +1 -0
- package/dist/css/choice.css +1 -0
- package/dist/css/color.css +1 -0
- package/dist/css/combobox.css +1 -0
- package/dist/css/command.css +1 -0
- package/dist/css/content.css +1 -0
- package/dist/css/data.css +1 -0
- package/dist/css/date.css +1 -0
- package/dist/css/display.css +1 -0
- package/dist/css/emoji.css +1 -0
- package/dist/css/extras.css +1 -0
- package/dist/css/feedback.css +1 -0
- package/dist/css/field.css +1 -0
- package/dist/css/filter.css +1 -0
- package/dist/css/form.css +1 -0
- package/dist/css/groups.json +346 -0
- package/dist/css/icon.css +1 -0
- package/dist/css/layout.css +1 -0
- package/dist/css/list.css +1 -0
- package/dist/css/media.css +1 -0
- package/dist/css/menu.css +1 -0
- package/dist/css/more.css +1 -0
- package/dist/css/navigation.css +1 -0
- package/dist/css/overlay.css +1 -0
- package/dist/css/page.css +1 -0
- package/dist/css/picker.css +1 -0
- package/dist/css/rating.css +1 -0
- package/dist/css/select.css +1 -0
- package/dist/css/shell.css +1 -0
- package/dist/css/slider.css +1 -0
- package/dist/css/surface.css +1 -0
- package/dist/css/table.css +1 -0
- package/dist/css/tabs.css +1 -0
- package/dist/css/tree.css +1 -0
- package/dist/css/typography.css +1 -0
- package/dist/css/upload.css +1 -0
- package/dist/css/work.css +1 -0
- package/dist/i18n/strings.js +842 -0
- package/dist/index.d.ts +71 -70
- package/dist/index.js +398 -7436
- package/dist/styles.css +1 -1
- package/dist/utils/Blueprint.js +131 -0
- package/dist/utils/DotField.js +32 -0
- package/dist/utils/attr.d.ts +1 -1
- package/dist/utils/attr.js +18 -0
- package/dist/utils/blueprintScene.js +161 -0
- package/dist/utils/controlled.js +11 -0
- package/dist/utils/cx.js +11 -0
- package/dist/utils/inert.js +9 -0
- package/dist/utils/refs.d.ts +3 -0
- package/dist/utils/refs.js +11 -0
- package/dist/utils/responsive.js +12 -0
- package/dist/utils/scrollEdges.js +31 -0
- package/dist/utils/space.js +10 -0
- package/dist/utils/vocabulary.d.ts +6 -0
- package/dist/utils/vocabulary.js +17 -0
- package/package.json +12 -8
|
@@ -14,6 +14,7 @@ export interface CodeStep {
|
|
|
14
14
|
children?: ReactNode;
|
|
15
15
|
}
|
|
16
16
|
export interface CodeStepsProps {
|
|
17
|
+
/** The steps, in order: a title, the code to show and an optional note. */
|
|
17
18
|
steps: CodeStep[];
|
|
18
19
|
/** Heading level of each step's title, to fit the page outline. Default 3. */
|
|
19
20
|
headingLevel?: 2 | 3 | 4;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as c, jsxs as o } from "react/jsx-runtime";
|
|
3
|
+
import { cx as n } from "../../utils/cx.js";
|
|
4
|
+
import { CodeBlock as r } from "./Extras.js";
|
|
5
|
+
function N({ steps: t, headingLevel: l = 3, start: d = 1, className: s }) {
|
|
6
|
+
const i = `h${l}`;
|
|
7
|
+
return /* @__PURE__ */ c("ol", { className: n("alea-codesteps", s), start: d, children: t.map((e, a) => /* @__PURE__ */ o("li", { className: "alea-codesteps-step", "data-code": e.code || e.codeContent ? !0 : void 0, children: [
|
|
8
|
+
/* @__PURE__ */ c("span", { className: "alea-codesteps-num", "aria-hidden": "true", children: d + a }),
|
|
9
|
+
/* @__PURE__ */ o("div", { className: "alea-codesteps-text", children: [
|
|
10
|
+
/* @__PURE__ */ c(i, { className: "alea-codesteps-title", children: e.title }),
|
|
11
|
+
e.description && /* @__PURE__ */ c("div", { className: "alea-codesteps-desc", children: e.description }),
|
|
12
|
+
e.children
|
|
13
|
+
] }),
|
|
14
|
+
e.codeContent ? /* @__PURE__ */ c("div", { className: "alea-codesteps-code", children: e.codeContent }) : e.code && /* @__PURE__ */ c("div", { className: "alea-codesteps-code", children: /* @__PURE__ */ c(r, { code: e.code, title: e.file }) })
|
|
15
|
+
] }, a)) });
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
N as CodeSteps
|
|
19
|
+
};
|
|
@@ -2,7 +2,7 @@ import { type HTMLAttributes, type ReactNode } from 'react';
|
|
|
2
2
|
export interface GradientTextProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
}
|
|
5
|
-
/** Text filled with the
|
|
5
|
+
/** Text filled with the accent gradient. Large text only (24 px, or 19 px bold, and up): the gradient keeps 3:1 against the page in every look and mode, not the 4.5:1 that body text needs. Use `Text` with `tone="accent"` for small accent text. */
|
|
6
6
|
export declare function GradientText({ className, ...props }: GradientTextProps): import("react").JSX.Element;
|
|
7
7
|
export interface GradientDotProps extends HTMLAttributes<HTMLSpanElement> {
|
|
8
8
|
/** Diameter in px. Default 14. */
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as d, jsx as e, Fragment as D } from "react/jsx-runtime";
|
|
3
|
+
import { useState as v, useRef as O, useEffect as P } from "react";
|
|
4
|
+
import { Check as y, Copy as k, Moon as x, Sun as I, Monitor as B } from "lucide-react";
|
|
5
|
+
import { useOffscreenPause as z } from "@alea-design/motion";
|
|
6
|
+
import { cx as p } from "../../utils/cx.js";
|
|
7
|
+
import { Button as S, IconButton as T } from "../button/Button.js";
|
|
8
|
+
import { useTheme as C } from "../theme/Theme.js";
|
|
9
|
+
import { useStrings as N } from "../../i18n/strings.js";
|
|
10
|
+
import { TooltipTrigger as R, Tooltip as j } from "../overlay/Overlay.js";
|
|
11
|
+
function Q({ className: t, ...r }) {
|
|
12
|
+
return /* @__PURE__ */ e("span", { ...r, className: p("alea-gradient-text", t) });
|
|
13
|
+
}
|
|
14
|
+
function U({ size: t = 14, pulse: r, className: n, style: s, ...a }) {
|
|
15
|
+
return /* @__PURE__ */ e("span", { ...a, "aria-hidden": "true", className: p("alea-gradient-dot", n), "data-pulse": r || void 0, style: { width: t, height: t, ...s } });
|
|
16
|
+
}
|
|
17
|
+
function V({ position: t = "absolute", grid: r = !0, className: n, ...s }) {
|
|
18
|
+
const a = z();
|
|
19
|
+
return /* @__PURE__ */ d("div", { ...s, ref: a, "aria-hidden": "true", className: p("alea-orbs", n), "data-position": t, children: [
|
|
20
|
+
/* @__PURE__ */ e("span", { className: "alea-orb", "data-n": "1" }),
|
|
21
|
+
/* @__PURE__ */ e("span", { className: "alea-orb", "data-n": "2" }),
|
|
22
|
+
/* @__PURE__ */ e("span", { className: "alea-orb", "data-n": "3" }),
|
|
23
|
+
r && /* @__PURE__ */ e("span", { className: "alea-orbs-grid" })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
function X({ appearance: t = "icon", className: r }) {
|
|
27
|
+
const n = N(), { theme: s, resolvedTheme: a, setTheme: l } = C();
|
|
28
|
+
if (t === "segmented") {
|
|
29
|
+
const i = [{ id: "dark", label: n.themeDark, Icon: x }, { id: "light", label: n.themeLight, Icon: I }, { id: "system", label: n.themeSystem, Icon: B }];
|
|
30
|
+
return /* @__PURE__ */ e("div", { role: "radiogroup", "aria-label": n.theme, className: p("alea-theme-toggle alea-segmented", r), "data-size": "sm", children: i.map((c) => /* @__PURE__ */ d("button", { type: "button", role: "radio", "aria-checked": s === c.id, className: "alea-segmented-item alea-focus-ring", "data-selected": s === c.id || void 0, onClick: () => l(c.id), children: [
|
|
31
|
+
/* @__PURE__ */ e(c.Icon, { size: 14, "aria-hidden": "true" }),
|
|
32
|
+
" ",
|
|
33
|
+
c.label
|
|
34
|
+
] }, c.id)) });
|
|
35
|
+
}
|
|
36
|
+
const o = a === "dark" ? "light" : "dark";
|
|
37
|
+
return /* @__PURE__ */ e(T, { "aria-label": n.switchTheme(o === "dark" ? n.themeDark : n.themeLight), className: p("alea-theme-toggle", r), onPress: () => l(o), children: a === "dark" ? /* @__PURE__ */ e(x, {}) : /* @__PURE__ */ e(I, {}) });
|
|
38
|
+
}
|
|
39
|
+
function M({ value: t, label: r, appearance: n = "icon", size: s = "sm", onCopy: a }) {
|
|
40
|
+
const l = N();
|
|
41
|
+
r ?? (r = l.copy);
|
|
42
|
+
const [o, i] = v(!1), c = async () => {
|
|
43
|
+
try {
|
|
44
|
+
await navigator.clipboard.writeText(t);
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
i(!0), a == null || a(), setTimeout(() => i(!1), 1400);
|
|
48
|
+
};
|
|
49
|
+
return /* @__PURE__ */ d(D, { children: [
|
|
50
|
+
n === "icon" ? /* @__PURE__ */ e(T, { size: s, "aria-label": o ? l.copied : r, onPress: c, children: o ? /* @__PURE__ */ e(y, {}) : /* @__PURE__ */ e(k, {}) }) : /* @__PURE__ */ e(S, { size: s, variant: "ghost", iconStart: o ? /* @__PURE__ */ e(y, {}) : /* @__PURE__ */ e(k, {}), onPress: c, children: o ? l.copied : r }),
|
|
51
|
+
/* @__PURE__ */ e("span", { className: "alea-visually-hidden", role: "status", children: o ? l.copied : "" })
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
function Y({ code: t, title: r, lineNumbers: n, highlightLines: s, maxLines: a, wrap: l, copy: o = !0, className: i }) {
|
|
55
|
+
const c = N(), u = t.replace(/\n$/, "").split(`
|
|
56
|
+
`), [m, h] = v(!1), f = a != null && u.length > a && !m, b = f ? u.slice(0, a) : u, $ = n || (s == null ? void 0 : s.length);
|
|
57
|
+
return /* @__PURE__ */ d("figure", { className: p("alea-codeblock", i), "data-wrap": l || void 0, children: [
|
|
58
|
+
(r || o) && /* @__PURE__ */ d("figcaption", { className: "alea-codeblock-head", children: [
|
|
59
|
+
/* @__PURE__ */ e("span", { children: r }),
|
|
60
|
+
o && /* @__PURE__ */ e(M, { value: t, label: c.copyCode })
|
|
61
|
+
] }),
|
|
62
|
+
/* @__PURE__ */ e("pre", { tabIndex: 0, className: "alea-codeblock-pre", "data-line-numbers": n || void 0, "data-cut": f || void 0, children: /* @__PURE__ */ e("code", { children: $ ? b.map((g, w) => /* @__PURE__ */ e("span", { className: "alea-codeblock-line", "data-highlight": (s == null ? void 0 : s.includes(w + 1)) || void 0, children: g || " " }, w)) : b.join(`
|
|
63
|
+
`) }) }),
|
|
64
|
+
a != null && u.length > a && /* @__PURE__ */ e("button", { type: "button", className: "alea-codeblock-more alea-focus-ring", "aria-expanded": m, onClick: () => h((g) => !g), children: m ? c.showLess : `${c.showMore} (${u.length - a})` })
|
|
65
|
+
] });
|
|
66
|
+
}
|
|
67
|
+
function Z({ code: t, variant: r = "single", prompt: n, className: s }) {
|
|
68
|
+
const a = N(), [l, o] = v(!1), i = O(null), [c, u] = v(!1);
|
|
69
|
+
P(() => {
|
|
70
|
+
const h = i.current;
|
|
71
|
+
if (!h || typeof ResizeObserver > "u") return;
|
|
72
|
+
const f = () => u(h.scrollWidth > h.clientWidth + 1);
|
|
73
|
+
f();
|
|
74
|
+
const b = new ResizeObserver(f);
|
|
75
|
+
return b.observe(h), () => b.disconnect();
|
|
76
|
+
}, [t]);
|
|
77
|
+
const m = async () => {
|
|
78
|
+
try {
|
|
79
|
+
await navigator.clipboard.writeText(t);
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
o(!0), setTimeout(() => o(!1), 1500);
|
|
83
|
+
};
|
|
84
|
+
return r === "inline" ? /* @__PURE__ */ d(R, { delay: 300, children: [
|
|
85
|
+
/* @__PURE__ */ e(S, { variant: "text", size: "xs", className: p("alea-snippet-inline", s), onPress: m, "aria-label": `${t}, ${l ? a.copied : a.copy}`, children: /* @__PURE__ */ e("code", { children: t }) }),
|
|
86
|
+
/* @__PURE__ */ e(j, { children: l ? a.copied : a.copy })
|
|
87
|
+
] }) : /* @__PURE__ */ d("div", { className: p("alea-snippet", s), children: [
|
|
88
|
+
/* @__PURE__ */ d("code", { ref: i, className: "alea-snippet-code", ...c ? { tabIndex: 0, role: "region", "aria-label": t } : {}, children: [
|
|
89
|
+
n && /* @__PURE__ */ d("span", { className: "alea-snippet-prompt", "aria-hidden": "true", children: [
|
|
90
|
+
n,
|
|
91
|
+
" "
|
|
92
|
+
] }),
|
|
93
|
+
t
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ e(T, { size: "sm", variant: "text", "aria-label": l ? a.copied : a.copy, onPress: m, children: l ? /* @__PURE__ */ e(y, {}) : /* @__PURE__ */ e(k, {}) }),
|
|
96
|
+
/* @__PURE__ */ e("span", { className: "alea-visually-hidden", role: "status", children: l ? a.copied : "" })
|
|
97
|
+
] });
|
|
98
|
+
}
|
|
99
|
+
function _({ children: t, stagger: r = 60, className: n, ...s }) {
|
|
100
|
+
const a = t.split(/(\s+)/);
|
|
101
|
+
let l = 0;
|
|
102
|
+
return /* @__PURE__ */ d("span", { ...s, className: p("alea-split", n), children: [
|
|
103
|
+
/* @__PURE__ */ e("span", { className: "alea-visually-hidden", children: t }),
|
|
104
|
+
/* @__PURE__ */ e("span", { "aria-hidden": "true", children: a.map((o, i) => /^\s+$/.test(o) ? o : /* @__PURE__ */ e("span", { className: "alea-split-word", style: { animationDelay: `${l++ * r}ms` }, children: o }, i)) })
|
|
105
|
+
] });
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
Y as CodeBlock,
|
|
109
|
+
Z as CodeSnippet,
|
|
110
|
+
M as CopyButton,
|
|
111
|
+
U as GradientDot,
|
|
112
|
+
Q as GradientText,
|
|
113
|
+
V as OrbBackground,
|
|
114
|
+
_ as SplitText,
|
|
115
|
+
X as ThemeToggle
|
|
116
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
2
|
import { type MotionProp } from '@alea-design/motion';
|
|
3
3
|
import { type ProgressBarProps as RACProgressBarProps, type MeterProps as RACMeterProps } from 'react-aria-components';
|
|
4
|
-
import type { Tone } from '../display/Display';
|
|
4
|
+
import type { Tone } from '../display/Display.js';
|
|
5
|
+
import { type SurfaceProps } from '../surface/Surface.js';
|
|
5
6
|
export interface ProgressBarProps extends RACProgressBarProps {
|
|
6
7
|
/** The visible label. */
|
|
7
8
|
label?: ReactNode;
|
|
@@ -9,8 +10,8 @@ export interface ProgressBarProps extends RACProgressBarProps {
|
|
|
9
10
|
showValue?: boolean;
|
|
10
11
|
/** Track height: sm 4 px, md 8 px (default) or lg 12 px. */
|
|
11
12
|
size?: 'sm' | 'md' | 'lg';
|
|
12
|
-
/** The fill color: accent (default, the gradient), success, warning, danger or info. */
|
|
13
|
-
tone?:
|
|
13
|
+
/** The fill color: accent (default, the gradient), neutral, success, warning, danger or info. */
|
|
14
|
+
tone?: Tone;
|
|
14
15
|
/** Moving stripes on the fill, for work that is running. */
|
|
15
16
|
striped?: boolean;
|
|
16
17
|
/** Where the value shows: top (next to the label, default) or end (after the bar). */
|
|
@@ -25,8 +26,8 @@ export interface ProgressCircleProps extends Omit<RACProgressBarProps, 'children
|
|
|
25
26
|
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
26
27
|
/** Show the percent in the middle (md and up). */
|
|
27
28
|
showValue?: boolean;
|
|
28
|
-
/** The ring color: accent (default), success, warning, danger or info. */
|
|
29
|
-
tone?:
|
|
29
|
+
/** The ring color: accent (default), neutral, success, warning, danger or info. */
|
|
30
|
+
tone?: Tone;
|
|
30
31
|
/** Ring thickness in the 48 unit drawing: 3 (thin), 5 (default) or 8 (bold). */
|
|
31
32
|
thickness?: number;
|
|
32
33
|
/** Your own content in the middle: an icon, an avatar, "3/5". */
|
|
@@ -82,12 +83,14 @@ export interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'
|
|
|
82
83
|
/** Your own icon instead of the tone's. */
|
|
83
84
|
icon?: ReactNode;
|
|
84
85
|
/** soft (tinted, default), outline (a border in the tone), solid (filled) or accent (a bar on the left). */
|
|
86
|
+
appearance?: 'soft' | 'outline' | 'solid' | 'accent';
|
|
87
|
+
/** @deprecated Use appearance. */
|
|
85
88
|
variant?: 'soft' | 'outline' | 'solid' | 'accent';
|
|
86
89
|
/** md (default) or sm: one compact line, for forms and tables. */
|
|
87
90
|
size?: 'sm' | 'md';
|
|
88
91
|
}
|
|
89
92
|
/** A message in the page: info, success, warning, danger, accent or neutral, in four looks and two sizes. */
|
|
90
|
-
export declare
|
|
93
|
+
export declare const Alert: import("react").ForwardRefExoticComponent<AlertProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
91
94
|
export interface ToastOptions {
|
|
92
95
|
title: ReactNode;
|
|
93
96
|
description?: ReactNode;
|
|
@@ -120,7 +123,7 @@ interface ToastApi {
|
|
|
120
123
|
error: ReactNode | ((e: unknown) => ReactNode);
|
|
121
124
|
}) => Promise<T>;
|
|
122
125
|
}
|
|
123
|
-
export interface ToastProviderProps {
|
|
126
|
+
export interface ToastProviderProps extends SurfaceProps {
|
|
124
127
|
children: ReactNode;
|
|
125
128
|
/** Where toasts stack: bottom-end (default), bottom, top-end or top. */
|
|
126
129
|
placement?: 'bottom-end' | 'bottom' | 'top-end' | 'top';
|
|
@@ -130,7 +133,7 @@ export interface ToastProviderProps {
|
|
|
130
133
|
stacked?: boolean;
|
|
131
134
|
}
|
|
132
135
|
/** Shows toasts anywhere below it; put it once near the root. */
|
|
133
|
-
export declare function ToastProvider({ children, placement, motion, stacked }: ToastProviderProps): import("react").JSX.Element;
|
|
136
|
+
export declare function ToastProvider({ children, placement, motion, stacked, surface, radius }: ToastProviderProps): import("react").JSX.Element;
|
|
134
137
|
/** show({ title, tone, description, action, timeout }) and close(id). Needs a ToastProvider above. */
|
|
135
138
|
export declare function useToast(): ToastApi;
|
|
136
139
|
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as x, jsx as a, Fragment as M } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as D, useState as S, useRef as B, useCallback as k, useContext as F, createContext as R, useEffect as j } from "react";
|
|
4
|
+
import { motionStyle as G } from "@alea-design/motion";
|
|
5
|
+
import { Meter as O, Label as E, ProgressBar as I } from "react-aria-components";
|
|
6
|
+
import { CircleAlert as V, TriangleAlert as W, CircleCheck as H, Info as A, X } from "lucide-react";
|
|
7
|
+
import { cx as w, withBase as C } from "../../utils/cx.js";
|
|
8
|
+
import { alertIcon as z } from "../icon/icon-contexts.js";
|
|
9
|
+
import { IconButton as $ } from "../button/Button.js";
|
|
10
|
+
import { useStrings as T } from "../../i18n/strings.js";
|
|
11
|
+
import { surfaceAttrs as U } from "../surface/Surface.js";
|
|
12
|
+
import { Spinner as q } from "./Spinner.js";
|
|
13
|
+
import { DotField as J } from "../../utils/DotField.js";
|
|
14
|
+
import { SkeletonBlueprint as K } from "../../utils/Blueprint.js";
|
|
15
|
+
import { inertProps as Q } from "../../utils/inert.js";
|
|
16
|
+
import { renamed as Y } from "../../utils/vocabulary.js";
|
|
17
|
+
function ha({ label: e, showValue: r, size: p = "md", tone: m, striped: i, valuePosition: s = "top", description: f, className: c, ...n }) {
|
|
18
|
+
const d = r ?? (!!e || s === "end");
|
|
19
|
+
return /* @__PURE__ */ a(I, { ...n, className: C("alea-progress", c), "data-size": p, "data-tone": m, "data-striped": i || void 0, "data-value-position": s !== "top" ? s : void 0, children: ({ percentage: u, valueText: g, isIndeterminate: h }) => /* @__PURE__ */ x(M, { children: [
|
|
20
|
+
(e || d && s === "top") && /* @__PURE__ */ x("div", { className: "alea-progress-head", children: [
|
|
21
|
+
e && /* @__PURE__ */ a(E, { className: "alea-label", children: e }),
|
|
22
|
+
d && s === "top" && !h && /* @__PURE__ */ a("span", { className: "alea-progress-value", children: g })
|
|
23
|
+
] }),
|
|
24
|
+
/* @__PURE__ */ x("div", { className: "alea-progress-row", children: [
|
|
25
|
+
/* @__PURE__ */ a("div", { className: "alea-progress-track", children: /* @__PURE__ */ a("div", { className: "alea-progress-fill", "data-indeterminate": h || void 0, style: h ? void 0 : { width: `${u}%` } }) }),
|
|
26
|
+
d && s === "end" && !h && /* @__PURE__ */ a("span", { className: "alea-progress-value", children: g })
|
|
27
|
+
] }),
|
|
28
|
+
f && /* @__PURE__ */ a("span", { className: "alea-description", children: f })
|
|
29
|
+
] }) });
|
|
30
|
+
}
|
|
31
|
+
function va({ size: e = "md", showValue: r, tone: p, thickness: m = 5, children: i, className: s, ...f }) {
|
|
32
|
+
return /* @__PURE__ */ a(I, { ...f, className: C("alea-progress-circle", s), "data-size": e, "data-tone": p, children: ({ percentage: c = 0, valueText: n, isIndeterminate: d }) => {
|
|
33
|
+
const u = 24 - m / 2 - 1, g = 2 * Math.PI * u;
|
|
34
|
+
return /* @__PURE__ */ x(M, { children: [
|
|
35
|
+
/* @__PURE__ */ x("svg", { viewBox: "0 0 48 48", "aria-hidden": "true", "data-indeterminate": d || void 0, children: [
|
|
36
|
+
/* @__PURE__ */ a("circle", { cx: "24", cy: "24", r: u, fill: "none", stroke: "var(--alea-surface-raised)", strokeWidth: m }),
|
|
37
|
+
/* @__PURE__ */ a("circle", { cx: "24", cy: "24", r: u, fill: "none", stroke: "var(--alea-progress-tone, var(--alea-accent))", strokeWidth: m, strokeLinecap: "round", strokeDasharray: g, strokeDashoffset: d ? g * 0.7 : g * (1 - c / 100), transform: "rotate(-90 24 24)", className: "alea-progress-circle-arc" })
|
|
38
|
+
] }),
|
|
39
|
+
i ? /* @__PURE__ */ a("span", { className: "alea-progress-circle-value", children: i }) : r && !d && /* @__PURE__ */ a("span", { className: "alea-progress-circle-value", children: n })
|
|
40
|
+
] });
|
|
41
|
+
} });
|
|
42
|
+
}
|
|
43
|
+
function Na({ label: e, showValue: r = !0, tone: p = "accent", className: m, ...i }) {
|
|
44
|
+
return /* @__PURE__ */ a(O, { ...i, className: C("alea-progress alea-meter", m), children: ({ percentage: s, valueText: f }) => {
|
|
45
|
+
const c = p === "auto" ? s > 90 ? "danger" : s > 70 ? "warning" : "success" : p;
|
|
46
|
+
return /* @__PURE__ */ x(M, { children: [
|
|
47
|
+
(e || r) && /* @__PURE__ */ x("div", { className: "alea-progress-head", children: [
|
|
48
|
+
e && /* @__PURE__ */ a(E, { className: "alea-label", children: e }),
|
|
49
|
+
r && /* @__PURE__ */ a("span", { className: "alea-progress-value", children: f })
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ a("div", { className: "alea-progress-track", children: /* @__PURE__ */ a("div", { className: "alea-progress-fill", "data-tone": c, style: { width: `${s}%` } }) })
|
|
52
|
+
] });
|
|
53
|
+
} });
|
|
54
|
+
}
|
|
55
|
+
function xa({ shape: e = "text", width: r, height: p, lines: m = 1, isLoaded: i, animation: s, rows: f, cols: c, children: n, className: d, style: u, ...g }) {
|
|
56
|
+
const h = T();
|
|
57
|
+
if (s === "blueprint") return /* @__PURE__ */ a(K, { ...g, shape: e, width: r, height: p, rows: f, isLoaded: i, className: d, style: u, children: n });
|
|
58
|
+
if (s === "matrix") {
|
|
59
|
+
const N = n != null && n !== !1, { "aria-label": y, ...o } = g, t = f != null || c != null;
|
|
60
|
+
return /* @__PURE__ */ x(
|
|
61
|
+
"span",
|
|
62
|
+
{
|
|
63
|
+
...o,
|
|
64
|
+
className: w("alea-skeleton-matrix", d),
|
|
65
|
+
"data-shape": e,
|
|
66
|
+
"data-state": i ? "loaded" : "loading",
|
|
67
|
+
"data-content": N || void 0,
|
|
68
|
+
"data-sized": t || void 0,
|
|
69
|
+
"aria-busy": !i,
|
|
70
|
+
style: { width: r, ...N ? { minHeight: p } : { height: p ?? (e === "circle" ? r : void 0) }, ...c != null ? { "--alea-dots-cols": c } : null, ...f != null ? { "--alea-dots-rows": f } : null, ...u },
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ a(J, { rows: f, cols: c }),
|
|
73
|
+
N && /* @__PURE__ */ a("span", { className: "alea-skeleton-matrix-content", ...Q(!i), children: n }),
|
|
74
|
+
/* @__PURE__ */ a("span", { role: "status", className: "alea-visually-hidden", children: i ? "" : y ?? h.loading })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return i ? /* @__PURE__ */ a("span", { className: "alea-skeleton-reveal", children: n }) : e === "text" && m > 1 ? /* @__PURE__ */ a("span", { className: w("alea-skeleton-lines", d), "aria-hidden": "true", children: Array.from({ length: m }, (N, y) => /* @__PURE__ */ a("span", { className: "alea-skeleton", "data-shape": "text", "data-animation": s, style: { width: y === m - 1 ? "60%" : r } }, y)) }) : /* @__PURE__ */ a("span", { ...g, "aria-hidden": "true", className: w("alea-skeleton", d), "data-shape": e, "data-animation": s, style: { width: r, height: p ?? (e === "circle" ? r : void 0), ...u } });
|
|
80
|
+
}
|
|
81
|
+
const L = { neutral: A, accent: A, info: A, success: H, warning: W, danger: V }, ya = D(function({ tone: r = "info", title: p, children: m, actions: i, onDismiss: s, live: f, hideIcon: c, icon: n, appearance: d, variant: u, size: g, className: h, ...N }, y) {
|
|
82
|
+
const o = T(), t = Y("Alert", "variant", u, "appearance", d) ?? "soft", l = L[r];
|
|
83
|
+
return /* @__PURE__ */ x("div", { ref: y, ...N, className: w("alea-alert", h), "data-tone": r, "data-variant": t !== "soft" ? t : void 0, "data-size": g, role: f ? r === "danger" ? "alert" : "status" : N.role, children: [
|
|
84
|
+
!c && (n ? /* @__PURE__ */ a("span", { className: "alea-alert-icon", "aria-hidden": "true", ...z(r, t === "solid"), children: n }) : /* @__PURE__ */ a(l, { className: "alea-alert-icon", size: g === "sm" ? 16 : 20, "aria-hidden": "true", ...z(r, t === "solid") })),
|
|
85
|
+
/* @__PURE__ */ x("div", { className: "alea-alert-body", children: [
|
|
86
|
+
p && /* @__PURE__ */ a("p", { className: "alea-alert-title", children: p }),
|
|
87
|
+
m && /* @__PURE__ */ a("div", { className: "alea-alert-text", children: m })
|
|
88
|
+
] }),
|
|
89
|
+
i && /* @__PURE__ */ a("div", { className: "alea-alert-actions", children: i }),
|
|
90
|
+
s && /* @__PURE__ */ a($, { "aria-label": o.dismiss, size: "sm", variant: "ghost", onPress: s, className: "alea-alert-x", children: /* @__PURE__ */ a(X, {}) })
|
|
91
|
+
] });
|
|
92
|
+
}), Z = 600, _ = R(null);
|
|
93
|
+
function ba({ children: e, placement: r = "bottom-end", motion: p, stacked: m, surface: i, radius: s }) {
|
|
94
|
+
const f = T(), [c, n] = S([]), d = B(1), u = k((o) => n((t) => t.filter((l) => l.id !== o)), []), g = k((o) => {
|
|
95
|
+
n((t) => t.map((l) => l.id === o ? { ...l, exiting: !0 } : l)), setTimeout(() => u(o), Z);
|
|
96
|
+
}, [u]), h = k((o) => {
|
|
97
|
+
const t = d.current++;
|
|
98
|
+
return n((l) => [...l.slice(-4), { ...o, id: t }]), t;
|
|
99
|
+
}, []), N = k((o, t) => n((l) => l.map((v) => v.id === o ? { ...v, ...t, version: (v.version ?? 0) + 1 } : v)), []), y = k((o, t) => {
|
|
100
|
+
const l = h({ title: t.loading, isLoading: !0, tone: "neutral" });
|
|
101
|
+
return o.then(
|
|
102
|
+
(v) => N(l, { title: typeof t.success == "function" ? t.success(v) : t.success, tone: "success", isLoading: !1 }),
|
|
103
|
+
(v) => N(l, { title: typeof t.error == "function" ? t.error(v) : t.error, tone: "danger", isLoading: !1 })
|
|
104
|
+
), o;
|
|
105
|
+
}, [h, N]);
|
|
106
|
+
return /* @__PURE__ */ x(_.Provider, { value: { show: h, close: g, update: N, promise: y }, children: [
|
|
107
|
+
e,
|
|
108
|
+
/* @__PURE__ */ a("section", { className: "alea-toast-region", "data-placement": r, "data-stacked": m || void 0, "aria-label": f.notifications, tabIndex: -1, children: /* @__PURE__ */ a("ol", { children: c.map((o) => /* @__PURE__ */ a(aa, { item: o, motion: p, surface: i, radius: s, onClose: () => g(o.id), onExited: () => u(o.id) }, o.id)) }) })
|
|
109
|
+
] });
|
|
110
|
+
}
|
|
111
|
+
function aa({ item: e, onClose: r, onExited: p, motion: m, surface: i, radius: s }) {
|
|
112
|
+
const f = T(), c = e.tone || "neutral", n = e.isLoading ? 0 : e.timeout ?? (c === "danger" ? 0 : 5e3), [d, u] = S(!1);
|
|
113
|
+
j(() => {
|
|
114
|
+
if (!n || d) return;
|
|
115
|
+
const t = setTimeout(r, n);
|
|
116
|
+
return () => clearTimeout(t);
|
|
117
|
+
}, [n, d, r, e.version]);
|
|
118
|
+
const g = L[c], h = B(null), N = (t) => {
|
|
119
|
+
t.button !== 0 || t.target.closest("button, a") || (h.current = { x: t.clientX, t: performance.now(), id: t.pointerId });
|
|
120
|
+
}, y = (t) => {
|
|
121
|
+
var P;
|
|
122
|
+
const l = h.current;
|
|
123
|
+
if (!l || l.id !== t.pointerId) return;
|
|
124
|
+
const v = t.clientX - l.x;
|
|
125
|
+
if (Math.abs(v) < 4) return;
|
|
126
|
+
const b = t.currentTarget;
|
|
127
|
+
b.setAttribute("data-swiping", ""), (P = b.setPointerCapture) == null || P.call(b, t.pointerId), b.style.setProperty("--alea-swipe-x", `${v}px`), b.style.setProperty("--alea-swipe-n", String(v / 160));
|
|
128
|
+
}, o = (t) => {
|
|
129
|
+
const l = h.current;
|
|
130
|
+
if (h.current = null, !l) return;
|
|
131
|
+
const v = t.currentTarget, b = t.clientX - l.x, P = Math.abs(b) / Math.max(1, performance.now() - l.t) > 0.6;
|
|
132
|
+
v.removeAttribute("data-swiping"), Math.abs(b) > 80 || P && Math.abs(b) > 24 ? r() : (v.style.removeProperty("--alea-swipe-x"), v.style.removeProperty("--alea-swipe-n"));
|
|
133
|
+
};
|
|
134
|
+
return /* @__PURE__ */ x(
|
|
135
|
+
"li",
|
|
136
|
+
{
|
|
137
|
+
className: "alea-toast",
|
|
138
|
+
...U({ surface: i, radius: s }),
|
|
139
|
+
"data-tone": c,
|
|
140
|
+
"data-exiting": e.exiting || void 0,
|
|
141
|
+
"data-paused": d || void 0,
|
|
142
|
+
role: c === "danger" ? "alert" : "status",
|
|
143
|
+
"aria-atomic": "true",
|
|
144
|
+
"aria-busy": e.isLoading || void 0,
|
|
145
|
+
style: { ...G(m), "--alea-toast-ms": `${n}ms` },
|
|
146
|
+
onAnimationEnd: (t) => {
|
|
147
|
+
e.exiting && t.target === t.currentTarget && p();
|
|
148
|
+
},
|
|
149
|
+
onPointerDown: N,
|
|
150
|
+
onPointerMove: y,
|
|
151
|
+
onPointerUp: o,
|
|
152
|
+
onPointerCancel: o,
|
|
153
|
+
onMouseEnter: () => u(!0),
|
|
154
|
+
onMouseLeave: () => u(!1),
|
|
155
|
+
onFocus: () => u(!0),
|
|
156
|
+
onBlur: () => u(!1),
|
|
157
|
+
children: [
|
|
158
|
+
e.isLoading ? /* @__PURE__ */ a("span", { className: "alea-alert-icon", children: /* @__PURE__ */ a(q, { size: "sm", "aria-label": "" }) }) : e.icon ? /* @__PURE__ */ a("span", { className: "alea-alert-icon", "aria-hidden": "true", children: e.icon }) : /* @__PURE__ */ a(g, { className: "alea-alert-icon", size: 18, "aria-hidden": "true" }, c),
|
|
159
|
+
e.showProgress && n > 0 && /* @__PURE__ */ a("span", { className: "alea-toast-progress", "aria-hidden": "true" }, e.version),
|
|
160
|
+
/* @__PURE__ */ x("div", { className: "alea-alert-body", children: [
|
|
161
|
+
/* @__PURE__ */ a("p", { className: "alea-alert-title", children: e.title }),
|
|
162
|
+
e.description && /* @__PURE__ */ a("div", { className: "alea-alert-text", children: e.description })
|
|
163
|
+
] }),
|
|
164
|
+
e.action && /* @__PURE__ */ a("button", { type: "button", className: "alea-toast-action alea-focus-ring", onClick: () => {
|
|
165
|
+
e.action.onAction(), r();
|
|
166
|
+
}, children: e.action.label }),
|
|
167
|
+
/* @__PURE__ */ a($, { "aria-label": f.closeNotification, size: "sm", variant: "ghost", onPress: r, className: "alea-alert-x", children: /* @__PURE__ */ a(X, {}) })
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
function ka() {
|
|
173
|
+
const e = F(_);
|
|
174
|
+
if (!e) throw new Error("useToast needs a <ToastProvider> above it.");
|
|
175
|
+
return e;
|
|
176
|
+
}
|
|
177
|
+
export {
|
|
178
|
+
ya as Alert,
|
|
179
|
+
Na as Meter,
|
|
180
|
+
ha as ProgressBar,
|
|
181
|
+
va as ProgressCircle,
|
|
182
|
+
xa as Skeleton,
|
|
183
|
+
ba as ToastProvider,
|
|
184
|
+
ka as useToast
|
|
185
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r, jsxs as s } from "react/jsx-runtime";
|
|
3
|
+
import { cx as t } from "../../utils/cx.js";
|
|
4
|
+
import { useStrings as d } from "../../i18n/strings.js";
|
|
5
|
+
function u({ size: a = "md", variant: i = "ring", className: o, "aria-label": e }) {
|
|
6
|
+
const l = d();
|
|
7
|
+
return e ?? (e = l.loading), i === "morph" ? /* @__PURE__ */ r("span", { role: "progressbar", "aria-label": e, className: t("alea-spinner alea-morph-loader", o), "data-size": a, children: /* @__PURE__ */ r("i", { "aria-hidden": "true" }) }) : i === "dots" ? /* @__PURE__ */ r("span", { role: "progressbar", "aria-label": e, className: t("alea-spinner alea-dot-loader", o), "data-size": a, children: Array.from({ length: 16 }, (p, n) => /* @__PURE__ */ r("i", { "aria-hidden": "true", style: { "--alea-dot-d": n % 4 + Math.floor(n / 4) } }, n)) }) : /* @__PURE__ */ r("span", { role: "progressbar", "aria-label": e, className: t("alea-spinner", o), "data-size": a, children: /* @__PURE__ */ s("svg", { viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
8
|
+
/* @__PURE__ */ r("defs", { children: /* @__PURE__ */ s("linearGradient", { id: "alea-spinner-grad", x1: "0", y1: "0", x2: "1", y2: "1", children: [
|
|
9
|
+
/* @__PURE__ */ r("stop", { offset: "0", stopColor: "var(--alea-accent)" }),
|
|
10
|
+
/* @__PURE__ */ r("stop", { offset: "1", stopColor: "var(--alea-accent-second)" })
|
|
11
|
+
] }) }),
|
|
12
|
+
/* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeOpacity: "0.15", strokeWidth: "3" }),
|
|
13
|
+
/* @__PURE__ */ r("path", { d: "M21 12a9 9 0 0 0-9-9", stroke: "url(#alea-spinner-grad)", strokeWidth: "3", strokeLinecap: "round" })
|
|
14
|
+
] }) });
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
u as Spinner
|
|
18
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type ReactNode, type CSSProperties } from 'react';
|
|
2
2
|
export interface ToggletipProps {
|
|
3
3
|
/** What the popover says. Can hold links and buttons (unlike a Tooltip). */
|
|
4
4
|
children: ReactNode;
|
|
@@ -12,9 +12,13 @@ export interface ToggletipProps {
|
|
|
12
12
|
placement?: 'top' | 'bottom' | 'start' | 'end';
|
|
13
13
|
/** sm (16 px icon, default) or md (20 px). */
|
|
14
14
|
size?: 'sm' | 'md';
|
|
15
|
+
/** Extra class names for the button. */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Inline style for the button. */
|
|
18
|
+
style?: CSSProperties;
|
|
15
19
|
}
|
|
16
20
|
/** A small info button that opens a popover on press: for explanations people may want to read, with links if needed. Escape or a press outside closes it. */
|
|
17
|
-
export declare
|
|
21
|
+
export declare const Toggletip: import("react").ForwardRefExoticComponent<ToggletipProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
18
22
|
export interface InfoLabelProps extends Omit<ToggletipProps, 'children'> {
|
|
19
23
|
/** The label text. */
|
|
20
24
|
children: ReactNode;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as b, useEffect as f, useState as N, forwardRef as k } from "react";
|
|
4
|
+
import { DialogTrigger as v, Button as w } from "react-aria-components";
|
|
5
|
+
import { CircleAlert as u, CircleHelp as x, Info as I } from "lucide-react";
|
|
6
|
+
import { cx as p } from "../../utils/cx.js";
|
|
7
|
+
import { Popover as L, PopoverDialog as T } from "../overlay/Overlay.js";
|
|
8
|
+
import { Spinner as C } from "./Spinner.js";
|
|
9
|
+
import { useStrings as j } from "../../i18n/strings.js";
|
|
10
|
+
const z = { info: I, help: x, warning: u }, S = k(function({ children: n, title: a, "aria-label": l, icon: o = "info", placement: i = "top", size: d = "sm", className: m, style: t }, c) {
|
|
11
|
+
const g = j(), h = z[o];
|
|
12
|
+
return /* @__PURE__ */ s(v, { children: [
|
|
13
|
+
/* @__PURE__ */ r(w, { ref: c, style: t, className: p("alea-toggletip-btn alea-focus-ring", m), "aria-label": l ?? g.moreInfo, "data-size": d, "data-icon": o, children: /* @__PURE__ */ r(h, { "aria-hidden": "true" }) }),
|
|
14
|
+
/* @__PURE__ */ r(L, { placement: i, showArrow: !0, className: "alea-popover alea-toggletip", children: /* @__PURE__ */ r(T, { title: a, children: n }) })
|
|
15
|
+
] });
|
|
16
|
+
});
|
|
17
|
+
function K({ children: e, info: n, htmlFor: a, isRequired: l, className: o, ...i }) {
|
|
18
|
+
return /* @__PURE__ */ s("span", { className: p("alea-info-label", o), children: [
|
|
19
|
+
/* @__PURE__ */ s("label", { className: "alea-label", htmlFor: a, children: [
|
|
20
|
+
e,
|
|
21
|
+
l && /* @__PURE__ */ r("span", { className: "alea-label-required", "aria-hidden": "true", children: " *" })
|
|
22
|
+
] }),
|
|
23
|
+
/* @__PURE__ */ r(S, { ...i, children: n })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
function M({ status: e, children: n, successDuration: a = 1500, onSuccessEnd: l, className: o }) {
|
|
27
|
+
const i = b(l);
|
|
28
|
+
i.current = l, f(() => {
|
|
29
|
+
if (e !== "success" || !i.current) return;
|
|
30
|
+
const t = setTimeout(() => {
|
|
31
|
+
var c;
|
|
32
|
+
return (c = i.current) == null ? void 0 : c.call(i);
|
|
33
|
+
}, a);
|
|
34
|
+
return () => clearTimeout(t);
|
|
35
|
+
}, [e, a]);
|
|
36
|
+
const [d, m] = N(0);
|
|
37
|
+
return f(() => m((t) => t + 1), [e]), /* @__PURE__ */ s("span", { className: p("alea-inline-loading", o), "data-status": e, role: "status", "aria-live": "polite", children: [
|
|
38
|
+
e === "loading" && /* @__PURE__ */ r(C, { size: "sm", "aria-label": "" }),
|
|
39
|
+
e === "success" && /* @__PURE__ */ r("svg", { className: "alea-inline-check", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ r("path", { d: "M5 12.5l4.5 4.5L19 7.5" }) }, d),
|
|
40
|
+
e === "error" && /* @__PURE__ */ r(u, { size: 16, "aria-hidden": "true" }),
|
|
41
|
+
e !== "idle" && /* @__PURE__ */ r("span", { className: "alea-inline-loading-text", children: n })
|
|
42
|
+
] });
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
K as InfoLabel,
|
|
46
|
+
M as InlineLoading,
|
|
47
|
+
S as Toggletip
|
|
48
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type TextFieldProps as RACTextFieldProps, type SearchFieldProps as RACSearchFieldProps, type NumberFieldProps as RACNumberFieldProps, type ValidationResult, type LabelProps } from 'react-aria-components';
|
|
3
|
-
import type { Responsive } from '../../utils/responsive';
|
|
3
|
+
import type { Responsive } from '../../utils/responsive.js';
|
|
4
4
|
/** A field label. Marks optional or required fields. */
|
|
5
5
|
export declare function Label({ className, ...props }: LabelProps): import("react").JSX.Element;
|
|
6
6
|
/** Help text under a field. */
|