@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
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ bun add @alea-design/ui
|
|
|
10
10
|
deno add npm:@alea-design/ui
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Use the line of your package manager. With Deno, set `"nodeModulesDir": "auto"` in `deno.json` if a bundler such as Vite has to find the package on disk. Where the stylesheet and the provider go in Vite, Next.js, React Router, Astro and TanStack Start: https://alea.alevasquez.dev/frameworks
|
|
13
|
+
Use the line of your package manager. With Deno, set `"nodeModulesDir": "auto"` in `deno.json` if a bundler such as Vite has to find the package on disk. Where the stylesheet and the provider go in Vite, Next.js, React Router, Astro and TanStack Start: https://alea.alevasquez.dev/frameworks?utm_source=npm&utm_medium=readme&utm_campaign=alea-ui
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
16
|
import '@alea-design/ui/styles.css';
|
|
@@ -21,4 +21,4 @@ import { ThemeProvider, Button } from '@alea-design/ui';
|
|
|
21
21
|
</ThemeProvider>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
Docs: https://alea.alevasquez.dev · MIT license · Alea Pro (charts, DataGrid, effects, templates): https://alea.alevasquez.dev/pro
|
|
24
|
+
Docs: https://alea.alevasquez.dev?utm_source=npm&utm_medium=readme&utm_campaign=alea-ui · MIT license · Alea Pro (charts, DataGrid, effects, templates): https://alea.alevasquez.dev/pro?utm_source=npm&utm_medium=readme&utm_campaign=alea-ui
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
3
|
+
import { DisclosureGroup as m, Disclosure as h, Heading as p, Button as u, DisclosurePanel as N } from "react-aria-components";
|
|
4
|
+
import { ChevronDown as f, Plus as g } from "lucide-react";
|
|
5
|
+
import { withBase as l } from "../../utils/cx.js";
|
|
6
|
+
function j({ variant: r = "separated", size: e, indicatorPosition: c, indicator: i, className: n, ...s }) {
|
|
7
|
+
return /* @__PURE__ */ a(m, { ...s, "data-variant": r, "data-size": e, "data-indicator-position": c, "data-indicator": i, className: l("alea-accordion", n) });
|
|
8
|
+
}
|
|
9
|
+
function w({ title: r, subtitle: e, icon: c, extra: i, children: n, headingLevel: s = 3, className: d, ...t }) {
|
|
10
|
+
return /* @__PURE__ */ o(h, { ...t, className: l("alea-accordion-item", d), children: [
|
|
11
|
+
/* @__PURE__ */ a(p, { level: s, className: "alea-accordion-heading", children: /* @__PURE__ */ o(u, { slot: "trigger", className: "alea-accordion-trigger alea-focus-ring", children: [
|
|
12
|
+
c && /* @__PURE__ */ a("span", { className: "alea-accordion-icon", "aria-hidden": "true", children: c }),
|
|
13
|
+
/* @__PURE__ */ o("span", { className: "alea-accordion-titles", children: [
|
|
14
|
+
/* @__PURE__ */ a("span", { className: "alea-accordion-title", children: r }),
|
|
15
|
+
e && /* @__PURE__ */ a("span", { className: "alea-accordion-subtitle", children: e })
|
|
16
|
+
] }),
|
|
17
|
+
i && /* @__PURE__ */ a("span", { className: "alea-accordion-extra", children: i }),
|
|
18
|
+
/* @__PURE__ */ o("span", { className: "alea-accordion-indicator", "aria-hidden": "true", children: [
|
|
19
|
+
/* @__PURE__ */ a(f, { size: 18, className: "alea-accordion-chevron" }),
|
|
20
|
+
/* @__PURE__ */ a(g, { size: 18, className: "alea-accordion-plus" })
|
|
21
|
+
] })
|
|
22
|
+
] }) }),
|
|
23
|
+
/* @__PURE__ */ a(N, { className: "alea-accordion-panel", children: /* @__PURE__ */ a("div", { className: "alea-accordion-content", children: n }) })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
j as Accordion,
|
|
28
|
+
w as AccordionItem
|
|
29
|
+
};
|
|
@@ -83,13 +83,17 @@ export interface ReasoningProps {
|
|
|
83
83
|
seconds?: number;
|
|
84
84
|
/** Open at first. Default: open while thinking, closed after. */
|
|
85
85
|
defaultOpen?: boolean;
|
|
86
|
+
/** Whether the panel is open (controlled). */
|
|
87
|
+
isOpen?: boolean;
|
|
88
|
+
/** Called when the panel opens or closes. */
|
|
89
|
+
onOpenChange?: (open: boolean) => void;
|
|
86
90
|
/** While it thinks and the panel is closed, show the latest lines of the reasoning as they stream in, scrolling up under a soft fade. How many lines (1 to 4). Off by default. */
|
|
87
91
|
previewLines?: 1 | 2 | 3 | 4;
|
|
88
92
|
/** Extra class names. */
|
|
89
93
|
className?: string;
|
|
90
94
|
}
|
|
91
95
|
/** The model's thinking, behind a disclosure: "Thinking…" shimmers while it works, then "Thought for 4 s" and it folds away. */
|
|
92
|
-
export declare function Reasoning({ children, isThinking, seconds, defaultOpen, previewLines, className }: ReasoningProps): import("react").JSX.Element;
|
|
96
|
+
export declare function Reasoning({ children, isThinking, seconds, defaultOpen, isOpen, onOpenChange, previewLines, className }: ReasoningProps): import("react").JSX.Element;
|
|
93
97
|
export interface ThinkingStatusProps {
|
|
94
98
|
/** What it is doing right now: "Searching the web". Each change swaps with a soft blur crossfade. */
|
|
95
99
|
children: string;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as o, jsx as a, Fragment as I } from "react/jsx-runtime";
|
|
3
|
+
import { useId as E, useState as S, useRef as R, useLayoutEffect as M, useEffect as L } from "react";
|
|
4
|
+
import { Paperclip as _, Square as q, ArrowUp as W, Sparkles as P, ChevronRight as K, Check as O, Copy as z, RefreshCw as D, ThumbsUp as F, ThumbsDown as G, Wrench as J, Loader2 as Q, CircleCheck as V, CircleAlert as X } from "lucide-react";
|
|
5
|
+
import { TextSwap as Y } from "@alea-design/motion";
|
|
6
|
+
import { cx as C } from "../../utils/cx.js";
|
|
7
|
+
import { useStrings as $ } from "../../i18n/strings.js";
|
|
8
|
+
function na({ value: t, defaultValue: e = "", onChange: l, onSubmit: n, isGenerating: i, onStop: r, onAttach: s, header: p, tools: h, placeholder: f, label: y, maxRows: m = 8, clearOnSubmit: g = !0, isDisabled: u, showHint: b, className: w }) {
|
|
9
|
+
const d = $(), N = E(), [v, x] = S(e), k = t ?? v, H = (c) => {
|
|
10
|
+
t === void 0 && x(c), l == null || l(c);
|
|
11
|
+
}, T = R(null);
|
|
12
|
+
M(() => {
|
|
13
|
+
const c = T.current;
|
|
14
|
+
if (!c) return;
|
|
15
|
+
c.style.height = "auto";
|
|
16
|
+
const B = parseFloat(getComputedStyle(c).lineHeight) || 24;
|
|
17
|
+
c.style.height = `${Math.min(c.scrollHeight, B * m + 16)}px`;
|
|
18
|
+
}, [k, m]);
|
|
19
|
+
const A = (c) => {
|
|
20
|
+
c == null || c.preventDefault(), !(i || u || !k.trim()) && (n == null || n(k.trim()), g && H(""));
|
|
21
|
+
}, j = (c) => {
|
|
22
|
+
c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(), A());
|
|
23
|
+
};
|
|
24
|
+
return /* @__PURE__ */ o("form", { className: C("alea-prompt", w), "data-generating": i || void 0, "data-disabled": u || void 0, onSubmit: A, children: [
|
|
25
|
+
y && /* @__PURE__ */ a("label", { className: "alea-label", htmlFor: `${N}-input`, children: y }),
|
|
26
|
+
/* @__PURE__ */ o("div", { className: "alea-prompt-box", children: [
|
|
27
|
+
p && /* @__PURE__ */ a("div", { className: "alea-prompt-header", children: p }),
|
|
28
|
+
/* @__PURE__ */ a(
|
|
29
|
+
"textarea",
|
|
30
|
+
{
|
|
31
|
+
ref: T,
|
|
32
|
+
id: `${N}-input`,
|
|
33
|
+
className: "alea-prompt-input",
|
|
34
|
+
rows: 1,
|
|
35
|
+
value: k,
|
|
36
|
+
placeholder: f,
|
|
37
|
+
disabled: u,
|
|
38
|
+
"aria-label": y ? void 0 : d.aiMessage,
|
|
39
|
+
"aria-describedby": b ? `${N}-hint` : void 0,
|
|
40
|
+
"aria-keyshortcuts": "Enter",
|
|
41
|
+
onChange: (c) => H(c.target.value),
|
|
42
|
+
onKeyDown: j
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
/* @__PURE__ */ o("div", { className: "alea-prompt-row", children: [
|
|
46
|
+
s && /* @__PURE__ */ a("button", { type: "button", className: "alea-prompt-btn alea-focus-ring", "aria-label": d.aiAttach, title: d.aiAttach, onClick: s, disabled: u, children: /* @__PURE__ */ a(_, { "aria-hidden": "true" }) }),
|
|
47
|
+
/* @__PURE__ */ a("div", { className: "alea-prompt-tools", children: h }),
|
|
48
|
+
i ? /* @__PURE__ */ a("button", { type: "button", className: "alea-prompt-send alea-focus-ring", "data-stop": !0, "aria-label": d.aiStop, title: d.aiStop, onClick: r, children: /* @__PURE__ */ a(q, { "aria-hidden": "true" }) }) : /* @__PURE__ */ a("button", { type: "submit", className: "alea-prompt-send alea-focus-ring", "aria-label": d.aiSend, title: d.aiSend, disabled: u || !k.trim(), children: /* @__PURE__ */ a(W, { "aria-hidden": "true" }) })
|
|
49
|
+
] })
|
|
50
|
+
] }),
|
|
51
|
+
b && /* @__PURE__ */ a("p", { className: "alea-prompt-hint", id: `${N}-hint`, children: d.aiHint }),
|
|
52
|
+
/* @__PURE__ */ a("span", { className: "alea-visually-hidden", role: "status", children: i ? d.aiGenerating : "" })
|
|
53
|
+
] });
|
|
54
|
+
}
|
|
55
|
+
function ra({ items: t, onSelect: e, variant: l = "chips", className: n }) {
|
|
56
|
+
const i = $();
|
|
57
|
+
return /* @__PURE__ */ a("ul", { className: C("alea-suggestions", n), "data-variant": l, "aria-label": i.aiSuggestions, children: t.map((r, s) => /* @__PURE__ */ a("li", { style: { "--i": s }, children: /* @__PURE__ */ o("button", { type: "button", className: "alea-suggestion alea-focus-ring", onClick: () => e(r.prompt ?? r.label, r), children: [
|
|
58
|
+
r.icon && /* @__PURE__ */ a("span", { className: "alea-suggestion-icon", "aria-hidden": "true", children: r.icon }),
|
|
59
|
+
/* @__PURE__ */ o("span", { className: "alea-suggestion-text", children: [
|
|
60
|
+
/* @__PURE__ */ a("span", { className: "alea-suggestion-label", children: r.label }),
|
|
61
|
+
l === "cards" && r.description && /* @__PURE__ */ a("span", { className: "alea-suggestion-desc", children: r.description })
|
|
62
|
+
] })
|
|
63
|
+
] }) }, r.id)) });
|
|
64
|
+
}
|
|
65
|
+
function sa({ copyText: t, onRegenerate: e, onFeedback: l, feedback: n, extra: i, className: r }) {
|
|
66
|
+
const s = $(), [p, h] = S(!1), [f, y] = S(null), m = n !== void 0 ? n : f, [g, u] = S(""), b = (d) => {
|
|
67
|
+
const N = m === d ? null : d;
|
|
68
|
+
y(N), l == null || l(N), u(N ? s.aiThanks : "");
|
|
69
|
+
}, w = async () => {
|
|
70
|
+
try {
|
|
71
|
+
await navigator.clipboard.writeText(t ?? "");
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
h(!0), u(s.aiCopied), setTimeout(() => h(!1), 1500);
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ o("div", { className: C("alea-response-actions", r), role: "group", "aria-label": s.aiResponseActions, children: [
|
|
77
|
+
t !== void 0 && /* @__PURE__ */ a("button", { type: "button", className: "alea-prompt-btn alea-focus-ring", "aria-label": p ? s.aiCopied : s.aiCopy, title: s.aiCopy, onClick: w, "data-done": p || void 0, children: p ? /* @__PURE__ */ a(O, { "aria-hidden": "true" }) : /* @__PURE__ */ a(z, { "aria-hidden": "true" }) }),
|
|
78
|
+
e && /* @__PURE__ */ a("button", { type: "button", className: "alea-prompt-btn alea-focus-ring", "aria-label": s.aiRegenerate, title: s.aiRegenerate, onClick: e, children: /* @__PURE__ */ a(D, { "aria-hidden": "true" }) }),
|
|
79
|
+
l && /* @__PURE__ */ o(I, { children: [
|
|
80
|
+
/* @__PURE__ */ a("button", { type: "button", className: "alea-prompt-btn alea-focus-ring", "aria-label": s.aiGood, title: s.aiGood, "aria-pressed": m === "good", onClick: () => b("good"), children: /* @__PURE__ */ a(F, { "aria-hidden": "true" }) }),
|
|
81
|
+
/* @__PURE__ */ a("button", { type: "button", className: "alea-prompt-btn alea-focus-ring", "aria-label": s.aiBad, title: s.aiBad, "aria-pressed": m === "bad", onClick: () => b("bad"), children: /* @__PURE__ */ a(G, { "aria-hidden": "true" }) })
|
|
82
|
+
] }),
|
|
83
|
+
i,
|
|
84
|
+
/* @__PURE__ */ a("span", { className: "alea-visually-hidden", role: "status", children: g })
|
|
85
|
+
] });
|
|
86
|
+
}
|
|
87
|
+
function oa({ children: t, isThinking: e, seconds: l, defaultOpen: n, isOpen: i, onOpenChange: r, previewLines: s, className: p }) {
|
|
88
|
+
const h = $(), f = E(), [y, m] = S(n ?? !!e), g = i ?? y, u = (v) => {
|
|
89
|
+
const x = typeof v == "function" ? v(g) : v;
|
|
90
|
+
i === void 0 && m(x), r == null || r(x);
|
|
91
|
+
}, b = R(e);
|
|
92
|
+
L(() => {
|
|
93
|
+
b.current && !e && n === void 0 && u(!1), b.current = e;
|
|
94
|
+
}, [e, n]);
|
|
95
|
+
const w = R(null), d = R(null), N = !!s && !!e && !g;
|
|
96
|
+
return M(() => {
|
|
97
|
+
if (!N || !w.current || !d.current) return;
|
|
98
|
+
const v = parseFloat(getComputedStyle(w.current).lineHeight) || 1, x = Math.max(0, d.current.scrollHeight - w.current.clientHeight);
|
|
99
|
+
w.current.style.setProperty("--alea-preview-shift", `${-Math.ceil(x / v - 0.01) * v}px`);
|
|
100
|
+
}, [t, N]), /* @__PURE__ */ o("div", { className: C("alea-reasoning", p), "data-thinking": e || void 0, "data-open": g || void 0, children: [
|
|
101
|
+
/* @__PURE__ */ o("button", { type: "button", className: "alea-reasoning-toggle alea-focus-ring", "aria-expanded": g, "aria-controls": `${f}-panel`, onClick: () => u((v) => !v), children: [
|
|
102
|
+
/* @__PURE__ */ a(P, { className: "alea-reasoning-icon", "aria-hidden": "true" }),
|
|
103
|
+
/* @__PURE__ */ a("span", { className: e ? "alea-text-shimmer" : void 0, children: e ? `${h.aiThinking}…` : l !== void 0 ? h.aiThoughtFor(l) : h.aiReasoning }),
|
|
104
|
+
/* @__PURE__ */ a(K, { className: "alea-reasoning-chevron", "aria-hidden": "true" })
|
|
105
|
+
] }),
|
|
106
|
+
N && /* @__PURE__ */ a("div", { ref: w, className: "alea-reasoning-preview", "data-lines": s, "aria-hidden": "true", children: /* @__PURE__ */ a("div", { ref: d, className: "alea-reasoning-preview-text", children: t }) }),
|
|
107
|
+
/* @__PURE__ */ a("div", { className: "alea-reasoning-panel", id: `${f}-panel`, role: "region", "aria-label": h.aiReasoning, hidden: !g, children: /* @__PURE__ */ a("div", { className: "alea-reasoning-body", children: t }) })
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
function ca({ children: t, isActive: e = !0, className: l }) {
|
|
111
|
+
return /* @__PURE__ */ o("span", { className: C("alea-thinking-status", l), "data-active": e || void 0, role: "status", children: [
|
|
112
|
+
e ? /* @__PURE__ */ a(P, { className: "alea-thinking-status-icon", "aria-hidden": "true" }) : /* @__PURE__ */ a(O, { className: "alea-thinking-status-icon", "aria-hidden": "true" }),
|
|
113
|
+
/* @__PURE__ */ a(Y, { className: e ? "alea-text-shimmer" : void 0, children: t })
|
|
114
|
+
] });
|
|
115
|
+
}
|
|
116
|
+
function da({ name: t, status: e, summary: l, input: n, output: i, icon: r, className: s }) {
|
|
117
|
+
const p = $(), h = E(), [f, y] = S(!1), m = n !== void 0 || i !== void 0, u = /* @__PURE__ */ o(I, { children: [
|
|
118
|
+
/* @__PURE__ */ a("span", { className: "alea-tool-icon", "aria-hidden": "true", children: r ?? /* @__PURE__ */ a(J, {}) }),
|
|
119
|
+
/* @__PURE__ */ o("span", { className: "alea-tool-text", children: [
|
|
120
|
+
/* @__PURE__ */ a("span", { className: "alea-tool-name", children: t }),
|
|
121
|
+
l && /* @__PURE__ */ a("span", { className: "alea-tool-summary", children: l })
|
|
122
|
+
] }),
|
|
123
|
+
/* @__PURE__ */ o("span", { className: "alea-tool-status", "data-status": e, children: [
|
|
124
|
+
/* @__PURE__ */ a(e === "running" ? Q : e === "done" ? V : X, { "aria-hidden": "true" }),
|
|
125
|
+
/* @__PURE__ */ a("span", { children: p.aiTool[e] })
|
|
126
|
+
] }),
|
|
127
|
+
m && /* @__PURE__ */ a(K, { className: "alea-reasoning-chevron", "aria-hidden": "true" })
|
|
128
|
+
] });
|
|
129
|
+
return /* @__PURE__ */ o("div", { className: C("alea-tool", s), "data-status": e, "data-open": f || void 0, children: [
|
|
130
|
+
m ? /* @__PURE__ */ a("button", { type: "button", className: "alea-tool-head alea-focus-ring", "aria-expanded": f, "aria-controls": `${h}-panel`, onClick: () => y((b) => !b), children: u }) : /* @__PURE__ */ a("div", { className: "alea-tool-head", children: u }),
|
|
131
|
+
/* @__PURE__ */ a("span", { className: "alea-visually-hidden", role: "status", children: `${t}: ${p.aiTool[e]}` }),
|
|
132
|
+
m && /* @__PURE__ */ o("div", { className: "alea-tool-panel", id: `${h}-panel`, hidden: !f, children: [
|
|
133
|
+
n !== void 0 && /* @__PURE__ */ o("div", { children: [
|
|
134
|
+
/* @__PURE__ */ a("p", { className: "alea-tool-label", children: p.aiToolInput }),
|
|
135
|
+
/* @__PURE__ */ a("div", { className: "alea-tool-code", children: n })
|
|
136
|
+
] }),
|
|
137
|
+
i !== void 0 && /* @__PURE__ */ o("div", { children: [
|
|
138
|
+
/* @__PURE__ */ a("p", { className: "alea-tool-label", children: p.aiToolOutput }),
|
|
139
|
+
/* @__PURE__ */ a("div", { className: "alea-tool-code", children: i })
|
|
140
|
+
] })
|
|
141
|
+
] })
|
|
142
|
+
] });
|
|
143
|
+
}
|
|
144
|
+
const U = (t) => {
|
|
145
|
+
try {
|
|
146
|
+
return new URL(t).hostname.replace(/^www\./, "");
|
|
147
|
+
} catch {
|
|
148
|
+
return t;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
function ua({ sources: t, className: e }) {
|
|
152
|
+
const l = $(), n = E();
|
|
153
|
+
return /* @__PURE__ */ o("section", { className: C("alea-sources", e), "aria-labelledby": `${n}-title`, children: [
|
|
154
|
+
/* @__PURE__ */ a("h3", { className: "alea-sources-title", id: `${n}-title`, children: l.aiSources }),
|
|
155
|
+
/* @__PURE__ */ a("ol", { className: "alea-sources-list", children: t.map((i, r) => /* @__PURE__ */ a("li", { id: `alea-source-${i.id}`, style: { "--i": r }, children: /* @__PURE__ */ o("a", { className: "alea-source alea-focus-ring", href: i.href, target: "_blank", rel: "noopener noreferrer", children: [
|
|
156
|
+
/* @__PURE__ */ a("span", { className: "alea-source-n", "aria-hidden": "true", children: r + 1 }),
|
|
157
|
+
/* @__PURE__ */ o("span", { className: "alea-source-text", children: [
|
|
158
|
+
/* @__PURE__ */ a("span", { className: "alea-source-title", children: i.title }),
|
|
159
|
+
/* @__PURE__ */ a("span", { className: "alea-source-host", children: U(i.href) }),
|
|
160
|
+
i.snippet && /* @__PURE__ */ a("span", { className: "alea-source-snippet", children: i.snippet })
|
|
161
|
+
] })
|
|
162
|
+
] }) }, i.id)) })
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
function pa({ n: t, source: e, className: l }) {
|
|
166
|
+
const n = $();
|
|
167
|
+
return /* @__PURE__ */ a("a", { className: C("alea-citation alea-focus-ring", l), href: e.href, target: "_blank", rel: "noopener noreferrer", "aria-label": n.aiSource(t, e.title), title: `${e.title} · ${U(e.href)}`, children: t });
|
|
168
|
+
}
|
|
169
|
+
function ha({ state: t = "idle", size: e = 48, announce: l, className: n }) {
|
|
170
|
+
const i = $();
|
|
171
|
+
return /* @__PURE__ */ o("span", { className: C("alea-orb-ai", n), "data-state": t, style: { "--orb": `${e}px` }, ...l ? { role: "img", "aria-label": i.aiOrb[t] } : { "aria-hidden": !0 }, children: [
|
|
172
|
+
/* @__PURE__ */ a("span", { className: "alea-orb-ai-glow" }),
|
|
173
|
+
/* @__PURE__ */ a("span", { className: "alea-orb-ai-core" }),
|
|
174
|
+
/* @__PURE__ */ a("span", { className: "alea-orb-ai-shine" })
|
|
175
|
+
] });
|
|
176
|
+
}
|
|
177
|
+
export {
|
|
178
|
+
ha as AIOrb,
|
|
179
|
+
pa as Citation,
|
|
180
|
+
na as PromptInput,
|
|
181
|
+
ra as PromptSuggestions,
|
|
182
|
+
oa as Reasoning,
|
|
183
|
+
sa as ResponseActions,
|
|
184
|
+
ua as Sources,
|
|
185
|
+
ca as ThinkingStatus,
|
|
186
|
+
da as ToolCall
|
|
187
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type ReactNode, type CSSProperties } from 'react';
|
|
2
2
|
export interface DockedWindowProps {
|
|
3
3
|
/** The title in the bar; it names the window. */
|
|
4
4
|
title: ReactNode;
|
|
@@ -7,6 +7,8 @@ export interface DockedWindowProps {
|
|
|
7
7
|
/** Content pinned at the bottom: Send, Discard. */
|
|
8
8
|
footer?: ReactNode;
|
|
9
9
|
/** Shows a close button and calls this. */
|
|
10
|
+
onDismiss?: () => void;
|
|
11
|
+
/** @deprecated Use onDismiss. */
|
|
10
12
|
onClose?: () => void;
|
|
11
13
|
/** Minimized to its title bar (controlled). */
|
|
12
14
|
isMinimized?: boolean;
|
|
@@ -26,7 +28,7 @@ export interface DockedWindowProps {
|
|
|
26
28
|
className?: string;
|
|
27
29
|
}
|
|
28
30
|
/** A window docked at the bottom of the screen that people keep open while they work: a message being written, uploads in progress, a chat. It minimizes to its bar, can grow to most of the screen, and several sit side by side in a DockedWindowStack. Not modal: the page stays usable. */
|
|
29
|
-
export declare function DockedWindow({ title, children, footer, onClose, isMinimized, defaultMinimized, onMinimizedChange, allowMaximize, width, height, meta, className }: DockedWindowProps): import("react").JSX.Element;
|
|
31
|
+
export declare function DockedWindow({ title, children, footer, onClose: oldOnClose, onDismiss, isMinimized, defaultMinimized, onMinimizedChange, allowMaximize, width, height, meta, className }: DockedWindowProps): import("react").JSX.Element;
|
|
30
32
|
export interface DockedWindowStackProps {
|
|
31
33
|
/** DockedWindow elements, newest last. */
|
|
32
34
|
children: ReactNode;
|
|
@@ -69,6 +71,8 @@ export interface KeyboardShortcutsProps {
|
|
|
69
71
|
}>;
|
|
70
72
|
/** Open (controlled). Leave out and pass openKey to open it from the keyboard. */
|
|
71
73
|
isOpen?: boolean;
|
|
74
|
+
/** Open at first (uncontrolled). */
|
|
75
|
+
defaultOpen?: boolean;
|
|
72
76
|
/** Called when it opens or closes. */
|
|
73
77
|
onOpenChange?: (open: boolean) => void;
|
|
74
78
|
/** A key that opens it from anywhere (outside text fields). Default "?". */
|
|
@@ -77,9 +81,13 @@ export interface KeyboardShortcutsProps {
|
|
|
77
81
|
trigger?: ReactNode;
|
|
78
82
|
/** The title. Default "Keyboard shortcuts". */
|
|
79
83
|
title?: ReactNode;
|
|
84
|
+
/** Extra class names for the dialog. */
|
|
85
|
+
className?: string;
|
|
86
|
+
/** Inline style for the dialog. */
|
|
87
|
+
style?: CSSProperties;
|
|
80
88
|
}
|
|
81
89
|
/** Every keyboard shortcut of an app in one searchable dialog, opened with "?" from anywhere. The main modifier shows as each system's own key (⌘ or Ctrl); sequences ("G then I") read as such. */
|
|
82
|
-
export declare
|
|
90
|
+
export declare const KeyboardShortcuts: import("react").ForwardRefExoticComponent<KeyboardShortcutsProps & import("react").RefAttributes<HTMLElement>>;
|
|
83
91
|
export interface AppLauncherItem {
|
|
84
92
|
id: string;
|
|
85
93
|
label: string;
|
|
@@ -100,6 +108,10 @@ export interface AppLauncherProps {
|
|
|
100
108
|
'aria-label'?: string;
|
|
101
109
|
/** Where the grid opens. Default bottom end. */
|
|
102
110
|
placement?: 'bottom end' | 'bottom start' | 'bottom';
|
|
111
|
+
/** Extra class names for the button that opens it. */
|
|
112
|
+
className?: string;
|
|
113
|
+
/** Inline style for the button that opens it. */
|
|
114
|
+
style?: CSSProperties;
|
|
103
115
|
}
|
|
104
116
|
/** The grid of apps behind a button in the header, to jump between the products of a suite. A navigation of links: arrows move in the grid, Tab leaves it. */
|
|
105
|
-
export declare
|
|
117
|
+
export declare const AppLauncher: import("react").ForwardRefExoticComponent<AppLauncherProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as l, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as M, useRef as q, useId as F, useState as P, useMemo as O, useEffect as B } from "react";
|
|
4
|
+
import { DialogTrigger as R } from "react-aria-components";
|
|
5
|
+
import { LayoutGrid as W, Minus as j, Minimize2 as I, Maximize2 as T, X as K } from "lucide-react";
|
|
6
|
+
import { renamed as G } from "../../utils/vocabulary.js";
|
|
7
|
+
import { cx as D } from "../../utils/cx.js";
|
|
8
|
+
import { useControlled as $ } from "../../utils/controlled.js";
|
|
9
|
+
import { IconButton as E } from "../button/Button.js";
|
|
10
|
+
import { Popover as Q, PopoverDialog as U } from "../overlay/Overlay.js";
|
|
11
|
+
import { Modal as X } from "../overlay/Modal.js";
|
|
12
|
+
import { SearchField as Y } from "../field/Field.js";
|
|
13
|
+
import { useStrings as z } from "../../i18n/strings.js";
|
|
14
|
+
import { inertProps as _ } from "../../utils/inert.js";
|
|
15
|
+
function me({ title: n, children: p, footer: c, onClose: h, onDismiss: b, isMinimized: u, defaultMinimized: v = !1, onMinimizedChange: g, allowMaximize: w, width: k = 480, height: N = 420, meta: f, className: x }) {
|
|
16
|
+
const a = z(), r = G("DockedWindow", "onClose", h, "onDismiss", b), d = F(), [o, m] = $(u, v, g), [i, y] = P(!1);
|
|
17
|
+
return /* @__PURE__ */ l(
|
|
18
|
+
"section",
|
|
19
|
+
{
|
|
20
|
+
className: D("alea-dock-win", x),
|
|
21
|
+
role: "dialog",
|
|
22
|
+
"aria-modal": "false",
|
|
23
|
+
"aria-labelledby": `${d}-t`,
|
|
24
|
+
"data-minimized": o || void 0,
|
|
25
|
+
"data-maximized": i || void 0,
|
|
26
|
+
style: { "--dock-w": `${k}px`, "--dock-h": `${N}px` },
|
|
27
|
+
onKeyDown: (S) => {
|
|
28
|
+
S.key === "Escape" && i && (S.stopPropagation(), y(!1));
|
|
29
|
+
},
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ l("header", { className: "alea-dock-bar", children: [
|
|
32
|
+
/* @__PURE__ */ l("button", { type: "button", className: "alea-dock-title alea-focus-ring", id: `${d}-t`, "aria-expanded": !o, "aria-controls": `${d}-c`, onClick: () => {
|
|
33
|
+
m(!o), o || y(!1);
|
|
34
|
+
}, children: [
|
|
35
|
+
/* @__PURE__ */ e("span", { className: "alea-dock-title-text", children: n }),
|
|
36
|
+
f && /* @__PURE__ */ e("span", { className: "alea-dock-meta", children: f })
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ l("div", { className: "alea-dock-tools", children: [
|
|
39
|
+
/* @__PURE__ */ e(E, { size: "sm", variant: "ghost", "aria-label": o ? a.restore : a.minimize, onPress: () => {
|
|
40
|
+
m(!o), y(!1);
|
|
41
|
+
}, children: /* @__PURE__ */ e(j, {}) }),
|
|
42
|
+
w && /* @__PURE__ */ e(E, { size: "sm", variant: "ghost", "aria-label": i ? a.exitMaximize : a.maximize, onPress: () => {
|
|
43
|
+
y(!i), m(!1);
|
|
44
|
+
}, children: i ? /* @__PURE__ */ e(I, {}) : /* @__PURE__ */ e(T, {}) }),
|
|
45
|
+
r && /* @__PURE__ */ e(E, { size: "sm", variant: "ghost", "aria-label": a.close, onPress: r, children: /* @__PURE__ */ e(K, {}) })
|
|
46
|
+
] })
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ l("div", { className: "alea-dock-content", id: `${d}-c`, hidden: o, children: [
|
|
49
|
+
/* @__PURE__ */ e("div", { className: "alea-dock-body", children: p }),
|
|
50
|
+
c && /* @__PURE__ */ e("div", { className: "alea-dock-footer", children: c })
|
|
51
|
+
] })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
function he({ children: n, placement: p = "end", position: c = "fixed", className: h }) {
|
|
57
|
+
return /* @__PURE__ */ e("div", { className: D("alea-dock-stack", h), "data-placement": p, "data-position": c, children: n });
|
|
58
|
+
}
|
|
59
|
+
function pe({ count: n, onClear: p, children: c, label: h, variant: b = "floating", className: u }) {
|
|
60
|
+
const v = z();
|
|
61
|
+
return /* @__PURE__ */ e("div", { className: D("alea-selbar", u), "data-variant": b, "data-visible": n > 0 || void 0, ..._(n === 0), "aria-hidden": n === 0 || void 0, children: /* @__PURE__ */ l("div", { className: "alea-selbar-inner", role: "toolbar", "aria-label": v.selection, onKeyDown: (g) => {
|
|
62
|
+
g.key === "Escape" && p();
|
|
63
|
+
}, children: [
|
|
64
|
+
/* @__PURE__ */ e(E, { size: "sm", variant: "ghost", "aria-label": v.clearSelection, onPress: p, children: /* @__PURE__ */ e(K, {}) }),
|
|
65
|
+
/* @__PURE__ */ e("span", { className: "alea-selbar-count", role: "status", children: n > 0 ? h ? h(n) : v.selectedN(n) : "" }),
|
|
66
|
+
/* @__PURE__ */ e("span", { className: "alea-selbar-sep", "aria-hidden": "true" }),
|
|
67
|
+
/* @__PURE__ */ e("div", { className: "alea-selbar-actions", children: c })
|
|
68
|
+
] }) });
|
|
69
|
+
}
|
|
70
|
+
const H = () => typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent), J = { mod: ["⌘", "Ctrl"], alt: ["⌥", "Alt"], shift: ["⇧", "Shift"], enter: ["↵", "Enter"], up: ["↑", "↑"], down: ["↓", "↓"], left: ["←", "←"], right: ["→", "→"], esc: ["Esc", "Esc"] }, ue = M(function({ groups: p, isOpen: c, defaultOpen: h, onOpenChange: b, openKey: u = "?", trigger: v, title: g, className: w, style: k }, N) {
|
|
71
|
+
const f = z(), [x, a] = $(c, h ?? !1, b), [r, d] = P(""), o = O(H, []);
|
|
72
|
+
B(() => {
|
|
73
|
+
if (!u) return;
|
|
74
|
+
const t = (s) => {
|
|
75
|
+
const A = s.target;
|
|
76
|
+
!(s.key === u || u === "?" && s.shiftKey && s.code === "Slash") || s.metaKey || s.ctrlKey || A.closest('input, textarea, select, [contenteditable="true"]') || (s.preventDefault(), a(!0));
|
|
77
|
+
};
|
|
78
|
+
return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
|
|
79
|
+
}, [u]);
|
|
80
|
+
const m = (t) => {
|
|
81
|
+
var s;
|
|
82
|
+
return ((s = J[t.toLowerCase()]) == null ? void 0 : s[o ? 0 : 1]) ?? t;
|
|
83
|
+
}, i = (t) => Array.isArray(t.keys[0]) ? t.keys : [t.keys], y = r.trim().toLowerCase(), S = p.map((t) => ({ ...t, shortcuts: t.shortcuts.filter((s) => !y || s.label.toLowerCase().includes(y) || i(s).flat().some((A) => m(A).toLowerCase() === y)) })).filter((t) => t.shortcuts.length);
|
|
84
|
+
return /* @__PURE__ */ l(X, { ref: N, className: w, style: k, isOpen: x, onOpenChange: (t) => {
|
|
85
|
+
a(t), t || d("");
|
|
86
|
+
}, trigger: v, title: g ?? f.keyboardShortcuts, size: "lg", placement: "top", fullscreenBelow: "sm", children: [
|
|
87
|
+
/* @__PURE__ */ e(Y, { "aria-label": f.searchShortcuts, placeholder: f.searchShortcuts, value: r, onChange: d, autoFocus: !0 }),
|
|
88
|
+
S.length === 0 ? /* @__PURE__ */ e("p", { className: "alea-kbs-empty", role: "status", children: f.noShortcuts }) : /* @__PURE__ */ e("div", { className: "alea-kbs", children: S.map((t) => /* @__PURE__ */ l("section", { className: "alea-kbs-group", "aria-label": t.title, children: [
|
|
89
|
+
/* @__PURE__ */ e("h3", { className: "alea-kbs-title", children: t.title }),
|
|
90
|
+
/* @__PURE__ */ e("dl", { className: "alea-kbs-list", children: t.shortcuts.map((s) => /* @__PURE__ */ l("div", { className: "alea-kbs-row", children: [
|
|
91
|
+
/* @__PURE__ */ e("dt", { children: s.label }),
|
|
92
|
+
/* @__PURE__ */ e("dd", { children: i(s).map((A, C) => /* @__PURE__ */ l("span", { className: "alea-kbs-combo", children: [
|
|
93
|
+
C > 0 && /* @__PURE__ */ e("span", { className: "alea-kbs-then", children: f.thenKey }),
|
|
94
|
+
A.map((L) => /* @__PURE__ */ e("kbd", { className: "alea-kbd", children: m(L) }, L))
|
|
95
|
+
] }, C)) })
|
|
96
|
+
] }, s.label)) })
|
|
97
|
+
] }, t.title)) })
|
|
98
|
+
] });
|
|
99
|
+
}), fe = M(function({ apps: p, columns: c = 3, moreHref: h, "aria-label": b, placement: u = "bottom end", className: v, style: g }, w) {
|
|
100
|
+
const k = z(), N = q(null), f = (a) => {
|
|
101
|
+
var o;
|
|
102
|
+
N.current = a;
|
|
103
|
+
const r = a == null ? void 0 : a.closest('[role="dialog"]');
|
|
104
|
+
if (!a || !r) return;
|
|
105
|
+
const d = (m) => {
|
|
106
|
+
var i;
|
|
107
|
+
m.target === r && ((i = a.querySelector("a")) == null || i.focus());
|
|
108
|
+
};
|
|
109
|
+
r.addEventListener("focus", d), document.activeElement === r && ((o = a.querySelector("a")) == null || o.focus());
|
|
110
|
+
}, x = (a) => {
|
|
111
|
+
var i;
|
|
112
|
+
const r = Array.from(((i = N.current) == null ? void 0 : i.querySelectorAll("a")) ?? []), d = r.indexOf(document.activeElement);
|
|
113
|
+
if (d < 0) return;
|
|
114
|
+
const o = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: c, ArrowUp: -c }[a.key], m = a.key === "Home" ? 0 : a.key === "End" ? r.length - 1 : o !== void 0 ? d + o : -1;
|
|
115
|
+
m >= 0 && m < r.length && (a.preventDefault(), r[m].focus());
|
|
116
|
+
};
|
|
117
|
+
return /* @__PURE__ */ l(R, { children: [
|
|
118
|
+
/* @__PURE__ */ e(E, { ref: w, className: v, style: g, "aria-label": b ?? k.apps, variant: "ghost", children: /* @__PURE__ */ e(W, {}) }),
|
|
119
|
+
/* @__PURE__ */ e(Q, { placement: u, className: "alea-popover alea-apps-popover", children: /* @__PURE__ */ e(U, { "aria-label": b ?? k.apps, children: /* @__PURE__ */ l("nav", { "aria-label": b ?? k.apps, children: [
|
|
120
|
+
/* @__PURE__ */ e("ul", { ref: f, className: "alea-apps", style: { gridTemplateColumns: `repeat(${c}, minmax(0, 1fr))` }, onKeyDown: x, children: p.map((a) => /* @__PURE__ */ e("li", { children: /* @__PURE__ */ l("a", { href: a.href, className: "alea-app alea-focus-ring", children: [
|
|
121
|
+
/* @__PURE__ */ e("span", { className: "alea-app-icon", "aria-hidden": "true", style: a.color ? { background: a.color } : void 0, children: a.icon }),
|
|
122
|
+
/* @__PURE__ */ e("span", { className: "alea-app-label", children: a.label })
|
|
123
|
+
] }) }, a.id)) }),
|
|
124
|
+
h && /* @__PURE__ */ e("a", { href: h, className: "alea-apps-more alea-focus-ring", children: k.moreApps })
|
|
125
|
+
] }) }) })
|
|
126
|
+
] });
|
|
127
|
+
});
|
|
128
|
+
export {
|
|
129
|
+
fe as AppLauncher,
|
|
130
|
+
me as DockedWindow,
|
|
131
|
+
he as DockedWindowStack,
|
|
132
|
+
ue as KeyboardShortcuts,
|
|
133
|
+
pe as SelectionBar
|
|
134
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type ButtonProps as RACButtonProps, type ToggleButtonProps as RACToggleButtonProps, type ToggleButtonGroupProps, type Key } from 'react-aria-components';
|
|
3
|
-
import type { Responsive } from '../../utils/responsive';
|
|
3
|
+
import type { Responsive } from '../../utils/responsive.js';
|
|
4
4
|
export type ButtonVariant = 'primary' | 'secondary' | 'soft' | 'ghost' | 'text' | 'dashed' | 'danger' | 'link';
|
|
5
5
|
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
6
|
export type ButtonTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger' | 'info';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as e, jsxs as p, Fragment as Y } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as G, useRef as A, useEffect as I, useState as Z } from "react";
|
|
4
|
+
import { useRipple as _ } from "@alea-design/motion";
|
|
5
|
+
import { Link as C, Button as V, composeRenderProps as ee, ToggleButtonGroup as ne, ToggleButton as W, SelectionIndicator as te } from "react-aria-components";
|
|
6
|
+
import { withBase as b } from "../../utils/cx.js";
|
|
7
|
+
import { useMergedRef as ae } from "../../utils/refs.js";
|
|
8
|
+
import { Spinner as P } from "../feedback/Spinner.js";
|
|
9
|
+
import { useStrings as q } from "../../i18n/strings.js";
|
|
10
|
+
import { responsiveAttrs as X } from "../../utils/responsive.js";
|
|
11
|
+
import { TooltipTrigger as oe, Tooltip as re } from "../overlay/Overlay.js";
|
|
12
|
+
import { buttonIcon as M } from "../icon/icon-contexts.js";
|
|
13
|
+
const J = G(function({ variant: a = "primary", tone: t, size: c, shape: m, iconStart: d, iconEnd: i, isLoading: o, loadingLabel: r, loadingPosition: f = "center", fullWidth: N, justify: v, shortcut: u, href: g, target: k, rel: L, isSuccess: R, successLabel: y, ripple: w, className: j, children: x, ...S }, O) {
|
|
14
|
+
const T = q();
|
|
15
|
+
y ?? (y = T.done);
|
|
16
|
+
const E = A(null), D = ae(O, E), { onPointerDown: $ } = _();
|
|
17
|
+
I(() => {
|
|
18
|
+
const n = E.current;
|
|
19
|
+
if (!w || !n) return;
|
|
20
|
+
const s = (B) => $({ currentTarget: n, clientX: B.clientX, clientY: B.clientY });
|
|
21
|
+
return n.addEventListener("pointerdown", s), () => n.removeEventListener("pointerdown", s);
|
|
22
|
+
}, [w, $]);
|
|
23
|
+
const h = o && (r != null || f !== "center"), H = /* @__PURE__ */ e("span", { className: "alea-button-icon alea-button-inline-spinner", children: /* @__PURE__ */ e(P, { size: "sm", "aria-label": T.loading }) }), F = (n, s) => /* @__PURE__ */ p(Y, { children: [
|
|
24
|
+
s && !h && /* @__PURE__ */ e("span", { className: "alea-button-spinner", children: /* @__PURE__ */ e(P, { size: "sm", "aria-label": T.loading }) }),
|
|
25
|
+
R && !s ? /* @__PURE__ */ p("span", { className: "alea-button-content alea-success-in", "aria-live": "polite", children: [
|
|
26
|
+
/* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", children: /* @__PURE__ */ e("svg", { className: "alea-success-check", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M5 12.5l4.5 4.5L19 7.5" }) }) }),
|
|
27
|
+
y != null && y !== !1 && /* @__PURE__ */ e("span", { className: "alea-button-label", children: y })
|
|
28
|
+
] }) : /* @__PURE__ */ p("span", { className: "alea-button-content", "data-hidden": s && !h || void 0, children: [
|
|
29
|
+
h && f !== "end" ? H : d && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...M(a, t), children: d }),
|
|
30
|
+
(h && r != null ? r : n) != null && n !== !1 && /* @__PURE__ */ e("span", { className: "alea-button-label", children: h && r != null ? r : n }),
|
|
31
|
+
h && f === "end" ? H : i && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...M(a, t), children: i }),
|
|
32
|
+
u && /* @__PURE__ */ e("kbd", { className: "alea-button-kbd", "aria-hidden": "true", children: u })
|
|
33
|
+
] })
|
|
34
|
+
] }), K = {
|
|
35
|
+
"data-success": R || void 0,
|
|
36
|
+
"data-ripple": w || void 0,
|
|
37
|
+
"data-variant": a,
|
|
38
|
+
"data-tone": t,
|
|
39
|
+
...X("size", c, "md"),
|
|
40
|
+
...X("full-width", N),
|
|
41
|
+
"data-shape": m,
|
|
42
|
+
"data-justify": v
|
|
43
|
+
}, z = typeof u == "string" ? u.replace("⌘", "Meta+").replace("⇧", "Shift+").replace("⌥", "Alt+").replace("⌃", "Control+") : void 0;
|
|
44
|
+
if (I(() => {
|
|
45
|
+
const n = E.current;
|
|
46
|
+
n && (z ? n.setAttribute("aria-keyshortcuts", z) : n.removeAttribute("aria-keyshortcuts"));
|
|
47
|
+
}, [z]), g) {
|
|
48
|
+
const { onPress: n, isDisabled: s, autoFocus: B, id: Q, style: U } = S;
|
|
49
|
+
return /* @__PURE__ */ e(
|
|
50
|
+
C,
|
|
51
|
+
{
|
|
52
|
+
href: g,
|
|
53
|
+
target: k,
|
|
54
|
+
rel: L,
|
|
55
|
+
onPress: n,
|
|
56
|
+
isDisabled: s,
|
|
57
|
+
autoFocus: B,
|
|
58
|
+
id: Q,
|
|
59
|
+
style: U,
|
|
60
|
+
ref: D,
|
|
61
|
+
...K,
|
|
62
|
+
"aria-label": S["aria-label"],
|
|
63
|
+
className: b("alea-button alea-focus-ring", j),
|
|
64
|
+
children: F(x, !1)
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return /* @__PURE__ */ e(V, { ...S, ...K, ref: D, isPending: o, className: b("alea-button alea-focus-ring", j), children: ee(x, (n, { isPending: s }) => F(n, s)) });
|
|
69
|
+
}), ge = G(function({ shape: a = "circle", variant: t = "ghost", tooltip: c, children: m, className: d, ...i }, o) {
|
|
70
|
+
const r = /* @__PURE__ */ e(J, { ...i, ref: o, variant: t, "data-icon-shape": a, "data-icon-only": !0, className: b("alea-icon-button", d), children: /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...M(t, i.tone), children: m }) });
|
|
71
|
+
return c ? /* @__PURE__ */ p(oe, { delay: 400, children: [
|
|
72
|
+
r,
|
|
73
|
+
/* @__PURE__ */ e(re, { children: i["aria-label"] })
|
|
74
|
+
] }) : r;
|
|
75
|
+
});
|
|
76
|
+
function Ne({ items: l, value: a, defaultValue: t, onChange: c, size: m = "md", className: d, ...i }) {
|
|
77
|
+
return /* @__PURE__ */ e(
|
|
78
|
+
ne,
|
|
79
|
+
{
|
|
80
|
+
...i,
|
|
81
|
+
selectionMode: "single",
|
|
82
|
+
disallowEmptySelection: !0,
|
|
83
|
+
selectedKeys: a !== void 0 ? [a] : void 0,
|
|
84
|
+
defaultSelectedKeys: t !== void 0 ? [t] : a === void 0 && l[0] ? [l[0].id] : void 0,
|
|
85
|
+
onSelectionChange: (o) => {
|
|
86
|
+
const r = [...o][0];
|
|
87
|
+
r !== void 0 && (c == null || c(r));
|
|
88
|
+
},
|
|
89
|
+
"data-size": m,
|
|
90
|
+
className: b("alea-segmented", d),
|
|
91
|
+
children: l.map((o) => /* @__PURE__ */ p(W, { id: o.id, isDisabled: o.isDisabled, className: "alea-segmented-item alea-focus-ring", children: [
|
|
92
|
+
/* @__PURE__ */ e("span", { className: "alea-segmented-label", children: o.label }),
|
|
93
|
+
/* @__PURE__ */ e(te, { className: "alea-sel-indicator" })
|
|
94
|
+
] }, String(o.id)))
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function ve({ size: l = "md", className: a, ...t }) {
|
|
99
|
+
return /* @__PURE__ */ e(W, { ...t, "data-size": l, className: b("alea-toggle-button alea-focus-ring", a) });
|
|
100
|
+
}
|
|
101
|
+
function ye({ onConfirm: l, duration: a = 1200, hint: t, variant: c = "danger", className: m, children: d, ...i }) {
|
|
102
|
+
const o = q();
|
|
103
|
+
t ?? (t = o.pressAndHold);
|
|
104
|
+
const [r, f] = Z(!1), N = A(null), v = A(`alea-hold-${Math.random().toString(36).slice(2, 8)}`).current;
|
|
105
|
+
return I(() => {
|
|
106
|
+
const u = N.current;
|
|
107
|
+
if (!u) return;
|
|
108
|
+
const g = (k) => {
|
|
109
|
+
k.animationName === "alea-hold" && (f(!1), l());
|
|
110
|
+
};
|
|
111
|
+
return u.addEventListener("animationend", g), () => u.removeEventListener("animationend", g);
|
|
112
|
+
}, [l]), /* @__PURE__ */ p(Y, { children: [
|
|
113
|
+
/* @__PURE__ */ e(
|
|
114
|
+
J,
|
|
115
|
+
{
|
|
116
|
+
...i,
|
|
117
|
+
ref: N,
|
|
118
|
+
variant: c,
|
|
119
|
+
"data-holding": r || void 0,
|
|
120
|
+
"aria-describedby": v,
|
|
121
|
+
onPressStart: () => f(!0),
|
|
122
|
+
onPressEnd: () => f(!1),
|
|
123
|
+
className: b("alea-hold", m),
|
|
124
|
+
style: { "--alea-hold-duration": `${a}ms` },
|
|
125
|
+
children: d
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
/* @__PURE__ */ e("span", { id: v, className: "alea-visually-hidden", children: t })
|
|
129
|
+
] });
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
J as Button,
|
|
133
|
+
ye as HoldButton,
|
|
134
|
+
ge as IconButton,
|
|
135
|
+
Ne as SegmentedControl,
|
|
136
|
+
ve as ToggleButton
|
|
137
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type ToolbarProps as RACToolbarProps, type Key } from 'react-aria-components';
|
|
3
|
-
import { type ButtonProps } from './Button';
|
|
3
|
+
import { type ButtonProps } from './Button.js';
|
|
4
4
|
export interface ButtonGroupProps {
|
|
5
5
|
/** What the buttons do together, for screen readers ("Text alignment"). */
|
|
6
6
|
'aria-label'?: string;
|