@lanfermann/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.
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { disclosureChevron, disclosurePanel } from "../../internal/disclosure.js";
3
3
  import { ChevronDownGlyph } from "../../internal/glyphs.js";
4
+ import { ruleTop } from "../../internal/rule.js";
4
5
  import { cn, mergeClassName } from "../../lib/cn.js";
5
6
  import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
6
7
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -16,7 +17,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
16
17
  function Accordion({ className, ...props }) {
17
18
  return /* @__PURE__ */ jsx(Accordion$1.Root, {
18
19
  "data-slot": "accordion",
19
- className: mergeClassName("flex w-full flex-col border-t-2 border-rule", className),
20
+ className: mergeClassName(["flex w-full flex-col", ruleTop], className),
20
21
  ...props
21
22
  });
22
23
  }
@@ -0,0 +1,46 @@
1
+ import { ComponentProps } from "react";
2
+ export type CopyPageProps = Omit<ComponentProps<"div">, "children"> & {
3
+ /** The page as Markdown, on this site: what is copied, and what "view" opens. */
4
+ href: string;
5
+ /** The button, and the first entry of the menu: the thing, then the action ("Seite kopieren"). */
6
+ label: string;
7
+ /** Under it in the menu: what the copy is, and for whom ("Als Markdown, für eine KI"). */
8
+ description: string;
9
+ /** The second entry: "Als Markdown ansehen". */
10
+ viewLabel: string;
11
+ /** Under it: "Die Seite als reiner Text". */
12
+ viewDescription: string;
13
+ /** The name of the button that opens the menu ("Weitere Möglichkeiten"). */
14
+ moreLabel: string;
15
+ /** Read out once the page is on the clipboard: a full sentence ("Die Seite ist kopiert."). */
16
+ copied: string;
17
+ /** Read out when the clipboard refused or the page could not be loaded. */
18
+ failed: string;
19
+ /** Called once the page has reached the clipboard. */
20
+ onCopied?: () => void;
21
+ /** Opens the menu on the first render: for stories and screenshots. */
22
+ defaultOpen?: boolean;
23
+ };
24
+ /**
25
+ * Hands a docs page on as Markdown: one raised fitting split in two, the copy and the menu. The
26
+ * copy fetches the page's Markdown and puts it on the clipboard, for a model or an agent; the
27
+ * menu repeats it with a line on what it is, and opens the Markdown in a new tab. Put it in the
28
+ * page header, at the end of the row above the title.
29
+ *
30
+ * It is one part with two keys, so it moves as one: under the pointer the whole fitting lifts,
31
+ * and the key under it takes the hover wash. Pressed, the fitting goes down and drops its
32
+ * ambient shadow, and only the pressed key takes the inner shade, so it rocks on that key and the
33
+ * other keeps its gloss. A copy is confirmed in the key, as in a code block: the copy symbol
34
+ * shrinks away and the tick draws itself, short leg first, then fades where it stands while the
35
+ * symbol seats back. There is no toast; a screen reader hears one sentence.
36
+ *
37
+ * The chevron turns over while the menu is open, settling with a small bounce; the sheet grows
38
+ * out of it and leaves by fading, as every sheet does. The menu's rows carry a tile with their
39
+ * symbol, and the row under the pointer or the keyboard highlights at once. Copying from the
40
+ * menu closes it and confirms in the key, where the eye goes back to.
41
+ *
42
+ * The Markdown is fetched as soon as a pointer or the keyboard reaches the fitting, so the copy
43
+ * that follows is immediate; where the browser takes a promise for the clipboard (Safari, Chrome)
44
+ * the fetch can finish inside the press. Word the labels as the thing, then the action.
45
+ */
46
+ export declare function CopyPage({ href, label, description, viewLabel, viewDescription, moreLabel, copied: copiedSentence, failed: failedSentence, onCopied, defaultOpen, className, onPointerEnter, onFocus, ...props }: CopyPageProps): import("react").JSX.Element;
@@ -0,0 +1,223 @@
1
+ "use client";
2
+ import { Icon } from "../icon/icon.js";
3
+ import { MenuContent, MenuItem, MenuLinkItem } from "../menu/menu.js";
4
+ import { ActionArrow } from "../../internal/arrow.js";
5
+ import { ChevronDownGlyph, TickGlyph } from "../../internal/glyphs.js";
6
+ import { cn } from "../../lib/cn.js";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { Copy01Icon } from "@hugeicons/core-free-icons";
9
+ import { useEffect, useRef, useState } from "react";
10
+ import { Menu } from "@base-ui/react/menu";
11
+ // src/components/copy-page/copy-page.tsx
12
+ /** How long a copy stays confirmed before the symbol comes back, in ms (as in a code block). */
13
+ const CONFIRM_MS = 1600;
14
+ /**
15
+ * Hands a docs page on as Markdown: one raised fitting split in two, the copy and the menu. The
16
+ * copy fetches the page's Markdown and puts it on the clipboard, for a model or an agent; the
17
+ * menu repeats it with a line on what it is, and opens the Markdown in a new tab. Put it in the
18
+ * page header, at the end of the row above the title.
19
+ *
20
+ * It is one part with two keys, so it moves as one: under the pointer the whole fitting lifts,
21
+ * and the key under it takes the hover wash. Pressed, the fitting goes down and drops its
22
+ * ambient shadow, and only the pressed key takes the inner shade, so it rocks on that key and the
23
+ * other keeps its gloss. A copy is confirmed in the key, as in a code block: the copy symbol
24
+ * shrinks away and the tick draws itself, short leg first, then fades where it stands while the
25
+ * symbol seats back. There is no toast; a screen reader hears one sentence.
26
+ *
27
+ * The chevron turns over while the menu is open, settling with a small bounce; the sheet grows
28
+ * out of it and leaves by fading, as every sheet does. The menu's rows carry a tile with their
29
+ * symbol, and the row under the pointer or the keyboard highlights at once. Copying from the
30
+ * menu closes it and confirms in the key, where the eye goes back to.
31
+ *
32
+ * The Markdown is fetched as soon as a pointer or the keyboard reaches the fitting, so the copy
33
+ * that follows is immediate; where the browser takes a promise for the clipboard (Safari, Chrome)
34
+ * the fetch can finish inside the press. Word the labels as the thing, then the action.
35
+ */
36
+ function CopyPage({ href, label, description, viewLabel, viewDescription, moreLabel, copied: copiedSentence, failed: failedSentence, onCopied, defaultOpen, className, onPointerEnter, onFocus, ...props }) {
37
+ const [state, setState] = useState("idle");
38
+ const timer = useRef(void 0);
39
+ useEffect(() => () => clearTimeout(timer.current), []);
40
+ const markdown = useRef(void 0);
41
+ const load = () => {
42
+ markdown.current ??= fetch(href).then((response) => {
43
+ if (!response.ok) throw new Error(`${response.status}`);
44
+ return response.text();
45
+ });
46
+ return markdown.current;
47
+ };
48
+ const settle = (next) => {
49
+ clearTimeout(timer.current);
50
+ setState(next);
51
+ timer.current = setTimeout(() => setState("idle"), CONFIRM_MS);
52
+ };
53
+ async function copy() {
54
+ const text = load();
55
+ try {
56
+ if (typeof ClipboardItem !== "undefined" && navigator.clipboard?.write) {
57
+ const blob = text.then((body) => new Blob([body], { type: "text/plain" }));
58
+ await navigator.clipboard.write([new ClipboardItem({ "text/plain": blob })]);
59
+ } else await navigator.clipboard.writeText(await text);
60
+ settle("copied");
61
+ onCopied?.();
62
+ } catch {
63
+ try {
64
+ await navigator.clipboard.writeText(await text);
65
+ settle("copied");
66
+ onCopied?.();
67
+ } catch {
68
+ markdown.current = void 0;
69
+ settle("failed");
70
+ }
71
+ }
72
+ }
73
+ const isCopied = state === "copied";
74
+ return /* @__PURE__ */ jsxs("div", {
75
+ "data-slot": "copy-page",
76
+ className: cn("relative inline-flex h-(--control-sm) shrink-0 items-stretch rounded-md bg-raised depth-raised text-sm font-medium text-fg", "transition-[box-shadow,scale] spring-seat", "has-[button:hover]:spring-snap has-[button:hover:not(:active)]:depth-raised-hover", "has-[button:active]:scale-(--motion-press-scale) has-[button:active]:shadow-pressed has-[button:active]:spring-snap", className),
77
+ onPointerEnter: (event) => {
78
+ load().catch(() => {});
79
+ onPointerEnter?.(event);
80
+ },
81
+ onFocus: (event) => {
82
+ load().catch(() => {});
83
+ onFocus?.(event);
84
+ },
85
+ ...props,
86
+ children: [
87
+ /* @__PURE__ */ jsxs("button", {
88
+ type: "button",
89
+ "data-slot": "copy-page-copy",
90
+ "data-copied": isCopied ? "" : void 0,
91
+ onClick: () => void copy(),
92
+ className: cn(key, "gap-1.5 rounded-l-md pr-2.5 pl-(--control-pad-sm)"),
93
+ children: [/* @__PURE__ */ jsxs("span", {
94
+ className: "relative flex size-4 shrink-0 items-center justify-center",
95
+ children: [/* @__PURE__ */ jsx(Icon, {
96
+ "data-slot": "copy-page-symbol",
97
+ icon: Copy01Icon,
98
+ size: 16,
99
+ className: "absolute"
100
+ }), /* @__PURE__ */ jsx(TickGlyph, {
101
+ "data-slot": "copy-page-tick",
102
+ width: 20,
103
+ height: 20,
104
+ strokeWidth: 21 / 20,
105
+ className: "absolute"
106
+ })]
107
+ }), label]
108
+ }),
109
+ /* @__PURE__ */ jsx("span", {
110
+ "aria-hidden": true,
111
+ "data-slot": "copy-page-divider",
112
+ className: "w-px bg-hairline"
113
+ }),
114
+ /* @__PURE__ */ jsxs(Menu.Root, {
115
+ modal: false,
116
+ defaultOpen,
117
+ children: [/* @__PURE__ */ jsx(Menu.Trigger, {
118
+ "data-slot": "copy-page-more",
119
+ "aria-label": moreLabel,
120
+ className: cn(key, "group/more justify-center rounded-r-md px-1.5 data-popup-open:bg-hover pointer-coarse:px-2.5"),
121
+ children: /* @__PURE__ */ jsx(ChevronDownGlyph, {
122
+ width: 12,
123
+ height: 12,
124
+ className: "text-fg-muted transition-[rotate,color] spring-seat group-hover/more:text-fg group-data-popup-open/more:rotate-180 group-data-popup-open/more:text-fg motion-reduce:transition-none"
125
+ })
126
+ }), /* @__PURE__ */ jsxs(MenuContent, {
127
+ align: "end",
128
+ className: "w-76 p-1.5",
129
+ children: [/* @__PURE__ */ jsxs(MenuItem, {
130
+ onClick: () => void copy(),
131
+ className: row,
132
+ children: [/* @__PURE__ */ jsx(Tile, { children: /* @__PURE__ */ jsx(Icon, {
133
+ icon: Copy01Icon,
134
+ size: 16
135
+ }) }), /* @__PURE__ */ jsx(RowText, {
136
+ title: label,
137
+ description
138
+ })]
139
+ }), /* @__PURE__ */ jsxs(MenuLinkItem, {
140
+ href,
141
+ target: "_blank",
142
+ rel: "noopener",
143
+ className: row,
144
+ children: [/* @__PURE__ */ jsx(Tile, { children: /* @__PURE__ */ jsx(MarkdownGlyph, {}) }), /* @__PURE__ */ jsx(RowText, {
145
+ title: /* @__PURE__ */ jsxs(Fragment, { children: [viewLabel, /* @__PURE__ */ jsx(ActionArrow, {
146
+ direction: "out",
147
+ size: 12,
148
+ className: "text-fg-muted"
149
+ })] }),
150
+ description: viewDescription
151
+ })]
152
+ })]
153
+ })]
154
+ }),
155
+ /* @__PURE__ */ jsx("span", {
156
+ role: "status",
157
+ className: "sr-only",
158
+ children: state === "copied" ? copiedSentence : state === "failed" ? failedSentence : ""
159
+ })
160
+ ]
161
+ });
162
+ }
163
+ /**
164
+ * One key of the fitting. It has no face of its own: the fitting's gloss shows through, a wash
165
+ * marks the key under the pointer, and a press shades only this key. On a touch screen its target
166
+ * grows to 44px up and down, never sideways, so the two keys never take each other's taps.
167
+ */
168
+ const key = [
169
+ "relative inline-flex items-center outline-offset-2 select-none",
170
+ "transition-[background-color,box-shadow] spring-seat hover:bg-hover hover:spring-snap",
171
+ "active:bg-raised-pressed active:inset-shadow-pressed active:spring-snap",
172
+ "focus-visible:z-1 focus-visible:rounded-md focus-visible:outline-2 focus-visible:outline-accent",
173
+ "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-['']"
174
+ ].join(" ");
175
+ /** A row of the menu: a tile, then two lines. It keeps the list's instant highlight. */
176
+ const row = "group/row items-center gap-3 px-2 py-2";
177
+ function Tile({ children }) {
178
+ return /* @__PURE__ */ jsx("span", {
179
+ "aria-hidden": true,
180
+ "data-slot": "copy-page-tile",
181
+ className: "flex size-8 shrink-0 items-center justify-center rounded-md bg-surface text-fg-muted inset-ring inset-ring-hairline group-data-highlighted/row:text-fg forced-colors:inset-ring-[CanvasText]",
182
+ children
183
+ });
184
+ }
185
+ function RowText({ title, description }) {
186
+ return /* @__PURE__ */ jsxs("span", {
187
+ className: "flex min-w-0 flex-col gap-0.5",
188
+ children: [/* @__PURE__ */ jsx("span", {
189
+ className: "flex items-center gap-1 text-control leading-tight text-fg",
190
+ children: title
191
+ }), /* @__PURE__ */ jsx("span", {
192
+ className: "text-sm leading-snug text-fg-muted",
193
+ children: description
194
+ })]
195
+ });
196
+ }
197
+ /** The Markdown mark (an M and a down arrow in a frame), drawn at the icons' weight. */
198
+ function MarkdownGlyph(props) {
199
+ return /* @__PURE__ */ jsxs("svg", {
200
+ "aria-hidden": true,
201
+ width: 16,
202
+ height: 16,
203
+ viewBox: "0 0 24 24",
204
+ fill: "none",
205
+ stroke: "currentColor",
206
+ strokeWidth: 1.5,
207
+ strokeLinecap: "round",
208
+ strokeLinejoin: "round",
209
+ ...props,
210
+ children: [
211
+ /* @__PURE__ */ jsx("rect", {
212
+ x: "2",
213
+ y: "5",
214
+ width: "20",
215
+ height: "14",
216
+ rx: "3"
217
+ }),
218
+ /* @__PURE__ */ jsx("path", { d: "M6 15V9l2.5 3L11 9v6" }),
219
+ /* @__PURE__ */ jsx("path", { d: "M16.5 9v6m-2.5-2.5 2.5 2.5 2.5-2.5" })
220
+ ]
221
+ });
222
+ }
223
+ export { CopyPage };
@@ -5,8 +5,10 @@ import { ComponentProps } from "react";
5
5
  * in the middle, the page's sections on the right.
6
6
  *
7
7
  * The side columns stay in view while the text scrolls, below a sticky bar of the height in
8
- * `--docs-top` (4rem: the `SiteHeader`'s bar, 8px off the top and 56px tall). The pages column shows from `lg`, the sections column
9
- * from `xl`; below that, the pages go into the site's menu and the sections fold above the text.
8
+ * `--docs-top` (4rem: the `SiteHeader`'s bar, 8px off the top and 56px tall). A side column
9
+ * longer than the window scrolls inside itself, and fades at the end that has more. The pages
10
+ * column shows from `lg`, the sections column from `xl`; below that, the pages go into the
11
+ * site's menu and the sections fold above the text.
10
12
  */
11
13
  export declare function DocsLayout({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
12
14
  /** The pages of the set: a `SideNav`. Hidden below `lg`. */
@@ -1,4 +1,5 @@
1
1
  import { containerVariants } from "../container/container.js";
2
+ import { ScrollFade } from "../../internal/scroll-fade.js";
2
3
  import { cn } from "../../lib/cn.js";
3
4
  import { jsx } from "react/jsx-runtime";
4
5
  // src/components/docs-layout/docs-layout.tsx
@@ -8,8 +9,10 @@ import { jsx } from "react/jsx-runtime";
8
9
  * in the middle, the page's sections on the right.
9
10
  *
10
11
  * The side columns stay in view while the text scrolls, below a sticky bar of the height in
11
- * `--docs-top` (4rem: the `SiteHeader`'s bar, 8px off the top and 56px tall). The pages column shows from `lg`, the sections column
12
- * from `xl`; below that, the pages go into the site's menu and the sections fold above the text.
12
+ * `--docs-top` (4rem: the `SiteHeader`'s bar, 8px off the top and 56px tall). A side column
13
+ * longer than the window scrolls inside itself, and fades at the end that has more. The pages
14
+ * column shows from `lg`, the sections column from `xl`; below that, the pages go into the
15
+ * site's menu and the sections fold above the text.
13
16
  */
14
17
  function DocsLayout({ className, ...props }) {
15
18
  return /* @__PURE__ */ jsx("div", {
@@ -18,10 +21,11 @@ function DocsLayout({ className, ...props }) {
18
21
  ...props
19
22
  });
20
23
  }
21
- const sticky = "sticky top-(--docs-top) max-h-[calc(100dvh-var(--docs-top))] self-start overflow-y-auto overscroll-contain [scrollbar-width:thin]";
24
+ const sticky = "sticky top-(--docs-top) max-h-[calc(100dvh-var(--docs-top))] scroll-py-10 self-start overflow-y-auto overscroll-contain [scrollbar-width:thin]";
22
25
  /** The pages of the set: a `SideNav`. Hidden below `lg`. */
23
26
  function DocsLayoutNav({ className, ...props }) {
24
- return /* @__PURE__ */ jsx("div", {
27
+ return /* @__PURE__ */ jsx(ScrollFade, {
28
+ axis: "y",
25
29
  "data-slot": "docs-layout-nav",
26
30
  className: cn(sticky, "-ml-2.5 hidden pt-10 pr-1 pb-10 pl-2.5 lg:block", className),
27
31
  ...props
@@ -37,7 +41,8 @@ function DocsLayoutMain({ className, ...props }) {
37
41
  }
38
42
  /** The sections of the page: a `TableOfContents`. Hidden below `xl`. */
39
43
  function DocsLayoutAside({ className, ...props }) {
40
- return /* @__PURE__ */ jsx("div", {
44
+ return /* @__PURE__ */ jsx(ScrollFade, {
45
+ axis: "y",
41
46
  "data-slot": "docs-layout-aside",
42
47
  className: cn(sticky, "hidden pt-10 pb-10 pl-1 xl:block", className),
43
48
  ...props
@@ -1,5 +1,6 @@
1
1
  import { Heading } from "../heading/heading.js";
2
2
  import { Text } from "../text/text.js";
3
+ import { ruleTop } from "../../internal/rule.js";
3
4
  import { cn } from "../../lib/cn.js";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  // src/components/page-header/page-header.tsx
@@ -10,7 +11,7 @@ import { jsx } from "react/jsx-runtime";
10
11
  function PageHeader({ rule = false, className, ...props }) {
11
12
  return /* @__PURE__ */ jsx("div", {
12
13
  "data-slot": "page-header",
13
- className: cn("flex flex-col items-start gap-4", rule && "border-t-2 border-rule pt-6", className),
14
+ className: cn("flex flex-col items-start gap-4", rule && [ruleTop, "pt-6"], className),
14
15
  ...props
15
16
  });
16
17
  }
@@ -1,3 +1,4 @@
1
+ import { ruleTop } from "../../internal/rule.js";
1
2
  import { cn } from "../../lib/cn.js";
2
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
4
  import { Fragment as Fragment$1 } from "react";
@@ -13,7 +14,7 @@ import { Fragment as Fragment$1 } from "react";
13
14
  function ParameterList({ className, ...props }) {
14
15
  return /* @__PURE__ */ jsx("dl", {
15
16
  "data-slot": "parameter-list",
16
- className: cn("flex flex-col border-t-2 border-rule", className),
17
+ className: cn("flex flex-col", ruleTop, className),
17
18
  ...props
18
19
  });
19
20
  }
@@ -10,8 +10,8 @@ const separatorVariants = cva("shrink-0 data-[orientation=horizontal]:h-(--separ
10
10
  hairline: "bg-hairline [--separator-size:1px]",
11
11
  /** The kit's structural 1px line, visible on its own (3:1). */
12
12
  line: "bg-line [--separator-size:1px]",
13
- /** The 2px rule that opens a block. */
14
- rule: "bg-rule [--separator-size:2px]"
13
+ /** The 2px rule that opens a block: a line with round ends. */
14
+ rule: "rounded-full bg-rule [--separator-size:2px]"
15
15
  } },
16
16
  defaultVariants: { variant: "hairline" }
17
17
  });
@@ -8,7 +8,7 @@ type Named = {
8
8
  "aria-label"?: undefined;
9
9
  };
10
10
  export type TableProps = Omit<ComponentProps<"table">, "aria-label" | "aria-labelledby"> & Named & {
11
- /** Classes for the scrolling region around the table. */
11
+ /** Classes for the box around the table (its rule and the scrolling region): its place. */
12
12
  containerClassName?: string;
13
13
  /**
14
14
  * What the cells hold. `data` (the default): short values, centred on the row's line.
@@ -26,13 +26,13 @@ export type TableProps = Omit<ComponentProps<"table">, "aria-label" | "aria-labe
26
26
  };
27
27
  /**
28
28
  * Rows of the same kind of thing, compared column by column: quotes, invoice lines, members.
29
- * Real `<table>` markup, structured by line and not by box: a 2px rule opens it, hairlines
30
- * divide the rows, no stripes and no card around it.
29
+ * Real `<table>` markup, structured by line and not by box: a 2px rule with round ends opens it,
30
+ * hairlines divide the rows, no stripes and no card around it.
31
31
  *
32
32
  * On a narrow screen the table keeps its columns and scrolls sideways inside its own region,
33
- * which is focusable so the keyboard can scroll it too. Name it with `aria-label` (or
34
- * `aria-labelledby`, pointing at a heading or the `TableCaption`). Give the table a `min-w-*`
35
- * if its columns must not squeeze.
33
+ * which is focusable so the keyboard can scroll it too. Its edges fade where more columns wait;
34
+ * the rule above stays whole. Name it with `aria-label` (or `aria-labelledby`, pointing at a
35
+ * heading or the `TableCaption`). Give the table a `min-w-*` if its columns must not squeeze.
36
36
  *
37
37
  * Sorting, filtering and paging are the caller's state; the table only provides the slots.
38
38
  */
@@ -1,34 +1,40 @@
1
1
  import { ArrowUpGlyph } from "../../internal/glyphs.js";
2
+ import { ruleTop } from "../../internal/rule.js";
3
+ import { ScrollFade } from "../../internal/scroll-fade.js";
2
4
  import { cn } from "../../lib/cn.js";
3
5
  import { jsx, jsxs } from "react/jsx-runtime";
4
6
  // src/components/table/table.tsx
5
7
  /**
6
8
  * Rows of the same kind of thing, compared column by column: quotes, invoice lines, members.
7
- * Real `<table>` markup, structured by line and not by box: a 2px rule opens it, hairlines
8
- * divide the rows, no stripes and no card around it.
9
+ * Real `<table>` markup, structured by line and not by box: a 2px rule with round ends opens it,
10
+ * hairlines divide the rows, no stripes and no card around it.
9
11
  *
10
12
  * On a narrow screen the table keeps its columns and scrolls sideways inside its own region,
11
- * which is focusable so the keyboard can scroll it too. Name it with `aria-label` (or
12
- * `aria-labelledby`, pointing at a heading or the `TableCaption`). Give the table a `min-w-*`
13
- * if its columns must not squeeze.
13
+ * which is focusable so the keyboard can scroll it too. Its edges fade where more columns wait;
14
+ * the rule above stays whole. Name it with `aria-label` (or `aria-labelledby`, pointing at a
15
+ * heading or the `TableCaption`). Give the table a `min-w-*` if its columns must not squeeze.
14
16
  *
15
17
  * Sorting, filtering and paging are the caller's state; the table only provides the slots.
16
18
  */
17
19
  function Table({ className, containerClassName, content = "data", stack = false, "aria-label": label, "aria-labelledby": labelledBy, ...props }) {
18
20
  return /* @__PURE__ */ jsx("div", {
19
21
  "data-slot": "table-container",
20
- role: "region",
21
- "aria-label": label,
22
- "aria-labelledby": labelledBy,
23
- tabIndex: 0,
24
- className: cn("relative w-full overflow-x-auto rounded-xs focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent", containerClassName),
25
- children: /* @__PURE__ */ jsx("table", {
26
- "data-slot": "table",
27
- "data-content": content,
28
- "data-stack": stack ? "" : void 0,
29
- role: "table",
30
- className: cn("w-full caption-bottom border-collapse border-t-2 border-rule text-left text-base text-fg-body", "data-stack:max-sm:block", className),
31
- ...props
22
+ className: cn(ruleTop, "rounded-xs", "has-[[data-slot=table-scroll]:focus-visible]:outline-2", "has-[[data-slot=table-scroll]:focus-visible]:outline-offset-2", "has-[[data-slot=table-scroll]:focus-visible]:outline-accent", containerClassName),
23
+ children: /* @__PURE__ */ jsx(ScrollFade, {
24
+ "data-slot": "table-scroll",
25
+ role: "region",
26
+ "aria-label": label,
27
+ "aria-labelledby": labelledBy,
28
+ tabIndex: 0,
29
+ className: cn("relative w-full overflow-x-auto focus-visible:outline-hidden", "scroll-px-10"),
30
+ children: /* @__PURE__ */ jsx("table", {
31
+ "data-slot": "table",
32
+ "data-content": content,
33
+ "data-stack": stack ? "" : void 0,
34
+ role: "table",
35
+ className: cn("w-full caption-bottom border-collapse text-left text-base text-fg-body", "data-stack:max-sm:block", className),
36
+ ...props
37
+ })
32
38
  })
33
39
  });
34
40
  }
@@ -79,18 +79,23 @@ function useCurrentSection(ids) {
79
79
  }
80
80
  return [current, hold];
81
81
  }
82
- /** Brings an entry into view inside the box that scrolls the contents, never the page. */
82
+ /**
83
+ * Brings an entry into view inside the box that scrolls the contents, never the page. It keeps
84
+ * the box's scroll padding off the edge, which clears the box's fade (`DocsLayoutAside`).
85
+ */
83
86
  function keepInView(link) {
84
87
  let box = link.parentElement;
88
+ let style;
85
89
  while (box && box !== document.body) {
86
- const { overflowY } = getComputedStyle(box);
87
- if (overflowY === "auto" || overflowY === "scroll") break;
90
+ style = getComputedStyle(box);
91
+ if (style.overflowY === "auto" || style.overflowY === "scroll") break;
88
92
  box = box.parentElement;
89
93
  }
90
- if (!box || box === document.body) return;
94
+ if (!box || box === document.body || !style) return;
95
+ const margin = parseFloat(style.scrollPaddingTop) || 24;
91
96
  const top = link.offsetTop - box.offsetTop;
92
- if (top < box.scrollTop + 24) box.scrollTop = Math.max(0, top - 24);
93
- else if (top + link.offsetHeight > box.scrollTop + box.clientHeight - 24) box.scrollTop = top + link.offsetHeight - box.clientHeight + 24;
97
+ if (top < box.scrollTop + margin) box.scrollTop = Math.max(0, top - margin);
98
+ else if (top + link.offsetHeight > box.scrollTop + box.clientHeight - margin) box.scrollTop = top + link.offsetHeight - box.clientHeight + margin;
94
99
  }
95
100
  const indent = {
96
101
  2: "",
@@ -2,6 +2,7 @@
2
2
  import { useReducedMotion } from "../../internal/reduced-motion.js";
3
3
  import { useScrollEdges } from "../../internal/scroll-edges.js";
4
4
  import { cn, mergeClassName } from "../../lib/cn.js";
5
+ import { mergeRefs } from "../../lib/merge-refs.js";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
7
  import { createContext, useContext, useEffect, useRef } from "react";
7
8
  import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
@@ -16,12 +17,6 @@ function Tabs({ className, ...props }) {
16
17
  }
17
18
  /** How far a tab keeps off the edge it is scrolled to: past the fade (tabs.css), in px. */
18
19
  const REVEAL_MARGIN = 40;
19
- function mergeRefs(own, theirs) {
20
- return (node) => {
21
- for (const ref of [own, theirs]) if (typeof ref === "function") ref(node);
22
- else if (ref) ref.current = node;
23
- };
24
- }
25
20
  /**
26
21
  * A row of labels, each with a mark. One soft highlight glides to the current tab (`glide`) and
27
22
  * its mark closes from ring to disc. Base UI measures the active tab; we only move the highlight.
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ import { LineSpec } from "./components/code-block/lines.js";
21
21
  import { Collapsible, CollapsiblePanel, CollapsiblePanelProps, CollapsibleProps, CollapsibleTrigger, CollapsibleTriggerProps } from "./components/collapsible/collapsible.js";
22
22
  import { Combobox, ComboboxCollection, ComboboxContent, ComboboxContentProps, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxInputProps, ComboboxItem, ComboboxItemProps, ComboboxOption, ComboboxOptionGroup, ComboboxProps, ComboboxSeparator } from "./components/combobox/combobox.js";
23
23
  import { Container, ContainerProps, containerVariants } from "./components/container/container.js";
24
+ import { CopyPage, CopyPageProps } from "./components/copy-page/copy-page.js";
24
25
  import { CopyPill, CopyPillMark, CopyPillProps } from "./components/copy-pill/copy-pill.js";
25
26
  import { Cta, CtaAction, CtaActionProps, CtaActions, CtaMessage, CtaMessageProps, CtaProps, CtaText, CtaTitle, CtaTone } from "./components/cta/cta.js";
26
27
  import { DateField, DateFieldProps } from "./components/date-field/date-field.js";
@@ -77,4 +78,4 @@ import { ToastOptions, ToastTone, Toaster, ToasterProps, toast, toastManager } f
77
78
  import { Tooltip, TooltipContent, TooltipContentProps, TooltipProvider, TooltipTrigger } from "./components/tooltip/tooltip.js";
78
79
  import { cn, mergeClassName } from "./lib/cn.js";
79
80
  import { SpringName, springs, transitions } from "./motion/springs.js";
80
- export { Accordion, AccordionItem, type AccordionItemProps, AccordionPanel, type AccordionPanelProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, Alert, AlertDescription, AlertDialog, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, type AlertProps, AlertTitle, AnchorHeading, type AnchorHeadingProps, Avatar, AvatarFallback, AvatarImage, type AvatarProps, Badge, type BadgeProps, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbPage, Breadcrumbs, type BreadcrumbsProps, Button, type ButtonProps, type ButtonVariants, Calendar, type CalendarProps, Callout, type CalloutProps, type CalloutTone, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroup, CheckboxGroupItems, type CheckboxGroupProps, type CheckboxProps, Code, CodeBlock, CodeBlockLive, type CodeBlockLiveProps, type CodeBlockProps, type CodeLanguage, type CodePiece, type CodeRole, type CodeTab, CodeTabs, type CodeTabsProps, Collapsible, CollapsiblePanel, type CollapsiblePanelProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, Combobox, ComboboxCollection, ComboboxContent, type ComboboxContentProps, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, type ComboboxInputProps, ComboboxItem, type ComboboxItemProps, type ComboboxOption, type ComboboxOptionGroup, type ComboboxProps, ComboboxSeparator, Container, type ContainerProps, CopyPill, CopyPillMark, type CopyPillProps, Cta, CtaAction, type CtaActionProps, CtaActions, CtaMessage, type CtaMessageProps, type CtaProps, CtaText, CtaTitle, type CtaTone, DateField, type DateFieldProps, type DateRange, DateRangeField, type DateRangeFieldProps, Dialog, DialogBody, DialogClose, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DocsLayout, DocsLayoutAside, DocsLayoutMain, DocsLayoutNav, Drawer, DrawerBody, DrawerClose, DrawerContent, type DrawerContentProps, DrawerDescription, DrawerFooter, DrawerHeader, type DrawerProps, type DrawerSide, DrawerTitle, DrawerTrigger, Field, FieldDescription, FieldError, FieldLabel, Fieldset, FieldsetLegend, Figure, FigureCaption, FigureFrame, Form, type FormProps, Ground, type GroundName, type GroundProps, Heading, type HeadingProps, Icon, type IconProps, type IconSvgElement, Input, InputGroup, InputGroupAddon, InputGroupButton, type InputGroupButtonProps, type InputGroupProps, type InputProps, Kbd, type LineSpec, Link, type LinkProps, type LinkVariants, Logomark, type LogomarkProps, Menu, MenuCheckboxItem, MenuContent, type MenuContentProps, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Meter, MeterLabel, type MeterProps, MeterTrack, MeterValue, NavigationMenu, NavigationMenuContent, type NavigationMenuEntryVariants, NavigationMenuItem, NavigationMenuLink, NavigationMenuLinkDescription, type NavigationMenuLinkProps, NavigationMenuLinkTitle, NavigationMenuList, type NavigationMenuProps, NavigationMenuTrigger, NumberField, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, type NumberFieldProps, PageHeader, PageHeaderActions, PageHeaderLead, type PageHeaderProps, PageHeaderTitle, type PageHeaderTitleProps, Pager, PagerLink, type PagerLinkProps, type PagerProps, Parameter, ParameterList, type ParameterProps, Popover, PopoverClose, PopoverContent, type PopoverContentProps, PopoverDescription, PopoverTitle, PopoverTrigger, Progress, ProgressLabel, type ProgressProps, ProgressTrack, ProgressValue, Prose, Quote, type QuoteProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, ReferenceEntry, ReferenceEntryBody, ReferenceEntryHeader, ReferenceEntryMeta, ReferenceEntryName, ReferenceEntryTitle, Seam, type SeamProps, Section, type SectionProps, Segment, type SegmentProps, SegmentedControl, type SegmentedControlProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectGroupLabel, SelectItem, type SelectItemProps, type SelectOption, type SelectOptionGroup, type SelectProps, SelectSeparator, SelectTrigger, type SelectTriggerProps, Separator, type SeparatorProps, SideNav, SideNavGroup, type SideNavGroupProps, SideNavLink, type SideNavLinkProps, type SideNavProps, SideNavSubLink, type SideNavSubLinkProps, SiteFooter, SiteFooterBrand, SiteFooterGroup, type SiteFooterGroupProps, SiteFooterLegal, SiteFooterLink, SiteFooterMain, SiteFooterNav, SiteHeader, SiteHeaderActions, SiteHeaderBrand, type SiteHeaderBrandProps, SiteHeaderMenu, SiteHeaderMenuGroup, type SiteHeaderMenuGroupProps, SiteHeaderMenuLink, type SiteHeaderMenuLinkProps, type SiteHeaderMenuProps, type SiteHeaderProps, Slider, SliderControl, type SliderControlProps, SliderLabel, type SliderProps, SliderThumb, type SliderThumbProps, SliderValue, Spinner, type SpinnerProps, type SpringName, Switch, type SwitchProps, Tab, Table, TableBody, TableCaption, TableCell, type TableCellProps, TableFooter, TableHead, type TableHeadProps, TableHeader, TableOfContents, type TableOfContentsProps, type TableProps, TableRow, type TableRowProps, TableSortButton, type TableSortButtonProps, Tabs, TabsList, TabsPanel, TabsPanels, type TabsPanelsProps, type TabsProps, Text, type TextProps, Textarea, type TextareaProps, TimeField, type TimeFieldProps, type ToastOptions, type ToastTone, Toaster, type ToasterProps, type TocItem, Tooltip, TooltipContent, type TooltipContentProps, TooltipProvider, TooltipTrigger, Wordmark, type WordmarkProps, buttonVariants, cn, containerVariants, linkVariants, mergeClassName, navigationMenuEntryVariants, siteFooterLinkClass, springs, toast, toastManager, transitions, useGround };
81
+ export { Accordion, AccordionItem, type AccordionItemProps, AccordionPanel, type AccordionPanelProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, Alert, AlertDescription, AlertDialog, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, type AlertProps, AlertTitle, AnchorHeading, type AnchorHeadingProps, Avatar, AvatarFallback, AvatarImage, type AvatarProps, Badge, type BadgeProps, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbPage, Breadcrumbs, type BreadcrumbsProps, Button, type ButtonProps, type ButtonVariants, Calendar, type CalendarProps, Callout, type CalloutProps, type CalloutTone, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroup, CheckboxGroupItems, type CheckboxGroupProps, type CheckboxProps, Code, CodeBlock, CodeBlockLive, type CodeBlockLiveProps, type CodeBlockProps, type CodeLanguage, type CodePiece, type CodeRole, type CodeTab, CodeTabs, type CodeTabsProps, Collapsible, CollapsiblePanel, type CollapsiblePanelProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, Combobox, ComboboxCollection, ComboboxContent, type ComboboxContentProps, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, type ComboboxInputProps, ComboboxItem, type ComboboxItemProps, type ComboboxOption, type ComboboxOptionGroup, type ComboboxProps, ComboboxSeparator, Container, type ContainerProps, CopyPage, type CopyPageProps, CopyPill, CopyPillMark, type CopyPillProps, Cta, CtaAction, type CtaActionProps, CtaActions, CtaMessage, type CtaMessageProps, type CtaProps, CtaText, CtaTitle, type CtaTone, DateField, type DateFieldProps, type DateRange, DateRangeField, type DateRangeFieldProps, Dialog, DialogBody, DialogClose, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DocsLayout, DocsLayoutAside, DocsLayoutMain, DocsLayoutNav, Drawer, DrawerBody, DrawerClose, DrawerContent, type DrawerContentProps, DrawerDescription, DrawerFooter, DrawerHeader, type DrawerProps, type DrawerSide, DrawerTitle, DrawerTrigger, Field, FieldDescription, FieldError, FieldLabel, Fieldset, FieldsetLegend, Figure, FigureCaption, FigureFrame, Form, type FormProps, Ground, type GroundName, type GroundProps, Heading, type HeadingProps, Icon, type IconProps, type IconSvgElement, Input, InputGroup, InputGroupAddon, InputGroupButton, type InputGroupButtonProps, type InputGroupProps, type InputProps, Kbd, type LineSpec, Link, type LinkProps, type LinkVariants, Logomark, type LogomarkProps, Menu, MenuCheckboxItem, MenuContent, type MenuContentProps, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Meter, MeterLabel, type MeterProps, MeterTrack, MeterValue, NavigationMenu, NavigationMenuContent, type NavigationMenuEntryVariants, NavigationMenuItem, NavigationMenuLink, NavigationMenuLinkDescription, type NavigationMenuLinkProps, NavigationMenuLinkTitle, NavigationMenuList, type NavigationMenuProps, NavigationMenuTrigger, NumberField, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, type NumberFieldProps, PageHeader, PageHeaderActions, PageHeaderLead, type PageHeaderProps, PageHeaderTitle, type PageHeaderTitleProps, Pager, PagerLink, type PagerLinkProps, type PagerProps, Parameter, ParameterList, type ParameterProps, Popover, PopoverClose, PopoverContent, type PopoverContentProps, PopoverDescription, PopoverTitle, PopoverTrigger, Progress, ProgressLabel, type ProgressProps, ProgressTrack, ProgressValue, Prose, Quote, type QuoteProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, ReferenceEntry, ReferenceEntryBody, ReferenceEntryHeader, ReferenceEntryMeta, ReferenceEntryName, ReferenceEntryTitle, Seam, type SeamProps, Section, type SectionProps, Segment, type SegmentProps, SegmentedControl, type SegmentedControlProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectGroupLabel, SelectItem, type SelectItemProps, type SelectOption, type SelectOptionGroup, type SelectProps, SelectSeparator, SelectTrigger, type SelectTriggerProps, Separator, type SeparatorProps, SideNav, SideNavGroup, type SideNavGroupProps, SideNavLink, type SideNavLinkProps, type SideNavProps, SideNavSubLink, type SideNavSubLinkProps, SiteFooter, SiteFooterBrand, SiteFooterGroup, type SiteFooterGroupProps, SiteFooterLegal, SiteFooterLink, SiteFooterMain, SiteFooterNav, SiteHeader, SiteHeaderActions, SiteHeaderBrand, type SiteHeaderBrandProps, SiteHeaderMenu, SiteHeaderMenuGroup, type SiteHeaderMenuGroupProps, SiteHeaderMenuLink, type SiteHeaderMenuLinkProps, type SiteHeaderMenuProps, type SiteHeaderProps, Slider, SliderControl, type SliderControlProps, SliderLabel, type SliderProps, SliderThumb, type SliderThumbProps, SliderValue, Spinner, type SpinnerProps, type SpringName, Switch, type SwitchProps, Tab, Table, TableBody, TableCaption, TableCell, type TableCellProps, TableFooter, TableHead, type TableHeadProps, TableHeader, TableOfContents, type TableOfContentsProps, type TableProps, TableRow, type TableRowProps, TableSortButton, type TableSortButtonProps, Tabs, TabsList, TabsPanel, TabsPanels, type TabsPanelsProps, type TabsProps, Text, type TextProps, Textarea, type TextareaProps, TimeField, type TimeFieldProps, type ToastOptions, type ToastTone, Toaster, type ToasterProps, type TocItem, Tooltip, TooltipContent, type TooltipContentProps, TooltipProvider, TooltipTrigger, Wordmark, type WordmarkProps, buttonVariants, cn, containerVariants, linkVariants, mergeClassName, navigationMenuEntryVariants, siteFooterLinkClass, springs, toast, toastManager, transitions, useGround };
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ import { CodeTabs } from "./components/code-block/code-tabs.js";
19
19
  import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "./components/collapsible/collapsible.js";
20
20
  import { Combobox, ComboboxCollection, ComboboxContent, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator } from "./components/combobox/combobox.js";
21
21
  import { Container, containerVariants } from "./components/container/container.js";
22
+ import { CopyPage } from "./components/copy-page/copy-page.js";
22
23
  import { CopyPill, CopyPillMark } from "./components/copy-pill/copy-pill.js";
23
24
  import { Cta, CtaAction, CtaActions, CtaMessage, CtaText, CtaTitle } from "./components/cta/cta.js";
24
25
  import { DateField } from "./components/date-field/date-field.js";
@@ -75,4 +76,4 @@ import { Toaster, toast, toastManager } from "./components/toast/toast.js";
75
76
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./components/tooltip/tooltip.js";
76
77
  import { cn, mergeClassName } from "./lib/cn.js";
77
78
  import { springs, transitions } from "./motion/springs.js";
78
- export { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnchorHeading, Avatar, AvatarFallback, AvatarImage, Badge, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, Breadcrumbs, Button, Calendar, Callout, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroup, CheckboxGroupItems, Code, CodeBlock, CodeBlockLive, CodeTabs, Collapsible, CollapsiblePanel, CollapsibleTrigger, Combobox, ComboboxCollection, ComboboxContent, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator, Container, CopyPill, CopyPillMark, Cta, CtaAction, CtaActions, CtaMessage, CtaText, CtaTitle, DateField, DateRangeField, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DocsLayout, DocsLayoutAside, DocsLayoutMain, DocsLayoutNav, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, Field, FieldDescription, FieldError, FieldLabel, Fieldset, FieldsetLegend, Figure, FigureCaption, FigureFrame, Form, Ground, Heading, Icon, Input, InputGroup, InputGroupAddon, InputGroupButton, Kbd, Link, Logomark, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Meter, MeterLabel, MeterTrack, MeterValue, NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuLinkDescription, NavigationMenuLinkTitle, NavigationMenuList, NavigationMenuTrigger, NumberField, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, PageHeader, PageHeaderActions, PageHeaderLead, PageHeaderTitle, Pager, PagerLink, Parameter, ParameterList, Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Progress, ProgressLabel, ProgressTrack, ProgressValue, Prose, Quote, Radio, RadioGroup, ReferenceEntry, ReferenceEntryBody, ReferenceEntryHeader, ReferenceEntryMeta, ReferenceEntryName, ReferenceEntryTitle, Seam, Section, Segment, SegmentedControl, Select, SelectContent, SelectGroup, SelectGroupLabel, SelectItem, SelectSeparator, SelectTrigger, Separator, SideNav, SideNavGroup, SideNavLink, SideNavSubLink, SiteFooter, SiteFooterBrand, SiteFooterGroup, SiteFooterLegal, SiteFooterLink, SiteFooterMain, SiteFooterNav, SiteHeader, SiteHeaderActions, SiteHeaderBrand, SiteHeaderMenu, SiteHeaderMenuGroup, SiteHeaderMenuLink, Slider, SliderControl, SliderLabel, SliderThumb, SliderValue, Spinner, Switch, Tab, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableOfContents, TableRow, TableSortButton, Tabs, TabsList, TabsPanel, TabsPanels, Text, Textarea, TimeField, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Wordmark, buttonVariants, cn, containerVariants, linkVariants, mergeClassName, navigationMenuEntryVariants, siteFooterLinkClass, springs, toast, toastManager, transitions, useGround };
79
+ export { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnchorHeading, Avatar, AvatarFallback, AvatarImage, Badge, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, Breadcrumbs, Button, Calendar, Callout, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroup, CheckboxGroupItems, Code, CodeBlock, CodeBlockLive, CodeTabs, Collapsible, CollapsiblePanel, CollapsibleTrigger, Combobox, ComboboxCollection, ComboboxContent, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator, Container, CopyPage, CopyPill, CopyPillMark, Cta, CtaAction, CtaActions, CtaMessage, CtaText, CtaTitle, DateField, DateRangeField, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DocsLayout, DocsLayoutAside, DocsLayoutMain, DocsLayoutNav, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, Field, FieldDescription, FieldError, FieldLabel, Fieldset, FieldsetLegend, Figure, FigureCaption, FigureFrame, Form, Ground, Heading, Icon, Input, InputGroup, InputGroupAddon, InputGroupButton, Kbd, Link, Logomark, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Meter, MeterLabel, MeterTrack, MeterValue, NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuLinkDescription, NavigationMenuLinkTitle, NavigationMenuList, NavigationMenuTrigger, NumberField, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, PageHeader, PageHeaderActions, PageHeaderLead, PageHeaderTitle, Pager, PagerLink, Parameter, ParameterList, Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Progress, ProgressLabel, ProgressTrack, ProgressValue, Prose, Quote, Radio, RadioGroup, ReferenceEntry, ReferenceEntryBody, ReferenceEntryHeader, ReferenceEntryMeta, ReferenceEntryName, ReferenceEntryTitle, Seam, Section, Segment, SegmentedControl, Select, SelectContent, SelectGroup, SelectGroupLabel, SelectItem, SelectSeparator, SelectTrigger, Separator, SideNav, SideNavGroup, SideNavLink, SideNavSubLink, SiteFooter, SiteFooterBrand, SiteFooterGroup, SiteFooterLegal, SiteFooterLink, SiteFooterMain, SiteFooterNav, SiteHeader, SiteHeaderActions, SiteHeaderBrand, SiteHeaderMenu, SiteHeaderMenuGroup, SiteHeaderMenuLink, Slider, SliderControl, SliderLabel, SliderThumb, SliderValue, Spinner, Switch, Tab, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableOfContents, TableRow, TableSortButton, Tabs, TabsList, TabsPanel, TabsPanels, Text, Textarea, TimeField, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Wordmark, buttonVariants, cn, containerVariants, linkVariants, mergeClassName, navigationMenuEntryVariants, siteFooterLinkClass, springs, toast, toastManager, transitions, useGround };
@@ -0,0 +1,15 @@
1
+ // src/internal/rule.ts
2
+ /**
3
+ * The 2px rule that opens a block (`Table`, `Accordion`, `ParameterList`, a `PageHeader` with
4
+ * `rule`): a straight line with round ends. The box keeps a transparent 2px top border, so it is
5
+ * laid out exactly as with `border-t-2`, and the line is drawn into that border as `::before`.
6
+ * A border cannot round its own ends: with a radius it bends down at the corners instead.
7
+ *
8
+ * The box becomes positioned, and must not clip its top edge. Server-safe.
9
+ */
10
+ const ruleTop = [
11
+ "relative border-t-2 border-t-transparent",
12
+ "before:absolute before:inset-x-0 before:-top-0.5 before:h-0.5 before:rounded-full before:bg-rule",
13
+ "forced-colors:before:bg-[color:CanvasText]"
14
+ ].join(" ");
15
+ export { ruleTop };
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { useScrollEdges } from "./scroll-edges.js";
3
+ import { mergeRefs } from "../lib/merge-refs.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { useRef } from "react";
6
+ // src/internal/scroll-fade.tsx
7
+ /**
8
+ * A box that scrolls and fades its edges where more waits (scroll-fade.css), as a code block's
9
+ * long lines and a long row of tabs do. The box itself still needs its `overflow-*`.
10
+ *
11
+ * It is the client part of components that stay server-safe (`Table`, `DocsLayout`): they render
12
+ * this one box, and everything inside it stays theirs. The mask also cuts what is drawn outside
13
+ * the box, so a focus outline belongs on a box around it.
14
+ */
15
+ function ScrollFade({ axis = "x", ref, ...props }) {
16
+ const box = useRef(null);
17
+ useScrollEdges(box, axis);
18
+ return /* @__PURE__ */ jsx("div", {
19
+ ref: mergeRefs(box, ref),
20
+ "data-scroll-fade": axis,
21
+ ...props
22
+ });
23
+ }
24
+ export { ScrollFade };
@@ -0,0 +1,9 @@
1
+ // src/lib/merge-refs.ts
2
+ /** One ref callback that fills both a component's own ref and the one its caller passed. */
3
+ function mergeRefs(own, theirs) {
4
+ return (node) => {
5
+ for (const ref of [own, theirs]) if (typeof ref === "function") ref(node);
6
+ else if (ref) ref.current = node;
7
+ };
8
+ }
9
+ export { mergeRefs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lanfermann/ui",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Lanfermann design system components for Next.js + Tailwind CSS v4, built on Base UI.",
5
5
  "license": "MIT",
6
6
  "author": "Justin Lanfermann",
@@ -218,35 +218,5 @@
218
218
  --code-fade-end: 2.5rem;
219
219
  }
220
220
 
221
- /*
222
- * Copy: the copy symbol shrinks away and a tick is drawn in its place, short leg first, as in
223
- * a checkbox. When the moment has passed the tick fades where it is (it is not undrawn) and the
224
- * copy symbol seats back with a little bounce.
225
- */
226
- [data-slot="code-copy-symbol"] {
227
- transition-property: scale, opacity;
228
- transition-duration: var(--transition-duration-spring-seat);
229
- transition-timing-function: var(--ease-spring-seat);
230
- }
231
- [data-copied] > [data-slot="code-copy-symbol"] {
232
- scale: 0.5;
233
- opacity: 0;
234
- transition-duration: var(--transition-duration-spring-leave);
235
- transition-timing-function: var(--ease-spring-leave);
236
- }
237
- [data-slot="code-copy-tick"] {
238
- stroke-dasharray: 1;
239
- stroke-dashoffset: 1;
240
- opacity: 0;
241
- transition:
242
- opacity var(--transition-duration-spring-leave) var(--ease-spring-leave),
243
- stroke-dashoffset 0s var(--transition-duration-spring-leave);
244
- }
245
- [data-copied] > [data-slot="code-copy-tick"] {
246
- stroke-dashoffset: 0;
247
- opacity: 1;
248
- transition:
249
- opacity 60ms linear 60ms,
250
- stroke-dashoffset 220ms cubic-bezier(0.3, 0, 0.2, 1) 60ms;
251
- }
221
+ /* The copy key's confirmation is shared with every control that copies: see copy.css. */
252
222
  }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * The confirmation of a copy, the same in every control that copies (a code block's key, the
3
+ * page copy): the copy symbol shrinks away and a tick is drawn in its place, short leg first, as
4
+ * in a checkbox. When the moment has passed the tick fades where it is (it is not undrawn) and
5
+ * the copy symbol seats back with a little bounce.
6
+ *
7
+ * The control sets `data-copied` while the moment lasts; the symbol and the tick are found inside
8
+ * it by their slots. Under reduced motion nothing scales or draws: the two only cross-fade.
9
+ */
10
+ @layer components {
11
+ :is([data-slot="code-copy-symbol"], [data-slot="copy-page-symbol"]) {
12
+ transition-property: scale, opacity;
13
+ transition-duration: var(--transition-duration-spring-seat);
14
+ transition-timing-function: var(--ease-spring-seat);
15
+ }
16
+ [data-copied] :is([data-slot="code-copy-symbol"], [data-slot="copy-page-symbol"]) {
17
+ scale: 0.5;
18
+ opacity: 0;
19
+ transition-duration: var(--transition-duration-spring-leave);
20
+ transition-timing-function: var(--ease-spring-leave);
21
+ }
22
+ :is([data-slot="code-copy-tick"], [data-slot="copy-page-tick"]) {
23
+ stroke-dasharray: 1;
24
+ stroke-dashoffset: 1;
25
+ opacity: 0;
26
+ transition:
27
+ opacity var(--transition-duration-spring-leave) var(--ease-spring-leave),
28
+ stroke-dashoffset 0s var(--transition-duration-spring-leave);
29
+ }
30
+ [data-copied] :is([data-slot="code-copy-tick"], [data-slot="copy-page-tick"]) {
31
+ stroke-dashoffset: 0;
32
+ opacity: 1;
33
+ transition:
34
+ opacity 60ms linear 60ms,
35
+ stroke-dashoffset 220ms cubic-bezier(0.3, 0, 0.2, 1) 60ms;
36
+ }
37
+
38
+ @media (prefers-reduced-motion: reduce) {
39
+ [data-copied] :is([data-slot="code-copy-symbol"], [data-slot="copy-page-symbol"]) {
40
+ scale: 1;
41
+ }
42
+ :is([data-slot="code-copy-tick"], [data-slot="copy-page-tick"]) {
43
+ stroke-dashoffset: 0;
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,52 @@
1
+ /*
2
+ * A box that scrolls (`ScrollFade`: a wide table, the side columns of a docs page) fades at the
3
+ * edges where more waits, as a code block's long lines (code.css) and a long row of tabs
4
+ * (tabs.css) do: what the edge cuts says that it goes on, instead of looking cut off.
5
+ * `useScrollEdges` sets `data-overflow` from the scroll position; the two lengths are
6
+ * registered so the mask moves on `settle`. A box that fits has no mask.
7
+ *
8
+ * The mask cuts everything the box paints, its outline too: a box that takes the keyboard
9
+ * focus has its outline drawn by a box around it (`Table`).
10
+ */
11
+ @property --scroll-fade-start {
12
+ syntax: "<length>";
13
+ inherits: false;
14
+ initial-value: 0px;
15
+ }
16
+ @property --scroll-fade-end {
17
+ syntax: "<length>";
18
+ inherits: false;
19
+ initial-value: 0px;
20
+ }
21
+
22
+ @layer components {
23
+ [data-scroll-fade] {
24
+ transition:
25
+ --scroll-fade-start var(--transition-duration-spring-settle) var(--ease-spring-settle),
26
+ --scroll-fade-end var(--transition-duration-spring-settle) var(--ease-spring-settle);
27
+ }
28
+ [data-scroll-fade="x"][data-overflow] {
29
+ mask-image: linear-gradient(
30
+ to right,
31
+ transparent,
32
+ #000 var(--scroll-fade-start),
33
+ #000 calc(100% - var(--scroll-fade-end)),
34
+ transparent
35
+ );
36
+ }
37
+ [data-scroll-fade="y"][data-overflow] {
38
+ mask-image: linear-gradient(
39
+ to bottom,
40
+ transparent,
41
+ #000 var(--scroll-fade-start),
42
+ #000 calc(100% - var(--scroll-fade-end)),
43
+ transparent
44
+ );
45
+ }
46
+ [data-scroll-fade][data-overflow~="start"] {
47
+ --scroll-fade-start: 2.5rem;
48
+ }
49
+ [data-scroll-fade][data-overflow~="end"] {
50
+ --scroll-fade-end: 2.5rem;
51
+ }
52
+ }
package/src/styles.css CHANGED
@@ -15,6 +15,7 @@
15
15
  @import "./styles/grounds.css";
16
16
  @import "./styles/status.css";
17
17
  @import "./styles/code.css";
18
+ @import "./styles/copy.css";
18
19
  @import "./styles/type.css";
19
20
  @import "./styles/radius.css";
20
21
  @import "./styles/density.css";
@@ -27,6 +28,7 @@
27
28
  @import "./styles/slider.css";
28
29
  @import "./styles/segmented.css";
29
30
  @import "./styles/tabs.css";
31
+ @import "./styles/scroll-fade.css";
30
32
  @import "./styles/calendar.css";
31
33
  @import "./styles/prose.css";
32
34
  @import "./styles/base.css";