@lanfermann/ui 0.2.0 → 0.4.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.js +2 -1
- package/dist/components/anchor-heading/anchor-heading.d.ts +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.js +5 -10
- package/dist/components/button/button.d.ts +3 -0
- package/dist/components/button/button.js +14 -4
- package/dist/components/button-group/button-group-context.js +14 -0
- package/dist/components/button-group/button-group-variants.d.ts +14 -0
- package/dist/components/button-group/button-group-variants.js +93 -0
- package/dist/components/button-group/button-group.d.ts +36 -0
- package/dist/components/button-group/button-group.js +46 -0
- package/dist/components/code-block/code-block-frame.js +22 -6
- package/dist/components/code-block/code-block-live.d.ts +3 -3
- package/dist/components/code-block/code-block-live.js +5 -3
- package/dist/components/code-block/code-block.d.ts +7 -3
- package/dist/components/code-block/code-block.js +9 -3
- package/dist/components/code-block/code-keys.d.ts +24 -0
- package/dist/components/code-block/code-keys.js +107 -0
- package/dist/components/code-block/code-scroll.js +2 -1
- package/dist/components/code-block/code-tabs-frame.js +12 -5
- package/dist/components/code-block/code-tabs.d.ts +9 -4
- package/dist/components/code-block/code-tabs.js +9 -6
- package/dist/components/code-block/lines.js +23 -1
- package/dist/components/copy-page/copy-page.d.ts +46 -0
- package/dist/components/copy-page/copy-page.js +211 -0
- package/dist/components/docs-layout/docs-layout.d.ts +4 -2
- package/dist/components/docs-layout/docs-layout.js +11 -6
- package/dist/components/docs-layout/docs-nav.d.ts +51 -0
- package/dist/components/docs-layout/docs-nav.js +60 -0
- package/dist/components/grow/grow.d.ts +20 -0
- package/dist/components/grow/grow.js +98 -0
- package/dist/components/heading/heading.d.ts +4 -0
- package/dist/components/heading/heading.js +8 -4
- package/dist/components/hover-card/hover-card.d.ts +24 -0
- package/dist/components/hover-card/hover-card.js +51 -0
- package/dist/components/pager/pager.js +19 -24
- package/dist/components/parameter-list/parameter-list.js +2 -1
- package/dist/components/scroll-fade/scroll-fade.d.ts +29 -0
- package/dist/components/scroll-fade/scroll-fade.js +40 -0
- package/dist/components/scroll-fade/use-scroll-edges.d.ts +13 -0
- package/dist/{internal/scroll-edges.js → components/scroll-fade/use-scroll-edges.js} +10 -7
- package/dist/components/section/section.d.ts +2 -1
- package/dist/components/section/section.js +2 -1
- package/dist/components/segmented-control/segmented-control.d.ts +7 -1
- package/dist/components/segmented-control/segmented-control.js +22 -11
- package/dist/components/select/select.d.ts +4 -1
- package/dist/components/select/select.js +15 -3
- package/dist/components/separator/separator.js +2 -2
- package/dist/components/shimmer/shimmer.d.ts +21 -0
- package/dist/components/shimmer/shimmer.js +24 -0
- package/dist/components/side-nav/side-nav.js +11 -20
- package/dist/components/site-header/site-header.d.ts +1 -1
- package/dist/components/site-header/site-header.js +6 -3
- package/dist/components/slider/slider.d.ts +3 -1
- package/dist/components/slider/slider.js +45 -19
- package/dist/components/table/table.d.ts +6 -6
- package/dist/components/table/table.js +24 -17
- package/dist/components/table-of-contents/table-of-contents.js +11 -6
- package/dist/components/tabs/tabs.js +4 -8
- package/dist/components/theme-switch/theme-switch.d.ts +47 -0
- package/dist/components/theme-switch/theme-switch.js +102 -0
- package/dist/components/trace/trace.d.ts +71 -0
- package/dist/components/trace/trace.js +201 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.js +11 -2
- package/dist/internal/render-as.js +24 -0
- package/dist/internal/rule.js +16 -0
- package/dist/lib/merge-refs.js +9 -0
- package/package.json +1 -1
- package/src/styles/button-group.css +57 -0
- package/src/styles/code.css +14 -68
- package/src/styles/copy.css +46 -0
- package/src/styles/marks.css +10 -0
- package/src/styles/motion.css +4 -3
- package/src/styles/scroll-fade.css +58 -0
- package/src/styles/shimmer.css +68 -0
- package/src/styles/slider.css +57 -19
- package/src/styles.css +4 -1
- package/dist/components/page-header/page-header.d.ts +0 -30
- package/dist/components/page-header/page-header.js +0 -48
- package/src/styles/tabs.css +0 -39
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { renderAs } from "../../internal/render-as.js";
|
|
2
2
|
import { cn } from "../../lib/cn.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useId } from "react";
|
|
5
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
6
5
|
// src/components/side-nav/side-nav.tsx
|
|
7
6
|
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent";
|
|
8
7
|
/**
|
|
@@ -45,15 +44,11 @@ function SideNavGroup({ title, className, children, ...props }) {
|
|
|
45
44
|
}
|
|
46
45
|
/** One page of the set. For a router's link, pass it as `render`. */
|
|
47
46
|
function SideNavLink({ current = false, sub, open = false, render, className, ...props }) {
|
|
48
|
-
const link =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"data-slot": "side-nav-link",
|
|
54
|
-
"aria-current": current ? "page" : void 0,
|
|
55
|
-
className: cn("flex min-h-8 items-center rounded-md px-2.5 py-1 text-control text-fg-body", "hover:bg-hover hover:text-fg", "aria-[current=page]:bg-tint aria-[current=page]:font-medium aria-[current=page]:text-fg", "forced-colors:aria-[current=page]:outline forced-colors:aria-[current=page]:-outline-offset-1", focusRing, className)
|
|
56
|
-
}
|
|
47
|
+
const link = renderAs("a", render, {
|
|
48
|
+
...props,
|
|
49
|
+
"data-slot": "side-nav-link",
|
|
50
|
+
"aria-current": current ? "page" : void 0,
|
|
51
|
+
className: cn("flex min-h-8 items-center rounded-md px-2.5 py-1 text-control text-fg-body", "hover:bg-hover hover:text-fg", "aria-[current=page]:bg-tint aria-[current=page]:font-medium aria-[current=page]:text-fg", "forced-colors:aria-[current=page]:outline forced-colors:aria-[current=page]:-outline-offset-1", focusRing, className)
|
|
57
52
|
});
|
|
58
53
|
return /* @__PURE__ */ jsxs("li", {
|
|
59
54
|
"data-slot": "side-nav-item",
|
|
@@ -71,15 +66,11 @@ function SideNavLink({ current = false, sub, open = false, render, className, ..
|
|
|
71
66
|
* it as `render`.
|
|
72
67
|
*/
|
|
73
68
|
function SideNavSubLink({ current = false, render, className, ...props }) {
|
|
74
|
-
const link =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"data-slot": "side-nav-sub-link",
|
|
80
|
-
"aria-current": current ? "page" : void 0,
|
|
81
|
-
className: cn("-ml-px flex min-h-7 items-center rounded-r-xs border-l border-transparent py-0.5 pl-3.5 text-sm text-fg-muted hover:border-line hover:text-fg", "aria-[current=page]:border-fg aria-[current=page]:font-medium aria-[current=page]:text-fg", "forced-colors:aria-[current=page]:border-[Highlight]", focusRing, className)
|
|
82
|
-
}
|
|
69
|
+
const link = renderAs("a", render, {
|
|
70
|
+
...props,
|
|
71
|
+
"data-slot": "side-nav-sub-link",
|
|
72
|
+
"aria-current": current ? "page" : void 0,
|
|
73
|
+
className: cn("-ml-px flex min-h-7 items-center rounded-r-xs border-l border-transparent py-0.5 pl-3.5 text-sm text-fg-muted hover:border-line hover:text-fg", "aria-[current=page]:border-fg aria-[current=page]:font-medium aria-[current=page]:text-fg", "forced-colors:aria-[current=page]:border-[Highlight]", focusRing, className)
|
|
83
74
|
});
|
|
84
75
|
return /* @__PURE__ */ jsx("li", {
|
|
85
76
|
"data-slot": "side-nav-sub-item",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode } from "react";
|
|
2
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
3
2
|
import { Dialog } from "@base-ui/react/dialog";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
4
|
export type SiteHeaderProps = ComponentProps<"header"> & {
|
|
5
5
|
/** Stays at the top of the window while the page scrolls under it. */
|
|
6
6
|
sticky?: boolean;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { Button } from "../button/button.js";
|
|
3
3
|
import { useGround } from "../ground/ground.js";
|
|
4
4
|
import { Icon } from "../icon/icon.js";
|
|
5
|
-
import { useScrollEdges } from "
|
|
5
|
+
import { useScrollEdges } from "../scroll-fade/use-scroll-edges.js";
|
|
6
6
|
import { cn } from "../../lib/cn.js";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { Cancel01Icon, Menu01Icon } from "@hugeicons/core-free-icons";
|
|
9
9
|
import { createContext, useCallback, useContext, useId, useRef, useState } from "react";
|
|
10
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
11
10
|
import { Dialog } from "@base-ui/react/dialog";
|
|
11
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
12
12
|
// src/components/site-header/site-header.tsx
|
|
13
13
|
/**
|
|
14
14
|
* Where the bar stands and how wide it is, shared by the bar and the top row of the open menu so
|
|
@@ -16,8 +16,11 @@ import { Dialog } from "@base-ui/react/dialog";
|
|
|
16
16
|
* the window (16px from `sm`) and padded 12px (16px), so what stands in it lines up with the
|
|
17
17
|
* content of a `Container`: 8 + 12 is its 20px gutter on a phone, 16 + 16 its 32px above. At its
|
|
18
18
|
* widest it is the page's 72rem plus its own padding.
|
|
19
|
+
*
|
|
20
|
+
* It is 48px tall: 8px above and below a control, the 8px it keeps from the window's top. (It was
|
|
21
|
+
* 56; Justin found it too tall, 2026-11-16.)
|
|
19
22
|
*/
|
|
20
|
-
const barFrame = "mx-auto flex h-
|
|
23
|
+
const barFrame = "mx-auto flex h-12 w-[calc(100%-1rem)] max-w-[calc(72rem+2rem)] items-center gap-6 px-3 sm:w-[calc(100%-2rem)] sm:px-4";
|
|
21
24
|
/**
|
|
22
25
|
* The bar at the top of a website: what this is, where one can go, and the next step. It floats:
|
|
23
26
|
* a frosted face with a light edge, 8px off the window's top and sides, over the page that
|
|
@@ -37,6 +37,8 @@ export type SliderThumbProps = Omit<Slider$1.Thumb.Props, "render" | "children">
|
|
|
37
37
|
* counterpart while it is held by the fill, the plain thumb colour in the empty trough.
|
|
38
38
|
*
|
|
39
39
|
* Two elements: Base UI's thumb is the invisible box that is pressed and holds the input; what
|
|
40
|
-
* is seen is the face beside it, placed from the same value and moved by transforms only.
|
|
40
|
+
* is seen is the face beside it, placed from the same value and moved by transforms only. The
|
|
41
|
+
* face stands in a seat at the end of its lane (slider.css), and the seat carries the focus
|
|
42
|
+
* ring.
|
|
41
43
|
*/
|
|
42
44
|
export declare function SliderThumb({ className, index, ...props }: SliderThumbProps): import("react").JSX.Element;
|
|
@@ -176,34 +176,54 @@ function useThumbInertia(anchor, places) {
|
|
|
176
176
|
* The fill and the caps that hold the thumbs. The fill is the bar; each thumb stands in a round
|
|
177
177
|
* cap of the fill's colour, as wide as the trough is tall, which keeps the gap to the thumb
|
|
178
178
|
* that the trough's wall keeps too. The cap deforms with its thumb.
|
|
179
|
+
*
|
|
180
|
+
* Every part rides in a lane that is moved by a share of its own width (slider.css): the bar
|
|
181
|
+
* ends in the middle of the last thumb, and in a range a window cuts it off at the first.
|
|
179
182
|
*/
|
|
180
183
|
function SliderFill({ state }) {
|
|
181
184
|
const anchor = useRef(null);
|
|
182
185
|
const places = state.values.map((_, index) => place(state, index));
|
|
183
186
|
useThumbInertia(anchor, places);
|
|
184
187
|
const range = places.length > 1;
|
|
188
|
+
const first = places[0] ?? 0;
|
|
185
189
|
const last = places[places.length - 1] ?? 0;
|
|
186
|
-
const centre = (at) => `calc(var(--switch-h) / 2 + ${at} * var(--slider-travel))`;
|
|
187
190
|
const colour = state.disabled ? "bg-on-disabled" : "bg-accent forced-colors:bg-[Highlight]";
|
|
188
191
|
return /* @__PURE__ */ jsxs("span", {
|
|
189
192
|
ref: anchor,
|
|
190
193
|
"data-slot": "slider-indicator",
|
|
191
194
|
"aria-hidden": true,
|
|
192
195
|
className: cn("absolute inset-0 transition-opacity spring-snap", !range && last <= 0 && "opacity-0"),
|
|
193
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
194
|
-
className: cn("slider-
|
|
195
|
-
style: vars({
|
|
196
|
-
|
|
197
|
-
"
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
children: [range ? /* @__PURE__ */ jsx("span", {
|
|
197
|
+
className: cn("slider-lane", travels),
|
|
198
|
+
style: vars({ "--p": first }),
|
|
199
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
200
|
+
className: "slider-fill-window",
|
|
201
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
202
|
+
className: cn("slider-lane", travels),
|
|
203
|
+
style: vars({ "--p": last - first }),
|
|
204
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
205
|
+
"data-slot": "slider-fill",
|
|
206
|
+
className: cn("slider-fill-bar", colour)
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
211
|
+
className: cn("slider-lane", travels),
|
|
212
|
+
style: vars({ "--p": last }),
|
|
213
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
214
|
+
"data-slot": "slider-fill",
|
|
215
|
+
className: cn("slider-fill-bar [--fill-lead:calc(var(--switch-h)/2)]", colour)
|
|
216
|
+
})
|
|
200
217
|
}), places.map((at, index) => /* @__PURE__ */ jsx("span", {
|
|
201
|
-
className: cn("slider-at
|
|
218
|
+
className: cn("slider-at h-(--switch-h)", travels),
|
|
202
219
|
style: vars({ "--p": at }),
|
|
203
220
|
children: /* @__PURE__ */ jsx("span", {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
221
|
+
className: "slider-seat",
|
|
222
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
223
|
+
"data-slot": "slider-cap",
|
|
224
|
+
className: cn("slider-body block h-full w-[calc(100%+var(--held,0px))] rounded-full [--squash:0]", colour, state.dragging && state.activeThumbIndex === index && "[--held:3px]"),
|
|
225
|
+
style: body(index, "var(--switch-h)")
|
|
226
|
+
})
|
|
207
227
|
})
|
|
208
228
|
}, index))]
|
|
209
229
|
});
|
|
@@ -222,14 +242,14 @@ function SliderControl({ className, children, ref, ...props }) {
|
|
|
222
242
|
if (ref) ref.current = node;
|
|
223
243
|
},
|
|
224
244
|
"data-slot": "slider-control",
|
|
225
|
-
className: mergeClassName("
|
|
245
|
+
className: mergeClassName("touch-target relative col-span-2 mx-0.5 flex h-(--control-md) touch-none items-center slider-geometry select-none data-disabled:pointer-events-none", className),
|
|
226
246
|
...props,
|
|
227
247
|
children: /* @__PURE__ */ jsxs(Slider$1.Track, {
|
|
228
248
|
"data-slot": "slider-track",
|
|
229
249
|
className: "h-(--switch-h) w-full",
|
|
230
250
|
children: [/* @__PURE__ */ jsx("span", {
|
|
231
251
|
"data-slot": "slider-trough",
|
|
232
|
-
className: cn("absolute -inset-x-0.5 top-0 h-(--switch-h)", troughTrack, "group-data-disabled/slider:bg-disabled group-data-disabled/slider:after:depth-flat"),
|
|
252
|
+
className: cn("absolute -inset-x-0.5 top-0 h-(--switch-h) [--slider-walls:4px]", troughTrack, "group-data-disabled/slider:bg-disabled group-data-disabled/slider:after:depth-flat"),
|
|
233
253
|
children: /* @__PURE__ */ jsx(Slider$1.Indicator, { render: (_, state) => /* @__PURE__ */ jsx(SliderFill, { state }) })
|
|
234
254
|
}), children ?? /* @__PURE__ */ jsx(SliderThumb, {})]
|
|
235
255
|
})
|
|
@@ -248,7 +268,9 @@ function SliderControl({ className, children, ref, ...props }) {
|
|
|
248
268
|
* counterpart while it is held by the fill, the plain thumb colour in the empty trough.
|
|
249
269
|
*
|
|
250
270
|
* Two elements: Base UI's thumb is the invisible box that is pressed and holds the input; what
|
|
251
|
-
* is seen is the face beside it, placed from the same value and moved by transforms only.
|
|
271
|
+
* is seen is the face beside it, placed from the same value and moved by transforms only. The
|
|
272
|
+
* face stands in a seat at the end of its lane (slider.css), and the seat carries the focus
|
|
273
|
+
* ring.
|
|
252
274
|
*/
|
|
253
275
|
function SliderThumb({ className, index = 0, ...props }) {
|
|
254
276
|
return /* @__PURE__ */ jsx(Slider$1.Thumb, {
|
|
@@ -262,15 +284,19 @@ function SliderThumb({ className, index = 0, ...props }) {
|
|
|
262
284
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { ...thumbProps }), /* @__PURE__ */ jsx("span", {
|
|
263
285
|
"aria-hidden": true,
|
|
264
286
|
"data-slot": "slider-thumb-rider",
|
|
265
|
-
className: cn("pointer-events-none slider-at
|
|
287
|
+
className: cn("pointer-events-none slider-at h-(--slider-thumb)", travels),
|
|
266
288
|
style: vars({
|
|
267
289
|
"--p": place(state, index),
|
|
268
290
|
"--thumb-face": onFill ? "var(--color-on-accent)" : "var(--color-thumb)"
|
|
269
291
|
}),
|
|
270
292
|
children: /* @__PURE__ */ jsx("span", {
|
|
271
|
-
"data-slot": "slider-thumb-
|
|
272
|
-
className: cn("slider-
|
|
273
|
-
|
|
293
|
+
"data-slot": "slider-thumb-seat",
|
|
294
|
+
className: cn("slider-seat rounded-full", "[[data-slot=slider-thumb]:has(:focus-visible)+*>&]:outline-2 [[data-slot=slider-thumb]:has(:focus-visible)+*>&]:outline-offset-2 [[data-slot=slider-thumb]:has(:focus-visible)+*>&]:outline-accent"),
|
|
295
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
296
|
+
"data-slot": "slider-thumb-face",
|
|
297
|
+
className: cn("slider-body block h-full w-[calc(100%+var(--held,0px))] rounded-full bg-(--thumb-face) depth-raised depth-tone-thumb", "[[data-slot=slider-thumb]:hover+*_&]:depth-raised-hover", held && "depth-raised-hover [--held:3px]", state.disabled && "bg-raised depth-flat"),
|
|
298
|
+
style: body(index, "var(--slider-thumb)")
|
|
299
|
+
})
|
|
274
300
|
})
|
|
275
301
|
})] });
|
|
276
302
|
}
|
|
@@ -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
|
|
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,
|
|
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.
|
|
34
|
-
*
|
|
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,41 @@
|
|
|
1
|
+
import { ScrollFade } from "../scroll-fade/scroll-fade.js";
|
|
1
2
|
import { ArrowUpGlyph } from "../../internal/glyphs.js";
|
|
3
|
+
import { ruleTop } from "../../internal/rule.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,
|
|
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.
|
|
12
|
-
*
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
+
axis: "x",
|
|
25
|
+
"data-slot": "table-scroll",
|
|
26
|
+
role: "region",
|
|
27
|
+
"aria-label": label,
|
|
28
|
+
"aria-labelledby": labelledBy,
|
|
29
|
+
tabIndex: 0,
|
|
30
|
+
className: cn("relative w-full overflow-x-auto focus-visible:outline-hidden", "scroll-px-10"),
|
|
31
|
+
children: /* @__PURE__ */ jsx("table", {
|
|
32
|
+
"data-slot": "table",
|
|
33
|
+
"data-content": content,
|
|
34
|
+
"data-stack": stack ? "" : void 0,
|
|
35
|
+
role: "table",
|
|
36
|
+
className: cn("w-full caption-bottom border-collapse text-left text-base text-fg-body", "data-stack:max-sm:block", className),
|
|
37
|
+
...props
|
|
38
|
+
})
|
|
32
39
|
})
|
|
33
40
|
});
|
|
34
41
|
}
|
|
@@ -79,18 +79,23 @@ function useCurrentSection(ids) {
|
|
|
79
79
|
}
|
|
80
80
|
return [current, hold];
|
|
81
81
|
}
|
|
82
|
-
/**
|
|
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
|
-
|
|
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 +
|
|
93
|
-
else if (top + link.offsetHeight > box.scrollTop + box.clientHeight -
|
|
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: "",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useScrollEdges } from "../scroll-fade/use-scroll-edges.js";
|
|
2
3
|
import { useReducedMotion } from "../../internal/reduced-motion.js";
|
|
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";
|
|
@@ -14,14 +15,8 @@ function Tabs({ className, ...props }) {
|
|
|
14
15
|
...props
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
|
-
/** How far a tab keeps off the edge it is scrolled to: past the fade (
|
|
18
|
+
/** How far a tab keeps off the edge it is scrolled to: past the fade (scroll-fade.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.
|
|
@@ -62,6 +57,7 @@ function TabsList({ className, children, ref, ...props }) {
|
|
|
62
57
|
return /* @__PURE__ */ jsxs(Tabs$1.List, {
|
|
63
58
|
ref: mergeRefs(list, ref),
|
|
64
59
|
"data-slot": "tabs-list",
|
|
60
|
+
"data-scroll-fade": "x",
|
|
65
61
|
className: mergeClassName(["relative isolate flex gap-1", "-m-1 max-w-[calc(100%+0.5rem)] [scrollbar-width:none] overflow-x-auto p-1"], className),
|
|
66
62
|
...props,
|
|
67
63
|
children: [children, /* @__PURE__ */ jsx(Tabs$1.Indicator, {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SelectProps, SelectTriggerProps } from "../select/select.js";
|
|
2
|
+
/** How a site should look: as the system says, light, or dark. */
|
|
3
|
+
export type Theme = "system" | "light" | "dark";
|
|
4
|
+
type Choice = {
|
|
5
|
+
/** The chosen appearance (controlled). */
|
|
6
|
+
value?: Theme;
|
|
7
|
+
/** The appearance chosen at first (uncontrolled). The system's unless said otherwise. */
|
|
8
|
+
defaultValue?: Theme;
|
|
9
|
+
onValueChange?: (theme: Theme) => void;
|
|
10
|
+
/** What the control is about, for assistive tech. */
|
|
11
|
+
"aria-label"?: string;
|
|
12
|
+
/** The names of the three choices: what is read, and what is said where only a symbol shows. */
|
|
13
|
+
labels?: Partial<Record<Theme, string>>;
|
|
14
|
+
id?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
type AsSelect = Choice & Pick<SelectProps<Theme>, "open" | "defaultOpen" | "onOpenChange" | "modal"> & {
|
|
18
|
+
/**
|
|
19
|
+
* `select` names the choice in one control and opens the three as a list: it takes a
|
|
20
|
+
* button's room, in a site's bar or footer. `segmented` lays the three out as symbols in a
|
|
21
|
+
* round trough: all in sight, each one press away.
|
|
22
|
+
*/
|
|
23
|
+
variant?: "select";
|
|
24
|
+
/** The size of the select's trigger. */
|
|
25
|
+
size?: SelectTriggerProps["size"];
|
|
26
|
+
};
|
|
27
|
+
type AsSegments = Choice & {
|
|
28
|
+
variant: "segmented";
|
|
29
|
+
/**
|
|
30
|
+
* Writes the names beside the symbols. For a settings page, where there is room; elsewhere
|
|
31
|
+
* the three symbols are enough.
|
|
32
|
+
*/
|
|
33
|
+
withLabels?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type ThemeSwitchProps = AsSelect | AsSegments;
|
|
36
|
+
/**
|
|
37
|
+
* The choice between the system's appearance, light and dark. Two forms of the same choice: a
|
|
38
|
+
* select that shows the chosen one by symbol and name, and three symbols in a round trough whose
|
|
39
|
+
* thumb travels to the chosen one.
|
|
40
|
+
*
|
|
41
|
+
* It is the control only. It holds a choice and reports it (`onValueChange`); it does not
|
|
42
|
+
* remember the choice, read the system's setting or change the page. The app does that: it sets
|
|
43
|
+
* `data-theme="paper"` or `"ink"` on `<html>`, and for `system` follows
|
|
44
|
+
* `prefers-color-scheme`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function ThemeSwitch(props: ThemeSwitchProps): import("react").JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Icon } from "../icon/icon.js";
|
|
3
|
+
import { Segment, SegmentedControl } from "../segmented-control/segmented-control.js";
|
|
4
|
+
import { Select, SelectContent, SelectItem, SelectTrigger } from "../select/select.js";
|
|
5
|
+
import { cn } from "../../lib/cn.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { ComputerIcon, Moon02Icon, Sun03Icon } from "@hugeicons/core-free-icons";
|
|
8
|
+
import { useMemo } from "react";
|
|
9
|
+
// src/components/theme-switch/theme-switch.tsx
|
|
10
|
+
const themes = [
|
|
11
|
+
{
|
|
12
|
+
value: "system",
|
|
13
|
+
icon: ComputerIcon
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
value: "light",
|
|
17
|
+
icon: Sun03Icon
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: "dark",
|
|
21
|
+
icon: Moon02Icon
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
const defaultLabels = {
|
|
25
|
+
system: "System",
|
|
26
|
+
light: "Hell",
|
|
27
|
+
dark: "Dunkel"
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The choice between the system's appearance, light and dark. Two forms of the same choice: a
|
|
31
|
+
* select that shows the chosen one by symbol and name, and three symbols in a round trough whose
|
|
32
|
+
* thumb travels to the chosen one.
|
|
33
|
+
*
|
|
34
|
+
* It is the control only. It holds a choice and reports it (`onValueChange`); it does not
|
|
35
|
+
* remember the choice, read the system's setting or change the page. The app does that: it sets
|
|
36
|
+
* `data-theme="paper"` or `"ink"` on `<html>`, and for `system` follows
|
|
37
|
+
* `prefers-color-scheme`.
|
|
38
|
+
*/
|
|
39
|
+
function ThemeSwitch(props) {
|
|
40
|
+
return props.variant === "segmented" ? /* @__PURE__ */ jsx(ThemeSegments, { ...props }) : /* @__PURE__ */ jsx(ThemeSelect, { ...props });
|
|
41
|
+
}
|
|
42
|
+
function ThemeSelect({ variant: _variant, value, defaultValue = "system", onValueChange, "aria-label": label = "Erscheinungsbild", labels, size, id, className, ...root }) {
|
|
43
|
+
const items = useMemo(() => themes.map((theme) => ({
|
|
44
|
+
value: theme.value,
|
|
45
|
+
label: labels?.[theme.value] ?? defaultLabels[theme.value],
|
|
46
|
+
icon: theme.icon
|
|
47
|
+
})), [labels]);
|
|
48
|
+
return /* @__PURE__ */ jsxs(Select, {
|
|
49
|
+
items,
|
|
50
|
+
value,
|
|
51
|
+
defaultValue: value === void 0 ? defaultValue : void 0,
|
|
52
|
+
onValueChange: (next) => {
|
|
53
|
+
if (next !== null) onValueChange?.(next);
|
|
54
|
+
},
|
|
55
|
+
...root,
|
|
56
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
57
|
+
id,
|
|
58
|
+
"aria-label": label,
|
|
59
|
+
size,
|
|
60
|
+
className: cn("min-w-32", className)
|
|
61
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: items.map((item) => /* @__PURE__ */ jsx(SelectItem, {
|
|
62
|
+
value: item.value,
|
|
63
|
+
children: item.label
|
|
64
|
+
}, item.value)) })]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function ThemeSegments({ variant: _variant, value, defaultValue = "system", onValueChange, "aria-label": label = "Erscheinungsbild", labels, withLabels = false, id, className }) {
|
|
68
|
+
const names = {
|
|
69
|
+
...defaultLabels,
|
|
70
|
+
...labels
|
|
71
|
+
};
|
|
72
|
+
return /* @__PURE__ */ jsx(SegmentedControl, {
|
|
73
|
+
id,
|
|
74
|
+
shape: "round",
|
|
75
|
+
marks: false,
|
|
76
|
+
"aria-label": label,
|
|
77
|
+
value,
|
|
78
|
+
defaultValue: value === void 0 ? defaultValue : void 0,
|
|
79
|
+
onValueChange: (next) => onValueChange?.(next),
|
|
80
|
+
className,
|
|
81
|
+
children: themes.map((theme) => withLabels ? /* @__PURE__ */ jsx(Segment, {
|
|
82
|
+
value: theme.value,
|
|
83
|
+
className: "px-3.5",
|
|
84
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
85
|
+
className: "inline-flex items-center gap-1.5",
|
|
86
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
87
|
+
icon: theme.icon,
|
|
88
|
+
size: 16
|
|
89
|
+
}), names[theme.value]]
|
|
90
|
+
})
|
|
91
|
+
}, theme.value) : /* @__PURE__ */ jsx(Segment, {
|
|
92
|
+
value: theme.value,
|
|
93
|
+
"aria-label": names[theme.value],
|
|
94
|
+
className: "w-(--control-md) px-0",
|
|
95
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
96
|
+
icon: theme.icon,
|
|
97
|
+
size: 16
|
|
98
|
+
})
|
|
99
|
+
}, theme.value))
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
export { ThemeSwitch };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { IconSvgElement } from "../icon/icon.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
/** Where a step stands: not begun, being worked on, finished, or failed. */
|
|
4
|
+
export type TraceStatus = "pending" | "running" | "done" | "error";
|
|
5
|
+
/** What stands in front of a finished step: the system's disc, or the step's own symbol. */
|
|
6
|
+
export type TraceMarks = "dots" | "symbols";
|
|
7
|
+
export type TraceProps = ComponentProps<"ol"> & {
|
|
8
|
+
/**
|
|
9
|
+
* `dots` keeps to the system's marks: ring, arc and disc. It is the quieter list. `symbols`
|
|
10
|
+
* shows a finished step's `icon` in place of its disc, so the kind of step can be read down
|
|
11
|
+
* the rail: a search, a file, a mail. A step without an `icon` keeps its disc.
|
|
12
|
+
*/
|
|
13
|
+
marks?: TraceMarks;
|
|
14
|
+
/** What each state is called for assistive tech, where the mark alone would say it. */
|
|
15
|
+
statusLabels?: Partial<Record<TraceStatus, string>>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* What an assistant is doing, step by step: the searches, the files, the tools, in the order
|
|
19
|
+
* they happen. It is read, not operated, so it is flat: a list of lines, each with the system's
|
|
20
|
+
* mark in front, joined by a hairline. An open ring waits, the spinner's arc works (it is the
|
|
21
|
+
* ring before it has closed), and the disc is done; a step that failed carries the danger
|
|
22
|
+
* symbol and says so in words.
|
|
23
|
+
*
|
|
24
|
+
* Put `TraceStep`s inside. A step that joins a list already on screen fades in, and its title
|
|
25
|
+
* is announced; the steps that are there when the list first shows do not move. For one line
|
|
26
|
+
* that stands for the whole of it and opens the steps, wrap the list in a `TraceSummary`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function Trace({ marks, statusLabels, className, ...props }: TraceProps): import("react").JSX.Element;
|
|
29
|
+
type RowProps = {
|
|
30
|
+
/** Where the step stands. Done unless said otherwise. */
|
|
31
|
+
status?: TraceStatus;
|
|
32
|
+
/**
|
|
33
|
+
* What is being done, as a short line: in the present while it runs ("Zahlungen werden
|
|
34
|
+
* abgeglichen"), in the past once it is done ("Zahlungen abgeglichen").
|
|
35
|
+
*/
|
|
36
|
+
title: ReactNode;
|
|
37
|
+
/** A second, quieter fact after the title: how long it took, how much was found. */
|
|
38
|
+
meta?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* A symbol for the kind of step. A list with `marks="symbols"` shows it in place of the disc
|
|
41
|
+
* once the step is done. Give every step one or none.
|
|
42
|
+
*/
|
|
43
|
+
icon?: IconSvgElement;
|
|
44
|
+
/** Whether the detail shows (controlled). */
|
|
45
|
+
open?: boolean;
|
|
46
|
+
/** Whether the detail shows at first. */
|
|
47
|
+
defaultOpen?: boolean;
|
|
48
|
+
onOpenChange?: (open: boolean) => void;
|
|
49
|
+
};
|
|
50
|
+
export type TraceStepProps = Omit<ComponentProps<"li">, "title"> & RowProps;
|
|
51
|
+
/**
|
|
52
|
+
* One step. With children it opens: the line becomes a button, and what it did stands under it
|
|
53
|
+
* (the command, the result, the sources as `Badge`s, the steps of a helper as a `Trace` of its
|
|
54
|
+
* own). Without children it is a plain line and not a tab stop.
|
|
55
|
+
*/
|
|
56
|
+
export declare function TraceStep({ status, title, meta, icon, open, defaultOpen, onOpenChange, className, children, ...props }: TraceStepProps): import("react").JSX.Element;
|
|
57
|
+
export type TraceSummaryProps = Omit<ComponentProps<"div">, "title"> & Omit<RowProps, "icon"> & {
|
|
58
|
+
/** The steps: a `Trace`. */
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* One line that stands for a whole piece of work and opens its steps: "Arbeitet …" while it
|
|
63
|
+
* goes on, "In 14 Sekunden erledigt" afterwards, the number of steps as its second fact. It is
|
|
64
|
+
* what a chat shows above an answer.
|
|
65
|
+
*
|
|
66
|
+
* It follows the work: open while the work is running, so the steps can be watched, and closed
|
|
67
|
+
* once it is done, so the answer has the room. From the moment the reader opens or closes it,
|
|
68
|
+
* it stays as they left it. `open` and `defaultOpen` fix it from outside.
|
|
69
|
+
*/
|
|
70
|
+
export declare function TraceSummary({ status, title, meta, open, defaultOpen, onOpenChange, className, children, ...props }: TraceSummaryProps): import("react").JSX.Element;
|
|
71
|
+
export {};
|