@lanfermann/ui 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion/accordion.d.ts +11 -3
- package/dist/components/accordion/accordion.js +15 -10
- package/dist/components/action-bar/action-bar.d.ts +60 -0
- package/dist/components/action-bar/action-bar.js +117 -0
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +3 -17
- package/dist/components/alert-dialog/alert-dialog.d.ts +1 -1
- package/dist/components/app-shell/app-shell.d.ts +33 -0
- package/dist/components/app-shell/app-shell.js +93 -0
- package/dist/components/attachment/attachment.d.ts +51 -0
- package/dist/components/attachment/attachment.js +255 -0
- package/dist/components/attachment/kinds.d.ts +7 -0
- package/dist/components/attachment/kinds.js +142 -0
- package/dist/components/avatar/avatar.d.ts +14 -4
- package/dist/components/avatar/avatar.js +57 -13
- package/dist/components/avatar-group/avatar-group.d.ts +33 -0
- package/dist/components/avatar-group/avatar-group.js +110 -0
- package/dist/components/avatar-group/people.d.ts +12 -0
- package/dist/components/avatar-group/people.js +24 -0
- package/dist/components/badge/badge.d.ts +9 -3
- package/dist/components/badge/badge.js +21 -6
- package/dist/components/banner/banner.d.ts +39 -0
- package/dist/components/banner/banner.js +149 -0
- package/dist/components/button-group/button-group-variants.d.ts +4 -3
- package/dist/components/button-group/button-group-variants.js +13 -12
- package/dist/components/button-group/button-group.d.ts +3 -3
- package/dist/components/button-group/button-group.js +3 -3
- package/dist/components/card/card.d.ts +20 -4
- package/dist/components/card/card.js +32 -6
- package/dist/components/checkbox-card/checkbox-card.d.ts +21 -0
- package/dist/components/checkbox-card/checkbox-card.js +50 -0
- package/dist/components/chip/chip-group.d.ts +15 -0
- package/dist/components/chip/chip-group.js +44 -0
- package/dist/components/chip/chip-variants.d.ts +6 -0
- package/dist/components/chip/chip-variants.js +28 -0
- package/dist/components/chip/chip.d.ts +39 -0
- package/dist/components/chip/chip.js +71 -0
- package/dist/components/code-block/code-copy.d.ts +3 -11
- package/dist/components/code-block/code-copy.js +15 -62
- package/dist/components/code-block/code-keys.js +10 -22
- package/dist/components/collapsible/collapsible.js +7 -3
- package/dist/components/combobox/combobox.d.ts +53 -3
- package/dist/components/combobox/combobox.js +204 -20
- package/dist/components/command/command.d.ts +131 -0
- package/dist/components/command/command.js +335 -0
- package/dist/components/consent/consent-card.js +365 -0
- package/dist/components/consent/consent-embed.d.ts +21 -0
- package/dist/components/consent/consent-embed.js +111 -0
- package/dist/components/consent/consent-labels.d.ts +70 -0
- package/dist/components/consent/consent-labels.js +61 -0
- package/dist/components/consent/consent-record.d.ts +95 -0
- package/dist/components/consent/consent-record.js +112 -0
- package/dist/components/consent/consent-store.d.ts +26 -0
- package/dist/components/consent/consent-store.js +240 -0
- package/dist/components/consent/consent.d.ts +86 -0
- package/dist/components/consent/consent.js +306 -0
- package/dist/components/container/container.d.ts +1 -1
- package/dist/components/context-menu/context-menu.d.ts +23 -0
- package/dist/components/context-menu/context-menu.js +50 -0
- package/dist/components/conversation/conversation.d.ts +45 -0
- package/dist/components/conversation/conversation.js +295 -0
- package/dist/components/conversation/stick.js +23 -0
- package/dist/components/copy-button/copy-button.d.ts +50 -0
- package/dist/components/copy-button/copy-button.js +65 -0
- package/dist/components/copy-page/copy-page.d.ts +4 -4
- package/dist/components/copy-page/copy-page.js +16 -36
- package/dist/components/copy-pill/copy-pill.js +1 -1
- package/dist/components/description-list/description-list.d.ts +32 -0
- package/dist/components/description-list/description-list.js +51 -0
- package/dist/components/empty/empty.d.ts +38 -0
- package/dist/components/empty/empty.js +57 -0
- package/dist/components/field/field.js +1 -1
- package/dist/components/file-upload/file-upload.d.ts +96 -0
- package/dist/components/file-upload/file-upload.js +347 -0
- package/dist/components/file-upload/files.d.ts +39 -0
- package/dist/components/file-upload/files.js +74 -0
- package/dist/components/grow/grow.d.ts +15 -3
- package/dist/components/grow/grow.js +24 -9
- package/dist/components/heading/heading.d.ts +1 -1
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/menu/menu.d.ts +20 -8
- package/dist/components/menu/menu.js +51 -29
- package/dist/components/message/message.d.ts +81 -0
- package/dist/components/message/message.js +208 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +7 -1
- package/dist/components/navigation-menu/navigation-menu.js +11 -4
- package/dist/components/otp-field/otp-field.d.ts +37 -0
- package/dist/components/otp-field/otp-field.js +161 -0
- package/dist/components/pagination/pagination.d.ts +50 -0
- package/dist/components/pagination/pagination.js +188 -0
- package/dist/components/prompt-input/keys.js +15 -0
- package/dist/components/prompt-input/prompt-input.d.ts +89 -0
- package/dist/components/prompt-input/prompt-input.js +331 -0
- package/dist/components/radio-card/radio-card.d.ts +23 -0
- package/dist/components/radio-card/radio-card.js +49 -0
- package/dist/components/rolling-number/rolling-number.d.ts +30 -0
- package/dist/components/rolling-number/rolling-number.js +149 -0
- package/dist/components/seam/seam.d.ts +1 -1
- package/dist/components/secret-field/secret-field.d.ts +53 -0
- package/dist/components/secret-field/secret-field.js +121 -0
- package/dist/components/section/section.d.ts +1 -1
- package/dist/components/segmented-control/segmented-control.js +29 -16
- package/dist/components/select/select.d.ts +5 -4
- package/dist/components/select/select.js +16 -11
- package/dist/components/shortcut/shortcut.d.ts +46 -0
- package/dist/components/shortcut/shortcut.js +87 -0
- package/dist/components/sidebar/sidebar-context.js +16 -0
- package/dist/components/sidebar/sidebar.d.ts +161 -0
- package/dist/components/sidebar/sidebar.js +588 -0
- package/dist/components/site-header/site-header.js +1 -1
- package/dist/components/skeleton/loaded.d.ts +21 -0
- package/dist/components/skeleton/loaded.js +57 -0
- package/dist/components/skeleton/skeleton.d.ts +43 -0
- package/dist/components/skeleton/skeleton.js +48 -0
- package/dist/components/sources/source-list.d.ts +17 -0
- package/dist/components/sources/source-list.js +26 -0
- package/dist/components/sources/sources.d.ts +45 -0
- package/dist/components/sources/sources.js +167 -0
- package/dist/components/stat/stat.d.ts +59 -0
- package/dist/components/stat/stat.js +112 -0
- package/dist/components/steps/steps.d.ts +57 -0
- package/dist/components/steps/steps.js +134 -0
- package/dist/components/table/table.d.ts +18 -9
- package/dist/components/table/table.js +21 -13
- package/dist/components/text/text.d.ts +1 -1
- package/dist/components/theme-switch/theme-switch.js +1 -1
- package/dist/components/time-field/time-field.js +7 -6
- package/dist/components/timeline/timeline.d.ts +45 -0
- package/dist/components/timeline/timeline.js +86 -0
- package/dist/components/toast/toast.js +10 -26
- package/dist/components/toggle/toggle.d.ts +27 -0
- package/dist/components/toggle/toggle.js +61 -0
- package/dist/components/toggle-group/toggle-group.d.ts +27 -0
- package/dist/components/toggle-group/toggle-group.js +38 -0
- package/dist/components/toolbar/toolbar-context.js +12 -0
- package/dist/components/toolbar/toolbar.d.ts +52 -0
- package/dist/components/toolbar/toolbar.js +105 -0
- package/dist/components/trace/trace.d.ts +2 -1
- package/dist/components/trace/trace.js +15 -27
- package/dist/index.d.ts +46 -3
- package/dist/index.js +44 -3
- package/dist/internal/arriving-pieces.js +56 -0
- package/dist/internal/arriving.js +171 -0
- package/dist/internal/avatar-cut.d.ts +15 -0
- package/dist/internal/avatar-cut.js +83 -0
- package/dist/internal/choice-card.d.ts +15 -0
- package/dist/internal/choice-card.js +81 -0
- package/dist/internal/clipboard.js +37 -0
- package/dist/internal/copy.js +58 -0
- package/dist/internal/disclosure.js +15 -3
- package/dist/internal/field.js +24 -4
- package/dist/internal/glyphs.js +26 -1
- package/dist/internal/key-tip.js +18 -0
- package/dist/internal/list-mark.js +39 -0
- package/dist/internal/live-list.js +41 -0
- package/dist/internal/number-places.js +157 -0
- package/dist/internal/picker-sheet.js +1 -1
- package/dist/internal/presence-dot.js +24 -0
- package/dist/internal/presence.js +104 -0
- package/dist/internal/rail-mark.d.ts +3 -0
- package/dist/internal/rail-mark.js +33 -0
- package/dist/internal/rule.js +2 -1
- package/dist/internal/status-icon.js +22 -0
- package/dist/internal/tile.js +23 -0
- package/dist/internal/travelling-mark.js +204 -0
- package/dist/lib/cn.js +10 -0
- package/dist/lib/shortcut.d.ts +11 -0
- package/dist/lib/shortcut.js +165 -0
- package/package.json +1 -1
- package/src/styles/accordion.css +176 -0
- package/src/styles/action-bar.css +28 -0
- package/src/styles/assistant.css +83 -0
- package/src/styles/avatar.css +24 -0
- package/src/styles/consent.css +65 -0
- package/src/styles/copy.css +12 -11
- package/src/styles/depth.css +120 -4
- package/src/styles/marks.css +20 -2
- package/src/styles/motion.css +3 -0
- package/src/styles/rail.css +49 -0
- package/src/styles/rolling-number.css +94 -0
- package/src/styles/segmented.css +14 -7
- package/src/styles/steps.css +98 -0
- package/src/styles/timeline.css +48 -0
- package/src/styles/travel.css +36 -0
- package/src/styles.css +10 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/components/avatar-group/people.ts
|
|
2
|
+
const defaultPresenceLabels = {
|
|
3
|
+
online: "Online",
|
|
4
|
+
away: "Abwesend",
|
|
5
|
+
offline: "Offline"
|
|
6
|
+
};
|
|
7
|
+
/** „Anna Weber“ → „AW“, „Cher“ → „C“. */
|
|
8
|
+
function initialsOf(name) {
|
|
9
|
+
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
10
|
+
if (words.length === 0) return "";
|
|
11
|
+
return (words[0].charAt(0) + (words.length > 1 ? words.at(-1).charAt(0) : "")).toLocaleUpperCase();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* What a person is called, with their presence in brackets, so it reads apart from the next
|
|
15
|
+
* name in a list: „Anna Weber (online)“.
|
|
16
|
+
*/
|
|
17
|
+
function personLabel(person, presenceLabels = defaultPresenceLabels) {
|
|
18
|
+
return person.presence ? `${person.name} (${presenceLabels[person.presence].toLocaleLowerCase()})` : person.name;
|
|
19
|
+
}
|
|
20
|
+
/** Everyone in one sentence: „Anna Weber, Jonas Klein und Lena Fischer“. */
|
|
21
|
+
function listOf(names, locale = "de-DE") {
|
|
22
|
+
return new Intl.ListFormat(locale, { type: "conjunction" }).format(names);
|
|
23
|
+
}
|
|
24
|
+
export { defaultPresenceLabels, initialsOf, listOf, personLabel };
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { VariantProps } from "class-variance-authority";
|
|
2
1
|
import { ComponentProps } from "react";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const badgeVariants: (props?: ({
|
|
4
4
|
tone?: "neutral" | "info" | "success" | "warning" | "danger" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
-
export type BadgeProps = ComponentProps<"span"> & VariantProps<typeof badgeVariants
|
|
6
|
+
export type BadgeProps = ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
7
|
+
/**
|
|
8
|
+
* The tone as a dot before the word, on a neutral badge. For a column of states in a table,
|
|
9
|
+
* where a tinted badge on every row is louder than what the row is about.
|
|
10
|
+
*/
|
|
11
|
+
dot?: boolean;
|
|
12
|
+
};
|
|
7
13
|
/**
|
|
8
14
|
* A short state on a row or a card: "Entwurf", "Bezahlt", "Überfällig". One or two words, in
|
|
9
15
|
* sentence case. Colour never carries the state alone: the word does, and a 12px icon may help.
|
|
10
16
|
*/
|
|
11
|
-
export declare function Badge({ className, tone, ...props }: BadgeProps): import("react").JSX.Element;
|
|
17
|
+
export declare function Badge({ className, tone, dot, children, ...props }: BadgeProps): import("react").JSX.Element;
|
|
12
18
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cn } from "../../lib/cn.js";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
4
|
// src/components/badge/badge.tsx
|
|
5
5
|
const badgeVariants = cva("inline-flex h-[1.375rem] shrink-0 items-center gap-1 rounded-sm px-2 text-sm font-medium whitespace-nowrap inset-ring inset-ring-current/15 forced-colors:outline", {
|
|
@@ -12,16 +12,31 @@ const badgeVariants = cva("inline-flex h-[1.375rem] shrink-0 items-center gap-1
|
|
|
12
12
|
} },
|
|
13
13
|
defaultVariants: { tone: "neutral" }
|
|
14
14
|
});
|
|
15
|
+
/** The dot of each tone. A neutral state is a ring: open, not yet anything (a draft). */
|
|
16
|
+
const dots = {
|
|
17
|
+
neutral: "border-[1.5px] border-fg-muted",
|
|
18
|
+
info: "bg-info forced-colors:bg-[CanvasText]",
|
|
19
|
+
success: "bg-success forced-colors:bg-[CanvasText]",
|
|
20
|
+
warning: "bg-warning forced-colors:bg-[CanvasText]",
|
|
21
|
+
danger: "bg-danger forced-colors:bg-[CanvasText]"
|
|
22
|
+
};
|
|
15
23
|
/**
|
|
16
24
|
* A short state on a row or a card: "Entwurf", "Bezahlt", "Überfällig". One or two words, in
|
|
17
25
|
* sentence case. Colour never carries the state alone: the word does, and a 12px icon may help.
|
|
18
26
|
*/
|
|
19
|
-
function Badge({ className, tone, ...props }) {
|
|
20
|
-
|
|
27
|
+
function Badge({ className, tone, dot = false, children, ...props }) {
|
|
28
|
+
const hue = tone ?? "neutral";
|
|
29
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
21
30
|
"data-slot": "badge",
|
|
22
|
-
"data-tone":
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
"data-tone": hue,
|
|
32
|
+
"data-dot": dot ? "" : void 0,
|
|
33
|
+
className: cn(badgeVariants({ tone: dot ? "neutral" : tone }), dot && "gap-1.5 ps-1.5", className),
|
|
34
|
+
...props,
|
|
35
|
+
children: [dot && /* @__PURE__ */ jsx("span", {
|
|
36
|
+
"aria-hidden": true,
|
|
37
|
+
"data-slot": "badge-dot",
|
|
38
|
+
className: cn("size-2 shrink-0 rounded-full", dots[hue])
|
|
39
|
+
}), children]
|
|
25
40
|
});
|
|
26
41
|
}
|
|
27
42
|
export { Badge };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode, RefObject } from "react";
|
|
2
|
+
export type BannerTone = "info" | "success" | "warning" | "danger";
|
|
3
|
+
export type BannerProps = Omit<ComponentProps<"div">, "title"> & {
|
|
4
|
+
tone?: BannerTone;
|
|
5
|
+
/** What is the case, as a sentence: „Ihre Testphase endet in drei Tagen.“ */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
/** What to do about it: „Wählen Sie einen Tarif, damit Ihre Angebote erhalten bleiben.“ */
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
/** One thing to do, at the end of the strip: a `Button size="sm"`, or a link styled as one. */
|
|
10
|
+
action?: ReactNode;
|
|
11
|
+
/** Whether it shows (controlled). */
|
|
12
|
+
open?: boolean;
|
|
13
|
+
/** Whether it shows at first. Default: it does. */
|
|
14
|
+
defaultOpen?: boolean;
|
|
15
|
+
onOpenChange?: (open: boolean) => void;
|
|
16
|
+
/** Whether it has a close key. A notice that stays true until it is acted on has none. */
|
|
17
|
+
dismissible?: boolean;
|
|
18
|
+
/** The name of the close key. */
|
|
19
|
+
closeLabel?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Where the focus goes when the close key is pressed and the banner leaves. By default the
|
|
22
|
+
* page's `<main>`, so a keyboard user is not dropped at the start of the document.
|
|
23
|
+
*/
|
|
24
|
+
finalFocus?: RefObject<HTMLElement | null>;
|
|
25
|
+
/** The word assistive tech hears before the title, where the symbol says it to the eye. */
|
|
26
|
+
toneLabels?: Partial<Record<BannerTone, string>>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A notice for the whole page: the trial ends in three days, a payment failed, maintenance
|
|
30
|
+
* tonight. For a message inside a page's content, use an `Alert`.
|
|
31
|
+
*
|
|
32
|
+
* A strip in the status wash across the full width of the page or of its main column, under its
|
|
33
|
+
* top edge, with the status symbol, a sentence, an optional action and a close key. Put it first
|
|
34
|
+
* in that column, not inside the content's padding. The title says what is the case, the text
|
|
35
|
+
* what to do. A banner that is there when the
|
|
36
|
+
* page loads stands still; one that arrives later pushes the page down and is announced. Closed,
|
|
37
|
+
* it leaves the way it came: it rises into the top edge as it fades, and the page follows it up.
|
|
38
|
+
*/
|
|
39
|
+
export declare function Banner({ tone, title, children, action, open, defaultOpen, onOpenChange, dismissible, closeLabel, finalFocus, toneLabels, className, ...props }: BannerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { Grow } from "../grow/grow.js";
|
|
4
|
+
import { Icon } from "../icon/icon.js";
|
|
5
|
+
import { CloseGlyph } from "../../internal/glyphs.js";
|
|
6
|
+
import { useLive } from "../../internal/presence.js";
|
|
7
|
+
import { statusIconTone, statusIcons } from "../../internal/status-icon.js";
|
|
8
|
+
import { cn } from "../../lib/cn.js";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
11
|
+
// src/components/banner/banner.tsx
|
|
12
|
+
const wash = {
|
|
13
|
+
info: "bg-info-soft",
|
|
14
|
+
success: "bg-success-soft",
|
|
15
|
+
warning: "bg-warning-soft",
|
|
16
|
+
danger: "bg-danger-soft"
|
|
17
|
+
};
|
|
18
|
+
/** The faint edge in the status colour under the strip. */
|
|
19
|
+
const edge = {
|
|
20
|
+
info: "shadow-[inset_0_-1px_0] shadow-info/20",
|
|
21
|
+
success: "shadow-[inset_0_-1px_0] shadow-success/25",
|
|
22
|
+
warning: "shadow-[inset_0_-1px_0] shadow-warning/30",
|
|
23
|
+
danger: "shadow-[inset_0_-1px_0] shadow-danger/25"
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A small control that takes the room of one line of the strip's text, standing out above and
|
|
27
|
+
* below it by the same amount, so its middle is the middle of the line. (`1lh` is read where
|
|
28
|
+
* this is set: on a box in the strip's text size, not on the button.) The action repeats it
|
|
29
|
+
* under a container query.
|
|
30
|
+
*/
|
|
31
|
+
const oneLine = "-my-[calc((var(--control-sm)-1lh)/2)]";
|
|
32
|
+
const defaultToneLabels = {
|
|
33
|
+
info: "Hinweis",
|
|
34
|
+
success: "Erledigt",
|
|
35
|
+
warning: "Warnung",
|
|
36
|
+
danger: "Fehler"
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A notice for the whole page: the trial ends in three days, a payment failed, maintenance
|
|
40
|
+
* tonight. For a message inside a page's content, use an `Alert`.
|
|
41
|
+
*
|
|
42
|
+
* A strip in the status wash across the full width of the page or of its main column, under its
|
|
43
|
+
* top edge, with the status symbol, a sentence, an optional action and a close key. Put it first
|
|
44
|
+
* in that column, not inside the content's padding. The title says what is the case, the text
|
|
45
|
+
* what to do. A banner that is there when the
|
|
46
|
+
* page loads stands still; one that arrives later pushes the page down and is announced. Closed,
|
|
47
|
+
* it leaves the way it came: it rises into the top edge as it fades, and the page follows it up.
|
|
48
|
+
*/
|
|
49
|
+
function Banner({ tone = "info", title, children, action, open, defaultOpen = true, onOpenChange, dismissible = true, closeLabel = "Hinweis schließen", finalFocus, toneLabels, className, ...props }) {
|
|
50
|
+
const [chosen, setChosen] = useState(defaultOpen);
|
|
51
|
+
const shown = open ?? chosen;
|
|
52
|
+
const [drawn, setDrawn] = useState(shown);
|
|
53
|
+
if (shown && !drawn) setDrawn(true);
|
|
54
|
+
const leaving = drawn && !shown;
|
|
55
|
+
const live = useLive();
|
|
56
|
+
const grow = useRef(null);
|
|
57
|
+
const labels = {
|
|
58
|
+
...defaultToneLabels,
|
|
59
|
+
...toneLabels
|
|
60
|
+
};
|
|
61
|
+
const close = () => {
|
|
62
|
+
setChosen(false);
|
|
63
|
+
onOpenChange?.(false);
|
|
64
|
+
};
|
|
65
|
+
useLayoutEffect(() => {
|
|
66
|
+
const box = grow.current;
|
|
67
|
+
if (!leaving || !box?.contains(document.activeElement)) return;
|
|
68
|
+
const target = finalFocus?.current ?? box.closest("main") ?? document.querySelector("main");
|
|
69
|
+
if (!target) return;
|
|
70
|
+
if (!target.hasAttribute("tabindex")) {
|
|
71
|
+
target.setAttribute("tabindex", "-1");
|
|
72
|
+
target.addEventListener("blur", () => target.removeAttribute("tabindex"), { once: true });
|
|
73
|
+
}
|
|
74
|
+
target.focus({ preventScroll: true });
|
|
75
|
+
}, [leaving, finalFocus]);
|
|
76
|
+
const settled = (event) => {
|
|
77
|
+
if (!leaving || event.target !== event.currentTarget) return;
|
|
78
|
+
if (grow.current?.dataset.moving !== void 0) return;
|
|
79
|
+
setDrawn(false);
|
|
80
|
+
};
|
|
81
|
+
return /* @__PURE__ */ jsx(Grow, {
|
|
82
|
+
ref: grow,
|
|
83
|
+
role: tone === "danger" ? "alert" : "status",
|
|
84
|
+
"data-slot": "banner",
|
|
85
|
+
"data-tone": tone,
|
|
86
|
+
"data-live": live ? "" : void 0,
|
|
87
|
+
onTransitionEnd: settled,
|
|
88
|
+
className,
|
|
89
|
+
...props,
|
|
90
|
+
children: drawn && /* @__PURE__ */ jsx("div", {
|
|
91
|
+
"data-slot": "banner-place",
|
|
92
|
+
className: cn(leaving && "h-0 motion-reduce:overflow-clip"),
|
|
93
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
94
|
+
"data-slot": "banner-strip",
|
|
95
|
+
"data-leaving": leaving ? "" : void 0,
|
|
96
|
+
inert: leaving,
|
|
97
|
+
onTransitionEnd: settled,
|
|
98
|
+
className: cn("flex items-start gap-3 py-2.5 ps-4 pe-2.5 text-control text-fg-body sm:ps-6 sm:pe-4", wash[tone], edge[tone], "transition-[opacity,translate] spring-settle", "in-data-live:starting:-translate-y-(--motion-enter-offset) in-data-live:starting:opacity-0", "data-leaving:-translate-y-(--motion-enter-offset) data-leaving:opacity-0", "forced-colors:outline"),
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ jsx("span", {
|
|
101
|
+
className: "flex h-lh shrink-0 items-center",
|
|
102
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
103
|
+
icon: statusIcons[tone],
|
|
104
|
+
size: 18,
|
|
105
|
+
className: statusIconTone[tone]
|
|
106
|
+
})
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ jsxs("div", {
|
|
109
|
+
className: "@container/banner flex min-w-0 flex-1 flex-wrap items-start gap-x-4 gap-y-2.5",
|
|
110
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
111
|
+
"data-slot": "banner-text",
|
|
112
|
+
className: "min-w-0 flex-[1_1_18rem] text-pretty @max-lg/banner:basis-full",
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ jsxs("span", {
|
|
115
|
+
className: "sr-only",
|
|
116
|
+
children: [labels[tone], ": "]
|
|
117
|
+
}),
|
|
118
|
+
/* @__PURE__ */ jsx("span", {
|
|
119
|
+
"data-slot": "banner-title",
|
|
120
|
+
className: "font-semibold text-fg",
|
|
121
|
+
children: title
|
|
122
|
+
}),
|
|
123
|
+
children !== void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [" ", children] })
|
|
124
|
+
]
|
|
125
|
+
}), action !== void 0 && /* @__PURE__ */ jsx("div", {
|
|
126
|
+
"data-slot": "banner-action",
|
|
127
|
+
className: "shrink-0 @lg/banner:-my-[calc((var(--control-sm)-1lh)/2)]",
|
|
128
|
+
children: action
|
|
129
|
+
})]
|
|
130
|
+
}),
|
|
131
|
+
dismissible && /* @__PURE__ */ jsx("div", {
|
|
132
|
+
className: cn("shrink-0", oneLine),
|
|
133
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
134
|
+
"data-slot": "banner-close",
|
|
135
|
+
iconOnly: true,
|
|
136
|
+
size: "sm",
|
|
137
|
+
variant: "quiet",
|
|
138
|
+
"aria-label": closeLabel,
|
|
139
|
+
onClick: close,
|
|
140
|
+
className: "text-fg-muted",
|
|
141
|
+
children: /* @__PURE__ */ jsx(CloseGlyph, {})
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
export { Banner };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { VariantProps } from "class-variance-authority";
|
|
2
2
|
/**
|
|
3
|
-
* The fitting of a `ButtonGroup`: the face, the edge and the shadow that all its keys share.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* The fitting of a `ButtonGroup`: the face, the edge and the shadow that all its keys share. Under
|
|
4
|
+
* the pointer the whole fitting lifts; a press moves only the key that was pressed (see
|
|
5
|
+
* `buttonGroupKeyVariants`), so the fitting itself stays where it is. Server-safe, like
|
|
6
|
+
* `buttonVariants`.
|
|
6
7
|
*
|
|
7
8
|
* `--key-hover` and `--key-pressed` are what a key lays over the face (button-group.css has the
|
|
8
9
|
* seams and the corners).
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
2
|
// src/components/button-group/button-group-variants.ts
|
|
3
3
|
/**
|
|
4
|
-
* The fitting of a `ButtonGroup`: the face, the edge and the shadow that all its keys share.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The fitting of a `ButtonGroup`: the face, the edge and the shadow that all its keys share. Under
|
|
5
|
+
* the pointer the whole fitting lifts; a press moves only the key that was pressed (see
|
|
6
|
+
* `buttonGroupKeyVariants`), so the fitting itself stays where it is. Server-safe, like
|
|
7
|
+
* `buttonVariants`.
|
|
7
8
|
*
|
|
8
9
|
* `--key-hover` and `--key-pressed` are what a key lays over the face (button-group.css has the
|
|
9
10
|
* seams and the corners).
|
|
10
11
|
*/
|
|
11
12
|
const buttonGroupVariants = cva([
|
|
12
13
|
"relative inline-flex shrink-0 items-stretch font-medium",
|
|
13
|
-
"transition-[box-shadow
|
|
14
|
-
"has-[[data-group-key]:hover]:
|
|
15
|
-
"has-[[data-group-key]:active]:scale-(--motion-press-scale) has-[[data-group-key]:active]:shadow-pressed has-[[data-group-key]:active]:spring-snap",
|
|
14
|
+
"transition-[box-shadow] spring-seat",
|
|
15
|
+
"has-[[data-group-key]:hover]:depth-raised-hover has-[[data-group-key]:hover]:spring-snap",
|
|
16
16
|
"data-[orientation=vertical]:flex-col",
|
|
17
17
|
"data-disabled:bg-disabled data-disabled:depth-flat"
|
|
18
18
|
], {
|
|
@@ -42,15 +42,16 @@ const buttonGroupVariants = cva([
|
|
|
42
42
|
*/
|
|
43
43
|
const buttonGroupKeyDisabledLook = "data-disabled:bg-disabled data-disabled:text-on-disabled";
|
|
44
44
|
/**
|
|
45
|
-
* One key of the fitting. It has no face of its own: the fitting's gloss shows through
|
|
46
|
-
* marks the key under the pointer
|
|
47
|
-
*
|
|
48
|
-
* never sideways, so two keys
|
|
45
|
+
* One key of the fitting. It has no face of its own: the fitting's gloss shows through and a wash
|
|
46
|
+
* marks the key under the pointer. A press moves only this key: it takes the pressed colour and
|
|
47
|
+
* the inner shade and goes down to the press scale, while the fitting and the other keys stay
|
|
48
|
+
* still. On a touch screen its target grows to 44px up and down, never sideways, so two keys
|
|
49
|
+
* never take each other's taps.
|
|
49
50
|
*/
|
|
50
51
|
const buttonGroupKeyVariants = cva([
|
|
51
52
|
"relative inline-flex shrink-0 items-center justify-center whitespace-nowrap outline-offset-2 select-none",
|
|
52
|
-
"transition-[background-color,box-shadow] spring-seat hover:bg-(--key-hover) hover:spring-snap",
|
|
53
|
-
"active:bg-(--key-pressed) active:inset-shadow-pressed active:spring-snap",
|
|
53
|
+
"transition-[background-color,box-shadow,scale] spring-seat hover:bg-(--key-hover) hover:spring-snap",
|
|
54
|
+
"active:scale-(--motion-press-scale) active:bg-(--key-pressed) active:inset-shadow-pressed active:spring-snap",
|
|
54
55
|
"data-popup-open:bg-(--key-hover)",
|
|
55
56
|
"focus-visible:z-1 focus-visible:rounded-[inherit] focus-visible:outline-2 focus-visible:outline-accent",
|
|
56
57
|
"pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:top-1/2 pointer-coarse:after:h-11 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']",
|
|
@@ -20,9 +20,9 @@ export type ButtonGroupProps = Omit<ComponentProps<"div">, "aria-label" | "aria-
|
|
|
20
20
|
* Actions that belong together, as one fitting with several keys: an action and the menu of its
|
|
21
21
|
* other forms ("Senden" and a chevron), two or three steps on the same thing ("Archivieren",
|
|
22
22
|
* "Melden", "Später"), a pair of arrows. The keys share one face, one edge and one shadow, a
|
|
23
|
-
* seam in the edge's colour divides them
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* seam in the edge's colour divides them. The fitting lifts under the pointer as one part; a
|
|
24
|
+
* press moves only the key that was pressed, which takes the inner shade and goes down while the
|
|
25
|
+
* fitting stays where it is.
|
|
26
26
|
*
|
|
27
27
|
* Put `Button`s inside, or a `SelectTrigger`. A key that opens a popup is its trigger rendered
|
|
28
28
|
* as a button (`<MenuTrigger render={<Button iconOnly aria-label="…" />}>`). The keys take the
|
|
@@ -9,9 +9,9 @@ import { useMemo } from "react";
|
|
|
9
9
|
* Actions that belong together, as one fitting with several keys: an action and the menu of its
|
|
10
10
|
* other forms ("Senden" and a chevron), two or three steps on the same thing ("Archivieren",
|
|
11
11
|
* "Melden", "Später"), a pair of arrows. The keys share one face, one edge and one shadow, a
|
|
12
|
-
* seam in the edge's colour divides them
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* seam in the edge's colour divides them. The fitting lifts under the pointer as one part; a
|
|
13
|
+
* press moves only the key that was pressed, which takes the inner shade and goes down while the
|
|
14
|
+
* fitting stays where it is.
|
|
15
15
|
*
|
|
16
16
|
* Put `Button`s inside, or a `SelectTrigger`. A key that opens a popup is its trigger rendered
|
|
17
17
|
* as a button (`<MenuTrigger render={<Button iconOnly aria-label="…" />}>`). The keys take the
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
2
|
type DivProps = ComponentProps<"div">;
|
|
3
3
|
/**
|
|
4
|
-
* A
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* A softly raised sheet. It holds one object you act on (a form you submit, a plan you choose,
|
|
5
|
+
* an account), or, on an app's page, one block of it: the latest quotes, what happened lately,
|
|
6
|
+
* the members of a team, each named by a `CardBar`, with its `Table` or list running to the
|
|
7
|
+
* card's edges (Justin, 2026-11-19). The pages of a site and the docs are not chopped into
|
|
8
|
+
* boxes: what is only read there stands on the ground under a rule (`Separator`).
|
|
9
|
+
*
|
|
10
|
+
* `variant="bevel"` (Fase) cuts the card like a fitting: a crisp edge, light along its top, a
|
|
11
|
+
* lip along its foot and a short shadow, so it stands on the page as a machined part instead of
|
|
12
|
+
* floating over it. For a card that is handled (a choice, a prompt to copy, a tile to open).
|
|
13
|
+
* `variant="gloss"` (Glanz) is the same cut with a face that visibly shines and darkens toward
|
|
14
|
+
* its foot, as Clerk's cards on a dark page. Both stay (Justin, 2026-11-20).
|
|
7
15
|
*/
|
|
8
|
-
export declare function Card({ className, ...props }: DivProps
|
|
16
|
+
export declare function Card({ variant, className, ...props }: DivProps & {
|
|
17
|
+
variant?: "default" | "bevel" | "gloss";
|
|
18
|
+
}): import("react").JSX.Element;
|
|
9
19
|
export declare function CardHeader({ className, ...props }: DivProps): import("react").JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* The bar across the top of a card that holds a list, a table or a feed: its name (a `Heading`
|
|
22
|
+
* of `size="label"`) and, at the end, a way to all of it („Alle Angebote“) or one action. A
|
|
23
|
+
* hairline under it; what follows runs to the card's edges, its text 20px in as the bar's is.
|
|
24
|
+
*/
|
|
25
|
+
export declare function CardBar({ className, ...props }: DivProps): import("react").JSX.Element;
|
|
10
26
|
/** A sentence, like every title in the kit. */
|
|
11
27
|
export declare function CardTitle({ className, ...props }: ComponentProps<"h3">): import("react").JSX.Element;
|
|
12
28
|
export declare function CardDescription({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
|
|
@@ -2,17 +2,31 @@ import { cn } from "../../lib/cn.js";
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
// src/components/card/card.tsx
|
|
4
4
|
/**
|
|
5
|
-
* A
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* A softly raised sheet. It holds one object you act on (a form you submit, a plan you choose,
|
|
6
|
+
* an account), or, on an app's page, one block of it: the latest quotes, what happened lately,
|
|
7
|
+
* the members of a team, each named by a `CardBar`, with its `Table` or list running to the
|
|
8
|
+
* card's edges (Justin, 2026-11-19). The pages of a site and the docs are not chopped into
|
|
9
|
+
* boxes: what is only read there stands on the ground under a rule (`Separator`).
|
|
10
|
+
*
|
|
11
|
+
* `variant="bevel"` (Fase) cuts the card like a fitting: a crisp edge, light along its top, a
|
|
12
|
+
* lip along its foot and a short shadow, so it stands on the page as a machined part instead of
|
|
13
|
+
* floating over it. For a card that is handled (a choice, a prompt to copy, a tile to open).
|
|
14
|
+
* `variant="gloss"` (Glanz) is the same cut with a face that visibly shines and darkens toward
|
|
15
|
+
* its foot, as Clerk's cards on a dark page. Both stay (Justin, 2026-11-20).
|
|
8
16
|
*/
|
|
9
|
-
function Card({ className, ...props }) {
|
|
17
|
+
function Card({ variant = "default", className, ...props }) {
|
|
10
18
|
return /* @__PURE__ */ jsx("div", {
|
|
11
19
|
"data-slot": "card",
|
|
12
|
-
|
|
20
|
+
"data-variant": variant,
|
|
21
|
+
className: cn("flex flex-col rounded-xl bg-surface", depthOf[variant], className),
|
|
13
22
|
...props
|
|
14
23
|
});
|
|
15
24
|
}
|
|
25
|
+
const depthOf = {
|
|
26
|
+
default: "depth-card",
|
|
27
|
+
bevel: "depth-bevel",
|
|
28
|
+
gloss: "depth-gloss"
|
|
29
|
+
};
|
|
16
30
|
function CardHeader({ className, ...props }) {
|
|
17
31
|
return /* @__PURE__ */ jsx("div", {
|
|
18
32
|
"data-slot": "card-header",
|
|
@@ -20,6 +34,18 @@ function CardHeader({ className, ...props }) {
|
|
|
20
34
|
...props
|
|
21
35
|
});
|
|
22
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* The bar across the top of a card that holds a list, a table or a feed: its name (a `Heading`
|
|
39
|
+
* of `size="label"`) and, at the end, a way to all of it („Alle Angebote“) or one action. A
|
|
40
|
+
* hairline under it; what follows runs to the card's edges, its text 20px in as the bar's is.
|
|
41
|
+
*/
|
|
42
|
+
function CardBar({ className, ...props }) {
|
|
43
|
+
return /* @__PURE__ */ jsx("div", {
|
|
44
|
+
"data-slot": "card-bar",
|
|
45
|
+
className: cn("flex min-h-12 shrink-0 flex-wrap items-center justify-between gap-x-4 gap-y-2 border-b border-hairline px-5 py-2", className),
|
|
46
|
+
...props
|
|
47
|
+
});
|
|
48
|
+
}
|
|
23
49
|
/** A sentence, like every title in the kit. */
|
|
24
50
|
function CardTitle({ className, ...props }) {
|
|
25
51
|
return /* @__PURE__ */ jsx("h3", {
|
|
@@ -50,4 +76,4 @@ function CardFooter({ className, ...props }) {
|
|
|
50
76
|
...props
|
|
51
77
|
});
|
|
52
78
|
}
|
|
53
|
-
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
|
|
79
|
+
export { Card, CardBar, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChoiceCardText } from "../../internal/choice-card.js";
|
|
2
|
+
import { Checkbox } from "@base-ui/react/checkbox";
|
|
3
|
+
export type CheckboxCardProps = Omit<Checkbox.Root.Props, "children" | "className" | "render" | "title" | "indeterminate" | "parent"> & ChoiceCardText & {
|
|
4
|
+
/**
|
|
5
|
+
* How the chosen card shows it. `edge` (the default): the accent as its edge, with its
|
|
6
|
+
* mark. `mark`: the mark alone.
|
|
7
|
+
*/
|
|
8
|
+
chosen?: "edge" | "mark";
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* One of several things that may each be chosen, where every option needs a sentence: what a
|
|
13
|
+
* workspace is for, which notices to get. The whole card is the control and the target, cut
|
|
14
|
+
* like a `RadioCard`: a softly raised sheet that stands still while its box dips under a press,
|
|
15
|
+
* and takes the accent as its edge when it is on.
|
|
16
|
+
*
|
|
17
|
+
* Put the cards into a `CheckboxGroup` (its value is the list of the chosen `value`s) and lay
|
|
18
|
+
* them out with a class on it. A single card on its own is a setting with an explanation; a
|
|
19
|
+
* `Switch` with a label is usually the better form for that.
|
|
20
|
+
*/
|
|
21
|
+
export declare function CheckboxCard({ title, description, detail, icon, chosen, className, children, ...props }: CheckboxCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ChoiceCardBody, choiceCard, choiceControl, followPointer } from "../../internal/choice-card.js";
|
|
3
|
+
import { TickGlyph } from "../../internal/glyphs.js";
|
|
4
|
+
import { cn } from "../../lib/cn.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
import { Checkbox } from "@base-ui/react/checkbox";
|
|
8
|
+
// src/components/checkbox-card/checkbox-card.tsx
|
|
9
|
+
/**
|
|
10
|
+
* One of several things that may each be chosen, where every option needs a sentence: what a
|
|
11
|
+
* workspace is for, which notices to get. The whole card is the control and the target, cut
|
|
12
|
+
* like a `RadioCard`: a softly raised sheet that stands still while its box dips under a press,
|
|
13
|
+
* and takes the accent as its edge when it is on.
|
|
14
|
+
*
|
|
15
|
+
* Put the cards into a `CheckboxGroup` (its value is the list of the chosen `value`s) and lay
|
|
16
|
+
* them out with a class on it. A single card on its own is a setting with an explanation; a
|
|
17
|
+
* `Switch` with a label is usually the better form for that.
|
|
18
|
+
*/
|
|
19
|
+
function CheckboxCard({ title, description, detail, icon, chosen = "edge", className, children, ...props }) {
|
|
20
|
+
const titleId = useId();
|
|
21
|
+
const descriptionId = useId();
|
|
22
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
23
|
+
"data-slot": "checkbox-card",
|
|
24
|
+
onPointerMove: followPointer,
|
|
25
|
+
className: cn(choiceCard, chosen === "edge" && "has-[[data-slot=choice-control][data-checked]]:depth-bevel-chosen", className),
|
|
26
|
+
children: [/* @__PURE__ */ jsx(Checkbox.Root, {
|
|
27
|
+
"data-slot": "choice-control",
|
|
28
|
+
"aria-labelledby": titleId,
|
|
29
|
+
"aria-describedby": description === void 0 ? void 0 : descriptionId,
|
|
30
|
+
className: cn(choiceControl, "rounded-xs bg-surface text-on-accent depth-socket transition-[box-shadow,background-color,scale]", "data-checked:bg-accent data-checked:depth-plug data-checked:depth-tone-accent", "data-disabled:bg-disabled data-disabled:depth-flat data-disabled:text-on-disabled"),
|
|
31
|
+
...props,
|
|
32
|
+
children: /* @__PURE__ */ jsx(Checkbox.Indicator, {
|
|
33
|
+
keepMounted: true,
|
|
34
|
+
"data-slot": "checkbox-card-indicator",
|
|
35
|
+
className: "flex items-center justify-center",
|
|
36
|
+
children: /* @__PURE__ */ jsx(TickGlyph, { className: "opacity-0 transition-[stroke-dashoffset,opacity] duration-150 ease-out [stroke-dasharray:1] [stroke-dashoffset:1] group-data-checked/control:opacity-100 group-data-checked/control:[stroke-dashoffset:0]" })
|
|
37
|
+
})
|
|
38
|
+
}), /* @__PURE__ */ jsx(ChoiceCardBody, {
|
|
39
|
+
slot: "checkbox-card",
|
|
40
|
+
titleId,
|
|
41
|
+
descriptionId,
|
|
42
|
+
title,
|
|
43
|
+
description,
|
|
44
|
+
detail,
|
|
45
|
+
icon,
|
|
46
|
+
children
|
|
47
|
+
})]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export { CheckboxCard };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
export type ChipGroupProps = ComponentProps<"div">;
|
|
3
|
+
/**
|
|
4
|
+
* A row of chips that belong together: the filters on a list, the values chosen in a field. It
|
|
5
|
+
* wraps onto further lines when the row is full. Name it (`aria-label`) with what the chips
|
|
6
|
+
* are ("Filter").
|
|
7
|
+
*
|
|
8
|
+
* The row is what moves. A chip that joins it later opens its place, and the chip seats in; one
|
|
9
|
+
* that is taken away fades, and the row closes its place. So the chips beside it glide instead
|
|
10
|
+
* of jumping, and the owner's list can lose the chip at once: the row keeps it on screen until
|
|
11
|
+
* it has left. The chips that are there when the row first shows do not move.
|
|
12
|
+
*
|
|
13
|
+
* Give each chip a `key` that stays its own.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ChipGroup({ className, children, ...props }: ChipGroupProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { placeInRow, placeProps, useLive, usePresence } from "../../internal/presence.js";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Children, isValidElement, useMemo, useRef } from "react";
|
|
6
|
+
// src/components/chip/chip-group.tsx
|
|
7
|
+
const keyOf = (element) => element.key ?? "";
|
|
8
|
+
/**
|
|
9
|
+
* A row of chips that belong together: the filters on a list, the values chosen in a field. It
|
|
10
|
+
* wraps onto further lines when the row is full. Name it (`aria-label`) with what the chips
|
|
11
|
+
* are ("Filter").
|
|
12
|
+
*
|
|
13
|
+
* The row is what moves. A chip that joins it later opens its place, and the chip seats in; one
|
|
14
|
+
* that is taken away fades, and the row closes its place. So the chips beside it glide instead
|
|
15
|
+
* of jumping, and the owner's list can lose the chip at once: the row keeps it on screen until
|
|
16
|
+
* it has left. The chips that are there when the row first shows do not move.
|
|
17
|
+
*
|
|
18
|
+
* Give each chip a `key` that stays its own.
|
|
19
|
+
*/
|
|
20
|
+
function ChipGroup({ className, children, ...props }) {
|
|
21
|
+
const live = useLive();
|
|
22
|
+
const box = useRef(null);
|
|
23
|
+
const chips = useMemo(() => Children.toArray(children).filter(isValidElement), [children]);
|
|
24
|
+
const { places, left } = usePresence(chips, keyOf, box);
|
|
25
|
+
return /* @__PURE__ */ jsx("div", {
|
|
26
|
+
ref: box,
|
|
27
|
+
role: "list",
|
|
28
|
+
"data-slot": "chip-group",
|
|
29
|
+
"data-live": live ? "" : void 0,
|
|
30
|
+
className: cn("flex flex-wrap items-center gap-(--chip-gap) [--chip-gap:0.375rem]", className),
|
|
31
|
+
...props,
|
|
32
|
+
children: places.map((place) => /* @__PURE__ */ jsx("span", {
|
|
33
|
+
role: "listitem",
|
|
34
|
+
"data-slot": "chip-place",
|
|
35
|
+
...placeProps(place, left),
|
|
36
|
+
className: placeInRow,
|
|
37
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
38
|
+
className: "flex min-w-0 *:shrink-0",
|
|
39
|
+
children: place.item
|
|
40
|
+
})
|
|
41
|
+
}, place.key))
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export { ChipGroup };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** `plug`: raised, a small fitting. `flat`: a quiet wash with a faint edge, like a `Badge`. */
|
|
2
|
+
export declare const chipFace: {
|
|
3
|
+
readonly plug: "bg-raised depth-plug text-fg";
|
|
4
|
+
readonly flat: "bg-surface-quiet text-fg-body inset-ring inset-ring-current/15 forced-colors:outline";
|
|
5
|
+
};
|
|
6
|
+
export type ChipVariant = keyof typeof chipFace;
|