@lanfermann/ui 0.6.0 → 0.7.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/accordion/accordion.d.ts +11 -3
- package/dist/components/accordion/accordion.js +15 -10
- package/dist/components/action-bar/action-bar.d.ts +2 -1
- package/dist/components/action-bar/action-bar.js +3 -2
- package/dist/components/attachment/attachment.d.ts +6 -1
- package/dist/components/attachment/attachment.js +64 -31
- package/dist/components/attachment/kinds.js +44 -2
- package/dist/components/button-group/button-group-variants.d.ts +4 -3
- package/dist/components/button-group/button-group-variants.js +13 -12
- package/dist/components/button-group/button-group.d.ts +3 -3
- package/dist/components/button-group/button-group.js +3 -3
- package/dist/components/card/card.d.ts +9 -1
- package/dist/components/card/card.js +14 -2
- package/dist/components/checkbox-card/checkbox-card.js +3 -2
- package/dist/components/collapsible/collapsible.js +7 -3
- package/dist/components/combobox/combobox.d.ts +3 -1
- package/dist/components/combobox/combobox.js +45 -30
- package/dist/components/copy-page/copy-page.d.ts +4 -4
- package/dist/components/copy-page/copy-page.js +9 -19
- package/dist/components/menu/menu.d.ts +20 -8
- package/dist/components/menu/menu.js +51 -29
- package/dist/components/message/message.d.ts +10 -2
- package/dist/components/message/message.js +20 -8
- package/dist/components/navigation-menu/navigation-menu.d.ts +7 -1
- package/dist/components/navigation-menu/navigation-menu.js +11 -4
- package/dist/components/otp-field/otp-field.js +46 -11
- package/dist/components/radio-card/radio-card.js +3 -2
- package/dist/components/segmented-control/segmented-control.js +29 -16
- package/dist/components/select/select.d.ts +4 -3
- package/dist/components/select/select.js +15 -10
- package/dist/components/stat/stat.d.ts +3 -1
- package/dist/components/stat/stat.js +3 -1
- package/dist/components/steps/steps.js +5 -2
- package/dist/components/time-field/time-field.js +6 -5
- package/dist/components/toggle/toggle.d.ts +5 -2
- package/dist/components/toggle/toggle.js +13 -5
- package/dist/components/toolbar/toolbar.d.ts +9 -2
- package/dist/components/toolbar/toolbar.js +18 -5
- package/dist/components/trace/trace.js +1 -1
- package/dist/internal/choice-card.js +27 -11
- package/dist/internal/disclosure.js +15 -3
- package/dist/internal/key-tip.js +18 -0
- package/dist/internal/list-mark.js +39 -0
- package/dist/internal/number-places.js +4 -3
- package/dist/internal/rule.js +2 -1
- package/dist/internal/tile.js +23 -0
- package/dist/lib/cn.js +10 -4
- package/package.json +1 -1
- package/src/styles/accordion.css +176 -0
- package/src/styles/depth.css +104 -32
- package/src/styles/motion.css +3 -0
- package/src/styles/segmented.css +14 -7
- package/src/styles.css +1 -0
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
|
|
2
|
-
export type AccordionProps = Accordion$1.Root.Props
|
|
2
|
+
export type AccordionProps = Accordion$1.Root.Props & {
|
|
3
|
+
/**
|
|
4
|
+
* No wash under the pointer: the lines stay and only the chevron answers. For a page where the
|
|
5
|
+
* accordion should recede, such as a docs page dense with other rows.
|
|
6
|
+
*/
|
|
7
|
+
quiet?: boolean;
|
|
8
|
+
};
|
|
3
9
|
/**
|
|
4
10
|
* Questions with their answers, or the sections of a long page that are read one at a time. One
|
|
5
11
|
* item is open at a time; `multiple` lets several stay open, for sections that are compared.
|
|
@@ -8,7 +14,7 @@ export type AccordionProps = Accordion$1.Root.Props;
|
|
|
8
14
|
* what everybody needs behind a row: an accordion is for the second look. `hiddenUntilFound`
|
|
9
15
|
* lets the browser's page search open the row that holds the match.
|
|
10
16
|
*/
|
|
11
|
-
export declare function Accordion({ className, ...props }: AccordionProps): import("react").JSX.Element;
|
|
17
|
+
export declare function Accordion({ className, quiet, ...props }: AccordionProps): import("react").JSX.Element;
|
|
12
18
|
export type AccordionItemProps = Accordion$1.Item.Props;
|
|
13
19
|
/** One row with its panel. Give it a `value` to open it at first or to control it. */
|
|
14
20
|
export declare function AccordionItem({ className, ...props }: AccordionItemProps): import("react").JSX.Element;
|
|
@@ -22,5 +28,7 @@ export type AccordionTriggerProps = Accordion$1.Trigger.Props & {
|
|
|
22
28
|
*/
|
|
23
29
|
export declare function AccordionTrigger({ className, children, level, ...props }: AccordionTriggerProps): import("react").JSX.Element;
|
|
24
30
|
export type AccordionPanelProps = Accordion$1.Panel.Props;
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* The answer. It opens on `settle` to its own height and unfolds, and leaves faster than it came.
|
|
33
|
+
*/
|
|
26
34
|
export declare function AccordionPanel({ className, children, ...props }: AccordionPanelProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { disclosureChevron, disclosurePanel } from "../../internal/disclosure.js";
|
|
2
|
+
import { disclosureChevron, disclosurePanel, disclosureUnfold } from "../../internal/disclosure.js";
|
|
3
3
|
import { ChevronDownGlyph } from "../../internal/glyphs.js";
|
|
4
|
-
import { ruleTop } from "../../internal/rule.js";
|
|
5
4
|
import { cn, mergeClassName } from "../../lib/cn.js";
|
|
6
5
|
import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -14,10 +13,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
14
13
|
* what everybody needs behind a row: an accordion is for the second look. `hiddenUntilFound`
|
|
15
14
|
* lets the browser's page search open the row that holds the match.
|
|
16
15
|
*/
|
|
17
|
-
function Accordion({ className, ...props }) {
|
|
16
|
+
function Accordion({ className, quiet = false, ...props }) {
|
|
18
17
|
return /* @__PURE__ */ jsx(Accordion$1.Root, {
|
|
19
18
|
"data-slot": "accordion",
|
|
20
|
-
|
|
19
|
+
"data-quiet": quiet || void 0,
|
|
20
|
+
className: mergeClassName("flex w-full flex-col", className),
|
|
21
21
|
...props
|
|
22
22
|
});
|
|
23
23
|
}
|
|
@@ -25,7 +25,7 @@ function Accordion({ className, ...props }) {
|
|
|
25
25
|
function AccordionItem({ className, ...props }) {
|
|
26
26
|
return /* @__PURE__ */ jsx(Accordion$1.Item, {
|
|
27
27
|
"data-slot": "accordion-item",
|
|
28
|
-
className
|
|
28
|
+
className,
|
|
29
29
|
...props
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -42,8 +42,7 @@ function AccordionTrigger({ className, children, level = 3, ...props }) {
|
|
|
42
42
|
children: /* @__PURE__ */ jsxs(Accordion$1.Trigger, {
|
|
43
43
|
"data-slot": "accordion-trigger",
|
|
44
44
|
className: mergeClassName([
|
|
45
|
-
"group touch-target relative flex min-h-(--control-lg) w-full items-start gap-4 rounded-
|
|
46
|
-
"hover:bg-hover",
|
|
45
|
+
"group touch-target relative flex min-h-(--control-lg) w-full items-start gap-4 rounded-md px-3 py-3 text-left text-base font-medium text-fg select-none",
|
|
47
46
|
"focus-visible:relative focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent",
|
|
48
47
|
"data-disabled:pointer-events-none data-disabled:text-on-disabled"
|
|
49
48
|
], className),
|
|
@@ -57,17 +56,23 @@ function AccordionTrigger({ className, children, level = 3, ...props }) {
|
|
|
57
56
|
className: "flex h-lh shrink-0 items-center",
|
|
58
57
|
children: /* @__PURE__ */ jsx(ChevronDownGlyph, {
|
|
59
58
|
"data-slot": "accordion-chevron",
|
|
60
|
-
className: cn(disclosureChevron, "group-data-panel-open:rotate-180")
|
|
59
|
+
className: cn(disclosureChevron, "[--lean:0_var(--motion-lean)] group-data-panel-open:rotate-180 group-data-panel-open:[--lean:0_calc(var(--motion-lean)*-1)]")
|
|
61
60
|
})
|
|
62
61
|
})]
|
|
63
62
|
})
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* The answer. It opens on `settle` to its own height and unfolds, and leaves faster than it came.
|
|
67
|
+
*/
|
|
67
68
|
function AccordionPanel({ className, children, ...props }) {
|
|
68
69
|
return /* @__PURE__ */ jsx(Accordion$1.Panel, {
|
|
69
70
|
"data-slot": "accordion-panel",
|
|
70
|
-
className: mergeClassName([
|
|
71
|
+
className: mergeClassName([
|
|
72
|
+
"h-(--accordion-panel-height) text-base text-fg-body",
|
|
73
|
+
disclosurePanel,
|
|
74
|
+
disclosureUnfold
|
|
75
|
+
], className),
|
|
71
76
|
...props,
|
|
72
77
|
children: /* @__PURE__ */ jsx("div", {
|
|
73
78
|
"data-slot": "accordion-panel-content",
|
|
@@ -36,7 +36,8 @@ export type ActionBarProps = Omit<ComponentProps<"div">, "children"> & {
|
|
|
36
36
|
* What can be done with the rows that are selected in a list: it rises at the foot of the
|
|
37
37
|
* window with the first row that is ticked, counts them, and leaves with the last. It is the
|
|
38
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
|
|
39
|
+
* dark page it can be the light one instead (`ground="paper"`). It is cut like a key that
|
|
40
|
+
* floats: a key's glossy face, light edge and lip, over a long, wide shadow (`depth-dock`).
|
|
40
41
|
*
|
|
41
42
|
* Put the actions inside as `ActionBarButton`s, worded like buttons ("Als PDF herunterladen").
|
|
42
43
|
* Two or three; what is rare belongs in a `Menu` behind the last one. The bar is one stop for
|
|
@@ -17,7 +17,8 @@ const places = {
|
|
|
17
17
|
* What can be done with the rows that are selected in a list: it rises at the foot of the
|
|
18
18
|
* window with the first row that is ticked, counts them, and leaves with the last. It is the
|
|
19
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
|
|
20
|
+
* dark page it can be the light one instead (`ground="paper"`). It is cut like a key that
|
|
21
|
+
* floats: a key's glossy face, light edge and lip, over a long, wide shadow (`depth-dock`).
|
|
21
22
|
*
|
|
22
23
|
* Put the actions inside as `ActionBarButton`s, worded like buttons ("Als PDF herunterladen").
|
|
23
24
|
* Two or three; what is rare belongs in a `Menu` behind the last one. The bar is one stop for
|
|
@@ -56,7 +57,7 @@ function ActionBar({ open, count, countLabel = () => "ausgewählt", onClear, cle
|
|
|
56
57
|
onKeyDown: (event) => {
|
|
57
58
|
if (event.key === "Escape") clear(event.currentTarget);
|
|
58
59
|
},
|
|
59
|
-
className: cn("pointer-events-auto action-bar-motion flex max-w-full items-center gap-1 rounded-xl bg-
|
|
60
|
+
className: cn("pointer-events-auto action-bar-motion flex max-w-full items-center gap-1 rounded-xl bg-raised depth-dock py-1.5 pr-1.5 pl-3.5 text-control text-fg", className),
|
|
60
61
|
...props,
|
|
61
62
|
children: [
|
|
62
63
|
/* @__PURE__ */ jsxs("p", {
|
|
@@ -24,6 +24,11 @@ export type AttachmentProps = Omit<ComponentProps<"div">, "children"> & {
|
|
|
24
24
|
href?: string;
|
|
25
25
|
/** In a prompt's row a chip, elsewhere a tile. */
|
|
26
26
|
variant?: AttachmentVariant;
|
|
27
|
+
/**
|
|
28
|
+
* The face of a chip: `plug` (the default), a small raised part, or `flat`, quiet like a
|
|
29
|
+
* `Badge`, for a row of many or a place that is already busy.
|
|
30
|
+
*/
|
|
31
|
+
chipVariant?: "plug" | "flat";
|
|
27
32
|
/** What each state is called. */
|
|
28
33
|
statusLabels?: Partial<Record<AttachmentStatus, string>>;
|
|
29
34
|
locale?: string;
|
|
@@ -37,7 +42,7 @@ export type AttachmentProps = Omit<ComponentProps<"div">, "children"> & {
|
|
|
37
42
|
* symbol comes back where the arc was. A failure is said in words („Fehlgeschlagen“, and in a
|
|
38
43
|
* tile why). The name is cut in its middle, so the end of it and the extension stay readable.
|
|
39
44
|
*/
|
|
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;
|
|
45
|
+
export declare function Attachment({ name, size, type, src, status, error, onRemove, removeLabel, href, variant: variantProp, chipVariant, statusLabels, locale, className, ...props }: AttachmentProps): import("react").JSX.Element;
|
|
41
46
|
export type MessageAttachmentsProps = ComponentProps<"div">;
|
|
42
47
|
/**
|
|
43
48
|
* The files of a message, side by side, wrapping: at the start of an answer, at the right above
|
|
@@ -6,9 +6,9 @@ import { Icon } from "../icon/icon.js";
|
|
|
6
6
|
import { Spinner } from "../spinner/spinner.js";
|
|
7
7
|
import { CloseGlyph } from "../../internal/glyphs.js";
|
|
8
8
|
import { cn } from "../../lib/cn.js";
|
|
9
|
-
import { kindOf, kindSymbols,
|
|
9
|
+
import { fitName, kindOf, kindSymbols, kindSymbolsSmall, typeWord } from "./kinds.js";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { createContext, useContext, useId, useLayoutEffect, useRef } from "react";
|
|
11
|
+
import { createContext, useContext, useId, useLayoutEffect, useRef, useState } from "react";
|
|
12
12
|
import { Alert02Icon } from "@hugeicons/core-free-icons";
|
|
13
13
|
// src/components/attachment/attachment.tsx
|
|
14
14
|
/** Inside a prompt's row of attachments, they are chips unless they say otherwise. */
|
|
@@ -18,40 +18,72 @@ const defaultStatusLabels = {
|
|
|
18
18
|
done: "Hochgeladen",
|
|
19
19
|
error: "Fehlgeschlagen"
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
21
|
+
/** How many letters before the extension stay where a name is cut: „Angebot-Ko…bst.pdf“. */
|
|
22
|
+
const KEPT_LETTERS = 3;
|
|
23
|
+
/**
|
|
24
|
+
* A name too long for its place, cut in its middle with an ellipsis as a file manager cuts it:
|
|
25
|
+
* the extension and the last three letters before it stay (`fitName`), „Angebot-Ko…bst.pdf“.
|
|
26
|
+
* Chosen by Justin (2026-11-20) over a cut at the end of the name and over the fade before the
|
|
27
|
+
* extension, which "looks odd". The room is the width the whole name would take, or less where
|
|
28
|
+
* the chip runs out: an unseen copy of the whole name sets it, and the cut is worked out again
|
|
29
|
+
* when the room changes.
|
|
30
|
+
*/
|
|
22
31
|
function FileName({ name, className }) {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
32
|
+
const room = useRef(null);
|
|
33
|
+
const probe = useRef(null);
|
|
34
|
+
const [shown, setShown] = useState(name);
|
|
25
35
|
useLayoutEffect(() => {
|
|
26
|
-
const box =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
const box = room.current;
|
|
37
|
+
const measuring = probe.current;
|
|
38
|
+
if (!box || !measuring) return;
|
|
39
|
+
let live = true;
|
|
40
|
+
let frame = 0;
|
|
41
|
+
const fit = () => {
|
|
42
|
+
const measure = (each) => {
|
|
43
|
+
measuring.textContent = each;
|
|
44
|
+
return measuring.offsetWidth;
|
|
45
|
+
};
|
|
46
|
+
const room = box.clientWidth;
|
|
47
|
+
setShown(measure(name) <= room ? name : fitName(name, room - 1, measure, KEPT_LETTERS));
|
|
31
48
|
};
|
|
32
|
-
|
|
33
|
-
const observer = new ResizeObserver(
|
|
49
|
+
fit();
|
|
50
|
+
const observer = new ResizeObserver(() => {
|
|
51
|
+
cancelAnimationFrame(frame);
|
|
52
|
+
frame = requestAnimationFrame(fit);
|
|
53
|
+
});
|
|
34
54
|
observer.observe(box);
|
|
35
|
-
|
|
55
|
+
document.fonts?.ready.then(() => live && fit());
|
|
56
|
+
return () => {
|
|
57
|
+
live = false;
|
|
58
|
+
cancelAnimationFrame(frame);
|
|
59
|
+
observer.disconnect();
|
|
60
|
+
};
|
|
36
61
|
}, [name]);
|
|
37
62
|
return /* @__PURE__ */ jsxs("span", {
|
|
63
|
+
ref: room,
|
|
38
64
|
"data-slot": "attachment-name",
|
|
39
|
-
className: cn("
|
|
40
|
-
children: [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
ref:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
className: cn("grid min-w-0 grid-cols-[minmax(0,max-content)]", className),
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx("span", {
|
|
68
|
+
"aria-hidden": true,
|
|
69
|
+
className: "col-start-1 row-start-1 overflow-hidden whitespace-nowrap",
|
|
70
|
+
children: shown
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx("span", {
|
|
73
|
+
ref: probe,
|
|
74
|
+
"aria-hidden": true,
|
|
75
|
+
className: "invisible absolute whitespace-nowrap"
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ jsx("span", {
|
|
78
|
+
"aria-hidden": true,
|
|
79
|
+
className: "invisible col-start-1 row-start-1 h-0 overflow-hidden whitespace-nowrap",
|
|
80
|
+
children: name
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ jsx("span", {
|
|
83
|
+
className: "sr-only",
|
|
84
|
+
children: name
|
|
85
|
+
})
|
|
86
|
+
]
|
|
55
87
|
});
|
|
56
88
|
}
|
|
57
89
|
/**
|
|
@@ -63,7 +95,7 @@ function FileName({ name, className }) {
|
|
|
63
95
|
* symbol comes back where the arc was. A failure is said in words („Fehlgeschlagen“, and in a
|
|
64
96
|
* tile why). The name is cut in its middle, so the end of it and the extension stay readable.
|
|
65
97
|
*/
|
|
66
|
-
function Attachment({ name, size, type, src, status = "done", error, onRemove, removeLabel = "entfernen", href, variant: variantProp, statusLabels, locale = "de-DE", className, ...props }) {
|
|
98
|
+
function Attachment({ name, size, type, src, status = "done", error, onRemove, removeLabel = "entfernen", href, variant: variantProp, chipVariant = "plug", statusLabels, locale = "de-DE", className, ...props }) {
|
|
67
99
|
const placed = useContext(AttachmentVariantContext);
|
|
68
100
|
const variant = variantProp ?? placed;
|
|
69
101
|
const labels = {
|
|
@@ -85,7 +117,7 @@ function Attachment({ name, size, type, src, status = "done", error, onRemove, r
|
|
|
85
117
|
size: small ? 12 : 16,
|
|
86
118
|
className: "text-danger"
|
|
87
119
|
}) : /* @__PURE__ */ jsx(Icon, {
|
|
88
|
-
icon: kindSymbols[kind],
|
|
120
|
+
icon: small ? kindSymbolsSmall[kind] : kindSymbols[kind],
|
|
89
121
|
size: small ? 14 : 18,
|
|
90
122
|
className: "text-fg-muted transition-opacity spring-settle in-data-live:starting:opacity-0"
|
|
91
123
|
});
|
|
@@ -93,6 +125,7 @@ function Attachment({ name, size, type, src, status = "done", error, onRemove, r
|
|
|
93
125
|
"data-slot": "attachment",
|
|
94
126
|
"data-variant": "chip",
|
|
95
127
|
"data-status": status,
|
|
128
|
+
variant: chipVariant,
|
|
96
129
|
title: name,
|
|
97
130
|
onRemove,
|
|
98
131
|
removeLabel,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Csv01Icon, Doc01Icon, File01Icon, FileAudioIcon, FileVideoIcon, Image01Icon, Pdf01Icon, Xls01Icon, Zip01Icon } from "@hugeicons/core-free-icons";
|
|
1
|
+
import { Csv01Icon, Doc01Icon, File01Icon, FileArchiveIcon, FileAudioIcon, FileEmpty02Icon, FileImageIcon, FilePenLineIcon, FileSpreadsheetIcon, FileTextIcon, FileVideoIcon, Image01Icon, Pdf01Icon, Xls01Icon, Zip01Icon } from "@hugeicons/core-free-icons";
|
|
2
2
|
// src/components/attachment/kinds.ts
|
|
3
3
|
/**
|
|
4
4
|
* What kind of file an attachment is, from its MIME type or else its name: the symbol it
|
|
5
5
|
* carries and the word that names it. Plain functions, so they can be tested and used anywhere.
|
|
6
6
|
*/
|
|
7
|
+
/** The symbol of a kind at a tile's size (18px), where the letters of a type stay readable. */
|
|
7
8
|
const kindSymbols = {
|
|
8
9
|
pdf: Pdf01Icon,
|
|
9
10
|
image: Image01Icon,
|
|
@@ -15,6 +16,23 @@ const kindSymbols = {
|
|
|
15
16
|
video: FileVideoIcon,
|
|
16
17
|
file: File01Icon
|
|
17
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* The symbol of a kind in a chip (14px): a sheet with what it holds, without letters. At 14px
|
|
21
|
+
* the stroke is pinned to 1.5px, and the letters of „PDF“ or „XLS“ ran together into blots
|
|
22
|
+
* (Justin, 2026-11-20: "the icons look too thick, they kinda explode"). The extension stands in
|
|
23
|
+
* the name beside it anyway.
|
|
24
|
+
*/
|
|
25
|
+
const kindSymbolsSmall = {
|
|
26
|
+
pdf: FileTextIcon,
|
|
27
|
+
image: FileImageIcon,
|
|
28
|
+
sheet: FileSpreadsheetIcon,
|
|
29
|
+
csv: FileSpreadsheetIcon,
|
|
30
|
+
document: FilePenLineIcon,
|
|
31
|
+
archive: FileArchiveIcon,
|
|
32
|
+
audio: FileAudioIcon,
|
|
33
|
+
video: FileVideoIcon,
|
|
34
|
+
file: FileEmpty02Icon
|
|
35
|
+
};
|
|
18
36
|
/** The word for a kind where the name has no extension to show. */
|
|
19
37
|
const kindWords = {
|
|
20
38
|
pdf: "PDF",
|
|
@@ -78,6 +96,30 @@ function splitName(name) {
|
|
|
78
96
|
end: `.${name.slice(-extension.length)}`
|
|
79
97
|
};
|
|
80
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* A file name shortened to fit `width`, cut with an ellipsis the way a file manager cuts it:
|
|
101
|
+
* the extension always stays, and so do the last `keep` letters before it, so „Angebot-
|
|
102
|
+
* Kornprobst.pdf“ becomes „Angebot-Ko…bst.pdf“. `measure` gives the drawn width of a text in
|
|
103
|
+
* the name's own font. The cut is exact, so no gap is left before what stays (a CSS ellipsis
|
|
104
|
+
* leaves up to a letter's room). A name that fits is returned as it is.
|
|
105
|
+
*/
|
|
106
|
+
function fitName(name, width, measure, keep = 3) {
|
|
107
|
+
if (measure(name) <= width) return name;
|
|
108
|
+
const { stem, end } = splitName(name);
|
|
109
|
+
for (let tail = Math.min(keep, Math.max(0, stem.length - 1)); tail >= 0; tail--) {
|
|
110
|
+
const after = `…${stem.slice(stem.length - tail)}${end}`;
|
|
111
|
+
const room = stem.length - tail;
|
|
112
|
+
let low = 0;
|
|
113
|
+
let high = room;
|
|
114
|
+
while (low < high) {
|
|
115
|
+
const mid = Math.ceil((low + high) / 2);
|
|
116
|
+
if (measure(stem.slice(0, mid) + after) <= width) low = mid;
|
|
117
|
+
else high = mid - 1;
|
|
118
|
+
}
|
|
119
|
+
if (low > 0) return stem.slice(0, low).trimEnd() + after;
|
|
120
|
+
}
|
|
121
|
+
return `…${end}`;
|
|
122
|
+
}
|
|
81
123
|
/** The kind of a file: its MIME type decides, and its extension where the type says too little. */
|
|
82
124
|
function kindOf({ name, type = "" }) {
|
|
83
125
|
const mime = type.toLowerCase();
|
|
@@ -97,4 +139,4 @@ function typeWord(file) {
|
|
|
97
139
|
if (extension && extension.length <= 5) return extension.toUpperCase();
|
|
98
140
|
return kindWords[kindOf(file)];
|
|
99
141
|
}
|
|
100
|
-
export { extensionOf, kindOf, kindSymbols, kindWords, splitName, typeWord };
|
|
142
|
+
export { extensionOf, fitName, kindOf, kindSymbols, kindSymbolsSmall, kindWords, splitName, typeWord };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { VariantProps } from "class-variance-authority";
|
|
2
2
|
/**
|
|
3
|
-
* The fitting of a `ButtonGroup`: the face, the edge and the shadow that all its keys share.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* The fitting of a `ButtonGroup`: the face, the edge and the shadow that all its keys share. Under
|
|
4
|
+
* the pointer the whole fitting lifts; a press moves only the key that was pressed (see
|
|
5
|
+
* `buttonGroupKeyVariants`), so the fitting itself stays where it is. Server-safe, like
|
|
6
|
+
* `buttonVariants`.
|
|
6
7
|
*
|
|
7
8
|
* `--key-hover` and `--key-pressed` are what a key lays over the face (button-group.css has the
|
|
8
9
|
* seams and the corners).
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
2
|
// src/components/button-group/button-group-variants.ts
|
|
3
3
|
/**
|
|
4
|
-
* The fitting of a `ButtonGroup`: the face, the edge and the shadow that all its keys share.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The fitting of a `ButtonGroup`: the face, the edge and the shadow that all its keys share. Under
|
|
5
|
+
* the pointer the whole fitting lifts; a press moves only the key that was pressed (see
|
|
6
|
+
* `buttonGroupKeyVariants`), so the fitting itself stays where it is. Server-safe, like
|
|
7
|
+
* `buttonVariants`.
|
|
7
8
|
*
|
|
8
9
|
* `--key-hover` and `--key-pressed` are what a key lays over the face (button-group.css has the
|
|
9
10
|
* seams and the corners).
|
|
10
11
|
*/
|
|
11
12
|
const buttonGroupVariants = cva([
|
|
12
13
|
"relative inline-flex shrink-0 items-stretch font-medium",
|
|
13
|
-
"transition-[box-shadow
|
|
14
|
-
"has-[[data-group-key]:hover]:
|
|
15
|
-
"has-[[data-group-key]:active]:scale-(--motion-press-scale) has-[[data-group-key]:active]:shadow-pressed has-[[data-group-key]:active]:spring-snap",
|
|
14
|
+
"transition-[box-shadow] spring-seat",
|
|
15
|
+
"has-[[data-group-key]:hover]:depth-raised-hover has-[[data-group-key]:hover]:spring-snap",
|
|
16
16
|
"data-[orientation=vertical]:flex-col",
|
|
17
17
|
"data-disabled:bg-disabled data-disabled:depth-flat"
|
|
18
18
|
], {
|
|
@@ -42,15 +42,16 @@ const buttonGroupVariants = cva([
|
|
|
42
42
|
*/
|
|
43
43
|
const buttonGroupKeyDisabledLook = "data-disabled:bg-disabled data-disabled:text-on-disabled";
|
|
44
44
|
/**
|
|
45
|
-
* One key of the fitting. It has no face of its own: the fitting's gloss shows through
|
|
46
|
-
* marks the key under the pointer
|
|
47
|
-
*
|
|
48
|
-
* never sideways, so two keys
|
|
45
|
+
* One key of the fitting. It has no face of its own: the fitting's gloss shows through and a wash
|
|
46
|
+
* marks the key under the pointer. A press moves only this key: it takes the pressed colour and
|
|
47
|
+
* the inner shade and goes down to the press scale, while the fitting and the other keys stay
|
|
48
|
+
* still. On a touch screen its target grows to 44px up and down, never sideways, so two keys
|
|
49
|
+
* never take each other's taps.
|
|
49
50
|
*/
|
|
50
51
|
const buttonGroupKeyVariants = cva([
|
|
51
52
|
"relative inline-flex shrink-0 items-center justify-center whitespace-nowrap outline-offset-2 select-none",
|
|
52
|
-
"transition-[background-color,box-shadow] spring-seat hover:bg-(--key-hover) hover:spring-snap",
|
|
53
|
-
"active:bg-(--key-pressed) active:inset-shadow-pressed active:spring-snap",
|
|
53
|
+
"transition-[background-color,box-shadow,scale] spring-seat hover:bg-(--key-hover) hover:spring-snap",
|
|
54
|
+
"active:scale-(--motion-press-scale) active:bg-(--key-pressed) active:inset-shadow-pressed active:spring-snap",
|
|
54
55
|
"data-popup-open:bg-(--key-hover)",
|
|
55
56
|
"focus-visible:z-1 focus-visible:rounded-[inherit] focus-visible:outline-2 focus-visible:outline-accent",
|
|
56
57
|
"pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:top-1/2 pointer-coarse:after:h-11 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']",
|
|
@@ -20,9 +20,9 @@ export type ButtonGroupProps = Omit<ComponentProps<"div">, "aria-label" | "aria-
|
|
|
20
20
|
* Actions that belong together, as one fitting with several keys: an action and the menu of its
|
|
21
21
|
* other forms ("Senden" and a chevron), two or three steps on the same thing ("Archivieren",
|
|
22
22
|
* "Melden", "Später"), a pair of arrows. The keys share one face, one edge and one shadow, a
|
|
23
|
-
* seam in the edge's colour divides them
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* seam in the edge's colour divides them. The fitting lifts under the pointer as one part; a
|
|
24
|
+
* press moves only the key that was pressed, which takes the inner shade and goes down while the
|
|
25
|
+
* fitting stays where it is.
|
|
26
26
|
*
|
|
27
27
|
* Put `Button`s inside, or a `SelectTrigger`. A key that opens a popup is its trigger rendered
|
|
28
28
|
* as a button (`<MenuTrigger render={<Button iconOnly aria-label="…" />}>`). The keys take the
|
|
@@ -9,9 +9,9 @@ import { useMemo } from "react";
|
|
|
9
9
|
* Actions that belong together, as one fitting with several keys: an action and the menu of its
|
|
10
10
|
* other forms ("Senden" and a chevron), two or three steps on the same thing ("Archivieren",
|
|
11
11
|
* "Melden", "Später"), a pair of arrows. The keys share one face, one edge and one shadow, a
|
|
12
|
-
* seam in the edge's colour divides them
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* seam in the edge's colour divides them. The fitting lifts under the pointer as one part; a
|
|
13
|
+
* press moves only the key that was pressed, which takes the inner shade and goes down while the
|
|
14
|
+
* fitting stays where it is.
|
|
15
15
|
*
|
|
16
16
|
* Put `Button`s inside, or a `SelectTrigger`. A key that opens a popup is its trigger rendered
|
|
17
17
|
* as a button (`<MenuTrigger render={<Button iconOnly aria-label="…" />}>`). The keys take the
|
|
@@ -6,8 +6,16 @@ type DivProps = ComponentProps<"div">;
|
|
|
6
6
|
* the members of a team, each named by a `CardBar`, with its `Table` or list running to the
|
|
7
7
|
* card's edges (Justin, 2026-11-19). The pages of a site and the docs are not chopped into
|
|
8
8
|
* boxes: what is only read there stands on the ground under a rule (`Separator`).
|
|
9
|
+
*
|
|
10
|
+
* `variant="bevel"` (Fase) cuts the card like a fitting: a crisp edge, light along its top, a
|
|
11
|
+
* lip along its foot and a short shadow, so it stands on the page as a machined part instead of
|
|
12
|
+
* floating over it. For a card that is handled (a choice, a prompt to copy, a tile to open).
|
|
13
|
+
* `variant="gloss"` (Glanz) is the same cut with a face that visibly shines and darkens toward
|
|
14
|
+
* its foot, as Clerk's cards on a dark page. Both stay (Justin, 2026-11-20).
|
|
9
15
|
*/
|
|
10
|
-
export declare function Card({ className, ...props }: DivProps
|
|
16
|
+
export declare function Card({ variant, className, ...props }: DivProps & {
|
|
17
|
+
variant?: "default" | "bevel" | "gloss";
|
|
18
|
+
}): import("react").JSX.Element;
|
|
11
19
|
export declare function CardHeader({ className, ...props }: DivProps): import("react").JSX.Element;
|
|
12
20
|
/**
|
|
13
21
|
* The bar across the top of a card that holds a list, a table or a feed: its name (a `Heading`
|
|
@@ -7,14 +7,26 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
* the members of a team, each named by a `CardBar`, with its `Table` or list running to the
|
|
8
8
|
* card's edges (Justin, 2026-11-19). The pages of a site and the docs are not chopped into
|
|
9
9
|
* boxes: what is only read there stands on the ground under a rule (`Separator`).
|
|
10
|
+
*
|
|
11
|
+
* `variant="bevel"` (Fase) cuts the card like a fitting: a crisp edge, light along its top, a
|
|
12
|
+
* lip along its foot and a short shadow, so it stands on the page as a machined part instead of
|
|
13
|
+
* floating over it. For a card that is handled (a choice, a prompt to copy, a tile to open).
|
|
14
|
+
* `variant="gloss"` (Glanz) is the same cut with a face that visibly shines and darkens toward
|
|
15
|
+
* its foot, as Clerk's cards on a dark page. Both stay (Justin, 2026-11-20).
|
|
10
16
|
*/
|
|
11
|
-
function Card({ className, ...props }) {
|
|
17
|
+
function Card({ variant = "default", className, ...props }) {
|
|
12
18
|
return /* @__PURE__ */ jsx("div", {
|
|
13
19
|
"data-slot": "card",
|
|
14
|
-
|
|
20
|
+
"data-variant": variant,
|
|
21
|
+
className: cn("flex flex-col rounded-xl bg-surface", depthOf[variant], className),
|
|
15
22
|
...props
|
|
16
23
|
});
|
|
17
24
|
}
|
|
25
|
+
const depthOf = {
|
|
26
|
+
default: "depth-card",
|
|
27
|
+
bevel: "depth-bevel",
|
|
28
|
+
gloss: "depth-gloss"
|
|
29
|
+
};
|
|
18
30
|
function CardHeader({ className, ...props }) {
|
|
19
31
|
return /* @__PURE__ */ jsx("div", {
|
|
20
32
|
"data-slot": "card-header",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { ChoiceCardBody, choiceCard, choiceControl } from "../../internal/choice-card.js";
|
|
2
|
+
import { ChoiceCardBody, choiceCard, choiceControl, followPointer } from "../../internal/choice-card.js";
|
|
3
3
|
import { TickGlyph } from "../../internal/glyphs.js";
|
|
4
4
|
import { cn } from "../../lib/cn.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -21,7 +21,8 @@ function CheckboxCard({ title, description, detail, icon, chosen = "edge", class
|
|
|
21
21
|
const descriptionId = useId();
|
|
22
22
|
return /* @__PURE__ */ jsxs("label", {
|
|
23
23
|
"data-slot": "checkbox-card",
|
|
24
|
-
|
|
24
|
+
onPointerMove: followPointer,
|
|
25
|
+
className: cn(choiceCard, chosen === "edge" && "has-[[data-slot=choice-control][data-checked]]:depth-bevel-chosen", className),
|
|
25
26
|
children: [/* @__PURE__ */ jsx(Checkbox.Root, {
|
|
26
27
|
"data-slot": "choice-control",
|
|
27
28
|
"aria-labelledby": titleId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { disclosureChevron, disclosurePanel } from "../../internal/disclosure.js";
|
|
2
|
+
import { disclosureChevron, disclosurePanel, disclosureUnfold } from "../../internal/disclosure.js";
|
|
3
3
|
import { ChevronRightGlyph } from "../../internal/glyphs.js";
|
|
4
4
|
import { cn, mergeClassName } from "../../lib/cn.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -34,7 +34,7 @@ function CollapsibleTrigger({ className, children, ...props }) {
|
|
|
34
34
|
...props,
|
|
35
35
|
children: [/* @__PURE__ */ jsx(ChevronRightGlyph, {
|
|
36
36
|
"data-slot": "collapsible-chevron",
|
|
37
|
-
className: cn(disclosureChevron, "-ml-1 group-data-panel-open:rotate-90")
|
|
37
|
+
className: cn(disclosureChevron, "-ml-1 [--lean:var(--motion-lean)_0] group-data-panel-open:rotate-90 group-data-panel-open:[--lean:0_var(--motion-lean)]")
|
|
38
38
|
}), children]
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -42,7 +42,11 @@ function CollapsibleTrigger({ className, children, ...props }) {
|
|
|
42
42
|
function CollapsiblePanel({ className, children, ...props }) {
|
|
43
43
|
return /* @__PURE__ */ jsx(Collapsible$1.Panel, {
|
|
44
44
|
"data-slot": "collapsible-panel",
|
|
45
|
-
className: mergeClassName([
|
|
45
|
+
className: mergeClassName([
|
|
46
|
+
"-mx-1 h-(--collapsible-panel-height) self-stretch",
|
|
47
|
+
disclosurePanel,
|
|
48
|
+
disclosureUnfold
|
|
49
|
+
], className),
|
|
46
50
|
...props,
|
|
47
51
|
children: /* @__PURE__ */ jsx("div", {
|
|
48
52
|
"data-slot": "collapsible-panel-content",
|
|
@@ -121,7 +121,9 @@ export type ComboboxItemProps = Combobox$1.Item.Props & {
|
|
|
121
121
|
};
|
|
122
122
|
/**
|
|
123
123
|
* One row. Pass the option as `value`; its label, icon and detail are shown unless you give
|
|
124
|
-
* children or props of your own.
|
|
124
|
+
* children or props of your own. As in a `Select`, the chosen row carries its mark at the right
|
|
125
|
+
* end (the disc, or the tick where several can be chosen), or stands on the tint where the rows
|
|
126
|
+
* have a detail; chosen rows that touch are one shape.
|
|
125
127
|
*/
|
|
126
128
|
export declare function ComboboxItem({ className, children, icon, detail, value, ...props }: ComboboxItemProps): import("react").JSX.Element;
|
|
127
129
|
/** A group of rows. Pass the group's `items`, then a `ComboboxGroupLabel` and a `ComboboxCollection`. */
|