@lanfermann/ui 0.0.0-stage → 0.1.1
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/LICENSE +24 -0
- package/README.md +17 -2
- package/TRADEMARK.md +10 -0
- package/brand/app-icon.svg +1 -0
- package/brand/avatar.svg +1 -0
- package/brand/favicon.svg +1 -0
- package/dist/components/accordion/accordion.d.ts +26 -0
- package/dist/components/accordion/accordion.js +78 -0
- package/dist/components/alert/alert.d.ts +19 -0
- package/dist/components/alert/alert.js +68 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +20 -0
- package/dist/components/alert-dialog/alert-dialog.js +75 -0
- package/dist/components/anchor-heading/anchor-heading.d.ts +19 -0
- package/dist/components/anchor-heading/anchor-heading.js +39 -0
- package/dist/components/avatar/avatar.d.ts +14 -0
- package/dist/components/avatar/avatar.js +42 -0
- package/dist/components/badge/badge.d.ts +12 -0
- package/dist/components/badge/badge.js +27 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +23 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +63 -0
- package/dist/components/button/button-variants.d.ts +15 -0
- package/dist/components/button/button-variants.js +76 -0
- package/dist/components/button/button.d.ts +25 -0
- package/dist/components/button/button.js +50 -0
- package/dist/components/calendar/calendar-selection.js +216 -0
- package/dist/components/calendar/calendar.d.ts +44 -0
- package/dist/components/calendar/calendar.js +208 -0
- package/dist/components/callout/callout.d.ts +21 -0
- package/dist/components/callout/callout.js +75 -0
- package/dist/components/card/card.d.ts +16 -0
- package/dist/components/card/card.js +53 -0
- package/dist/components/checkbox/checkbox.d.ts +9 -0
- package/dist/components/checkbox/checkbox.js +33 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +18 -0
- package/dist/components/checkbox-group/checkbox-group.js +33 -0
- package/dist/components/code/code.d.ts +7 -0
- package/dist/components/code/code.js +16 -0
- package/dist/components/code-block/code-block-frame.js +146 -0
- package/dist/components/code-block/code-block-live.d.ts +45 -0
- package/dist/components/code-block/code-block-live.js +51 -0
- package/dist/components/code-block/code-block.d.ts +36 -0
- package/dist/components/code-block/code-block.js +51 -0
- package/dist/components/code-block/code-copy.d.ts +12 -0
- package/dist/components/code-block/code-copy.js +71 -0
- package/dist/components/code-block/code-lines-view.d.ts +16 -0
- package/dist/components/code-block/code-lines-view.js +48 -0
- package/dist/components/code-block/code-lines.js +17 -0
- package/dist/components/code-block/code-scroll.js +29 -0
- package/dist/components/code-block/code-surface.js +13 -0
- package/dist/components/code-block/code-tabs-frame.js +85 -0
- package/dist/components/code-block/code-tabs-store.js +25 -0
- package/dist/components/code-block/code-tabs.d.ts +28 -0
- package/dist/components/code-block/code-tabs.js +29 -0
- package/dist/components/code-block/highlight.d.ts +34 -0
- package/dist/components/code-block/highlight.js +258 -0
- package/dist/components/code-block/lines.d.ts +5 -0
- package/dist/components/code-block/lines.js +40 -0
- package/dist/components/collapsible/collapsible.d.ts +19 -0
- package/dist/components/collapsible/collapsible.js +54 -0
- package/dist/components/combobox/combobox.d.ts +84 -0
- package/dist/components/combobox/combobox.js +169 -0
- package/dist/components/container/container.d.ts +16 -0
- package/dist/components/container/container.js +30 -0
- package/dist/components/copy-pill/copy-pill.d.ts +52 -0
- package/dist/components/copy-pill/copy-pill.js +232 -0
- package/dist/components/cta/cta.d.ts +109 -0
- package/dist/components/cta/cta.js +375 -0
- package/dist/components/date-field/date-field.d.ts +40 -0
- package/dist/components/date-field/date-field.js +99 -0
- package/dist/components/date-range-field/date-range-field.d.ts +41 -0
- package/dist/components/date-range-field/date-range-field.js +155 -0
- package/dist/components/dialog/dialog.d.ts +29 -0
- package/dist/components/dialog/dialog.js +96 -0
- package/dist/components/docs-layout/docs-layout.d.ts +17 -0
- package/dist/components/docs-layout/docs-layout.js +46 -0
- package/dist/components/drawer/drawer.d.ts +39 -0
- package/dist/components/drawer/drawer.js +181 -0
- package/dist/components/field/field.d.ts +18 -0
- package/dist/components/field/field.js +77 -0
- package/dist/components/fieldset/fieldset.d.ts +8 -0
- package/dist/components/fieldset/fieldset.js +25 -0
- package/dist/components/figure/figure.d.ts +14 -0
- package/dist/components/figure/figure.js +35 -0
- package/dist/components/form/form.d.ts +31 -0
- package/dist/components/form/form.js +55 -0
- package/dist/components/ground/ground.d.ts +20 -0
- package/dist/components/ground/ground.js +31 -0
- package/dist/components/heading/heading.d.ts +16 -0
- package/dist/components/heading/heading.js +36 -0
- package/dist/components/icon/icon.d.ts +22 -0
- package/dist/components/icon/icon.js +24 -0
- package/dist/components/input/input.d.ts +19 -0
- package/dist/components/input/input.js +46 -0
- package/dist/components/input-group/input-group.d.ts +34 -0
- package/dist/components/input-group/input-group.js +61 -0
- package/dist/components/kbd/kbd.d.ts +6 -0
- package/dist/components/kbd/kbd.js +15 -0
- package/dist/components/link/link-variants.d.ts +13 -0
- package/dist/components/link/link-variants.js +27 -0
- package/dist/components/link/link.d.ts +9 -0
- package/dist/components/link/link.js +18 -0
- package/dist/components/logo/logo-paths.js +22 -0
- package/dist/components/logo/logomark.d.ts +19 -0
- package/dist/components/logo/logomark.js +49 -0
- package/dist/components/logo/wordmark.d.ts +35 -0
- package/dist/components/logo/wordmark.js +48 -0
- package/dist/components/menu/menu.d.ts +26 -0
- package/dist/components/menu/menu.js +132 -0
- package/dist/components/meter/meter.d.ts +29 -0
- package/dist/components/meter/meter.js +68 -0
- package/dist/components/navigation-menu/navigation-menu-variants.d.ts +12 -0
- package/dist/components/navigation-menu/navigation-menu-variants.js +18 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +42 -0
- package/dist/components/navigation-menu/navigation-menu.js +128 -0
- package/dist/components/number-field/number-field.d.ts +32 -0
- package/dist/components/number-field/number-field.js +85 -0
- package/dist/components/page-header/page-header.d.ts +27 -0
- package/dist/components/page-header/page-header.js +48 -0
- package/dist/components/pager/pager.d.ts +24 -0
- package/dist/components/pager/pager.js +51 -0
- package/dist/components/parameter-list/parameter-list.d.ts +34 -0
- package/dist/components/parameter-list/parameter-list.js +70 -0
- package/dist/components/popover/popover.d.ts +15 -0
- package/dist/components/popover/popover.js +64 -0
- package/dist/components/progress/progress.d.ts +19 -0
- package/dist/components/progress/progress.js +67 -0
- package/dist/components/prose/prose.d.ts +13 -0
- package/dist/components/prose/prose.js +22 -0
- package/dist/components/quote/quote.d.ts +21 -0
- package/dist/components/quote/quote.js +46 -0
- package/dist/components/radio/radio.d.ts +12 -0
- package/dist/components/radio/radio.js +37 -0
- package/dist/components/reference-entry/reference-entry.d.ts +25 -0
- package/dist/components/reference-entry/reference-entry.js +66 -0
- package/dist/components/section/section.d.ts +13 -0
- package/dist/components/section/section.js +30 -0
- package/dist/components/segmented-control/segmented-control.d.ts +42 -0
- package/dist/components/segmented-control/segmented-control.js +413 -0
- package/dist/components/select/select.d.ts +70 -0
- package/dist/components/select/select.js +189 -0
- package/dist/components/separator/separator.d.ts +12 -0
- package/dist/components/separator/separator.js +29 -0
- package/dist/components/side-nav/side-nav.d.ts +48 -0
- package/dist/components/side-nav/side-nav.js +89 -0
- package/dist/components/site-footer/site-footer-floor.js +48 -0
- package/dist/components/site-footer/site-footer.d.ts +38 -0
- package/dist/components/site-footer/site-footer.js +96 -0
- package/dist/components/site-header/site-header.d.ts +77 -0
- package/dist/components/site-header/site-header.js +214 -0
- package/dist/components/slider/slider.d.ts +42 -0
- package/dist/components/slider/slider.js +279 -0
- package/dist/components/spinner/spinner.d.ts +15 -0
- package/dist/components/spinner/spinner.js +34 -0
- package/dist/components/switch/switch.d.ts +8 -0
- package/dist/components/switch/switch.js +28 -0
- package/dist/components/table/table.d.ts +83 -0
- package/dist/components/table/table.js +123 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts +32 -0
- package/dist/components/table-of-contents/table-of-contents.js +187 -0
- package/dist/components/tabs/tabs.d.ts +28 -0
- package/dist/components/tabs/tabs.js +124 -0
- package/dist/components/text/text.d.ts +16 -0
- package/dist/components/text/text.js +63 -0
- package/dist/components/textarea/textarea.d.ts +19 -0
- package/dist/components/textarea/textarea.js +30 -0
- package/dist/components/time-field/time-field.d.ts +40 -0
- package/dist/components/time-field/time-field.js +123 -0
- package/dist/components/toast/toast.d.ts +55 -0
- package/dist/components/toast/toast.js +129 -0
- package/dist/components/tooltip/tooltip.d.ts +16 -0
- package/dist/components/tooltip/tooltip.js +41 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +77 -0
- package/dist/internal/arrow.js +41 -0
- package/dist/internal/disclosure.js +20 -0
- package/dist/internal/field-context.js +21 -0
- package/dist/internal/field.d.ts +23 -0
- package/dist/internal/field.js +49 -0
- package/dist/internal/glyphs.js +84 -0
- package/dist/internal/iso-date.d.ts +2 -0
- package/dist/internal/iso-date.js +268 -0
- package/dist/internal/overlay.js +40 -0
- package/dist/internal/picker-sheet.js +74 -0
- package/dist/internal/popup.js +37 -0
- package/dist/internal/range-shape.js +295 -0
- package/dist/internal/reduced-motion.js +19 -0
- package/dist/internal/scroll-edges.js +45 -0
- package/dist/internal/trough.js +39 -0
- package/dist/internal/typed-input.d.ts +16 -0
- package/dist/internal/typed-input.js +133 -0
- package/dist/lib/cn.d.ts +11 -0
- package/dist/lib/cn.js +98 -0
- package/dist/motion/inertia.js +111 -0
- package/dist/motion/spring-step.js +35 -0
- package/dist/motion/springs.d.ts +78 -0
- package/dist/motion/springs.js +81 -0
- package/package.json +107 -4
- package/src/styles/base.css +93 -0
- package/src/styles/calendar.css +117 -0
- package/src/styles/code.css +252 -0
- package/src/styles/density.css +53 -0
- package/src/styles/depth.css +501 -0
- package/src/styles/grounds.css +191 -0
- package/src/styles/marks.css +50 -0
- package/src/styles/motion.css +55 -0
- package/src/styles/motion.generated.css +101 -0
- package/src/styles/prose.css +252 -0
- package/src/styles/radius.css +20 -0
- package/src/styles/segmented.css +208 -0
- package/src/styles/slider.css +110 -0
- package/src/styles/status.css +108 -0
- package/src/styles/tabs.css +39 -0
- package/src/styles/toast.css +106 -0
- package/src/styles/touch.css +41 -0
- package/src/styles/type.css +54 -0
- package/src/styles.css +38 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
2
|
+
export type SwitchProps = Switch$1.Root.Props;
|
|
3
|
+
/**
|
|
4
|
+
* For a setting that takes effect at once. A raised thumb runs in a sunken track: it travels on
|
|
5
|
+
* `seat`, stretches a little while held, and the track fills with Indigo when on. The thumb takes
|
|
6
|
+
* the colour that reads on the track it is on, so it stays visible on every ground.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Switch({ className, ...props }: SwitchProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn, mergeClassName } from "../../lib/cn.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
5
|
+
// src/components/switch/switch.tsx
|
|
6
|
+
/**
|
|
7
|
+
* For a setting that takes effect at once. A raised thumb runs in a sunken track: it travels on
|
|
8
|
+
* `seat`, stretches a little while held, and the track fills with Indigo when on. The thumb takes
|
|
9
|
+
* the colour that reads on the track it is on, so it stays visible on every ground.
|
|
10
|
+
*/
|
|
11
|
+
function Switch({ className, ...props }) {
|
|
12
|
+
return /* @__PURE__ */ jsx(Switch$1.Root, {
|
|
13
|
+
"data-slot": "switch",
|
|
14
|
+
className: mergeClassName([
|
|
15
|
+
"group touch-target relative inline-flex h-(--switch-h) w-(--switch-w) shrink-0 items-center rounded-full bg-trough px-0.5 depth-trough",
|
|
16
|
+
"transition-[background-color,box-shadow] duration-150 ease-out",
|
|
17
|
+
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent",
|
|
18
|
+
"data-checked:bg-accent forced-colors:data-checked:bg-[color:Highlight]",
|
|
19
|
+
"data-disabled:pointer-events-none data-disabled:bg-disabled data-disabled:depth-flat"
|
|
20
|
+
], className),
|
|
21
|
+
...props,
|
|
22
|
+
children: /* @__PURE__ */ jsx(Switch$1.Thumb, {
|
|
23
|
+
"data-slot": "switch-thumb",
|
|
24
|
+
className: cn("block size-[calc(var(--switch-h)-4px)] rounded-full bg-thumb depth-raised depth-tone-thumb", "transition-[translate,width,background-color] spring-seat", "group-active:w-[calc(var(--switch-h)-1px)]", "data-checked:translate-x-[calc(var(--switch-w)-var(--switch-h))] data-checked:bg-on-accent", "data-checked:group-active:translate-x-[calc(var(--switch-w)-var(--switch-h)-3px)]", "group-data-disabled:bg-raised group-data-disabled:depth-flat")
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export { Switch };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
/** A table scrolls sideways in its own region, and a region needs a name. */
|
|
3
|
+
type Named = {
|
|
4
|
+
"aria-label": string;
|
|
5
|
+
"aria-labelledby"?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
"aria-labelledby": string;
|
|
8
|
+
"aria-label"?: undefined;
|
|
9
|
+
};
|
|
10
|
+
export type TableProps = Omit<ComponentProps<"table">, "aria-label" | "aria-labelledby"> & Named & {
|
|
11
|
+
/** Classes for the scrolling region around the table. */
|
|
12
|
+
containerClassName?: string;
|
|
13
|
+
/**
|
|
14
|
+
* What the cells hold. `data` (the default): short values, centred on the row's line.
|
|
15
|
+
* `text`: sentences, as in a reference or the docs. Cells then start at the row's top, so a
|
|
16
|
+
* long cell does not push the short ones beside it down to its middle.
|
|
17
|
+
*/
|
|
18
|
+
content?: "data" | "text";
|
|
19
|
+
/**
|
|
20
|
+
* Below `sm`, every row becomes a block of its own and each cell is named by its column
|
|
21
|
+
* (`TableCell label`), instead of the table scrolling sideways. For tables of text with two
|
|
22
|
+
* or three columns, which a phone cannot show side by side. It stays a table to assistive
|
|
23
|
+
* tech.
|
|
24
|
+
*/
|
|
25
|
+
stack?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
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.
|
|
31
|
+
*
|
|
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.
|
|
36
|
+
*
|
|
37
|
+
* Sorting, filtering and paging are the caller's state; the table only provides the slots.
|
|
38
|
+
*/
|
|
39
|
+
export declare function Table({ className, containerClassName, content, stack, "aria-label": label, "aria-labelledby": labelledBy, ...props }: TableProps): import("react").JSX.Element;
|
|
40
|
+
/** A line under the table that says what it shows, or where its numbers come from. */
|
|
41
|
+
export declare function TableCaption({ className, ...props }: ComponentProps<"caption">): import("react").JSX.Element;
|
|
42
|
+
export declare function TableHeader({ className, ...props }: ComponentProps<"thead">): import("react").JSX.Element;
|
|
43
|
+
export declare function TableBody({ className, ...props }: ComponentProps<"tbody">): import("react").JSX.Element;
|
|
44
|
+
/** The sum line: set off by the structural line, in the weight of a result. */
|
|
45
|
+
export declare function TableFooter({ className, ...props }: ComponentProps<"tfoot">): import("react").JSX.Element;
|
|
46
|
+
export type TableRowProps = ComponentProps<"tr"> & {
|
|
47
|
+
/**
|
|
48
|
+
* The row can be opened: it is washed under the pointer. The wash is feedback only; put the
|
|
49
|
+
* real link or button inside the row, so it works from the keyboard.
|
|
50
|
+
*/
|
|
51
|
+
interactive?: boolean;
|
|
52
|
+
/** The row is part of the current selection: washed in the tint. */
|
|
53
|
+
selected?: boolean;
|
|
54
|
+
};
|
|
55
|
+
export declare function TableRow({ className, interactive, selected, ...props }: TableRowProps): import("react").JSX.Element;
|
|
56
|
+
export type TableHeadProps = ComponentProps<"th"> & {
|
|
57
|
+
/** A column of numbers: its heading stands right, above the digits. */
|
|
58
|
+
numeric?: boolean;
|
|
59
|
+
/** How the table is sorted by this column, for assistive tech. Use with a `TableSortButton`. */
|
|
60
|
+
sort?: "ascending" | "descending" | "none";
|
|
61
|
+
};
|
|
62
|
+
/** A column heading: small and muted, so the rows are what is read. */
|
|
63
|
+
export declare function TableHead({ className, numeric: isNumeric, sort, ...props }: TableHeadProps): import("react").JSX.Element;
|
|
64
|
+
export type TableCellProps = ComponentProps<"td"> & {
|
|
65
|
+
/** A number: set right, in tabular digits, so the column lines up. */
|
|
66
|
+
numeric?: boolean;
|
|
67
|
+
/** The name of the cell's column, shown above it when the table is stacked on a phone. */
|
|
68
|
+
label?: string;
|
|
69
|
+
/** Kept on one line, like a name in code that must not break. A stacked table still wraps it. */
|
|
70
|
+
nowrap?: boolean;
|
|
71
|
+
};
|
|
72
|
+
export declare function TableCell({ className, numeric: isNumeric, label, nowrap, ...props }: TableCellProps): import("react").JSX.Element;
|
|
73
|
+
export type TableSortButtonProps = ComponentProps<"button"> & {
|
|
74
|
+
/** The current direction, if the table is sorted by this column. */
|
|
75
|
+
direction?: "ascending" | "descending";
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* The heading of a sortable column, as a button. An arrow shows the direction and turns over
|
|
79
|
+
* (`seat`) when it changes; an unsorted column shows it faintly under the pointer. Keep the state
|
|
80
|
+
* yourself, and put the same direction on the `TableHead` as `sort`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function TableSortButton({ className, direction, children, ...props }: TableSortButtonProps): import("react").JSX.Element;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ArrowUpGlyph } from "../../internal/glyphs.js";
|
|
2
|
+
import { cn } from "../../lib/cn.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
// src/components/table/table.tsx
|
|
5
|
+
/**
|
|
6
|
+
* 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
|
+
*
|
|
10
|
+
* 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.
|
|
14
|
+
*
|
|
15
|
+
* Sorting, filtering and paging are the caller's state; the table only provides the slots.
|
|
16
|
+
*/
|
|
17
|
+
function Table({ className, containerClassName, content = "data", stack = false, "aria-label": label, "aria-labelledby": labelledBy, ...props }) {
|
|
18
|
+
return /* @__PURE__ */ jsx("div", {
|
|
19
|
+
"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
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const stackedGroup = "in-data-stack:max-sm:block";
|
|
36
|
+
const stackedRow = "in-data-stack:max-sm:block in-data-stack:max-sm:py-3";
|
|
37
|
+
const stackedCell = [
|
|
38
|
+
"in-data-stack:max-sm:block in-data-stack:max-sm:px-0 in-data-stack:max-sm:py-1 in-data-stack:max-sm:whitespace-normal",
|
|
39
|
+
"in-data-stack:max-sm:first:font-medium in-data-stack:max-sm:first:text-fg",
|
|
40
|
+
"in-data-stack:max-sm:before:block in-data-stack:max-sm:before:pb-0.5 in-data-stack:max-sm:before:text-sm in-data-stack:max-sm:before:text-fg-muted in-data-stack:max-sm:before:content-[attr(data-label)]"
|
|
41
|
+
].join(" ");
|
|
42
|
+
/** A line under the table that says what it shows, or where its numbers come from. */
|
|
43
|
+
function TableCaption({ className, ...props }) {
|
|
44
|
+
return /* @__PURE__ */ jsx("caption", {
|
|
45
|
+
"data-slot": "table-caption",
|
|
46
|
+
className: cn("pt-3 text-left text-sm text-fg-muted", className),
|
|
47
|
+
...props
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function TableHeader({ className, ...props }) {
|
|
51
|
+
return /* @__PURE__ */ jsx("thead", {
|
|
52
|
+
"data-slot": "table-header",
|
|
53
|
+
role: "rowgroup",
|
|
54
|
+
className: cn("in-data-stack:max-sm:sr-only", className),
|
|
55
|
+
...props
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function TableBody({ className, ...props }) {
|
|
59
|
+
return /* @__PURE__ */ jsx("tbody", {
|
|
60
|
+
"data-slot": "table-body",
|
|
61
|
+
role: "rowgroup",
|
|
62
|
+
className: cn(stackedGroup, className),
|
|
63
|
+
...props
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** The sum line: set off by the structural line, in the weight of a result. */
|
|
67
|
+
function TableFooter({ className, ...props }) {
|
|
68
|
+
return /* @__PURE__ */ jsx("tfoot", {
|
|
69
|
+
"data-slot": "table-footer",
|
|
70
|
+
role: "rowgroup",
|
|
71
|
+
className: cn("border-t border-line font-medium text-fg [&>tr:last-child]:border-b-0", stackedGroup, className),
|
|
72
|
+
...props
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function TableRow({ className, interactive, selected, ...props }) {
|
|
76
|
+
return /* @__PURE__ */ jsx("tr", {
|
|
77
|
+
"data-slot": "table-row",
|
|
78
|
+
role: "row",
|
|
79
|
+
"data-interactive": interactive ? "" : void 0,
|
|
80
|
+
"data-selected": selected ? "" : void 0,
|
|
81
|
+
"aria-selected": selected,
|
|
82
|
+
className: cn("border-b border-hairline", "data-interactive:hover:bg-hover data-selected:bg-tint data-selected:text-fg", stackedRow, className),
|
|
83
|
+
...props
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const cell = "px-3 text-left align-middle in-data-[content=text]:align-top";
|
|
87
|
+
const numeric = "text-right tabular-nums whitespace-nowrap";
|
|
88
|
+
/** A column heading: small and muted, so the rows are what is read. */
|
|
89
|
+
function TableHead({ className, numeric: isNumeric, sort, ...props }) {
|
|
90
|
+
return /* @__PURE__ */ jsx("th", {
|
|
91
|
+
"data-slot": "table-head",
|
|
92
|
+
scope: "col",
|
|
93
|
+
role: "columnheader",
|
|
94
|
+
"aria-sort": sort,
|
|
95
|
+
className: cn(cell, "h-(--control-lg) text-sm font-normal whitespace-nowrap text-fg-muted", "in-data-[content=text]:pb-2 in-data-[content=text]:align-bottom", isNumeric && "text-right", className),
|
|
96
|
+
...props
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function TableCell({ className, numeric: isNumeric, label, nowrap = false, ...props }) {
|
|
100
|
+
return /* @__PURE__ */ jsx("td", {
|
|
101
|
+
"data-slot": "table-cell",
|
|
102
|
+
role: "cell",
|
|
103
|
+
"data-label": label,
|
|
104
|
+
className: cn(cell, "py-3 in-data-[content=text]:[text-wrap-style:pretty]", isNumeric && numeric, nowrap && "whitespace-nowrap", stackedCell, className),
|
|
105
|
+
...props
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The heading of a sortable column, as a button. An arrow shows the direction and turns over
|
|
110
|
+
* (`seat`) when it changes; an unsorted column shows it faintly under the pointer. Keep the state
|
|
111
|
+
* yourself, and put the same direction on the `TableHead` as `sort`.
|
|
112
|
+
*/
|
|
113
|
+
function TableSortButton({ className, direction, children, ...props }) {
|
|
114
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
115
|
+
type: "button",
|
|
116
|
+
"data-slot": "table-sort-button",
|
|
117
|
+
"data-direction": direction,
|
|
118
|
+
className: cn("group/sort touch-target relative -mx-1.5 inline-flex h-(--control-sm) items-center gap-1 rounded-sm px-1.5 text-sm text-fg-muted select-none", "hover:bg-hover hover:text-fg data-direction:text-fg", "focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-accent", className),
|
|
119
|
+
...props,
|
|
120
|
+
children: [children, /* @__PURE__ */ jsx(ArrowUpGlyph, { className: cn("transition-[rotate,opacity] spring-seat", direction ? "opacity-100" : "opacity-0 group-hover/sort:opacity-50", direction === "descending" && "rotate-180") })]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSortButton };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
export type TocItem = {
|
|
3
|
+
/** The id of the heading the entry leads to. */
|
|
4
|
+
id: string;
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
/** 2 for a section, 3 for a part of it. */
|
|
7
|
+
depth?: 2 | 3 | 4;
|
|
8
|
+
};
|
|
9
|
+
export type TableOfContentsProps = Omit<ComponentProps<"nav">, "children" | "title"> & {
|
|
10
|
+
items: readonly TocItem[];
|
|
11
|
+
/** The visible name of the list, which also names the navigation ("Auf dieser Seite"). */
|
|
12
|
+
title?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Folded under its title, for a narrow window where it stands above the text instead of
|
|
15
|
+
* beside it. It does not follow the reading position there.
|
|
16
|
+
*/
|
|
17
|
+
collapsible?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The id of the section being read, when the app tracks it itself. Without it the list reads
|
|
20
|
+
* the scroll position of the window.
|
|
21
|
+
*/
|
|
22
|
+
current?: string | null;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The sections of the page the reader is on, beside the text on a wide window. A hairline runs
|
|
26
|
+
* along the list, and a 2px piece of it in the text colour stands by the section being read: it
|
|
27
|
+
* glides from one entry to the next as the page scrolls (`glide`). A press on an entry goes there.
|
|
28
|
+
*
|
|
29
|
+
* Give it the page's second- and third-level headings, worded as they stand. On a narrow window
|
|
30
|
+
* set it `collapsible` above the text.
|
|
31
|
+
*/
|
|
32
|
+
export declare function TableOfContents({ items, title, collapsible, current: controlled, className, ...props }: TableOfContentsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../collapsible/collapsible.js";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
// src/components/table-of-contents/table-of-contents.tsx
|
|
7
|
+
/** How long the scroll has to rest after a jump before the reading position counts again. */
|
|
8
|
+
const SETTLE_MS = 140;
|
|
9
|
+
/**
|
|
10
|
+
* Which section the reader is in: the last heading whose top has passed the line where a jump
|
|
11
|
+
* would put it (the scroll padding of the page, or the heading's scroll margin). Nothing before
|
|
12
|
+
* the first heading. At the very end of the page the last section counts, even if its heading
|
|
13
|
+
* cannot be scrolled up to the line.
|
|
14
|
+
*
|
|
15
|
+
* After a press on an entry the page glides to the heading; until it rests, the pressed entry
|
|
16
|
+
* stays current, so the mark does not sweep over every section on the way.
|
|
17
|
+
*/
|
|
18
|
+
function useCurrentSection(ids) {
|
|
19
|
+
const [current, setCurrent] = useState(null);
|
|
20
|
+
const held = useRef(null);
|
|
21
|
+
const settle = useRef(void 0);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (ids.length === 0) return;
|
|
24
|
+
const root = document.documentElement;
|
|
25
|
+
let frame = 0;
|
|
26
|
+
const lineOf = (heading) => Math.max(parseFloat(getComputedStyle(root).scrollPaddingTop) || 0, parseFloat(getComputedStyle(heading).scrollMarginTop) || 0);
|
|
27
|
+
let line = 0;
|
|
28
|
+
const measureLine = () => {
|
|
29
|
+
const first = ids.map((id) => document.getElementById(id)).find(Boolean);
|
|
30
|
+
line = first ? lineOf(first) : 0;
|
|
31
|
+
};
|
|
32
|
+
const read = () => {
|
|
33
|
+
frame = 0;
|
|
34
|
+
if (held.current) return;
|
|
35
|
+
let found = null;
|
|
36
|
+
for (const id of ids) {
|
|
37
|
+
const heading = document.getElementById(id);
|
|
38
|
+
if (!heading) continue;
|
|
39
|
+
if (heading.getBoundingClientRect().top <= line + 4) found = id;
|
|
40
|
+
else break;
|
|
41
|
+
}
|
|
42
|
+
if (window.innerHeight + window.scrollY >= root.scrollHeight - 2 && found) found = ids[ids.length - 1] ?? found;
|
|
43
|
+
setCurrent(found);
|
|
44
|
+
};
|
|
45
|
+
const onScroll = () => {
|
|
46
|
+
if (held.current) {
|
|
47
|
+
clearTimeout(settle.current);
|
|
48
|
+
settle.current = setTimeout(() => {
|
|
49
|
+
held.current = null;
|
|
50
|
+
read();
|
|
51
|
+
}, SETTLE_MS);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!frame) frame = requestAnimationFrame(read);
|
|
55
|
+
};
|
|
56
|
+
const onResize = () => {
|
|
57
|
+
measureLine();
|
|
58
|
+
onScroll();
|
|
59
|
+
};
|
|
60
|
+
measureLine();
|
|
61
|
+
read();
|
|
62
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
63
|
+
window.addEventListener("resize", onResize);
|
|
64
|
+
return () => {
|
|
65
|
+
cancelAnimationFrame(frame);
|
|
66
|
+
clearTimeout(settle.current);
|
|
67
|
+
window.removeEventListener("scroll", onScroll);
|
|
68
|
+
window.removeEventListener("resize", onResize);
|
|
69
|
+
};
|
|
70
|
+
}, [ids]);
|
|
71
|
+
/** An entry was pressed: it is current at once, and stays so until the page has settled. */
|
|
72
|
+
function hold(id) {
|
|
73
|
+
held.current = id;
|
|
74
|
+
setCurrent(id);
|
|
75
|
+
clearTimeout(settle.current);
|
|
76
|
+
settle.current = setTimeout(() => {
|
|
77
|
+
held.current = null;
|
|
78
|
+
}, 840);
|
|
79
|
+
}
|
|
80
|
+
return [current, hold];
|
|
81
|
+
}
|
|
82
|
+
/** Brings an entry into view inside the box that scrolls the contents, never the page. */
|
|
83
|
+
function keepInView(link) {
|
|
84
|
+
let box = link.parentElement;
|
|
85
|
+
while (box && box !== document.body) {
|
|
86
|
+
const { overflowY } = getComputedStyle(box);
|
|
87
|
+
if (overflowY === "auto" || overflowY === "scroll") break;
|
|
88
|
+
box = box.parentElement;
|
|
89
|
+
}
|
|
90
|
+
if (!box || box === document.body) return;
|
|
91
|
+
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;
|
|
94
|
+
}
|
|
95
|
+
const indent = {
|
|
96
|
+
2: "",
|
|
97
|
+
3: "pl-3",
|
|
98
|
+
4: "pl-6"
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* The sections of the page the reader is on, beside the text on a wide window. A hairline runs
|
|
102
|
+
* along the list, and a 2px piece of it in the text colour stands by the section being read: it
|
|
103
|
+
* glides from one entry to the next as the page scrolls (`glide`). A press on an entry goes there.
|
|
104
|
+
*
|
|
105
|
+
* Give it the page's second- and third-level headings, worded as they stand. On a narrow window
|
|
106
|
+
* set it `collapsible` above the text.
|
|
107
|
+
*/
|
|
108
|
+
function TableOfContents({ items, title = "Auf dieser Seite", collapsible = false, current: controlled, className, ...props }) {
|
|
109
|
+
const titleId = useId();
|
|
110
|
+
const ids = useStableIds(items);
|
|
111
|
+
const [read, hold] = useCurrentSection(controlled === void 0 && !collapsible ? ids : NO_IDS);
|
|
112
|
+
const current = controlled !== void 0 ? controlled : read;
|
|
113
|
+
const list = useRef(null);
|
|
114
|
+
const [mark, setMark] = useState(null);
|
|
115
|
+
useLayoutEffect(() => {
|
|
116
|
+
const box = list.current;
|
|
117
|
+
if (collapsible || !box) return;
|
|
118
|
+
const link = current ? box.querySelector(`a[href="#${CSS.escape(current)}"]`) : null;
|
|
119
|
+
if (!link) {
|
|
120
|
+
setMark(null);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const place = () => setMark({
|
|
124
|
+
top: link.offsetTop,
|
|
125
|
+
height: link.offsetHeight
|
|
126
|
+
});
|
|
127
|
+
place();
|
|
128
|
+
keepInView(link);
|
|
129
|
+
const resized = new ResizeObserver(place);
|
|
130
|
+
resized.observe(box);
|
|
131
|
+
return () => resized.disconnect();
|
|
132
|
+
}, [current, collapsible]);
|
|
133
|
+
const entries = /* @__PURE__ */ jsxs("ol", {
|
|
134
|
+
ref: list,
|
|
135
|
+
"data-slot": "toc-list",
|
|
136
|
+
className: cn("relative flex flex-col", !collapsible && "border-l border-hairline"),
|
|
137
|
+
children: [items.map((item) => /* @__PURE__ */ jsx("li", {
|
|
138
|
+
className: indent[item.depth ?? 2],
|
|
139
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
140
|
+
href: `#${item.id}`,
|
|
141
|
+
"data-slot": "toc-link",
|
|
142
|
+
"aria-current": !collapsible && current === item.id ? "location" : void 0,
|
|
143
|
+
onClick: () => hold(item.id),
|
|
144
|
+
className: cn("block rounded-xs py-1 text-sm text-pretty text-fg-muted transition-colors duration-150 ease-out hover:text-fg aria-[current=location]:text-fg", !collapsible && "pl-3.5", "focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-accent"),
|
|
145
|
+
children: item.label
|
|
146
|
+
})
|
|
147
|
+
}, item.id)), !collapsible ? /* @__PURE__ */ jsx("span", {
|
|
148
|
+
"aria-hidden": true,
|
|
149
|
+
"data-slot": "toc-mark",
|
|
150
|
+
"data-shown": mark ? "" : void 0,
|
|
151
|
+
style: {
|
|
152
|
+
"--toc-top": `${mark?.top ?? 0}px`,
|
|
153
|
+
"--toc-height": `${mark?.height ?? 0}px`
|
|
154
|
+
},
|
|
155
|
+
className: "pointer-events-none absolute top-0 -left-px h-(--toc-height) w-0.5 translate-y-(--toc-top) bg-rule opacity-0 transition-[translate,height,opacity] spring-glide data-shown:opacity-100 motion-reduce:transition-[opacity] forced-colors:bg-[CanvasText]"
|
|
156
|
+
}) : null]
|
|
157
|
+
});
|
|
158
|
+
if (collapsible) return /* @__PURE__ */ jsx("nav", {
|
|
159
|
+
"data-slot": "toc",
|
|
160
|
+
"data-collapsible": "",
|
|
161
|
+
"aria-label": title,
|
|
162
|
+
className,
|
|
163
|
+
...props,
|
|
164
|
+
children: /* @__PURE__ */ jsxs(Collapsible, { children: [/* @__PURE__ */ jsx(CollapsibleTrigger, { children: title }), /* @__PURE__ */ jsx(CollapsiblePanel, { children: /* @__PURE__ */ jsx("div", {
|
|
165
|
+
className: "pt-1 pb-2 pl-5",
|
|
166
|
+
children: entries
|
|
167
|
+
}) })] })
|
|
168
|
+
});
|
|
169
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
170
|
+
"data-slot": "toc",
|
|
171
|
+
"aria-labelledby": titleId,
|
|
172
|
+
className,
|
|
173
|
+
...props,
|
|
174
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
175
|
+
id: titleId,
|
|
176
|
+
className: "pb-3 text-sm font-semibold text-fg",
|
|
177
|
+
children: title
|
|
178
|
+
}), entries]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const NO_IDS = [];
|
|
182
|
+
/** The ids as one array that only changes when they do, so the reader is not set up anew. */
|
|
183
|
+
function useStableIds(items) {
|
|
184
|
+
const key = items.map((item) => item.id).join("\n");
|
|
185
|
+
return useMemo(() => key ? key.split("\n") : NO_IDS, [key]);
|
|
186
|
+
}
|
|
187
|
+
export { TableOfContents };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
|
|
3
|
+
export type TabsProps = Tabs$1.Root.Props;
|
|
4
|
+
/** Sections of one page. For views of the same data, use a `SegmentedControl` instead. */
|
|
5
|
+
export declare function Tabs({ className, ...props }: TabsProps): import("react").JSX.Element;
|
|
6
|
+
/**
|
|
7
|
+
* A row of labels, each with a mark. One soft highlight glides to the current tab (`glide`) and
|
|
8
|
+
* its mark closes from ring to disc. Base UI measures the active tab; we only move the highlight.
|
|
9
|
+
*
|
|
10
|
+
* A row wider than its place stays one row: it scrolls sideways inside itself, its edges fade
|
|
11
|
+
* where more tabs wait, and the current tab is brought into view when it changes (and when the
|
|
12
|
+
* row first shows), sideways only, so the page never moves.
|
|
13
|
+
*/
|
|
14
|
+
export declare function TabsList({ className, children, ref, ...props }: Tabs$1.List.Props): import("react").JSX.Element;
|
|
15
|
+
export declare function Tab({ className, children, ...props }: Tabs$1.Tab.Props): import("react").JSX.Element;
|
|
16
|
+
export type TabsPanelsProps = ComponentProps<"div">;
|
|
17
|
+
/**
|
|
18
|
+
* The panels of one `Tabs`, stacked in one place: every panel stays rendered, the ones not shown
|
|
19
|
+
* are invisible and inert, and the place is as tall as the tallest of them. Switching tabs then
|
|
20
|
+
* never moves what stands below. For panels of different heights on a page that is read
|
|
21
|
+
* downwards, such as the cases of a graphic.
|
|
22
|
+
*
|
|
23
|
+
* What moves by itself inside a panel (a demo on a timer) should wait while its panel is not
|
|
24
|
+
* shown: Base UI marks such a panel `data-hidden`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function TabsPanels({ className, ...props }: TabsPanelsProps): import("react").JSX.Element;
|
|
27
|
+
/** Panels do not slide: the highlight already showed where you went. */
|
|
28
|
+
export declare function TabsPanel({ className, keepMounted, render, ...props }: Tabs$1.Panel.Props): import("react").JSX.Element;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useReducedMotion } from "../../internal/reduced-motion.js";
|
|
3
|
+
import { useScrollEdges } from "../../internal/scroll-edges.js";
|
|
4
|
+
import { cn, mergeClassName } from "../../lib/cn.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { createContext, useContext, useEffect, useRef } from "react";
|
|
7
|
+
import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
|
|
8
|
+
// src/components/tabs/tabs.tsx
|
|
9
|
+
/** Sections of one page. For views of the same data, use a `SegmentedControl` instead. */
|
|
10
|
+
function Tabs({ className, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Tabs$1.Root, {
|
|
12
|
+
"data-slot": "tabs",
|
|
13
|
+
className: mergeClassName("flex flex-col gap-4", className),
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** How far a tab keeps off the edge it is scrolled to: past the fade (tabs.css), in px. */
|
|
18
|
+
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
|
+
/**
|
|
26
|
+
* A row of labels, each with a mark. One soft highlight glides to the current tab (`glide`) and
|
|
27
|
+
* its mark closes from ring to disc. Base UI measures the active tab; we only move the highlight.
|
|
28
|
+
*
|
|
29
|
+
* A row wider than its place stays one row: it scrolls sideways inside itself, its edges fade
|
|
30
|
+
* where more tabs wait, and the current tab is brought into view when it changes (and when the
|
|
31
|
+
* row first shows), sideways only, so the page never moves.
|
|
32
|
+
*/
|
|
33
|
+
function TabsList({ className, children, ref, ...props }) {
|
|
34
|
+
const list = useRef(null);
|
|
35
|
+
const reduced = useReducedMotion();
|
|
36
|
+
useScrollEdges(list);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const row = list.current;
|
|
39
|
+
if (!row) return;
|
|
40
|
+
const reveal = (behavior) => {
|
|
41
|
+
const tab = row.querySelector("[data-slot=\"tab\"][data-active]");
|
|
42
|
+
if (!tab || row.scrollWidth <= row.clientWidth) return;
|
|
43
|
+
const start = tab.offsetLeft - REVEAL_MARGIN;
|
|
44
|
+
const end = tab.offsetLeft + tab.offsetWidth + REVEAL_MARGIN - row.clientWidth;
|
|
45
|
+
if (row.scrollLeft > start) row.scrollTo({
|
|
46
|
+
left: Math.max(0, start),
|
|
47
|
+
behavior
|
|
48
|
+
});
|
|
49
|
+
else if (row.scrollLeft < end) row.scrollTo({
|
|
50
|
+
left: end,
|
|
51
|
+
behavior
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
reveal("instant");
|
|
55
|
+
const observer = new MutationObserver(() => reveal(reduced ? "instant" : "smooth"));
|
|
56
|
+
observer.observe(row, {
|
|
57
|
+
attributeFilter: ["data-active"],
|
|
58
|
+
subtree: true
|
|
59
|
+
});
|
|
60
|
+
return () => observer.disconnect();
|
|
61
|
+
}, [reduced]);
|
|
62
|
+
return /* @__PURE__ */ jsxs(Tabs$1.List, {
|
|
63
|
+
ref: mergeRefs(list, ref),
|
|
64
|
+
"data-slot": "tabs-list",
|
|
65
|
+
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
|
+
...props,
|
|
67
|
+
children: [children, /* @__PURE__ */ jsx(Tabs$1.Indicator, {
|
|
68
|
+
"data-slot": "tabs-indicator",
|
|
69
|
+
className: "absolute top-(--active-tab-top) left-0 -z-10 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) rounded-md bg-hover transition-[translate,width] spring-glide forced-colors:outline forced-colors:-outline-offset-1"
|
|
70
|
+
})]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function Tab({ className, children, ...props }) {
|
|
74
|
+
return /* @__PURE__ */ jsxs(Tabs$1.Tab, {
|
|
75
|
+
"data-slot": "tab",
|
|
76
|
+
className: mergeClassName([
|
|
77
|
+
"group touch-target relative inline-flex h-(--control-md) items-center gap-2 rounded-md pr-3.5 pl-3 text-control font-medium whitespace-nowrap text-fg-muted select-none",
|
|
78
|
+
"transition-colors duration-150 ease-out hover:text-fg data-active:text-fg",
|
|
79
|
+
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent",
|
|
80
|
+
"data-disabled:pointer-events-none data-disabled:text-on-disabled"
|
|
81
|
+
], className),
|
|
82
|
+
...props,
|
|
83
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
84
|
+
"data-slot": "tab-mark",
|
|
85
|
+
"aria-hidden": true,
|
|
86
|
+
className: "mark group-data-active:mark-on"
|
|
87
|
+
}), children]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const StackContext = createContext(false);
|
|
91
|
+
/**
|
|
92
|
+
* The panels of one `Tabs`, stacked in one place: every panel stays rendered, the ones not shown
|
|
93
|
+
* are invisible and inert, and the place is as tall as the tallest of them. Switching tabs then
|
|
94
|
+
* never moves what stands below. For panels of different heights on a page that is read
|
|
95
|
+
* downwards, such as the cases of a graphic.
|
|
96
|
+
*
|
|
97
|
+
* What moves by itself inside a panel (a demo on a timer) should wait while its panel is not
|
|
98
|
+
* shown: Base UI marks such a panel `data-hidden`.
|
|
99
|
+
*/
|
|
100
|
+
function TabsPanels({ className, ...props }) {
|
|
101
|
+
return /* @__PURE__ */ jsx(StackContext, {
|
|
102
|
+
value: true,
|
|
103
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
104
|
+
"data-slot": "tabs-panels",
|
|
105
|
+
className: cn("grid *:col-start-1 *:row-start-1", className),
|
|
106
|
+
...props
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** Panels do not slide: the highlight already showed where you went. */
|
|
111
|
+
function TabsPanel({ className, keepMounted, render, ...props }) {
|
|
112
|
+
const stacked = useContext(StackContext);
|
|
113
|
+
return /* @__PURE__ */ jsx(Tabs$1.Panel, {
|
|
114
|
+
"data-slot": "tabs-panel",
|
|
115
|
+
keepMounted: stacked || keepMounted,
|
|
116
|
+
render: stacked ? (panel) => /* @__PURE__ */ jsx("div", {
|
|
117
|
+
...panel,
|
|
118
|
+
hidden: void 0
|
|
119
|
+
}) : render,
|
|
120
|
+
className: mergeClassName(["focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-accent", stacked && "data-hidden:invisible"], className),
|
|
121
|
+
...props
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
export { Tab, Tabs, TabsList, TabsPanel, TabsPanels };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
declare const textVariants: (props?: ({
|
|
4
|
+
size?: "sm" | "lg" | "base" | "xs" | null | undefined;
|
|
5
|
+
tone?: "success" | "warning" | "danger" | "body" | "strong" | "muted" | null | undefined;
|
|
6
|
+
weight?: "regular" | "medium" | "semibold" | null | undefined;
|
|
7
|
+
mono?: boolean | null | undefined;
|
|
8
|
+
numeric?: boolean | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
export type TextProps = ComponentProps<"p"> & VariantProps<typeof textVariants> & {
|
|
11
|
+
/** The element to render. A paragraph unless the text sits inside another one. */
|
|
12
|
+
as?: "p" | "span" | "div";
|
|
13
|
+
};
|
|
14
|
+
/** Running text on the type scale. For titles use `Heading`. */
|
|
15
|
+
export declare function Text({ as: Tag, size, tone, weight, mono, numeric, className, ...props }: TextProps): import("react").JSX.Element;
|
|
16
|
+
export {};
|