@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,77 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
4
|
+
export type SiteHeaderProps = ComponentProps<"header"> & {
|
|
5
|
+
/** Stays at the top of the window while the page scrolls under it. */
|
|
6
|
+
sticky?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The bar at the top of a website: what this is, where one can go, and the next step. It floats:
|
|
10
|
+
* a frosted face with a light edge, 8px off the window's top and sides, over the page that
|
|
11
|
+
* scrolls under it.
|
|
12
|
+
*
|
|
13
|
+
* Safari 26 colours its status bar from what it finds about 4px below the window's top edge: if
|
|
14
|
+
* that is inside a fixed or sticky element, it paints that element's colour across the bar, or
|
|
15
|
+
* samples its pixels once when it has no plain colour. So nothing of the bar may reach the top
|
|
16
|
+
* 8px, not even a decoration inside it: a graded blur that reached up to the edge made Safari
|
|
17
|
+
* sample the bar and paint the status bar white (Justin's iPhone, 2026-11-16). With nothing
|
|
18
|
+
* there, the page itself shows behind the status bar.
|
|
19
|
+
*
|
|
20
|
+
* Put a `SiteHeaderBrand` first, then a `NavigationMenu` (with `className="max-lg:hidden"`), then
|
|
21
|
+
* `SiteHeaderActions`. On a phone the `NavigationMenu` gives way to a `SiteHeaderMenu`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function SiteHeader({ sticky, className, children, ...props }: SiteHeaderProps): import("react").JSX.Element;
|
|
24
|
+
export type SiteHeaderBrandProps = useRender.ComponentProps<"a">;
|
|
25
|
+
/**
|
|
26
|
+
* Whose site this is, as the way home: a product's mark with its name in type, or the drawn
|
|
27
|
+
* `Wordmark` (then give the link an `aria-label` that says where it leads). For a router's link,
|
|
28
|
+
* pass it as `render`. Pass the same element to the `SiteHeaderMenu` as its `brand`, and it
|
|
29
|
+
* stands in the open menu where it stands in the bar.
|
|
30
|
+
*/
|
|
31
|
+
export declare function SiteHeaderBrand({ render, className, ...props }: SiteHeaderBrandProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
32
|
+
/** The next step, at the end of the bar: one button, and at most a quiet one beside it. */
|
|
33
|
+
export declare function SiteHeaderActions({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
34
|
+
export type SiteHeaderMenuProps = Pick<Dialog.Root.Props, "open" | "defaultOpen" | "onOpenChange" | "modal"> & {
|
|
35
|
+
/** The name of the button that opens it ("Menü öffnen"). */
|
|
36
|
+
label: string;
|
|
37
|
+
/** What the menu is about ("Alle Seiten."). It names the menu for assistive tech; not shown. */
|
|
38
|
+
title: string;
|
|
39
|
+
/** The name of the button that closes it. */
|
|
40
|
+
closeLabel?: string;
|
|
41
|
+
/** The bar's `SiteHeaderBrand`, to stand in the menu's top row where it stands in the bar. */
|
|
42
|
+
brand?: ReactNode;
|
|
43
|
+
/** The bar's next step, at the foot of the menu: a button at full width, a quiet link under it. */
|
|
44
|
+
actions?: ReactNode;
|
|
45
|
+
className?: string;
|
|
46
|
+
/** `SiteHeaderMenuGroup`s, or `SiteHeaderMenuLink`s for a short list. */
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The places of the `NavigationMenu` on a phone: one button at the end of the bar that opens
|
|
51
|
+
* them over the whole window, on the page's own ground. Its top row repeats the bar, with the
|
|
52
|
+
* close button where the menu button was; the places follow in groups, and the next step stands
|
|
53
|
+
* at the foot. It shows below `lg`, where the `NavigationMenu` is hidden.
|
|
54
|
+
*
|
|
55
|
+
* Safari 26 tints its status bar and its toolbar from what covers them: the menu covers both
|
|
56
|
+
* (`h-lvh`, the window with the browser's bars collapsed), square to the window, so both take
|
|
57
|
+
* the ground's colour and no page shows above or below it. Its content fills the visible window
|
|
58
|
+
* (`lvh` less the toolbar's `lvh − dvh`), so the foot stands above the toolbar.
|
|
59
|
+
*/
|
|
60
|
+
export declare function SiteHeaderMenu({ label, title, closeLabel, brand, actions, className, children, ...dialog }: SiteHeaderMenuProps): import("react").JSX.Element;
|
|
61
|
+
export type SiteHeaderMenuGroupProps = Omit<ComponentProps<"li">, "title"> & {
|
|
62
|
+
/** The entry of the `NavigationMenu` these places stand behind ("Dokumentation"). */
|
|
63
|
+
title: ReactNode;
|
|
64
|
+
/**
|
|
65
|
+
* One column of large places (the default), for the few a reader came for; or two columns of
|
|
66
|
+
* small ones, for a longer list that should not push the rest out of view.
|
|
67
|
+
*/
|
|
68
|
+
columns?: 1 | 2;
|
|
69
|
+
};
|
|
70
|
+
/** The places behind one entry of the `NavigationMenu`, under its name. */
|
|
71
|
+
export declare function SiteHeaderMenuGroup({ title, columns, className, children, ...props }: SiteHeaderMenuGroupProps): import("react").JSX.Element;
|
|
72
|
+
export type SiteHeaderMenuLinkProps = useRender.ComponentProps<"a"> & {
|
|
73
|
+
/** The page this link leads to is the one the reader is on. */
|
|
74
|
+
current?: boolean;
|
|
75
|
+
};
|
|
76
|
+
/** One place in the `SiteHeaderMenu`. Following it closes the menu, as every link in it does. */
|
|
77
|
+
export declare function SiteHeaderMenuLink({ current, render, className, children, ...props }: SiteHeaderMenuLinkProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { useGround } from "../ground/ground.js";
|
|
4
|
+
import { Icon } from "../icon/icon.js";
|
|
5
|
+
import { useScrollEdges } from "../../internal/scroll-edges.js";
|
|
6
|
+
import { cn } from "../../lib/cn.js";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Cancel01Icon, Menu01Icon } from "@hugeicons/core-free-icons";
|
|
9
|
+
import { createContext, useCallback, useContext, useId, useRef, useState } from "react";
|
|
10
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
11
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
12
|
+
// src/components/site-header/site-header.tsx
|
|
13
|
+
/**
|
|
14
|
+
* Where the bar stands and how wide it is, shared by the bar and the top row of the open menu so
|
|
15
|
+
* the way home and the menu button do not move when the menu opens. The bar is inset 8px from
|
|
16
|
+
* the window (16px from `sm`) and padded 12px (16px), so what stands in it lines up with the
|
|
17
|
+
* content of a `Container`: 8 + 12 is its 20px gutter on a phone, 16 + 16 its 32px above. At its
|
|
18
|
+
* widest it is the page's 72rem plus its own padding.
|
|
19
|
+
*/
|
|
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";
|
|
21
|
+
/**
|
|
22
|
+
* The bar at the top of a website: what this is, where one can go, and the next step. It floats:
|
|
23
|
+
* a frosted face with a light edge, 8px off the window's top and sides, over the page that
|
|
24
|
+
* scrolls under it.
|
|
25
|
+
*
|
|
26
|
+
* Safari 26 colours its status bar from what it finds about 4px below the window's top edge: if
|
|
27
|
+
* that is inside a fixed or sticky element, it paints that element's colour across the bar, or
|
|
28
|
+
* samples its pixels once when it has no plain colour. So nothing of the bar may reach the top
|
|
29
|
+
* 8px, not even a decoration inside it: a graded blur that reached up to the edge made Safari
|
|
30
|
+
* sample the bar and paint the status bar white (Justin's iPhone, 2026-11-16). With nothing
|
|
31
|
+
* there, the page itself shows behind the status bar.
|
|
32
|
+
*
|
|
33
|
+
* Put a `SiteHeaderBrand` first, then a `NavigationMenu` (with `className="max-lg:hidden"`), then
|
|
34
|
+
* `SiteHeaderActions`. On a phone the `NavigationMenu` gives way to a `SiteHeaderMenu`.
|
|
35
|
+
*/
|
|
36
|
+
function SiteHeader({ sticky = true, className, children, ...props }) {
|
|
37
|
+
return /* @__PURE__ */ jsx("header", {
|
|
38
|
+
"data-slot": "site-header",
|
|
39
|
+
className: cn("isolate z-40 mt-2 w-full", sticky ? "sticky top-2" : "relative", className),
|
|
40
|
+
...props,
|
|
41
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
42
|
+
"data-slot": "site-header-bar",
|
|
43
|
+
className: cn(barFrame, "rounded-xl bg-ground/85 depth-bar backdrop-blur-xl backdrop-saturate-150"),
|
|
44
|
+
children
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent";
|
|
49
|
+
/**
|
|
50
|
+
* Whose site this is, as the way home: a product's mark with its name in type, or the drawn
|
|
51
|
+
* `Wordmark` (then give the link an `aria-label` that says where it leads). For a router's link,
|
|
52
|
+
* pass it as `render`. Pass the same element to the `SiteHeaderMenu` as its `brand`, and it
|
|
53
|
+
* stands in the open menu where it stands in the bar.
|
|
54
|
+
*/
|
|
55
|
+
function SiteHeaderBrand({ render, className, ...props }) {
|
|
56
|
+
return useRender({
|
|
57
|
+
defaultTagName: "a",
|
|
58
|
+
render,
|
|
59
|
+
props: {
|
|
60
|
+
...props,
|
|
61
|
+
"data-slot": "site-header-brand",
|
|
62
|
+
className: cn("inline-flex shrink-0 items-center gap-2.5 rounded-xs text-lg font-semibold whitespace-nowrap text-fg", focusRing, className)
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** The next step, at the end of the bar: one button, and at most a quiet one beside it. */
|
|
67
|
+
function SiteHeaderActions({ className, ...props }) {
|
|
68
|
+
return /* @__PURE__ */ jsx("div", {
|
|
69
|
+
"data-slot": "site-header-actions",
|
|
70
|
+
className: cn("ml-auto flex items-center gap-2", className),
|
|
71
|
+
...props
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The places of the `NavigationMenu` on a phone: one button at the end of the bar that opens
|
|
76
|
+
* them over the whole window, on the page's own ground. Its top row repeats the bar, with the
|
|
77
|
+
* close button where the menu button was; the places follow in groups, and the next step stands
|
|
78
|
+
* at the foot. It shows below `lg`, where the `NavigationMenu` is hidden.
|
|
79
|
+
*
|
|
80
|
+
* Safari 26 tints its status bar and its toolbar from what covers them: the menu covers both
|
|
81
|
+
* (`h-lvh`, the window with the browser's bars collapsed), square to the window, so both take
|
|
82
|
+
* the ground's colour and no page shows above or below it. Its content fills the visible window
|
|
83
|
+
* (`lvh` less the toolbar's `lvh − dvh`), so the foot stands above the toolbar.
|
|
84
|
+
*/
|
|
85
|
+
function SiteHeaderMenu({ label, title, closeLabel = "Menü schließen", brand, actions, className, children, ...dialog }) {
|
|
86
|
+
const ground = useGround();
|
|
87
|
+
const menu = useRef(null);
|
|
88
|
+
const sheet = useRef(null);
|
|
89
|
+
const [mounted, setMounted] = useState(false);
|
|
90
|
+
useScrollEdges(sheet, "y", mounted);
|
|
91
|
+
const sheetRef = useCallback((node) => {
|
|
92
|
+
sheet.current = node;
|
|
93
|
+
setMounted(node !== null);
|
|
94
|
+
}, []);
|
|
95
|
+
const close = () => menu.current?.close();
|
|
96
|
+
return /* @__PURE__ */ jsxs(Dialog.Root, {
|
|
97
|
+
actionsRef: menu,
|
|
98
|
+
...dialog,
|
|
99
|
+
children: [/* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
100
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
101
|
+
iconOnly: true,
|
|
102
|
+
variant: "quiet",
|
|
103
|
+
"aria-label": label,
|
|
104
|
+
"data-slot": "site-header-menu-trigger",
|
|
105
|
+
className: cn("lg:hidden", className)
|
|
106
|
+
}),
|
|
107
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
108
|
+
icon: Menu01Icon,
|
|
109
|
+
size: 18
|
|
110
|
+
})
|
|
111
|
+
}), /* @__PURE__ */ jsx(Dialog.Portal, { children: /* @__PURE__ */ jsx(Dialog.Popup, {
|
|
112
|
+
ref: sheetRef,
|
|
113
|
+
initialFocus: sheet,
|
|
114
|
+
"data-slot": "site-header-menu-sheet",
|
|
115
|
+
"data-theme": ground,
|
|
116
|
+
onClick: (event) => {
|
|
117
|
+
if (event.target instanceof Element && event.target.closest("a[href]")) close();
|
|
118
|
+
},
|
|
119
|
+
className: cn("group/menu fixed inset-x-0 top-0 z-50 h-lvh overflow-y-auto overscroll-contain bg-ground/99 text-base text-fg-body outline-hidden", "transition-opacity spring-sheet data-starting-style:opacity-0", "data-ending-style:opacity-0 data-ending-style:spring-leave"),
|
|
120
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
121
|
+
className: "flex min-h-lvh flex-col pb-[calc(100lvh-100dvh)]",
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsx("div", {
|
|
124
|
+
className: "sticky top-0 z-10 bg-ground pt-2",
|
|
125
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
126
|
+
className: barFrame,
|
|
127
|
+
children: [brand, /* @__PURE__ */ jsx(Dialog.Close, {
|
|
128
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
129
|
+
iconOnly: true,
|
|
130
|
+
variant: "quiet",
|
|
131
|
+
"aria-label": closeLabel,
|
|
132
|
+
"data-slot": "site-header-menu-close",
|
|
133
|
+
className: "ml-auto"
|
|
134
|
+
}),
|
|
135
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
136
|
+
icon: Cancel01Icon,
|
|
137
|
+
size: 18
|
|
138
|
+
})
|
|
139
|
+
})]
|
|
140
|
+
})
|
|
141
|
+
}),
|
|
142
|
+
/* @__PURE__ */ jsx(Dialog.Title, {
|
|
143
|
+
className: "sr-only",
|
|
144
|
+
children: title
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ jsx("nav", {
|
|
147
|
+
"data-slot": "site-header-menu",
|
|
148
|
+
"aria-label": title,
|
|
149
|
+
className: cn("mx-auto w-full max-w-[calc(72rem+4rem)] flex-1 px-5 pt-8 sm:px-8", "transition-[opacity,translate] spring-sheet", "group-data-starting-style/menu:opacity-0 motion-safe:group-data-starting-style/menu:-translate-y-2"),
|
|
150
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
151
|
+
className: "flex flex-col divide-y divide-hairline",
|
|
152
|
+
children
|
|
153
|
+
})
|
|
154
|
+
}),
|
|
155
|
+
actions && /* @__PURE__ */ jsx("div", {
|
|
156
|
+
"data-slot": "site-header-menu-actions",
|
|
157
|
+
className: cn("mx-auto flex w-full max-w-[calc(72rem+4rem)] flex-col gap-2 px-5 pt-10 pb-6 sm:px-8", "*:w-full *:justify-center", "transition-[opacity,translate] delay-[60ms] spring-sheet", "group-data-starting-style/menu:opacity-0 motion-safe:group-data-starting-style/menu:translate-y-2"),
|
|
158
|
+
children: actions
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ jsx("div", {
|
|
161
|
+
"aria-hidden": true,
|
|
162
|
+
"data-slot": "site-header-menu-fade",
|
|
163
|
+
className: "pointer-events-none sticky bottom-0 -mt-16 h-16 shrink-0 bg-linear-to-b from-transparent to-ground opacity-0 transition-opacity duration-200 ease-out group-data-[overflow~=end]/menu:opacity-100"
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
})
|
|
167
|
+
}) })]
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const ColumnsContext = createContext(1);
|
|
171
|
+
/** The places behind one entry of the `NavigationMenu`, under its name. */
|
|
172
|
+
function SiteHeaderMenuGroup({ title, columns = 1, className, children, ...props }) {
|
|
173
|
+
const id = useId();
|
|
174
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
175
|
+
"data-slot": "site-header-menu-group",
|
|
176
|
+
className: cn("flex flex-col gap-2 py-6 first:pt-0 last:pb-0", className),
|
|
177
|
+
...props,
|
|
178
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
179
|
+
id,
|
|
180
|
+
className: "text-sm text-fg-muted",
|
|
181
|
+
children: title
|
|
182
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
183
|
+
"aria-labelledby": id,
|
|
184
|
+
className: cn("flex flex-col", columns === 2 && "grid grid-cols-2 gap-x-6"),
|
|
185
|
+
children: /* @__PURE__ */ jsx(ColumnsContext, {
|
|
186
|
+
value: columns,
|
|
187
|
+
children
|
|
188
|
+
})
|
|
189
|
+
})]
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/** One place in the `SiteHeaderMenu`. Following it closes the menu, as every link in it does. */
|
|
193
|
+
function SiteHeaderMenuLink({ current = false, render, className, children, ...props }) {
|
|
194
|
+
const columns = useContext(ColumnsContext);
|
|
195
|
+
const link = useRender({
|
|
196
|
+
defaultTagName: "a",
|
|
197
|
+
render,
|
|
198
|
+
props: {
|
|
199
|
+
...props,
|
|
200
|
+
"data-slot": "site-header-menu-link",
|
|
201
|
+
"aria-current": current ? "page" : void 0,
|
|
202
|
+
className: cn("flex items-center gap-2.5 rounded-xs font-medium", columns === 2 ? "min-h-10 text-base text-fg-body hover:text-fg aria-[current=page]:text-fg" : "min-h-11 text-xl text-fg", focusRing, className),
|
|
203
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [children, current && /* @__PURE__ */ jsx("span", {
|
|
204
|
+
"aria-hidden": true,
|
|
205
|
+
className: "size-1.5 shrink-0 rounded-full bg-accent"
|
|
206
|
+
})] })
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return /* @__PURE__ */ jsx("li", {
|
|
210
|
+
"data-slot": "site-header-menu-item",
|
|
211
|
+
children: link
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
export { SiteHeader, SiteHeaderActions, SiteHeaderBrand, SiteHeaderMenu, SiteHeaderMenuGroup, SiteHeaderMenuLink };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Slider as Slider$1 } from "@base-ui/react/slider";
|
|
2
|
+
export type SliderProps<Value extends number | readonly number[] = number | readonly number[]> = Omit<Slider$1.Root.Props<Value>, "orientation">;
|
|
3
|
+
/**
|
|
4
|
+
* A value picked by feel from a range, where the exact number matters less than the place: a
|
|
5
|
+
* discount, an opacity, a price span. Where the number matters, use a `NumberField`.
|
|
6
|
+
*
|
|
7
|
+
* It is a long switch: a raised thumb runs in a sunken trough that fills with Indigo up to it.
|
|
8
|
+
* An array as value (`defaultValue={[20, 60]}`) makes a range with two thumbs. Horizontal only.
|
|
9
|
+
*
|
|
10
|
+
* Name it with a `SliderLabel`, or with an `aria-label` on the `SliderThumb` when there is no
|
|
11
|
+
* visible label; in a range, name both thumbs ("Mindestpreis", "Höchstpreis").
|
|
12
|
+
*
|
|
13
|
+
* It follows one finger at a time: while a thumb is dragged, a second finger is ignored.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Slider<Value extends number | readonly number[]>({ className, thumbAlignment, ...props }: SliderProps<Value>): import("react").JSX.Element;
|
|
16
|
+
/** Says what is being set. */
|
|
17
|
+
export declare function SliderLabel({ className, ...props }: Slider$1.Label.Props): import("react").JSX.Element;
|
|
18
|
+
/** The value as text, formatted by the slider's `format` and `locale`; a range shows both ends. */
|
|
19
|
+
export declare function SliderValue({ className, ...props }: Slider$1.Value.Props): import("react").JSX.Element;
|
|
20
|
+
export type SliderControlProps = Slider$1.Control.Props;
|
|
21
|
+
/**
|
|
22
|
+
* The part that is pressed and dragged: as tall as a control, with the trough in its middle.
|
|
23
|
+
* Without children it holds one thumb; pass `SliderThumb`s to name them or to make a range.
|
|
24
|
+
*/
|
|
25
|
+
export declare function SliderControl({ className, children, ref, ...props }: SliderControlProps): import("react").JSX.Element;
|
|
26
|
+
export type SliderThumbProps = Omit<Slider$1.Thumb.Props, "render" | "children">;
|
|
27
|
+
/**
|
|
28
|
+
* The thumb, raised like the switch's, and it behaves like it: held, it widens into a short pill
|
|
29
|
+
* and lifts; let go, it seats back. Under the pointer it chases on the short spring, which
|
|
30
|
+
* smooths the steps of a coarse slider; moved by the keyboard or from outside, it glides. In a
|
|
31
|
+
* range, give each its `index`.
|
|
32
|
+
*
|
|
33
|
+
* It has inertia: pulled fast, its trailing side lags and it stretches along the way; when it
|
|
34
|
+
* stops, it swings back past its shape for a moment and settles.
|
|
35
|
+
*
|
|
36
|
+
* Like the switch's thumb it takes the colour that reads on what it stands on: the fill's
|
|
37
|
+
* counterpart while it is held by the fill, the plain thumb colour in the empty trough.
|
|
38
|
+
*
|
|
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.
|
|
41
|
+
*/
|
|
42
|
+
export declare function SliderThumb({ className, index, ...props }: SliderThumbProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { gaugeLabel, gaugeRoot, gaugeValue, troughTrack } from "../../internal/trough.js";
|
|
3
|
+
import { cn, mergeClassName } from "../../lib/cn.js";
|
|
4
|
+
import { restingMotion, trackMotion } from "../../motion/inertia.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useEffect, useRef } from "react";
|
|
7
|
+
import { Slider as Slider$1 } from "@base-ui/react/slider";
|
|
8
|
+
// src/components/slider/slider.tsx
|
|
9
|
+
/** Custom properties as an inline style. */
|
|
10
|
+
const vars = (properties) => properties;
|
|
11
|
+
/** Where thumb `index` stands: 0 at the lowest value, 1 at the highest. */
|
|
12
|
+
function place(state, index) {
|
|
13
|
+
const span = state.max - state.min;
|
|
14
|
+
const value = state.values[index] ?? state.min;
|
|
15
|
+
return span > 0 ? Math.min(1, Math.max(0, (value - state.min) / span)) : 0;
|
|
16
|
+
}
|
|
17
|
+
/** The deformation of thumb `index`, as it is kept on the control (see `useThumbInertia`). */
|
|
18
|
+
const body = (index, size) => vars({
|
|
19
|
+
"--size": size,
|
|
20
|
+
"--s": `var(--thumb-${index}-s, 1)`,
|
|
21
|
+
"--d": `var(--thumb-${index}-d, 1)`
|
|
22
|
+
});
|
|
23
|
+
/** What travels (see `slider-travels`): gliding to a new value, chasing a dragged pointer. */
|
|
24
|
+
const travels = "slider-travels";
|
|
25
|
+
/**
|
|
26
|
+
* A value picked by feel from a range, where the exact number matters less than the place: a
|
|
27
|
+
* discount, an opacity, a price span. Where the number matters, use a `NumberField`.
|
|
28
|
+
*
|
|
29
|
+
* It is a long switch: a raised thumb runs in a sunken trough that fills with Indigo up to it.
|
|
30
|
+
* An array as value (`defaultValue={[20, 60]}`) makes a range with two thumbs. Horizontal only.
|
|
31
|
+
*
|
|
32
|
+
* Name it with a `SliderLabel`, or with an `aria-label` on the `SliderThumb` when there is no
|
|
33
|
+
* visible label; in a range, name both thumbs ("Mindestpreis", "Höchstpreis").
|
|
34
|
+
*
|
|
35
|
+
* It follows one finger at a time: while a thumb is dragged, a second finger is ignored.
|
|
36
|
+
*/
|
|
37
|
+
function Slider({ className, thumbAlignment = "edge", ...props }) {
|
|
38
|
+
return /* @__PURE__ */ jsx(Slider$1.Root, {
|
|
39
|
+
"data-slot": "slider",
|
|
40
|
+
thumbAlignment,
|
|
41
|
+
className: mergeClassName(["group/slider", gaugeRoot], className),
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** Says what is being set. */
|
|
46
|
+
function SliderLabel({ className, ...props }) {
|
|
47
|
+
return /* @__PURE__ */ jsx(Slider$1.Label, {
|
|
48
|
+
"data-slot": "slider-label",
|
|
49
|
+
className: mergeClassName([gaugeLabel, "group-data-disabled/slider:text-on-disabled"], className),
|
|
50
|
+
...props
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** The value as text, formatted by the slider's `format` and `locale`; a range shows both ends. */
|
|
54
|
+
function SliderValue({ className, ...props }) {
|
|
55
|
+
return /* @__PURE__ */ jsx(Slider$1.Value, {
|
|
56
|
+
"data-slot": "slider-value",
|
|
57
|
+
className: mergeClassName([gaugeValue, "group-data-disabled/slider:text-on-disabled"], className),
|
|
58
|
+
...props
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* One finger at a time. Base UI follows every pointer that moves while a thumb is dragged, so a
|
|
63
|
+
* second finger on the screen throws the thumb back and forth between the two. Here the pointer
|
|
64
|
+
* that began the drag owns it: until it lifts, the others do not reach the slider.
|
|
65
|
+
*
|
|
66
|
+
* The listeners sit on the window, in the capture phase, because that is the one place before
|
|
67
|
+
* Base UI's own (on the control and on the document).
|
|
68
|
+
*
|
|
69
|
+
* The price, for as long as a thumb is held: another finger's moves and its lifting reach
|
|
70
|
+
* nothing else on the page either, and two sliders pulled at the same moment still disturb each
|
|
71
|
+
* other (Base UI's listeners take any pointer). Both would need Base UI to tell pointers apart.
|
|
72
|
+
*/
|
|
73
|
+
function useSinglePointer(control) {
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const element = control.current;
|
|
76
|
+
if (!element) return;
|
|
77
|
+
let owner = null;
|
|
78
|
+
const inside = (target) => target instanceof Node && element.contains(target);
|
|
79
|
+
const elsewhere = (target) => target instanceof Element && target.closest("[data-slot=\"slider-control\"]") !== null && !element.contains(target);
|
|
80
|
+
const foreign = (event) => owner !== null && event.pointerId !== owner && element.hasAttribute("data-dragging");
|
|
81
|
+
const down = (event) => {
|
|
82
|
+
if (!inside(event.target)) return;
|
|
83
|
+
if (foreign(event)) event.stopPropagation();
|
|
84
|
+
else owner = event.pointerId;
|
|
85
|
+
};
|
|
86
|
+
const move = (event) => {
|
|
87
|
+
if (foreign(event) && !elsewhere(event.target)) event.stopPropagation();
|
|
88
|
+
};
|
|
89
|
+
const up = (event) => {
|
|
90
|
+
if (event.pointerId === owner) owner = null;
|
|
91
|
+
else if (foreign(event) && !elsewhere(event.target)) event.stopPropagation();
|
|
92
|
+
};
|
|
93
|
+
const touch = (event) => {
|
|
94
|
+
const here = [...event.touches].filter((finger) => inside(finger.target));
|
|
95
|
+
if (inside(event.target) && here.length > 1) event.stopPropagation();
|
|
96
|
+
};
|
|
97
|
+
const options = { capture: true };
|
|
98
|
+
window.addEventListener("pointerdown", down, options);
|
|
99
|
+
window.addEventListener("pointermove", move, options);
|
|
100
|
+
window.addEventListener("pointerup", up, options);
|
|
101
|
+
window.addEventListener("pointercancel", up, options);
|
|
102
|
+
window.addEventListener("touchstart", touch, options);
|
|
103
|
+
return () => {
|
|
104
|
+
window.removeEventListener("pointerdown", down, options);
|
|
105
|
+
window.removeEventListener("pointermove", move, options);
|
|
106
|
+
window.removeEventListener("pointerup", up, options);
|
|
107
|
+
window.removeEventListener("pointercancel", up, options);
|
|
108
|
+
window.removeEventListener("touchstart", touch, options);
|
|
109
|
+
};
|
|
110
|
+
}, [control]);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Gives the thumbs inertia. Each time a thumb has moved, how fast it travels decides how far it
|
|
114
|
+
* is stretched (`trackMotion`); that goes to the control as `--thumb-<index>-s` and
|
|
115
|
+
* `--thumb-<index>-d`, which the thumb's face and the cap of the fill both read
|
|
116
|
+
* (`slider-body`). A moment after the last move they are let go and rebound.
|
|
117
|
+
*
|
|
118
|
+
* It runs once per move, not once per frame, and reads no layout: the width of the control is
|
|
119
|
+
* kept by a `ResizeObserver`. The drawing between two moves is the compositor's.
|
|
120
|
+
*/
|
|
121
|
+
function useThumbInertia(anchor, places) {
|
|
122
|
+
const motions = useRef([]);
|
|
123
|
+
const metrics = useRef({
|
|
124
|
+
travel: 0,
|
|
125
|
+
thumb: 0,
|
|
126
|
+
rtl: false
|
|
127
|
+
});
|
|
128
|
+
const release = useRef(void 0);
|
|
129
|
+
const key = places.join(" ");
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
const control = anchor.current?.closest("[data-slot=\"slider-control\"]");
|
|
132
|
+
const thumb = control?.querySelector("[data-slot=\"slider-thumb\"]");
|
|
133
|
+
if (!control || !thumb) return;
|
|
134
|
+
const measure = () => {
|
|
135
|
+
metrics.current = {
|
|
136
|
+
thumb: thumb.offsetWidth,
|
|
137
|
+
travel: Math.max(0, control.clientWidth - thumb.offsetWidth),
|
|
138
|
+
rtl: getComputedStyle(control).direction === "rtl"
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
measure();
|
|
142
|
+
const observer = new ResizeObserver(measure);
|
|
143
|
+
observer.observe(control);
|
|
144
|
+
return () => {
|
|
145
|
+
observer.disconnect();
|
|
146
|
+
clearTimeout(release.current);
|
|
147
|
+
};
|
|
148
|
+
}, [anchor]);
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
const control = anchor.current?.closest("[data-slot=\"slider-control\"]");
|
|
151
|
+
if (!control) return;
|
|
152
|
+
const { travel, thumb, rtl } = metrics.current;
|
|
153
|
+
const now = performance.now();
|
|
154
|
+
const still = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
155
|
+
let moved = false;
|
|
156
|
+
key.split(" ").forEach((place, index) => {
|
|
157
|
+
const x = Number(place) * travel * (rtl ? -1 : 1);
|
|
158
|
+
const before = motions.current[index];
|
|
159
|
+
const next = before ? trackMotion(before, x, now, thumb) : restingMotion(x, now);
|
|
160
|
+
motions.current[index] = next;
|
|
161
|
+
if (!before || next.x === before.x || still) return;
|
|
162
|
+
control.style.setProperty(`--thumb-${index}-s`, next.stretch.toFixed(3));
|
|
163
|
+
control.style.setProperty(`--thumb-${index}-d`, String(next.direction));
|
|
164
|
+
moved = true;
|
|
165
|
+
});
|
|
166
|
+
if (!moved) return;
|
|
167
|
+
control.setAttribute("data-moving", "");
|
|
168
|
+
clearTimeout(release.current);
|
|
169
|
+
release.current = setTimeout(() => {
|
|
170
|
+
control.removeAttribute("data-moving");
|
|
171
|
+
key.split(" ").forEach((_, index) => control.style.removeProperty(`--thumb-${index}-s`));
|
|
172
|
+
}, 90);
|
|
173
|
+
}, [anchor, key]);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The fill and the caps that hold the thumbs. The fill is the bar; each thumb stands in a round
|
|
177
|
+
* cap of the fill's colour, as wide as the trough is tall, which keeps the gap to the thumb
|
|
178
|
+
* that the trough's wall keeps too. The cap deforms with its thumb.
|
|
179
|
+
*/
|
|
180
|
+
function SliderFill({ state }) {
|
|
181
|
+
const anchor = useRef(null);
|
|
182
|
+
const places = state.values.map((_, index) => place(state, index));
|
|
183
|
+
useThumbInertia(anchor, places);
|
|
184
|
+
const range = places.length > 1;
|
|
185
|
+
const last = places[places.length - 1] ?? 0;
|
|
186
|
+
const centre = (at) => `calc(var(--switch-h) / 2 + ${at} * var(--slider-travel))`;
|
|
187
|
+
const colour = state.disabled ? "bg-on-disabled" : "bg-accent forced-colors:bg-[Highlight]";
|
|
188
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
189
|
+
ref: anchor,
|
|
190
|
+
"data-slot": "slider-indicator",
|
|
191
|
+
"aria-hidden": true,
|
|
192
|
+
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) })
|
|
200
|
+
}), places.map((at, index) => /* @__PURE__ */ jsx("span", {
|
|
201
|
+
className: cn("slider-at size-(--switch-h)", travels),
|
|
202
|
+
style: vars({ "--p": at }),
|
|
203
|
+
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)")
|
|
207
|
+
})
|
|
208
|
+
}, index))]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The part that is pressed and dragged: as tall as a control, with the trough in its middle.
|
|
213
|
+
* Without children it holds one thumb; pass `SliderThumb`s to name them or to make a range.
|
|
214
|
+
*/
|
|
215
|
+
function SliderControl({ className, children, ref, ...props }) {
|
|
216
|
+
const control = useRef(null);
|
|
217
|
+
useSinglePointer(control);
|
|
218
|
+
return /* @__PURE__ */ jsx(Slider$1.Control, {
|
|
219
|
+
ref: (node) => {
|
|
220
|
+
control.current = node;
|
|
221
|
+
if (typeof ref === "function") return ref(node);
|
|
222
|
+
if (ref) ref.current = node;
|
|
223
|
+
},
|
|
224
|
+
"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),
|
|
226
|
+
...props,
|
|
227
|
+
children: /* @__PURE__ */ jsxs(Slider$1.Track, {
|
|
228
|
+
"data-slot": "slider-track",
|
|
229
|
+
className: "h-(--switch-h) w-full",
|
|
230
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
231
|
+
"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"),
|
|
233
|
+
children: /* @__PURE__ */ jsx(Slider$1.Indicator, { render: (_, state) => /* @__PURE__ */ jsx(SliderFill, { state }) })
|
|
234
|
+
}), children ?? /* @__PURE__ */ jsx(SliderThumb, {})]
|
|
235
|
+
})
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The thumb, raised like the switch's, and it behaves like it: held, it widens into a short pill
|
|
240
|
+
* and lifts; let go, it seats back. Under the pointer it chases on the short spring, which
|
|
241
|
+
* smooths the steps of a coarse slider; moved by the keyboard or from outside, it glides. In a
|
|
242
|
+
* range, give each its `index`.
|
|
243
|
+
*
|
|
244
|
+
* It has inertia: pulled fast, its trailing side lags and it stretches along the way; when it
|
|
245
|
+
* stops, it swings back past its shape for a moment and settles.
|
|
246
|
+
*
|
|
247
|
+
* Like the switch's thumb it takes the colour that reads on what it stands on: the fill's
|
|
248
|
+
* counterpart while it is held by the fill, the plain thumb colour in the empty trough.
|
|
249
|
+
*
|
|
250
|
+
* 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.
|
|
252
|
+
*/
|
|
253
|
+
function SliderThumb({ className, index = 0, ...props }) {
|
|
254
|
+
return /* @__PURE__ */ jsx(Slider$1.Thumb, {
|
|
255
|
+
"data-slot": "slider-thumb",
|
|
256
|
+
index,
|
|
257
|
+
className: mergeClassName("size-(--slider-thumb) rounded-full", className),
|
|
258
|
+
...props,
|
|
259
|
+
render: (thumbProps, state) => {
|
|
260
|
+
const held = state.dragging && state.activeThumbIndex === index;
|
|
261
|
+
const onFill = state.values.length > 1 || place(state, 0) > 0;
|
|
262
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { ...thumbProps }), /* @__PURE__ */ jsx("span", {
|
|
263
|
+
"aria-hidden": true,
|
|
264
|
+
"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"),
|
|
266
|
+
style: vars({
|
|
267
|
+
"--p": place(state, index),
|
|
268
|
+
"--thumb-face": onFill ? "var(--color-on-accent)" : "var(--color-thumb)"
|
|
269
|
+
}),
|
|
270
|
+
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)")
|
|
274
|
+
})
|
|
275
|
+
})] });
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
export { Slider, SliderControl, SliderLabel, SliderThumb, SliderValue };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SVGProps } from "react";
|
|
2
|
+
export type SpinnerProps = Omit<SVGProps<SVGSVGElement>, "children"> & {
|
|
3
|
+
/** Edge length in px. Match the icon size of the context: 14, 16 or 18. */
|
|
4
|
+
size?: number;
|
|
5
|
+
/** An accessible name ("Angebot wird gesendet"). Without it the spinner is decorative. */
|
|
6
|
+
label?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Work in progress with no known end: an arc running round an open ring. It is the system's ring
|
|
10
|
+
* before it has closed into a disc. Under reduced motion the arc stands still and breathes.
|
|
11
|
+
*
|
|
12
|
+
* Use it for waits a person started (a button, a panel loading). If the wait has a length, show
|
|
13
|
+
* progress instead; if it is shorter than about 300ms, show nothing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Spinner({ size, label, className, ...props }: SpinnerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/components/spinner/spinner.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Work in progress with no known end: an arc running round an open ring. It is the system's ring
|
|
6
|
+
* before it has closed into a disc. Under reduced motion the arc stands still and breathes.
|
|
7
|
+
*
|
|
8
|
+
* Use it for waits a person started (a button, a panel loading). If the wait has a length, show
|
|
9
|
+
* progress instead; if it is shorter than about 300ms, show nothing.
|
|
10
|
+
*/
|
|
11
|
+
function Spinner({ size = 16, label, className, ...props }) {
|
|
12
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
13
|
+
"data-slot": "spinner",
|
|
14
|
+
width: size,
|
|
15
|
+
height: size,
|
|
16
|
+
viewBox: "0 0 16 16",
|
|
17
|
+
fill: "none",
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
strokeWidth: 28 / size,
|
|
20
|
+
strokeLinecap: "butt",
|
|
21
|
+
role: label ? "status" : void 0,
|
|
22
|
+
"aria-label": label,
|
|
23
|
+
"aria-hidden": label ? void 0 : true,
|
|
24
|
+
className: cn("shrink-0 motion-safe:animate-spinner motion-reduce:animate-breathe", className),
|
|
25
|
+
...props,
|
|
26
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
27
|
+
cx: "8",
|
|
28
|
+
cy: "8",
|
|
29
|
+
r: "6",
|
|
30
|
+
opacity: "0.22"
|
|
31
|
+
}), /* @__PURE__ */ jsx("path", { d: "M8 2a6 6 0 0 1 6 6" })]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export { Spinner };
|