@lanfermann/ui 0.4.0 → 0.6.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/dist/components/action-bar/action-bar.d.ts +59 -0
- package/dist/components/action-bar/action-bar.js +116 -0
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +3 -17
- package/dist/components/alert-dialog/alert-dialog.d.ts +1 -1
- package/dist/components/app-shell/app-shell.d.ts +33 -0
- package/dist/components/app-shell/app-shell.js +93 -0
- package/dist/components/attachment/attachment.d.ts +46 -0
- package/dist/components/attachment/attachment.js +222 -0
- package/dist/components/attachment/kinds.d.ts +7 -0
- package/dist/components/attachment/kinds.js +100 -0
- package/dist/components/avatar/avatar.d.ts +14 -4
- package/dist/components/avatar/avatar.js +57 -13
- package/dist/components/avatar-group/avatar-group.d.ts +33 -0
- package/dist/components/avatar-group/avatar-group.js +110 -0
- package/dist/components/avatar-group/people.d.ts +12 -0
- package/dist/components/avatar-group/people.js +24 -0
- package/dist/components/badge/badge.d.ts +9 -3
- package/dist/components/badge/badge.js +21 -6
- package/dist/components/banner/banner.d.ts +39 -0
- package/dist/components/banner/banner.js +149 -0
- package/dist/components/card/card.d.ts +11 -3
- package/dist/components/card/card.js +18 -4
- package/dist/components/checkbox-card/checkbox-card.d.ts +21 -0
- package/dist/components/checkbox-card/checkbox-card.js +49 -0
- package/dist/components/chip/chip-group.d.ts +15 -0
- package/dist/components/chip/chip-group.js +44 -0
- package/dist/components/chip/chip-variants.d.ts +6 -0
- package/dist/components/chip/chip-variants.js +28 -0
- package/dist/components/chip/chip.d.ts +39 -0
- package/dist/components/chip/chip.js +71 -0
- package/dist/components/code-block/code-block-live.d.ts +13 -1
- package/dist/components/code-block/code-block-live.js +10 -4
- package/dist/components/code-block/code-block.d.ts +1 -0
- package/dist/components/code-block/code-copy.d.ts +3 -11
- package/dist/components/code-block/code-copy.js +15 -62
- package/dist/components/code-block/code-keys.js +10 -22
- package/dist/components/code-block/code-lines-live.d.ts +7 -0
- package/dist/components/code-block/code-lines-live.js +167 -0
- package/dist/components/code-block/code-lines-view.d.ts +1 -0
- package/dist/components/code-block/code-lines-view.js +50 -18
- package/dist/components/code-block/code-lines.d.ts +3 -0
- package/dist/components/code-block/code-tabs.d.ts +1 -0
- package/dist/components/code-block/highlight.d.ts +1 -0
- package/dist/components/code-block/line-diff.js +135 -0
- package/dist/components/combobox/combobox.d.ts +50 -2
- package/dist/components/combobox/combobox.js +178 -9
- package/dist/components/command/command.d.ts +131 -0
- package/dist/components/command/command.js +335 -0
- package/dist/components/consent/consent-card.js +365 -0
- package/dist/components/consent/consent-embed.d.ts +21 -0
- package/dist/components/consent/consent-embed.js +111 -0
- package/dist/components/consent/consent-labels.d.ts +70 -0
- package/dist/components/consent/consent-labels.js +61 -0
- package/dist/components/consent/consent-record.d.ts +95 -0
- package/dist/components/consent/consent-record.js +112 -0
- package/dist/components/consent/consent-store.d.ts +26 -0
- package/dist/components/consent/consent-store.js +240 -0
- package/dist/components/consent/consent.d.ts +86 -0
- package/dist/components/consent/consent.js +306 -0
- package/dist/components/container/container.d.ts +1 -1
- package/dist/components/context-menu/context-menu.d.ts +23 -0
- package/dist/components/context-menu/context-menu.js +50 -0
- package/dist/components/conversation/conversation.d.ts +45 -0
- package/dist/components/conversation/conversation.js +295 -0
- package/dist/components/conversation/stick.js +23 -0
- package/dist/components/copy-button/copy-button.d.ts +50 -0
- package/dist/components/copy-button/copy-button.js +65 -0
- package/dist/components/copy-page/copy-page.js +7 -17
- package/dist/components/copy-pill/copy-pill.js +1 -1
- package/dist/components/description-list/description-list.d.ts +32 -0
- package/dist/components/description-list/description-list.js +51 -0
- package/dist/components/empty/empty.d.ts +38 -0
- package/dist/components/empty/empty.js +57 -0
- package/dist/components/field/field.js +1 -1
- package/dist/components/file-upload/file-upload.d.ts +96 -0
- package/dist/components/file-upload/file-upload.js +347 -0
- package/dist/components/file-upload/files.d.ts +39 -0
- package/dist/components/file-upload/files.js +74 -0
- package/dist/components/grow/grow.d.ts +15 -3
- package/dist/components/grow/grow.js +31 -10
- package/dist/components/heading/heading.d.ts +1 -1
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/message/message.d.ts +73 -0
- package/dist/components/message/message.js +196 -0
- package/dist/components/otp-field/otp-field.d.ts +37 -0
- package/dist/components/otp-field/otp-field.js +126 -0
- package/dist/components/pagination/pagination.d.ts +50 -0
- package/dist/components/pagination/pagination.js +188 -0
- package/dist/components/prompt-input/keys.js +15 -0
- package/dist/components/prompt-input/prompt-input.d.ts +89 -0
- package/dist/components/prompt-input/prompt-input.js +331 -0
- package/dist/components/radio-card/radio-card.d.ts +23 -0
- package/dist/components/radio-card/radio-card.js +48 -0
- package/dist/components/rolling-number/rolling-number.d.ts +30 -0
- package/dist/components/rolling-number/rolling-number.js +149 -0
- package/dist/components/seam/seam.d.ts +1 -1
- package/dist/components/secret-field/secret-field.d.ts +53 -0
- package/dist/components/secret-field/secret-field.js +121 -0
- package/dist/components/section/section.d.ts +1 -1
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.js +1 -1
- package/dist/components/shortcut/shortcut.d.ts +46 -0
- package/dist/components/shortcut/shortcut.js +87 -0
- package/dist/components/sidebar/sidebar-context.js +16 -0
- package/dist/components/sidebar/sidebar.d.ts +161 -0
- package/dist/components/sidebar/sidebar.js +588 -0
- package/dist/components/site-header/site-header.js +1 -1
- package/dist/components/skeleton/loaded.d.ts +21 -0
- package/dist/components/skeleton/loaded.js +57 -0
- package/dist/components/skeleton/skeleton.d.ts +43 -0
- package/dist/components/skeleton/skeleton.js +48 -0
- package/dist/components/sources/source-list.d.ts +17 -0
- package/dist/components/sources/source-list.js +26 -0
- package/dist/components/sources/sources.d.ts +45 -0
- package/dist/components/sources/sources.js +167 -0
- package/dist/components/stat/stat.d.ts +57 -0
- package/dist/components/stat/stat.js +110 -0
- package/dist/components/steps/steps.d.ts +57 -0
- package/dist/components/steps/steps.js +131 -0
- package/dist/components/table/table.d.ts +18 -9
- package/dist/components/table/table.js +21 -13
- package/dist/components/text/text.d.ts +1 -1
- package/dist/components/theme-switch/theme-switch.js +1 -1
- package/dist/components/time-field/time-field.js +1 -1
- package/dist/components/timeline/timeline.d.ts +45 -0
- package/dist/components/timeline/timeline.js +86 -0
- package/dist/components/toast/toast.js +10 -26
- package/dist/components/toggle/toggle.d.ts +24 -0
- package/dist/components/toggle/toggle.js +53 -0
- package/dist/components/toggle-group/toggle-group.d.ts +27 -0
- package/dist/components/toggle-group/toggle-group.js +38 -0
- package/dist/components/toolbar/toolbar-context.js +12 -0
- package/dist/components/toolbar/toolbar.d.ts +45 -0
- package/dist/components/toolbar/toolbar.js +92 -0
- package/dist/components/trace/trace.d.ts +2 -1
- package/dist/components/trace/trace.js +14 -26
- package/dist/index.d.ts +46 -3
- package/dist/index.js +44 -3
- package/dist/internal/arriving-pieces.js +56 -0
- package/dist/internal/arriving.js +171 -0
- package/dist/internal/avatar-cut.d.ts +15 -0
- package/dist/internal/avatar-cut.js +83 -0
- package/dist/internal/choice-card.d.ts +15 -0
- package/dist/internal/choice-card.js +65 -0
- package/dist/internal/clipboard.js +37 -0
- package/dist/internal/copy.js +58 -0
- package/dist/internal/field.js +24 -4
- package/dist/internal/glyphs.js +26 -1
- package/dist/internal/live-list.js +41 -0
- package/dist/internal/number-places.js +156 -0
- package/dist/internal/picker-sheet.js +1 -1
- package/dist/internal/presence-dot.js +24 -0
- package/dist/internal/presence.js +104 -0
- package/dist/internal/rail-mark.d.ts +3 -0
- package/dist/internal/rail-mark.js +33 -0
- package/dist/internal/status-icon.js +22 -0
- package/dist/internal/travelling-mark.js +204 -0
- package/dist/lib/cn.js +4 -0
- package/dist/lib/shortcut.d.ts +11 -0
- package/dist/lib/shortcut.js +165 -0
- package/package.json +1 -1
- package/src/styles/action-bar.css +28 -0
- package/src/styles/assistant.css +83 -0
- package/src/styles/avatar.css +24 -0
- package/src/styles/code.css +89 -1
- package/src/styles/consent.css +65 -0
- package/src/styles/copy.css +12 -11
- package/src/styles/depth.css +46 -2
- package/src/styles/marks.css +20 -2
- package/src/styles/rail.css +49 -0
- package/src/styles/rolling-number.css +94 -0
- package/src/styles/steps.css +98 -0
- package/src/styles/timeline.css +48 -0
- package/src/styles/travel.css +36 -0
- package/src/styles.css +9 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ButtonProps } from "../button/button.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
export type ActionBarProps = Omit<ComponentProps<"div">, "children"> & {
|
|
4
|
+
/** There is a selection: the bar shows. */
|
|
5
|
+
open: boolean;
|
|
6
|
+
/** How many are selected. */
|
|
7
|
+
count: number;
|
|
8
|
+
/** The word after the count: "ausgewählt". */
|
|
9
|
+
countLabel?: (count: number) => ReactNode;
|
|
10
|
+
/** Called by the cross and by Escape. Take the selection back here. */
|
|
11
|
+
onClear: () => void;
|
|
12
|
+
/** The name of the cross. */
|
|
13
|
+
clearLabel?: string;
|
|
14
|
+
/** The name of the bar for assistive tech. */
|
|
15
|
+
"aria-label"?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Where it stands. `fixed` (the default): at the foot of the window, in its middle.
|
|
18
|
+
* `sticky`: at the foot of the box it is the last child of, and of the window while that box
|
|
19
|
+
* is taller. For the page beside a sidebar, where the middle of the window is not the middle
|
|
20
|
+
* of the list; give that box `flex flex-col`, so the bar stands at its foot when the list is
|
|
21
|
+
* short. It keeps a place of its own at the end of that box: scrolled to the end, it stands
|
|
22
|
+
* under the list and not on its last row. `absolute`: at the foot of its nearest positioned
|
|
23
|
+
* box.
|
|
24
|
+
*/
|
|
25
|
+
position?: "fixed" | "sticky" | "absolute";
|
|
26
|
+
/**
|
|
27
|
+
* What it is cut from. `ink` (the default): a dark sheet, the way a toast speaks. `paper`: a
|
|
28
|
+
* light one. Take the one that stands apart from the page it floats over: the dark sheet
|
|
29
|
+
* over a light page, the light sheet over a dark one.
|
|
30
|
+
*/
|
|
31
|
+
ground?: "ink" | "paper";
|
|
32
|
+
/** The actions: `ActionBarButton`s. */
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* What can be done with the rows that are selected in a list: it rises at the foot of the
|
|
37
|
+
* window with the first row that is ticked, counts them, and leaves with the last. It is the
|
|
38
|
+
* system speaking about the selection, so by default it speaks on Ink, as a toast does; over a
|
|
39
|
+
* dark page it can be the light sheet instead (`ground="paper"`).
|
|
40
|
+
*
|
|
41
|
+
* Put the actions inside as `ActionBarButton`s, worded like buttons ("Als PDF herunterladen").
|
|
42
|
+
* Two or three; what is rare belongs in a `Menu` behind the last one. The bar is one stop for
|
|
43
|
+
* the Tab key, and the arrow keys move between its actions. Escape, pressed inside it, takes
|
|
44
|
+
* the selection back, and so does the cross.
|
|
45
|
+
*
|
|
46
|
+
* It does not take the focus when it appears: whoever is ticking rows keeps doing that.
|
|
47
|
+
*/
|
|
48
|
+
export declare function ActionBar({ open, count, countLabel, onClear, clearLabel, "aria-label": label, position, ground, className, children, ...props }: ActionBarProps): import("react").JSX.Element;
|
|
49
|
+
/** `Omit` that keeps a union a union: a button is named either by its words or by `aria-label`. */
|
|
50
|
+
type Without<Props, Key extends PropertyKey> = Props extends unknown ? Omit<Props, Key> : never;
|
|
51
|
+
export type ActionBarButtonProps = Without<ButtonProps, "variant" | "size">;
|
|
52
|
+
/**
|
|
53
|
+
* One action on the selection: a quiet button on the bar, with a 14px symbol before its words
|
|
54
|
+
* if it helps. Where the bar is narrow (a phone), `iconOnly` leaves the symbol alone and
|
|
55
|
+
* `aria-label` names it. The one that cannot be undone goes last, and is confirmed in an
|
|
56
|
+
* `AlertDialog`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function ActionBarButton({ className, disabled, ...props }: ActionBarButtonProps): import("react").JSX.Element;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { RollingNumber } from "../rolling-number/rolling-number.js";
|
|
4
|
+
import { ScrollFade } from "../scroll-fade/scroll-fade.js";
|
|
5
|
+
import { CloseGlyph } from "../../internal/glyphs.js";
|
|
6
|
+
import { cn } from "../../lib/cn.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Toolbar } from "@base-ui/react/toolbar";
|
|
9
|
+
import { useRef, useState } from "react";
|
|
10
|
+
// src/components/action-bar/action-bar.tsx
|
|
11
|
+
const places = {
|
|
12
|
+
fixed: "fixed inset-x-0 bottom-0",
|
|
13
|
+
absolute: "absolute inset-x-0 bottom-0",
|
|
14
|
+
sticky: "sticky bottom-0 mt-auto"
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* What can be done with the rows that are selected in a list: it rises at the foot of the
|
|
18
|
+
* window with the first row that is ticked, counts them, and leaves with the last. It is the
|
|
19
|
+
* system speaking about the selection, so by default it speaks on Ink, as a toast does; over a
|
|
20
|
+
* dark page it can be the light sheet instead (`ground="paper"`).
|
|
21
|
+
*
|
|
22
|
+
* Put the actions inside as `ActionBarButton`s, worded like buttons ("Als PDF herunterladen").
|
|
23
|
+
* Two or three; what is rare belongs in a `Menu` behind the last one. The bar is one stop for
|
|
24
|
+
* the Tab key, and the arrow keys move between its actions. Escape, pressed inside it, takes
|
|
25
|
+
* the selection back, and so does the cross.
|
|
26
|
+
*
|
|
27
|
+
* It does not take the focus when it appears: whoever is ticking rows keeps doing that.
|
|
28
|
+
*/
|
|
29
|
+
function ActionBar({ open, count, countLabel = () => "ausgewählt", onClear, clearLabel = "Auswahl aufheben", "aria-label": label = "Auswahl", position = "fixed", ground = "ink", className, children, ...props }) {
|
|
30
|
+
const [last, setLast] = useState(count);
|
|
31
|
+
const [was, setWas] = useState(open);
|
|
32
|
+
const [arrivals, setArrivals] = useState(0);
|
|
33
|
+
if (open && count !== last) setLast(count);
|
|
34
|
+
if (open !== was) {
|
|
35
|
+
setWas(open);
|
|
36
|
+
if (open) setArrivals(arrivals + 1);
|
|
37
|
+
}
|
|
38
|
+
const cameFrom = useRef(null);
|
|
39
|
+
const clear = (bar) => {
|
|
40
|
+
if (bar?.contains(document.activeElement) && cameFrom.current?.isConnected) cameFrom.current.focus();
|
|
41
|
+
onClear();
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ jsx("div", {
|
|
44
|
+
"data-slot": "action-bar-place",
|
|
45
|
+
className: cn("pointer-events-none z-40 flex justify-center px-2 pb-[max(1rem,env(safe-area-inset-bottom))]", places[position]),
|
|
46
|
+
children: /* @__PURE__ */ jsxs(Toolbar.Root, {
|
|
47
|
+
"data-slot": "action-bar",
|
|
48
|
+
"data-theme": ground,
|
|
49
|
+
"data-open": open ? "" : void 0,
|
|
50
|
+
"aria-label": label,
|
|
51
|
+
inert: !open,
|
|
52
|
+
onFocus: (event) => {
|
|
53
|
+
const from = event.relatedTarget;
|
|
54
|
+
if (from instanceof HTMLElement && !event.currentTarget.contains(from)) cameFrom.current = from;
|
|
55
|
+
},
|
|
56
|
+
onKeyDown: (event) => {
|
|
57
|
+
if (event.key === "Escape") clear(event.currentTarget);
|
|
58
|
+
},
|
|
59
|
+
className: cn("pointer-events-auto action-bar-motion flex max-w-full items-center gap-1 rounded-xl bg-sheet py-1.5 pr-1.5 pl-3.5 text-control text-fg depth-floating", className),
|
|
60
|
+
...props,
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsxs("p", {
|
|
63
|
+
"data-slot": "action-bar-count",
|
|
64
|
+
"aria-live": "polite",
|
|
65
|
+
"aria-atomic": "true",
|
|
66
|
+
className: "flex shrink-0 items-center gap-1.5 pr-2 font-medium whitespace-nowrap",
|
|
67
|
+
children: [/* @__PURE__ */ jsx(RollingNumber, { value: open ? count : last }, arrivals), /* @__PURE__ */ jsx("span", {
|
|
68
|
+
className: "text-fg-body",
|
|
69
|
+
children: countLabel(open ? count : last)
|
|
70
|
+
})]
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx(Toolbar.Separator, {
|
|
73
|
+
"data-slot": "action-bar-separator",
|
|
74
|
+
className: "mx-1 h-5 w-px shrink-0 bg-hairline"
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx(ScrollFade, {
|
|
77
|
+
axis: "x",
|
|
78
|
+
"data-slot": "action-bar-actions",
|
|
79
|
+
className: "-m-1 flex min-w-0 [scrollbar-width:none] items-center gap-0.5 p-1",
|
|
80
|
+
children
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ jsx(Toolbar.Button, {
|
|
83
|
+
"data-slot": "action-bar-clear",
|
|
84
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
85
|
+
iconOnly: true,
|
|
86
|
+
size: "sm",
|
|
87
|
+
variant: "quiet",
|
|
88
|
+
"aria-label": clearLabel,
|
|
89
|
+
className: "ml-1 shrink-0 text-fg-muted"
|
|
90
|
+
}),
|
|
91
|
+
onClick: (event) => clear(event.currentTarget.closest("[data-slot=\"action-bar\"]")),
|
|
92
|
+
children: /* @__PURE__ */ jsx(CloseGlyph, {})
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* One action on the selection: a quiet button on the bar, with a 14px symbol before its words
|
|
100
|
+
* if it helps. Where the bar is narrow (a phone), `iconOnly` leaves the symbol alone and
|
|
101
|
+
* `aria-label` names it. The one that cannot be undone goes last, and is confirmed in an
|
|
102
|
+
* `AlertDialog`.
|
|
103
|
+
*/
|
|
104
|
+
function ActionBarButton({ className, disabled, ...props }) {
|
|
105
|
+
return /* @__PURE__ */ jsx(Toolbar.Button, {
|
|
106
|
+
"data-slot": "action-bar-button",
|
|
107
|
+
disabled,
|
|
108
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
109
|
+
size: "sm",
|
|
110
|
+
variant: "quiet",
|
|
111
|
+
...props,
|
|
112
|
+
className: cn("shrink-0", className)
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export { ActionBar, ActionBarButton };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IconSvgElement } from "../icon/icon.js";
|
|
2
|
-
import { VariantProps } from "class-variance-authority";
|
|
3
2
|
import { ComponentProps } from "react";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
4
|
declare const alertVariants: (props?: ({
|
|
5
5
|
tone?: "neutral" | "info" | "success" | "warning" | "danger" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Icon } from "../icon/icon.js";
|
|
2
|
+
import { statusIconTone, statusIcons } from "../../internal/status-icon.js";
|
|
2
3
|
import { cn } from "../../lib/cn.js";
|
|
3
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { Alert02Icon, AlertCircleIcon, CheckmarkCircle02Icon, InformationCircleIcon } from "@hugeicons/core-free-icons";
|
|
5
5
|
import { cva } from "class-variance-authority";
|
|
6
6
|
// src/components/alert/alert.tsx
|
|
7
7
|
const alertVariants = cva("grid grid-cols-[auto_1fr] items-start gap-x-3 rounded-lg px-4 py-3 text-base text-fg-body inset-ring forced-colors:outline", {
|
|
@@ -14,20 +14,6 @@ const alertVariants = cva("grid grid-cols-[auto_1fr] items-start gap-x-3 rounded
|
|
|
14
14
|
} },
|
|
15
15
|
defaultVariants: { tone: "neutral" }
|
|
16
16
|
});
|
|
17
|
-
const icons = {
|
|
18
|
-
neutral: InformationCircleIcon,
|
|
19
|
-
info: InformationCircleIcon,
|
|
20
|
-
success: CheckmarkCircle02Icon,
|
|
21
|
-
warning: Alert02Icon,
|
|
22
|
-
danger: AlertCircleIcon
|
|
23
|
-
};
|
|
24
|
-
const iconTone = {
|
|
25
|
-
neutral: "text-fg-muted",
|
|
26
|
-
info: "text-fg",
|
|
27
|
-
success: "text-success",
|
|
28
|
-
warning: "text-warning",
|
|
29
|
-
danger: "text-danger"
|
|
30
|
-
};
|
|
31
17
|
/**
|
|
32
18
|
* A message that belongs to the page, not to a moment: a plan that ends, a form that could not
|
|
33
19
|
* be sent. Say what happened in the title and what to do in the description. It is announced
|
|
@@ -42,9 +28,9 @@ function Alert({ className, tone, icon, children, ...props }) {
|
|
|
42
28
|
className: cn(alertVariants({ tone }), className),
|
|
43
29
|
...props,
|
|
44
30
|
children: [/* @__PURE__ */ jsx(Icon, {
|
|
45
|
-
icon: icon ??
|
|
31
|
+
icon: icon ?? statusIcons[resolved],
|
|
46
32
|
size: 18,
|
|
47
|
-
className: cn("mt-[3px]",
|
|
33
|
+
className: cn("mt-[3px]", statusIconTone[resolved])
|
|
48
34
|
}), /* @__PURE__ */ jsx("div", {
|
|
49
35
|
className: "flex min-w-0 flex-col gap-0.5",
|
|
50
36
|
children
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AlertDialog as AlertDialog$1 } from "@base-ui/react/alert-dialog";
|
|
2
1
|
import { ComponentProps } from "react";
|
|
2
|
+
import { AlertDialog as AlertDialog$1 } from "@base-ui/react/alert-dialog";
|
|
3
3
|
/**
|
|
4
4
|
* A question that must be answered before anything else: confirming something that cannot be
|
|
5
5
|
* undone. It has no close button and a click outside does not dismiss it. Name the consequence in
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
export type AppShellProps = ComponentProps<"div"> & {
|
|
3
|
+
/** Whether the sidebar is open (controlled). */
|
|
4
|
+
sidebarOpen?: boolean;
|
|
5
|
+
/** Whether the sidebar is open at first. Open unless said otherwise. */
|
|
6
|
+
defaultSidebarOpen?: boolean;
|
|
7
|
+
onSidebarOpenChange?: (open: boolean) => void;
|
|
8
|
+
/**
|
|
9
|
+
* The shortcut that collapses and expands the sidebar, written like the `keys` of a
|
|
10
|
+
* `Shortcut`. `false` for none.
|
|
11
|
+
*/
|
|
12
|
+
sidebarShortcut?: string | false;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The frame of an app: the `Sidebar` on the left, the page beside it. Put the sidebar first,
|
|
16
|
+
* then an `AppShellPage` with the page's `AppShellBar` and its `AppShellMain`.
|
|
17
|
+
*
|
|
18
|
+
* The shell keeps whether the sidebar is open, so the `SidebarTrigger` in the bar and the
|
|
19
|
+
* sidebar agree. To have the sidebar come back the way it was left, keep the state yourself
|
|
20
|
+
* (`sidebarOpen`, `onSidebarOpenChange`) in a cookie and hand it in on the server: the page
|
|
21
|
+
* then arrives with the sidebar at its width, and nothing moves on load.
|
|
22
|
+
*/
|
|
23
|
+
export declare function AppShell({ sidebarOpen, defaultSidebarOpen, onSidebarOpenChange, sidebarShortcut, className, ...props }: AppShellProps): import("react").JSX.Element;
|
|
24
|
+
/** Everything beside the sidebar: the page's bar and its content, one under the other. */
|
|
25
|
+
export declare function AppShellPage({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* The bar across the top of the page: the `SidebarTrigger`, where one is (`Breadcrumbs`), and
|
|
28
|
+
* what can be done from everywhere (the search). It stays in view while the page scrolls. What
|
|
29
|
+
* belongs to one page only (its title, its actions) stands in the page, not here.
|
|
30
|
+
*/
|
|
31
|
+
export declare function AppShellBar({ className, ...props }: ComponentProps<"header">): import("react").JSX.Element;
|
|
32
|
+
/** The page itself. It is the page's `<main>`; give it an id for the skip link. */
|
|
33
|
+
export declare function AppShellMain({ className, ...props }: ComponentProps<"main">): import("react").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useShortcut } from "../shortcut/shortcut.js";
|
|
3
|
+
import { SIDEBAR_WIDE, SidebarStateContext } from "../sidebar/sidebar-context.js";
|
|
4
|
+
import { cn } from "../../lib/cn.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { useCallback, useEffect, useId, useMemo, useState } from "react";
|
|
7
|
+
// src/components/app-shell/app-shell.tsx
|
|
8
|
+
/**
|
|
9
|
+
* The frame of an app: the `Sidebar` on the left, the page beside it. Put the sidebar first,
|
|
10
|
+
* then an `AppShellPage` with the page's `AppShellBar` and its `AppShellMain`.
|
|
11
|
+
*
|
|
12
|
+
* The shell keeps whether the sidebar is open, so the `SidebarTrigger` in the bar and the
|
|
13
|
+
* sidebar agree. To have the sidebar come back the way it was left, keep the state yourself
|
|
14
|
+
* (`sidebarOpen`, `onSidebarOpenChange`) in a cookie and hand it in on the server: the page
|
|
15
|
+
* then arrives with the sidebar at its width, and nothing moves on load.
|
|
16
|
+
*/
|
|
17
|
+
function AppShell({ sidebarOpen, defaultSidebarOpen = true, onSidebarOpenChange, sidebarShortcut = "mod+b", className, ...props }) {
|
|
18
|
+
const id = useId();
|
|
19
|
+
const [kept, setKept] = useState(defaultSidebarOpen);
|
|
20
|
+
const open = sidebarOpen ?? kept;
|
|
21
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
22
|
+
const setOpen = useCallback((next) => {
|
|
23
|
+
setKept(next);
|
|
24
|
+
onSidebarOpenChange?.(next);
|
|
25
|
+
}, [onSidebarOpenChange]);
|
|
26
|
+
const toggle = useCallback(() => {
|
|
27
|
+
if (window.matchMedia("(min-width: 48rem)").matches) setOpen(!open);
|
|
28
|
+
else setDrawerOpen((shown) => !shown);
|
|
29
|
+
}, [open, setOpen]);
|
|
30
|
+
useShortcut(sidebarShortcut || "mod+b", toggle, { enabled: sidebarShortcut !== false });
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const query = window.matchMedia(SIDEBAR_WIDE);
|
|
33
|
+
const widened = () => {
|
|
34
|
+
if (query.matches) setDrawerOpen(false);
|
|
35
|
+
};
|
|
36
|
+
query.addEventListener("change", widened);
|
|
37
|
+
return () => query.removeEventListener("change", widened);
|
|
38
|
+
}, []);
|
|
39
|
+
const state = useMemo(() => ({
|
|
40
|
+
open,
|
|
41
|
+
setOpen,
|
|
42
|
+
drawerOpen,
|
|
43
|
+
setDrawerOpen,
|
|
44
|
+
toggle,
|
|
45
|
+
id,
|
|
46
|
+
shortcut: sidebarShortcut
|
|
47
|
+
}), [
|
|
48
|
+
open,
|
|
49
|
+
setOpen,
|
|
50
|
+
drawerOpen,
|
|
51
|
+
toggle,
|
|
52
|
+
id,
|
|
53
|
+
sidebarShortcut
|
|
54
|
+
]);
|
|
55
|
+
return /* @__PURE__ */ jsx(SidebarStateContext, {
|
|
56
|
+
value: state,
|
|
57
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
58
|
+
"data-slot": "app-shell",
|
|
59
|
+
"data-sidebar": open ? "expanded" : "collapsed",
|
|
60
|
+
className: cn("flex min-h-dvh", className),
|
|
61
|
+
...props
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** Everything beside the sidebar: the page's bar and its content, one under the other. */
|
|
66
|
+
function AppShellPage({ className, ...props }) {
|
|
67
|
+
return /* @__PURE__ */ jsx("div", {
|
|
68
|
+
"data-slot": "app-shell-page",
|
|
69
|
+
className: cn("flex min-w-0 flex-1 flex-col", className),
|
|
70
|
+
...props
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The bar across the top of the page: the `SidebarTrigger`, where one is (`Breadcrumbs`), and
|
|
75
|
+
* what can be done from everywhere (the search). It stays in view while the page scrolls. What
|
|
76
|
+
* belongs to one page only (its title, its actions) stands in the page, not here.
|
|
77
|
+
*/
|
|
78
|
+
function AppShellBar({ className, ...props }) {
|
|
79
|
+
return /* @__PURE__ */ jsx("header", {
|
|
80
|
+
"data-slot": "app-shell-bar",
|
|
81
|
+
className: cn("sticky top-0 z-10 flex h-12 shrink-0 items-center gap-2 border-b border-hairline bg-ground px-3", className),
|
|
82
|
+
...props
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** The page itself. It is the page's `<main>`; give it an id for the skip link. */
|
|
86
|
+
function AppShellMain({ className, ...props }) {
|
|
87
|
+
return /* @__PURE__ */ jsx("main", {
|
|
88
|
+
"data-slot": "app-shell-main",
|
|
89
|
+
className: cn("min-w-0 flex-1 px-4 py-6 sm:px-6", className),
|
|
90
|
+
...props
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export { AppShell, AppShellBar, AppShellMain, AppShellPage };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
/** Where a file stands: on its way, arrived, or failed. */
|
|
3
|
+
export type AttachmentStatus = "uploading" | "done" | "error";
|
|
4
|
+
/** `chip`: a plug in a prompt. `tile`: a file shown in a message, a picture as itself. */
|
|
5
|
+
export type AttachmentVariant = "chip" | "tile";
|
|
6
|
+
export type AttachmentProps = Omit<ComponentProps<"div">, "children"> & {
|
|
7
|
+
/** The file's name, as it is shown and read out: „Angebot-Kornprobst.pdf“. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Its size in bytes. */
|
|
10
|
+
size?: number;
|
|
11
|
+
/** Its MIME type, which says what kind of file it is. Without it the extension does. */
|
|
12
|
+
type?: string;
|
|
13
|
+
/** The address of a picture, which then shows itself. */
|
|
14
|
+
src?: string;
|
|
15
|
+
/** Done unless said otherwise. */
|
|
16
|
+
status?: AttachmentStatus;
|
|
17
|
+
/** Why it failed, as a sentence, where there is room for one (a tile). */
|
|
18
|
+
error?: string;
|
|
19
|
+
/** With it there is a key that takes the file away again. */
|
|
20
|
+
onRemove?: () => void;
|
|
21
|
+
/** What the key that takes it away is called, as one verb after the file's name. */
|
|
22
|
+
removeLabel?: string;
|
|
23
|
+
/** Where the file can be opened: the tile becomes a link to it. */
|
|
24
|
+
href?: string;
|
|
25
|
+
/** In a prompt's row a chip, elsewhere a tile. */
|
|
26
|
+
variant?: AttachmentVariant;
|
|
27
|
+
/** What each state is called. */
|
|
28
|
+
statusLabels?: Partial<Record<AttachmentStatus, string>>;
|
|
29
|
+
locale?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A file attached to a prompt or shown in a message: a symbol for its kind, its name, its size,
|
|
33
|
+
* and a key that takes it away while it still can be. In a prompt it is a chip, a plug in the
|
|
34
|
+
* field; in a message a small flat tile, and a picture shows itself.
|
|
35
|
+
*
|
|
36
|
+
* While it uploads it carries the system's arc in place of its symbol; once it has arrived, the
|
|
37
|
+
* symbol comes back where the arc was. A failure is said in words („Fehlgeschlagen“, and in a
|
|
38
|
+
* tile why). The name is cut in its middle, so the end of it and the extension stay readable.
|
|
39
|
+
*/
|
|
40
|
+
export declare function Attachment({ name, size, type, src, status, error, onRemove, removeLabel, href, variant: variantProp, statusLabels, locale, className, ...props }: AttachmentProps): import("react").JSX.Element;
|
|
41
|
+
export type MessageAttachmentsProps = ComponentProps<"div">;
|
|
42
|
+
/**
|
|
43
|
+
* The files of a message, side by side, wrapping: at the start of an answer, at the right above
|
|
44
|
+
* the person's words. Put `Attachment`s inside.
|
|
45
|
+
*/
|
|
46
|
+
export declare function MessageAttachments({ className, ...props }: MessageAttachmentsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Chip } from "../chip/chip.js";
|
|
3
|
+
import { chipRemoveKey } from "../chip/chip-variants.js";
|
|
4
|
+
import { formatFileSize } from "../file-upload/files.js";
|
|
5
|
+
import { Icon } from "../icon/icon.js";
|
|
6
|
+
import { Spinner } from "../spinner/spinner.js";
|
|
7
|
+
import { CloseGlyph } from "../../internal/glyphs.js";
|
|
8
|
+
import { cn } from "../../lib/cn.js";
|
|
9
|
+
import { kindOf, kindSymbols, splitName, typeWord } from "./kinds.js";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { createContext, useContext, useId, useLayoutEffect, useRef } from "react";
|
|
12
|
+
import { Alert02Icon } from "@hugeicons/core-free-icons";
|
|
13
|
+
// src/components/attachment/attachment.tsx
|
|
14
|
+
/** Inside a prompt's row of attachments, they are chips unless they say otherwise. */
|
|
15
|
+
const AttachmentVariantContext = createContext("tile");
|
|
16
|
+
const defaultStatusLabels = {
|
|
17
|
+
uploading: "Wird hochgeladen",
|
|
18
|
+
done: "Hochgeladen",
|
|
19
|
+
error: "Fehlgeschlagen"
|
|
20
|
+
};
|
|
21
|
+
/** A name cut in its middle: the end of it, the extension, always stays. */
|
|
22
|
+
function FileName({ name, className }) {
|
|
23
|
+
const { stem, end } = splitName(name);
|
|
24
|
+
const cut = useRef(null);
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
const box = cut.current;
|
|
27
|
+
if (!box) return;
|
|
28
|
+
const measure = () => {
|
|
29
|
+
if (box.scrollWidth > box.clientWidth + .5) box.dataset.cut = "";
|
|
30
|
+
else delete box.dataset.cut;
|
|
31
|
+
};
|
|
32
|
+
measure();
|
|
33
|
+
const observer = new ResizeObserver(measure);
|
|
34
|
+
observer.observe(box);
|
|
35
|
+
return () => observer.disconnect();
|
|
36
|
+
}, [name]);
|
|
37
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
38
|
+
"data-slot": "attachment-name",
|
|
39
|
+
className: cn("flex min-w-0", className),
|
|
40
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
41
|
+
className: "sr-only",
|
|
42
|
+
children: name
|
|
43
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
44
|
+
"aria-hidden": true,
|
|
45
|
+
className: "flex min-w-0",
|
|
46
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
47
|
+
ref: cut,
|
|
48
|
+
className: "overflow-hidden whitespace-nowrap data-cut:[mask-image:linear-gradient(to_right,#000_calc(100%-1.25em),transparent)]",
|
|
49
|
+
children: stem
|
|
50
|
+
}), end && /* @__PURE__ */ jsx("span", {
|
|
51
|
+
className: "shrink-0",
|
|
52
|
+
children: end
|
|
53
|
+
})]
|
|
54
|
+
})]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A file attached to a prompt or shown in a message: a symbol for its kind, its name, its size,
|
|
59
|
+
* and a key that takes it away while it still can be. In a prompt it is a chip, a plug in the
|
|
60
|
+
* field; in a message a small flat tile, and a picture shows itself.
|
|
61
|
+
*
|
|
62
|
+
* While it uploads it carries the system's arc in place of its symbol; once it has arrived, the
|
|
63
|
+
* symbol comes back where the arc was. A failure is said in words („Fehlgeschlagen“, and in a
|
|
64
|
+
* tile why). The name is cut in its middle, so the end of it and the extension stay readable.
|
|
65
|
+
*/
|
|
66
|
+
function Attachment({ name, size, type, src, status = "done", error, onRemove, removeLabel = "entfernen", href, variant: variantProp, statusLabels, locale = "de-DE", className, ...props }) {
|
|
67
|
+
const placed = useContext(AttachmentVariantContext);
|
|
68
|
+
const variant = variantProp ?? placed;
|
|
69
|
+
const labels = {
|
|
70
|
+
...defaultStatusLabels,
|
|
71
|
+
...statusLabels
|
|
72
|
+
};
|
|
73
|
+
const kind = kindOf({
|
|
74
|
+
name,
|
|
75
|
+
type
|
|
76
|
+
});
|
|
77
|
+
const picture = kind === "image" && src !== void 0;
|
|
78
|
+
const sizeWord = size === void 0 ? void 0 : formatFileSize(size, locale);
|
|
79
|
+
/** In front: the arc on the way, the danger symbol after a failure, else the kind. */
|
|
80
|
+
const mark = (small) => status === "uploading" ? /* @__PURE__ */ jsx(Spinner, {
|
|
81
|
+
size: small ? 12 : 16,
|
|
82
|
+
className: "text-fg"
|
|
83
|
+
}) : status === "error" ? /* @__PURE__ */ jsx(Icon, {
|
|
84
|
+
icon: Alert02Icon,
|
|
85
|
+
size: small ? 12 : 16,
|
|
86
|
+
className: "text-danger"
|
|
87
|
+
}) : /* @__PURE__ */ jsx(Icon, {
|
|
88
|
+
icon: kindSymbols[kind],
|
|
89
|
+
size: small ? 14 : 18,
|
|
90
|
+
className: "text-fg-muted transition-opacity spring-settle in-data-live:starting:opacity-0"
|
|
91
|
+
});
|
|
92
|
+
if (variant === "chip") return /* @__PURE__ */ jsx(Chip, {
|
|
93
|
+
"data-slot": "attachment",
|
|
94
|
+
"data-variant": "chip",
|
|
95
|
+
"data-status": status,
|
|
96
|
+
title: name,
|
|
97
|
+
onRemove,
|
|
98
|
+
removeLabel,
|
|
99
|
+
className: cn("max-w-64", className),
|
|
100
|
+
lead: /* @__PURE__ */ jsx("span", {
|
|
101
|
+
"data-slot": "attachment-mark",
|
|
102
|
+
"aria-hidden": true,
|
|
103
|
+
className: "-ml-0.5 flex size-3.5 shrink-0 items-center justify-center",
|
|
104
|
+
children: picture && status === "done" ? /* @__PURE__ */ jsx("img", {
|
|
105
|
+
src,
|
|
106
|
+
alt: "",
|
|
107
|
+
className: "size-4 max-w-none rounded-[3px] object-cover"
|
|
108
|
+
}) : mark(true)
|
|
109
|
+
}),
|
|
110
|
+
...props,
|
|
111
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
112
|
+
className: "flex min-w-0 items-baseline gap-1.5",
|
|
113
|
+
children: [/* @__PURE__ */ jsx(FileName, { name }), status === "error" ? /* @__PURE__ */ jsx("span", {
|
|
114
|
+
className: "shrink-0 font-normal text-danger",
|
|
115
|
+
children: labels.error
|
|
116
|
+
}) : status === "uploading" ? /* @__PURE__ */ jsx("span", {
|
|
117
|
+
className: "sr-only",
|
|
118
|
+
children: labels.uploading
|
|
119
|
+
}) : sizeWord && /* @__PURE__ */ jsx("span", {
|
|
120
|
+
className: "shrink-0 font-normal text-fg-muted tabular-nums",
|
|
121
|
+
children: sizeWord
|
|
122
|
+
})]
|
|
123
|
+
})
|
|
124
|
+
});
|
|
125
|
+
return /* @__PURE__ */ jsx(AttachmentTile, {
|
|
126
|
+
name,
|
|
127
|
+
picture: picture ? src : void 0,
|
|
128
|
+
href,
|
|
129
|
+
onRemove,
|
|
130
|
+
removeLabel,
|
|
131
|
+
status,
|
|
132
|
+
className,
|
|
133
|
+
mark: mark(false),
|
|
134
|
+
meta: status === "uploading" ? labels.uploading : status === "error" ? /* @__PURE__ */ jsx("span", {
|
|
135
|
+
className: "text-danger",
|
|
136
|
+
children: error ?? labels.error
|
|
137
|
+
}) : [typeWord({
|
|
138
|
+
name,
|
|
139
|
+
type
|
|
140
|
+
}), sizeWord].filter(Boolean).join(" · "),
|
|
141
|
+
...props
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** A file in a message: read, so flat; a picture as itself. */
|
|
145
|
+
function AttachmentTile({ name, picture, href, onRemove, removeLabel, status, mark, meta, className, ...props }) {
|
|
146
|
+
const nameId = useId();
|
|
147
|
+
const removeId = useId();
|
|
148
|
+
const Root = href ? "a" : "div";
|
|
149
|
+
const remove = onRemove && /* @__PURE__ */ jsx("button", {
|
|
150
|
+
type: "button",
|
|
151
|
+
id: removeId,
|
|
152
|
+
"data-slot": "attachment-remove",
|
|
153
|
+
"aria-label": removeLabel,
|
|
154
|
+
"aria-labelledby": `${nameId} ${removeId}`,
|
|
155
|
+
onClick: onRemove,
|
|
156
|
+
className: cn(chipRemoveKey, picture ? "absolute top-1.5 right-1.5 size-6 rounded-full bg-raised depth-plug text-fg" : "absolute right-2.5"),
|
|
157
|
+
children: /* @__PURE__ */ jsx(CloseGlyph, {
|
|
158
|
+
width: 8,
|
|
159
|
+
height: 8
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
if (picture) return /* @__PURE__ */ jsxs("div", {
|
|
163
|
+
"data-slot": "attachment",
|
|
164
|
+
"data-variant": "tile",
|
|
165
|
+
"data-status": status,
|
|
166
|
+
className: cn("relative inline-flex max-w-64", className),
|
|
167
|
+
...props,
|
|
168
|
+
children: [/* @__PURE__ */ jsxs(Root, {
|
|
169
|
+
...href ? { href } : {},
|
|
170
|
+
className: cn("relative block overflow-hidden rounded-lg", "after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:inset-ring after:inset-ring-hairline", href && "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent"),
|
|
171
|
+
children: [/* @__PURE__ */ jsx("img", {
|
|
172
|
+
id: nameId,
|
|
173
|
+
src: picture,
|
|
174
|
+
alt: name,
|
|
175
|
+
className: "block h-auto max-h-40 w-auto max-w-64 object-cover"
|
|
176
|
+
}), status !== "done" && /* @__PURE__ */ jsx("span", {
|
|
177
|
+
className: "absolute bottom-1.5 left-1.5 flex size-6 items-center justify-center rounded-full bg-raised depth-plug",
|
|
178
|
+
children: mark
|
|
179
|
+
})]
|
|
180
|
+
}), remove]
|
|
181
|
+
});
|
|
182
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
183
|
+
"data-slot": "attachment",
|
|
184
|
+
"data-variant": "tile",
|
|
185
|
+
"data-status": status,
|
|
186
|
+
className: cn("relative flex w-64 max-w-full items-center", className),
|
|
187
|
+
...props,
|
|
188
|
+
children: [/* @__PURE__ */ jsxs(Root, {
|
|
189
|
+
...href ? { href } : {},
|
|
190
|
+
className: cn("flex min-w-0 flex-1 items-center gap-3 rounded-lg bg-surface p-2 inset-ring inset-ring-hairline forced-colors:inset-ring-[CanvasText]", remove ? "pr-10" : "pr-3", href && ["transition-colors spring-snap hover:bg-surface-quiet", "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent"]),
|
|
191
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
192
|
+
"data-slot": "attachment-mark",
|
|
193
|
+
"aria-hidden": true,
|
|
194
|
+
className: "flex size-10 shrink-0 items-center justify-center rounded-md bg-surface-quiet",
|
|
195
|
+
children: mark
|
|
196
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
197
|
+
className: "flex min-w-0 flex-col",
|
|
198
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
199
|
+
id: nameId,
|
|
200
|
+
className: "min-w-0 text-sm font-medium text-fg",
|
|
201
|
+
children: /* @__PURE__ */ jsx(FileName, { name })
|
|
202
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
203
|
+
"data-slot": "attachment-meta",
|
|
204
|
+
className: cn("text-sm text-fg-muted tabular-nums", status === "error" ? "line-clamp-3" : "truncate"),
|
|
205
|
+
children: meta
|
|
206
|
+
})]
|
|
207
|
+
})]
|
|
208
|
+
}), remove]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The files of a message, side by side, wrapping: at the start of an answer, at the right above
|
|
213
|
+
* the person's words. Put `Attachment`s inside.
|
|
214
|
+
*/
|
|
215
|
+
function MessageAttachments({ className, ...props }) {
|
|
216
|
+
return /* @__PURE__ */ jsx("div", {
|
|
217
|
+
"data-slot": "message-attachments",
|
|
218
|
+
className: cn("flex flex-wrap items-end gap-2 *:shrink-0 in-data-[from=user]:justify-end", className),
|
|
219
|
+
...props
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
export { Attachment, AttachmentVariantContext, MessageAttachments };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "../icon/icon.js";
|
|
2
|
+
export type FileKind = "pdf" | "image" | "sheet" | "csv" | "document" | "archive" | "audio" | "video" | "file";
|
|
3
|
+
/** The kind of a file: its MIME type decides, and its extension where the type says too little. */
|
|
4
|
+
export declare function kindOf({ name, type }: {
|
|
5
|
+
name: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
}): FileKind;
|