@lanfermann/ui 0.3.0 → 0.5.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.
Files changed (81) hide show
  1. package/dist/components/anchor-heading/anchor-heading.d.ts +1 -1
  2. package/dist/components/breadcrumbs/breadcrumbs.js +5 -10
  3. package/dist/components/button/button.d.ts +3 -0
  4. package/dist/components/button/button.js +14 -4
  5. package/dist/components/button-group/button-group-context.js +14 -0
  6. package/dist/components/button-group/button-group-variants.d.ts +14 -0
  7. package/dist/components/button-group/button-group-variants.js +93 -0
  8. package/dist/components/button-group/button-group.d.ts +36 -0
  9. package/dist/components/button-group/button-group.js +46 -0
  10. package/dist/components/code-block/code-block-frame.js +22 -6
  11. package/dist/components/code-block/code-block-live.d.ts +15 -3
  12. package/dist/components/code-block/code-block-live.js +14 -6
  13. package/dist/components/code-block/code-block.d.ts +8 -3
  14. package/dist/components/code-block/code-block.js +9 -3
  15. package/dist/components/code-block/code-keys.d.ts +24 -0
  16. package/dist/components/code-block/code-keys.js +107 -0
  17. package/dist/components/code-block/code-lines-live.d.ts +7 -0
  18. package/dist/components/code-block/code-lines-live.js +167 -0
  19. package/dist/components/code-block/code-lines-view.d.ts +1 -0
  20. package/dist/components/code-block/code-lines-view.js +50 -18
  21. package/dist/components/code-block/code-lines.d.ts +3 -0
  22. package/dist/components/code-block/code-scroll.js +2 -1
  23. package/dist/components/code-block/code-tabs-frame.js +12 -5
  24. package/dist/components/code-block/code-tabs.d.ts +10 -4
  25. package/dist/components/code-block/code-tabs.js +9 -6
  26. package/dist/components/code-block/highlight.d.ts +1 -0
  27. package/dist/components/code-block/line-diff.js +135 -0
  28. package/dist/components/code-block/lines.js +23 -1
  29. package/dist/components/copy-page/copy-page.d.ts +4 -4
  30. package/dist/components/copy-page/copy-page.js +16 -28
  31. package/dist/components/docs-layout/docs-layout.d.ts +1 -1
  32. package/dist/components/docs-layout/docs-layout.js +3 -3
  33. package/dist/components/docs-layout/docs-nav.d.ts +51 -0
  34. package/dist/components/docs-layout/docs-nav.js +60 -0
  35. package/dist/components/grow/grow.d.ts +20 -0
  36. package/dist/components/grow/grow.js +104 -0
  37. package/dist/components/heading/heading.d.ts +4 -0
  38. package/dist/components/heading/heading.js +8 -4
  39. package/dist/components/hover-card/hover-card.d.ts +24 -0
  40. package/dist/components/hover-card/hover-card.js +51 -0
  41. package/dist/components/pager/pager.js +19 -24
  42. package/dist/components/scroll-fade/scroll-fade.d.ts +29 -0
  43. package/dist/components/scroll-fade/scroll-fade.js +40 -0
  44. package/dist/components/scroll-fade/use-scroll-edges.d.ts +13 -0
  45. package/dist/{internal/scroll-edges.js → components/scroll-fade/use-scroll-edges.js} +10 -7
  46. package/dist/components/section/section.d.ts +2 -1
  47. package/dist/components/section/section.js +2 -1
  48. package/dist/components/segmented-control/segmented-control.d.ts +7 -1
  49. package/dist/components/segmented-control/segmented-control.js +22 -11
  50. package/dist/components/select/select.d.ts +4 -1
  51. package/dist/components/select/select.js +15 -3
  52. package/dist/components/shimmer/shimmer.d.ts +21 -0
  53. package/dist/components/shimmer/shimmer.js +24 -0
  54. package/dist/components/side-nav/side-nav.js +11 -20
  55. package/dist/components/site-header/site-header.d.ts +1 -1
  56. package/dist/components/site-header/site-header.js +6 -3
  57. package/dist/components/slider/slider.d.ts +3 -1
  58. package/dist/components/slider/slider.js +45 -19
  59. package/dist/components/table/table.js +2 -1
  60. package/dist/components/tabs/tabs.js +3 -2
  61. package/dist/components/theme-switch/theme-switch.d.ts +47 -0
  62. package/dist/components/theme-switch/theme-switch.js +102 -0
  63. package/dist/components/trace/trace.d.ts +71 -0
  64. package/dist/components/trace/trace.js +201 -0
  65. package/dist/index.d.ts +11 -2
  66. package/dist/index.js +10 -2
  67. package/dist/internal/render-as.js +24 -0
  68. package/dist/internal/rule.js +5 -4
  69. package/package.json +1 -1
  70. package/src/styles/button-group.css +57 -0
  71. package/src/styles/code.css +102 -38
  72. package/src/styles/marks.css +10 -0
  73. package/src/styles/motion.css +4 -3
  74. package/src/styles/scroll-fade.css +26 -20
  75. package/src/styles/shimmer.css +68 -0
  76. package/src/styles/slider.css +57 -19
  77. package/src/styles.css +2 -1
  78. package/dist/components/page-header/page-header.d.ts +0 -30
  79. package/dist/components/page-header/page-header.js +0 -49
  80. package/dist/internal/scroll-fade.js +0 -24
  81. package/src/styles/tabs.css +0 -39
@@ -1,13 +1,16 @@
1
1
  "use client";
2
2
  import { useEffect } from "react";
3
- // src/internal/scroll-edges.ts
3
+ // src/components/scroll-fade/use-scroll-edges.ts
4
4
  /**
5
5
  * Says on a box that scrolls which of its ends has more to show: `data-overflow` holds `start`,
6
- * `end`, both, or is absent. The stylesheet fades those edges (the code block's lines, a row of
7
- * tabs, the foot of the site's menu). The state is written straight onto the element, so
8
- * scrolling never renders. `axis` is the direction the box scrolls in. For a box that mounts
9
- * later than the component (a popup), pass something that changes when it does as `mounted`,
10
- * so the edges are watched from then on.
6
+ * `end`, both, or is absent. The stylesheet fades those edges (scroll-fade.css) once the box
7
+ * also carries `data-scroll-fade="x"` or `"y"`. The state is written straight onto the element,
8
+ * so scrolling never renders.
9
+ *
10
+ * Use it where the scrolling box is another part's element and cannot be a `ScrollFade` (a list
11
+ * of tabs, the popup of a menu). `axis` is the direction the box scrolls in. For a box that
12
+ * mounts later than the component (a popup), pass something that changes when it does as
13
+ * `mounted`, so the edges are watched from then on.
11
14
  */
12
15
  function useScrollEdges(ref, axis = "x", mounted) {
13
16
  useEffect(() => {
@@ -16,7 +19,7 @@ function useScrollEdges(ref, axis = "x", mounted) {
16
19
  let frame = 0;
17
20
  const update = () => {
18
21
  frame = 0;
19
- const start = axis === "x" ? scroller.scrollLeft : scroller.scrollTop;
22
+ const start = Math.abs(axis === "x" ? scroller.scrollLeft : scroller.scrollTop);
20
23
  const visible = axis === "x" ? scroller.clientWidth : scroller.clientHeight;
21
24
  const total = axis === "x" ? scroller.scrollWidth : scroller.scrollHeight;
22
25
  const overflow = [start > 1 ? "start" : "", start + visible < total - 1 ? "end" : ""].filter(Boolean).join(" ");
@@ -7,7 +7,8 @@ export type SectionProps = ComponentProps<"section"> & VariantProps<typeof secti
7
7
  /**
8
8
  * One part of a page, with the air above and below it. It is a `<section>`: name it with
9
9
  * `aria-labelledby` and the id of its title. Put a `Container` inside, and open it with a
10
- * `PageHeader`. A part on another ground stands in a `Ground` with the section inside.
10
+ * `Heading` (`size="title"`), under a `Separator` rule unless a `Seam` opens the section. A part
11
+ * on another ground stands in a `Ground` with the section inside.
11
12
  */
12
13
  export declare function Section({ space, className, ...props }: SectionProps): import("react").JSX.Element;
13
14
  export {};
@@ -18,7 +18,8 @@ const sectionVariants = cva("", {
18
18
  /**
19
19
  * One part of a page, with the air above and below it. It is a `<section>`: name it with
20
20
  * `aria-labelledby` and the id of its title. Put a `Container` inside, and open it with a
21
- * `PageHeader`. A part on another ground stands in a `Ground` with the section inside.
21
+ * `Heading` (`size="title"`), under a `Separator` rule unless a `Seam` opens the section. A part
22
+ * on another ground stands in a `Ground` with the section inside.
22
23
  */
23
24
  function Section({ space, className, ...props }) {
24
25
  return /* @__PURE__ */ jsx("section", {
@@ -13,6 +13,12 @@ export type SegmentedControlProps = Omit<ToggleGroup.Props, "value" | "defaultVa
13
13
  * `round` is a pill whose thumb rides on the trough's full height, each segment with its mark.
14
14
  */
15
15
  shape?: Shape;
16
+ /**
17
+ * The round shape draws the system's mark before every label: a ring, and the disc where the
18
+ * thumb is. `false` leaves it out, for segments that are a symbol each: the symbol is the
19
+ * mark then. The square shape has no marks.
20
+ */
21
+ marks?: boolean;
16
22
  /**
17
23
  * The thumb has weight: it can be pulled to another segment, it stretches along its way and
18
24
  * squashes as it lands, and it reaches for a mouse that rests over another segment. `false`
@@ -33,7 +39,7 @@ export type SegmentedControlProps = Omit<ToggleGroup.Props, "value" | "defaultVa
33
39
  * parents. Its weight is the slider's, decided in src/motion/inertia.ts once per move and drawn
34
40
  * by CSS: nothing renders while it moves.
35
41
  */
36
- export declare function SegmentedControl({ value: valueProp, defaultValue, onValueChange, shape, inertia, className, children, ...props }: SegmentedControlProps): import("react").JSX.Element;
42
+ export declare function SegmentedControl({ value: valueProp, defaultValue, onValueChange, shape, marks, inertia, className, children, ...props }: SegmentedControlProps): import("react").JSX.Element;
37
43
  export type SegmentProps = Omit<Toggle.Props, "value"> & {
38
44
  value: string;
39
45
  children?: ReactNode;
@@ -22,7 +22,8 @@ const seatDepth = {
22
22
  const TrackContext = createContext({
23
23
  shape: "square",
24
24
  value: void 0,
25
- lens: false
25
+ lens: false,
26
+ marks: true
26
27
  });
27
28
  /** How far a press on the thumb must travel before it is a drag and not a click, in px. */
28
29
  const DRAG_SLOP = 4;
@@ -60,7 +61,7 @@ function widthAt(boxes, middle) {
60
61
  * parents. Its weight is the slider's, decided in src/motion/inertia.ts once per move and drawn
61
62
  * by CSS: nothing renders while it moves.
62
63
  */
63
- function SegmentedControl({ value: valueProp, defaultValue, onValueChange, shape = "square", inertia = true, className, children, ...props }) {
64
+ function SegmentedControl({ value: valueProp, defaultValue, onValueChange, shape = "square", marks = true, inertia = true, className, children, ...props }) {
64
65
  const [inner, setInner] = useState(defaultValue);
65
66
  const value = valueProp ?? inner;
66
67
  const trackRef = useRef(null);
@@ -303,13 +304,23 @@ function SegmentedControl({ value: valueProp, defaultValue, onValueChange, shape
303
304
  const track = useMemo(() => ({
304
305
  shape,
305
306
  value,
306
- lens: false
307
- }), [shape, value]);
307
+ lens: false,
308
+ marks
309
+ }), [
310
+ shape,
311
+ value,
312
+ marks
313
+ ]);
308
314
  const lens = useMemo(() => ({
309
315
  shape,
310
316
  value,
311
- lens: true
312
- }), [shape, value]);
317
+ lens: true,
318
+ marks
319
+ }), [
320
+ shape,
321
+ value,
322
+ marks
323
+ ]);
313
324
  return /* @__PURE__ */ jsxs(ToggleGroup, {
314
325
  ref: trackRef,
315
326
  "data-slot": "segmented-control",
@@ -368,15 +379,15 @@ const segmentBox = {
368
379
  const segmentText = "inline-flex items-center justify-center text-control font-medium whitespace-nowrap select-none";
369
380
  function Segment({ value, className, children, ...props }) {
370
381
  const track = useContext(TrackContext);
371
- const round = track.shape === "round";
382
+ const marked = track.shape === "round" && track.marks;
372
383
  if (track.lens) return /* @__PURE__ */ jsx("span", {
373
384
  "data-slot": "segment-copy",
374
385
  "data-pressed": track.value === value ? "" : void 0,
375
386
  className: cn("group", segmentText, segmentBox[track.shape], "text-fg", typeof className === "string" && className),
376
387
  children: /* @__PURE__ */ jsxs("span", {
377
388
  "data-slot": "segment-label",
378
- className: cn("inline-flex items-center", round && "gap-1.5"),
379
- children: [round && /* @__PURE__ */ jsx("span", {
389
+ className: cn("inline-flex items-center", marked && "gap-1.5"),
390
+ children: [marked && /* @__PURE__ */ jsx("span", {
380
391
  "data-slot": "segment-mark",
381
392
  className: "mark group-data-pressed:mark-on group-data-pressed:delay-(--segment-seat)"
382
393
  }), children]
@@ -401,8 +412,8 @@ function Segment({ value, className, children, ...props }) {
401
412
  ...props,
402
413
  children: /* @__PURE__ */ jsxs("span", {
403
414
  "data-slot": "segment-label",
404
- className: cn("relative -z-1 inline-flex items-center", round && "gap-1.5"),
405
- children: [round && /* @__PURE__ */ jsx("span", {
415
+ className: cn("relative -z-1 inline-flex items-center", marked && "gap-1.5"),
416
+ children: [marked && /* @__PURE__ */ jsx("span", {
406
417
  "data-slot": "segment-mark",
407
418
  "aria-hidden": true,
408
419
  className: "mark group-hover:[--mark-ring:var(--lf-text-muted)] group-not-data-placed/track:group-data-pressed:mark-on"
@@ -44,7 +44,10 @@ export type SelectTriggerProps = Omit<Select$1.Trigger.Props, "children"> & Vari
44
44
  /** Replaces how the chosen value is rendered. By default its label, and icon, from `items`. */
45
45
  children?: Select$1.Value.Props["children"];
46
46
  };
47
- /** Shows the chosen value and opens the list. Give it a name: a `FieldLabel` or `aria-label`. */
47
+ /**
48
+ * Shows the chosen value and opens the list. Give it a name: a `FieldLabel` or `aria-label`.
49
+ * Inside a `ButtonGroup` it is one key of the group's fitting and takes the group's size.
50
+ */
48
51
  export declare function SelectTrigger({ className, size, placeholder, children, ...props }: SelectTriggerProps): import("react").JSX.Element;
49
52
  export type SelectContentProps = Select$1.Popup.Props & Pick<Select$1.Positioner.Props, "side" | "align" | "sideOffset" | "alignOffset" | "alignItemWithTrigger">;
50
53
  /**
@@ -1,4 +1,6 @@
1
1
  "use client";
2
+ import { useButtonGroup } from "../button-group/button-group-context.js";
3
+ import { buttonGroupKeyDisabledLook, buttonGroupKeyVariants } from "../button-group/button-group-variants.js";
2
4
  import { useGround } from "../ground/ground.js";
3
5
  import { Icon } from "../icon/icon.js";
4
6
  import { ChevronDownGlyph } from "../../internal/glyphs.js";
@@ -88,15 +90,25 @@ const selectTriggerVariants = cva([
88
90
  } },
89
91
  defaultVariants: { size: "md" }
90
92
  });
91
- /** Shows the chosen value and opens the list. Give it a name: a `FieldLabel` or `aria-label`. */
93
+ /**
94
+ * Shows the chosen value and opens the list. Give it a name: a `FieldLabel` or `aria-label`.
95
+ * Inside a `ButtonGroup` it is one key of the group's fitting and takes the group's size.
96
+ */
92
97
  function SelectTrigger({ className, size, placeholder, children, ...props }) {
93
98
  const options = useContext(OptionsContext);
94
- const resolvedSize = size ?? "md";
99
+ const group = useButtonGroup();
100
+ const resolvedSize = group?.size ?? size ?? "md";
95
101
  const rich = options?.some((option) => option.icon !== void 0 || option.detail !== void 0) === true ? (value) => renderValue(value, options, placeholder, resolvedSize) : void 0;
96
102
  return /* @__PURE__ */ jsxs(Select$1.Trigger, {
97
103
  "data-slot": "select-trigger",
104
+ "data-group-key": group ? "" : void 0,
98
105
  "data-size": resolvedSize,
99
- className: mergeClassName(selectTriggerVariants({ size }), className),
106
+ disabled: group?.disabled || void 0,
107
+ className: mergeClassName(group ? [
108
+ buttonGroupKeyVariants({ size: resolvedSize }),
109
+ buttonGroupKeyDisabledLook,
110
+ "min-w-32 justify-between text-left font-normal"
111
+ ] : selectTriggerVariants({ size }), className),
100
112
  ...props,
101
113
  children: [/* @__PURE__ */ jsx(Select$1.Value, {
102
114
  "data-slot": "select-value",
@@ -0,0 +1,21 @@
1
+ import { ComponentProps } from "react";
2
+ export type ShimmerProps = ComponentProps<"span"> & {
3
+ /**
4
+ * The work is going on (the default). Set it to `false` when it is done: the same element
5
+ * then is plain text in the colour around it, so the line does not jump.
6
+ */
7
+ active?: boolean;
8
+ };
9
+ /**
10
+ * A line of text that names work in progress: a soft light passes through it for as long as the
11
+ * work goes on. Use it where a wait has words ("Zahlungen werden abgeglichen", "Antwort wird
12
+ * geschrieben"), as in the steps of a `Trace`. A wait without words is a `Spinner`; a wait with
13
+ * a known length is a `Progress`.
14
+ *
15
+ * Word it as what is happening, in a few words, and keep it to one line: the light is redrawn
16
+ * on every frame. It is decoration: say that something is busy where assistive tech looks for
17
+ * it (`aria-busy` on the region, a `role="status"` line).
18
+ *
19
+ * The same look is the `shimmer` utility, for text that already has an element.
20
+ */
21
+ export declare function Shimmer({ active, className, ...props }: ShimmerProps): import("react").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { cn } from "../../lib/cn.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ // src/components/shimmer/shimmer.tsx
4
+ /**
5
+ * A line of text that names work in progress: a soft light passes through it for as long as the
6
+ * work goes on. Use it where a wait has words ("Zahlungen werden abgeglichen", "Antwort wird
7
+ * geschrieben"), as in the steps of a `Trace`. A wait without words is a `Spinner`; a wait with
8
+ * a known length is a `Progress`.
9
+ *
10
+ * Word it as what is happening, in a few words, and keep it to one line: the light is redrawn
11
+ * on every frame. It is decoration: say that something is busy where assistive tech looks for
12
+ * it (`aria-busy` on the region, a `role="status"` line).
13
+ *
14
+ * The same look is the `shimmer` utility, for text that already has an element.
15
+ */
16
+ function Shimmer({ active = true, className, ...props }) {
17
+ return /* @__PURE__ */ jsx("span", {
18
+ "data-slot": "shimmer",
19
+ "data-active": active ? "" : void 0,
20
+ className: cn(active && "shimmer", className),
21
+ ...props
22
+ });
23
+ }
24
+ export { Shimmer };
@@ -1,8 +1,7 @@
1
- "use client";
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 = useRender({
49
- defaultTagName: "a",
50
- render,
51
- props: {
52
- ...props,
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 = useRender({
75
- defaultTagName: "a",
76
- render,
77
- props: {
78
- ...props,
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 "../../internal/scroll-edges.js";
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-14 w-[calc(100%-1rem)] max-w-[calc(72rem+2rem)] items-center gap-6 px-3 sm:w-[calc(100%-2rem)] sm:px-4";
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-fill-window", travels),
195
- style: vars({
196
- "--fill-start": range ? centre(places[0] ?? 0) : "0px",
197
- "--fill-end": centre(last)
198
- }),
199
- children: /* @__PURE__ */ jsx("span", { className: cn("slider-fill-bar", colour, travels) })
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 size-(--switch-h)", travels),
218
+ className: cn("slider-at h-(--switch-h)", travels),
202
219
  style: vars({ "--p": at }),
203
220
  children: /* @__PURE__ */ jsx("span", {
204
- "data-slot": "slider-cap",
205
- 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]"),
206
- style: body(index, "var(--switch-h)")
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("slider-geometry touch-target relative col-span-2 mx-0.5 flex h-(--control-md) touch-none items-center select-none data-disabled:pointer-events-none", className),
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 size-(--slider-thumb) rounded-full", travels, "[[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", "[[data-slot=slider-thumb]:hover+&]:*:depth-raised-hover"),
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-face",
272
- className: cn("slider-body block h-full w-[calc(100%+var(--held,0px))] rounded-full bg-(--thumb-face) depth-raised depth-tone-thumb", held && "depth-raised-hover [--held:3px]", state.disabled && "bg-raised depth-flat"),
273
- style: body(index, "var(--slider-thumb)")
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
  }
@@ -1,6 +1,6 @@
1
+ import { ScrollFade } from "../scroll-fade/scroll-fade.js";
1
2
  import { ArrowUpGlyph } from "../../internal/glyphs.js";
2
3
  import { ruleTop } from "../../internal/rule.js";
3
- import { ScrollFade } from "../../internal/scroll-fade.js";
4
4
  import { cn } from "../../lib/cn.js";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  // src/components/table/table.tsx
@@ -21,6 +21,7 @@ function Table({ className, containerClassName, content = "data", stack = false,
21
21
  "data-slot": "table-container",
22
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
23
  children: /* @__PURE__ */ jsx(ScrollFade, {
24
+ axis: "x",
24
25
  "data-slot": "table-scroll",
25
26
  role: "region",
26
27
  "aria-label": label,
@@ -1,6 +1,6 @@
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
5
  import { mergeRefs } from "../../lib/merge-refs.js";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -15,7 +15,7 @@ function Tabs({ className, ...props }) {
15
15
  ...props
16
16
  });
17
17
  }
18
- /** How far a tab keeps off the edge it is scrolled to: past the fade (tabs.css), in px. */
18
+ /** How far a tab keeps off the edge it is scrolled to: past the fade (scroll-fade.css), in px. */
19
19
  const REVEAL_MARGIN = 40;
20
20
  /**
21
21
  * A row of labels, each with a mark. One soft highlight glides to the current tab (`glide`) and
@@ -57,6 +57,7 @@ function TabsList({ className, children, ref, ...props }) {
57
57
  return /* @__PURE__ */ jsxs(Tabs$1.List, {
58
58
  ref: mergeRefs(list, ref),
59
59
  "data-slot": "tabs-list",
60
+ "data-scroll-fade": "x",
60
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),
61
62
  ...props,
62
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 {};