@lanfermann/ui 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/dist/components/action-bar/action-bar.d.ts +59 -0
  2. package/dist/components/action-bar/action-bar.js +116 -0
  3. package/dist/components/alert/alert.d.ts +1 -1
  4. package/dist/components/alert/alert.js +3 -17
  5. package/dist/components/alert-dialog/alert-dialog.d.ts +1 -1
  6. package/dist/components/app-shell/app-shell.d.ts +33 -0
  7. package/dist/components/app-shell/app-shell.js +93 -0
  8. package/dist/components/attachment/attachment.d.ts +46 -0
  9. package/dist/components/attachment/attachment.js +222 -0
  10. package/dist/components/attachment/kinds.d.ts +7 -0
  11. package/dist/components/attachment/kinds.js +100 -0
  12. package/dist/components/avatar/avatar.d.ts +14 -4
  13. package/dist/components/avatar/avatar.js +57 -13
  14. package/dist/components/avatar-group/avatar-group.d.ts +33 -0
  15. package/dist/components/avatar-group/avatar-group.js +110 -0
  16. package/dist/components/avatar-group/people.d.ts +12 -0
  17. package/dist/components/avatar-group/people.js +24 -0
  18. package/dist/components/badge/badge.d.ts +9 -3
  19. package/dist/components/badge/badge.js +21 -6
  20. package/dist/components/banner/banner.d.ts +39 -0
  21. package/dist/components/banner/banner.js +149 -0
  22. package/dist/components/card/card.d.ts +11 -3
  23. package/dist/components/card/card.js +18 -4
  24. package/dist/components/checkbox-card/checkbox-card.d.ts +21 -0
  25. package/dist/components/checkbox-card/checkbox-card.js +49 -0
  26. package/dist/components/chip/chip-group.d.ts +15 -0
  27. package/dist/components/chip/chip-group.js +44 -0
  28. package/dist/components/chip/chip-variants.d.ts +6 -0
  29. package/dist/components/chip/chip-variants.js +28 -0
  30. package/dist/components/chip/chip.d.ts +39 -0
  31. package/dist/components/chip/chip.js +71 -0
  32. package/dist/components/code-block/code-copy.d.ts +3 -11
  33. package/dist/components/code-block/code-copy.js +15 -62
  34. package/dist/components/code-block/code-keys.js +10 -22
  35. package/dist/components/combobox/combobox.d.ts +50 -2
  36. package/dist/components/combobox/combobox.js +178 -9
  37. package/dist/components/command/command.d.ts +131 -0
  38. package/dist/components/command/command.js +335 -0
  39. package/dist/components/consent/consent-card.js +365 -0
  40. package/dist/components/consent/consent-embed.d.ts +21 -0
  41. package/dist/components/consent/consent-embed.js +111 -0
  42. package/dist/components/consent/consent-labels.d.ts +70 -0
  43. package/dist/components/consent/consent-labels.js +61 -0
  44. package/dist/components/consent/consent-record.d.ts +95 -0
  45. package/dist/components/consent/consent-record.js +112 -0
  46. package/dist/components/consent/consent-store.d.ts +26 -0
  47. package/dist/components/consent/consent-store.js +240 -0
  48. package/dist/components/consent/consent.d.ts +86 -0
  49. package/dist/components/consent/consent.js +306 -0
  50. package/dist/components/container/container.d.ts +1 -1
  51. package/dist/components/context-menu/context-menu.d.ts +23 -0
  52. package/dist/components/context-menu/context-menu.js +50 -0
  53. package/dist/components/conversation/conversation.d.ts +45 -0
  54. package/dist/components/conversation/conversation.js +295 -0
  55. package/dist/components/conversation/stick.js +23 -0
  56. package/dist/components/copy-button/copy-button.d.ts +50 -0
  57. package/dist/components/copy-button/copy-button.js +65 -0
  58. package/dist/components/copy-page/copy-page.js +7 -17
  59. package/dist/components/copy-pill/copy-pill.js +1 -1
  60. package/dist/components/description-list/description-list.d.ts +32 -0
  61. package/dist/components/description-list/description-list.js +51 -0
  62. package/dist/components/empty/empty.d.ts +38 -0
  63. package/dist/components/empty/empty.js +57 -0
  64. package/dist/components/field/field.js +1 -1
  65. package/dist/components/file-upload/file-upload.d.ts +96 -0
  66. package/dist/components/file-upload/file-upload.js +347 -0
  67. package/dist/components/file-upload/files.d.ts +39 -0
  68. package/dist/components/file-upload/files.js +74 -0
  69. package/dist/components/grow/grow.d.ts +15 -3
  70. package/dist/components/grow/grow.js +24 -9
  71. package/dist/components/heading/heading.d.ts +1 -1
  72. package/dist/components/icon/icon.d.ts +1 -1
  73. package/dist/components/input/input.js +1 -1
  74. package/dist/components/message/message.d.ts +73 -0
  75. package/dist/components/message/message.js +196 -0
  76. package/dist/components/otp-field/otp-field.d.ts +37 -0
  77. package/dist/components/otp-field/otp-field.js +126 -0
  78. package/dist/components/pagination/pagination.d.ts +50 -0
  79. package/dist/components/pagination/pagination.js +188 -0
  80. package/dist/components/prompt-input/keys.js +15 -0
  81. package/dist/components/prompt-input/prompt-input.d.ts +89 -0
  82. package/dist/components/prompt-input/prompt-input.js +331 -0
  83. package/dist/components/radio-card/radio-card.d.ts +23 -0
  84. package/dist/components/radio-card/radio-card.js +48 -0
  85. package/dist/components/rolling-number/rolling-number.d.ts +30 -0
  86. package/dist/components/rolling-number/rolling-number.js +149 -0
  87. package/dist/components/seam/seam.d.ts +1 -1
  88. package/dist/components/secret-field/secret-field.d.ts +53 -0
  89. package/dist/components/secret-field/secret-field.js +121 -0
  90. package/dist/components/section/section.d.ts +1 -1
  91. package/dist/components/select/select.d.ts +1 -1
  92. package/dist/components/select/select.js +1 -1
  93. package/dist/components/shortcut/shortcut.d.ts +46 -0
  94. package/dist/components/shortcut/shortcut.js +87 -0
  95. package/dist/components/sidebar/sidebar-context.js +16 -0
  96. package/dist/components/sidebar/sidebar.d.ts +161 -0
  97. package/dist/components/sidebar/sidebar.js +588 -0
  98. package/dist/components/site-header/site-header.js +1 -1
  99. package/dist/components/skeleton/loaded.d.ts +21 -0
  100. package/dist/components/skeleton/loaded.js +57 -0
  101. package/dist/components/skeleton/skeleton.d.ts +43 -0
  102. package/dist/components/skeleton/skeleton.js +48 -0
  103. package/dist/components/sources/source-list.d.ts +17 -0
  104. package/dist/components/sources/source-list.js +26 -0
  105. package/dist/components/sources/sources.d.ts +45 -0
  106. package/dist/components/sources/sources.js +167 -0
  107. package/dist/components/stat/stat.d.ts +57 -0
  108. package/dist/components/stat/stat.js +110 -0
  109. package/dist/components/steps/steps.d.ts +57 -0
  110. package/dist/components/steps/steps.js +131 -0
  111. package/dist/components/table/table.d.ts +18 -9
  112. package/dist/components/table/table.js +21 -13
  113. package/dist/components/text/text.d.ts +1 -1
  114. package/dist/components/theme-switch/theme-switch.js +1 -1
  115. package/dist/components/time-field/time-field.js +1 -1
  116. package/dist/components/timeline/timeline.d.ts +45 -0
  117. package/dist/components/timeline/timeline.js +86 -0
  118. package/dist/components/toast/toast.js +10 -26
  119. package/dist/components/toggle/toggle.d.ts +24 -0
  120. package/dist/components/toggle/toggle.js +53 -0
  121. package/dist/components/toggle-group/toggle-group.d.ts +27 -0
  122. package/dist/components/toggle-group/toggle-group.js +38 -0
  123. package/dist/components/toolbar/toolbar-context.js +12 -0
  124. package/dist/components/toolbar/toolbar.d.ts +45 -0
  125. package/dist/components/toolbar/toolbar.js +92 -0
  126. package/dist/components/trace/trace.d.ts +2 -1
  127. package/dist/components/trace/trace.js +14 -26
  128. package/dist/index.d.ts +46 -3
  129. package/dist/index.js +44 -3
  130. package/dist/internal/arriving-pieces.js +56 -0
  131. package/dist/internal/arriving.js +171 -0
  132. package/dist/internal/avatar-cut.d.ts +15 -0
  133. package/dist/internal/avatar-cut.js +83 -0
  134. package/dist/internal/choice-card.d.ts +15 -0
  135. package/dist/internal/choice-card.js +65 -0
  136. package/dist/internal/clipboard.js +37 -0
  137. package/dist/internal/copy.js +58 -0
  138. package/dist/internal/field.js +24 -4
  139. package/dist/internal/glyphs.js +26 -1
  140. package/dist/internal/live-list.js +41 -0
  141. package/dist/internal/number-places.js +156 -0
  142. package/dist/internal/picker-sheet.js +1 -1
  143. package/dist/internal/presence-dot.js +24 -0
  144. package/dist/internal/presence.js +104 -0
  145. package/dist/internal/rail-mark.d.ts +3 -0
  146. package/dist/internal/rail-mark.js +33 -0
  147. package/dist/internal/status-icon.js +22 -0
  148. package/dist/internal/travelling-mark.js +204 -0
  149. package/dist/lib/cn.js +4 -0
  150. package/dist/lib/shortcut.d.ts +11 -0
  151. package/dist/lib/shortcut.js +165 -0
  152. package/package.json +1 -1
  153. package/src/styles/action-bar.css +28 -0
  154. package/src/styles/assistant.css +83 -0
  155. package/src/styles/avatar.css +24 -0
  156. package/src/styles/consent.css +65 -0
  157. package/src/styles/copy.css +12 -11
  158. package/src/styles/depth.css +46 -2
  159. package/src/styles/marks.css +20 -2
  160. package/src/styles/rail.css +49 -0
  161. package/src/styles/rolling-number.css +94 -0
  162. package/src/styles/steps.css +98 -0
  163. package/src/styles/timeline.css +48 -0
  164. package/src/styles/travel.css +36 -0
  165. package/src/styles.css +9 -0
@@ -29,13 +29,17 @@ function heightMoving(box) {
29
29
  * then learns of it a frame late.
30
30
  *
31
31
  * At rest it is a plain block of the content's height that clips nothing. It clips only while
32
- * it moves, so a line that joins at its foot is uncovered as the block opens. From rest it does
32
+ * it moves, and only above and below, so a line that joins at its foot is uncovered as the
33
+ * block opens. What paints outside its content there (the shadow of a card, an accent edge, a
34
+ * halo) would be cut for the length of the move and come back at its end: give it room inside
35
+ * the block and take the room back outside, `className="-my-5" contentClassName="py-5"`. To
36
+ * the sides nothing is cut. From rest it does
33
37
  * not animate the first height, a resize of the window, or a height that something inside is
34
38
  * already animating (an opening `Collapsible`): then it simply follows.
35
39
  * Already on its way, it takes a new height as its goal from where it stands. Under reduced
36
40
  * motion it always follows.
37
41
  */
38
- function Grow({ className, children, ref, ...props }) {
42
+ function Grow({ className, contentClassName, children, ref, ...props }) {
39
43
  const box = useRef(null);
40
44
  const content = useRef(null);
41
45
  useLayoutEffect(() => {
@@ -43,21 +47,31 @@ function Grow({ className, children, ref, ...props }) {
43
47
  const inner = content.current;
44
48
  if (!outer || !inner) return;
45
49
  const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");
46
- /** The content's height when it was last measured, and the window's width then. */
50
+ /** The content's height when it was last measured. */
47
51
  let height = inner.offsetHeight;
48
- let width = window.innerWidth;
52
+ /**
53
+ * The frame in which the window last changed its size. The browser runs the resize event and
54
+ * then the size observers in the same frame, so a measure in that frame was caused by the
55
+ * resize. (A width remembered from the last measure went stale when the window was resized
56
+ * without this content changing, and the next real change was then taken for a resize.)
57
+ */
58
+ const frame = () => Number(document.timeline.currentTime ?? performance.now());
59
+ let resizedIn = NaN;
60
+ const resized = () => {
61
+ resizedIn = frame();
62
+ };
63
+ window.addEventListener("resize", resized);
49
64
  const rest = () => {
50
65
  delete outer.dataset.moving;
51
66
  outer.style.height = "";
52
67
  };
53
68
  const observer = new ResizeObserver(() => {
54
69
  const nextHeight = inner.offsetHeight;
55
- const nextWidth = window.innerWidth;
56
70
  const moving = outer.dataset.moving !== void 0;
57
71
  const from = moving ? outer.getBoundingClientRect().height : height;
58
- const follow = reduced.matches || nextWidth !== width || movingInside(inner);
72
+ const resizing = frame() === resizedIn;
73
+ const follow = reduced.matches || resizing || movingInside(inner);
59
74
  height = nextHeight;
60
- width = nextWidth;
61
75
  if (Math.abs(nextHeight - from) < .5) {
62
76
  if (moving) rest();
63
77
  return;
@@ -83,6 +97,7 @@ function Grow({ className, children, ref, ...props }) {
83
97
  outer.addEventListener("transitioncancel", arrived);
84
98
  return () => {
85
99
  observer.disconnect();
100
+ window.removeEventListener("resize", resized);
86
101
  outer.removeEventListener("transitionend", arrived);
87
102
  outer.removeEventListener("transitioncancel", arrived);
88
103
  rest();
@@ -91,12 +106,12 @@ function Grow({ className, children, ref, ...props }) {
91
106
  return /* @__PURE__ */ jsx("div", {
92
107
  ref: mergeRefs(box, ref),
93
108
  "data-slot": "grow",
94
- className: cn("transition-[height] spring-settle data-moving:overflow-clip", className),
109
+ className: cn("[transition:height_var(--transition-duration-spring-settle)_var(--ease-spring-settle),var(--grow-also,visibility_0s)] data-moving:overflow-y-clip", className),
95
110
  ...props,
96
111
  children: /* @__PURE__ */ jsx("div", {
97
112
  ref: content,
98
113
  "data-slot": "grow-content",
99
- className: "flow-root",
114
+ className: cn("flow-root", contentClassName),
100
115
  children
101
116
  })
102
117
  });
@@ -1,5 +1,5 @@
1
- import { VariantProps } from "class-variance-authority";
2
1
  import { ComponentProps } from "react";
2
+ import { VariantProps } from "class-variance-authority";
3
3
  declare const headingVariants: (props?: ({
4
4
  size?: "label" | "section" | "sub" | "title" | "display" | null | undefined;
5
5
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,5 +1,5 @@
1
- import { IconSvgElement } from "@hugeicons/react";
2
1
  import { SVGProps } from "react";
2
+ import { IconSvgElement } from "@hugeicons/react";
3
3
  export type IconProps = Omit<SVGProps<SVGSVGElement>, "ref" | "stroke" | "strokeWidth"> & {
4
4
  /** An icon from `@hugeicons/core-free-icons`, e.g. `Search01Icon`. */
5
5
  icon: IconSvgElement;
@@ -3,8 +3,8 @@ import { bareControl, fieldFace, fieldText } from "../../internal/field.js";
3
3
  import { FieldShellContext } from "../../internal/field-context.js";
4
4
  import { mergeClassName } from "../../lib/cn.js";
5
5
  import { jsx } from "react/jsx-runtime";
6
- import { cva } from "class-variance-authority";
7
6
  import { useContext } from "react";
7
+ import { cva } from "class-variance-authority";
8
8
  import { Input as Input$1 } from "@base-ui/react/input";
9
9
  // src/components/input/input.tsx
10
10
  /**
@@ -0,0 +1,73 @@
1
+ import { ButtonProps } from "../button/button.js";
2
+ import { IconSvgElement } from "../icon/icon.js";
3
+ import { ComponentProps, ReactNode } from "react";
4
+ /** Who wrote a message: the assistant, or the person using it. */
5
+ export type MessageFrom = "assistant" | "user";
6
+ export type MessageProps = ComponentProps<"article"> & {
7
+ from: MessageFrom;
8
+ /** The answer is still being written: its text arrives, and its actions wait. */
9
+ streaming?: boolean;
10
+ /** Who wrote it, for assistive tech: „KI“ for the assistant, „Du“ for the person. */
11
+ label?: string;
12
+ };
13
+ /**
14
+ * One message of a conversation with an assistant. The answer is read, so it is flat prose on
15
+ * the page, with no bubble and no avatar; the person's own words are someone else's to the
16
+ * page, so they stand on the tint at the right, in the bubble of a `Quote` (Justin,
17
+ * 2026-11-19). Put a `MessageContent` inside, and under an answer its `MessageActions`.
18
+ *
19
+ * In a `Conversation`, a message of the person's that joins rises into place, and brings the
20
+ * view back to the foot: whoever sends a prompt wants to see the answer.
21
+ */
22
+ export declare function Message({ from, streaming, label, className, children, ...props }: MessageProps): import("react").JSX.Element;
23
+ export type MessageContentProps = ComponentProps<"div">;
24
+ /**
25
+ * What a message says. In an answer it is `Prose`: hand over the rendered Markdown (the
26
+ * elements, not a component that renders the Markdown itself), and while the message is
27
+ * `streaming` what is new fades in, a few words at a time; code and pictures arrive whole.
28
+ * The person's words stand as they were typed, line breaks kept.
29
+ */
30
+ export declare function MessageContent({ className, children, ref, ...props }: MessageContentProps): import("react").JSX.Element;
31
+ /**
32
+ * The keys under an answer: copy (`CopyButton`), the verdict (`MessageFeedback`), „Noch
33
+ * einmal“ (`MessageAction`). They are always there, not only under the pointer, so a finger and
34
+ * the keyboard reach them. While the answer is written they wait unseen, and come in together
35
+ * once it is complete; their room is kept, so nothing moves when they do.
36
+ */
37
+ export declare function MessageActions({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
38
+ export type MessageActionProps = Omit<ButtonProps, "iconOnly" | "variant" | "size" | "children" | "aria-label"> & {
39
+ /** What the key does, as a button says it: its name and its tooltip. */
40
+ label: string;
41
+ icon: IconSvgElement;
42
+ };
43
+ /**
44
+ * A quiet key under an answer, with a symbol and a tooltip: „Noch einmal“, „Teilen“. Its name
45
+ * is its tooltip, worded like a button.
46
+ */
47
+ export declare function MessageAction({ label, icon, className, ...props }: MessageActionProps): import("react").JSX.Element;
48
+ /** The person's verdict on an answer: good, bad, or none yet. */
49
+ export type MessageVerdict = "good" | "bad" | null;
50
+ export type MessageFeedbackProps = Omit<ComponentProps<"div">, "defaultValue" | "onChange"> & {
51
+ value?: MessageVerdict;
52
+ defaultValue?: MessageVerdict;
53
+ onValueChange?: (value: MessageVerdict) => void;
54
+ goodLabel?: string;
55
+ badLabel?: string;
56
+ };
57
+ /**
58
+ * Two keys that stay down, thumbs up and thumbs down: at most one is on, and pressed again it
59
+ * is taken back. The symbol of the key that is turned on seats into it with a small nod.
60
+ */
61
+ export declare function MessageFeedback({ value: valueProp, defaultValue, onValueChange, goodLabel, badLabel, className, ...props }: MessageFeedbackProps): import("react").JSX.Element;
62
+ export type MessageErrorProps = Omit<ComponentProps<"div">, "children"> & {
63
+ /** What happened, as a sentence. */
64
+ children?: ReactNode;
65
+ /** Asks for the answer again. Without it there is no key. */
66
+ onRetry?: () => void;
67
+ retryLabel?: string;
68
+ };
69
+ /**
70
+ * An answer that failed: the danger symbol, what happened in a sentence, and the next step as
71
+ * a key. Nothing shakes and no colour flashes; the words carry it.
72
+ */
73
+ export declare function MessageError({ children, onRetry, retryLabel, className, ...props }: MessageErrorProps): import("react").JSX.Element;
@@ -0,0 +1,196 @@
1
+ "use client";
2
+ import { Button } from "../button/button.js";
3
+ import { useConversation } from "../conversation/conversation.js";
4
+ import { Icon } from "../icon/icon.js";
5
+ import { Toggle } from "../toggle/toggle.js";
6
+ import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip/tooltip.js";
7
+ import { useArrivingText } from "../../internal/arriving.js";
8
+ import { useLive } from "../../internal/presence.js";
9
+ import { cn } from "../../lib/cn.js";
10
+ import { mergeRefs } from "../../lib/merge-refs.js";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
13
+ import { Alert02Icon, RefreshIcon, ThumbsDownIcon, ThumbsUpIcon } from "@hugeicons/core-free-icons";
14
+ // src/components/message/message.tsx
15
+ const MessageContext = createContext({
16
+ from: "assistant",
17
+ streaming: false
18
+ });
19
+ /**
20
+ * One message of a conversation with an assistant. The answer is read, so it is flat prose on
21
+ * the page, with no bubble and no avatar; the person's own words are someone else's to the
22
+ * page, so they stand on the tint at the right, in the bubble of a `Quote` (Justin,
23
+ * 2026-11-19). Put a `MessageContent` inside, and under an answer its `MessageActions`.
24
+ *
25
+ * In a `Conversation`, a message of the person's that joins rises into place, and brings the
26
+ * view back to the foot: whoever sends a prompt wants to see the answer.
27
+ */
28
+ function Message({ from, streaming = false, label = from === "user" ? "Du" : "KI", className, children, ...props }) {
29
+ const conversation = useConversation();
30
+ const joined = useRef(conversation?.live ?? false);
31
+ useLayoutEffect(() => {
32
+ if (from === "user" && joined.current) conversation?.toLatest();
33
+ }, []);
34
+ return /* @__PURE__ */ jsx(MessageContext, {
35
+ value: {
36
+ from,
37
+ streaming
38
+ },
39
+ children: /* @__PURE__ */ jsx("article", {
40
+ "data-slot": "message",
41
+ "data-from": from,
42
+ "data-streaming": streaming ? "" : void 0,
43
+ "aria-label": label,
44
+ className: cn("flex min-w-0 flex-col", from === "user" ? ["items-end gap-2", "transition-[opacity,translate] spring-settle in-data-live:starting:translate-y-(--motion-enter-offset) in-data-live:starting:opacity-0"] : "items-start gap-3", className),
45
+ ...props,
46
+ children
47
+ })
48
+ });
49
+ }
50
+ /**
51
+ * What a message says. In an answer it is `Prose`: hand over the rendered Markdown (the
52
+ * elements, not a component that renders the Markdown itself), and while the message is
53
+ * `streaming` what is new fades in, a few words at a time; code and pictures arrive whole.
54
+ * The person's words stand as they were typed, line breaks kept.
55
+ */
56
+ function MessageContent({ className, children, ref, ...props }) {
57
+ const { from, streaming } = useContext(MessageContext);
58
+ const box = useRef(null);
59
+ const conversation = useConversation();
60
+ const content = useArrivingText(children, {
61
+ streaming: from === "assistant" && streaming,
62
+ box
63
+ });
64
+ const wasStreaming = useRef(streaming);
65
+ useEffect(() => {
66
+ if (wasStreaming.current && !streaming && from === "assistant") {
67
+ const text = box.current?.textContent?.trim();
68
+ if (text) conversation?.announce(text);
69
+ }
70
+ wasStreaming.current = streaming;
71
+ }, [
72
+ streaming,
73
+ from,
74
+ conversation
75
+ ]);
76
+ if (from === "user") return /* @__PURE__ */ jsx("div", {
77
+ ref: mergeRefs(box, ref),
78
+ "data-slot": "message-content",
79
+ className: cn("max-w-[min(80%,36rem)] text-base break-words whitespace-pre-wrap text-fg", "rounded-2xl rounded-tr-sm bg-tint px-4 py-2.5", className),
80
+ ...props,
81
+ children
82
+ });
83
+ return /* @__PURE__ */ jsx("div", {
84
+ ref: mergeRefs(box, ref),
85
+ "data-slot": "message-content",
86
+ "aria-busy": streaming || void 0,
87
+ className: cn("prose w-full max-w-[42rem] min-w-0", className),
88
+ ...props,
89
+ children: content
90
+ });
91
+ }
92
+ /**
93
+ * The keys under an answer: copy (`CopyButton`), the verdict (`MessageFeedback`), „Noch
94
+ * einmal“ (`MessageAction`). They are always there, not only under the pointer, so a finger and
95
+ * the keyboard reach them. While the answer is written they wait unseen, and come in together
96
+ * once it is complete; their room is kept, so nothing moves when they do.
97
+ */
98
+ function MessageActions({ className, ...props }) {
99
+ const { streaming } = useContext(MessageContext);
100
+ return /* @__PURE__ */ jsx("div", {
101
+ "data-slot": "message-actions",
102
+ inert: streaming,
103
+ className: cn("-ml-1 flex items-center gap-0.5", "transition-opacity spring-settle in-data-live:starting:opacity-0", streaming && "opacity-0", className),
104
+ ...props
105
+ });
106
+ }
107
+ /**
108
+ * A quiet key under an answer, with a symbol and a tooltip: „Noch einmal“, „Teilen“. Its name
109
+ * is its tooltip, worded like a button.
110
+ */
111
+ function MessageAction({ label, icon, className, ...props }) {
112
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx(Button, {
113
+ iconOnly: true,
114
+ size: "sm",
115
+ variant: "quiet",
116
+ "aria-label": label,
117
+ "data-slot": "message-action",
118
+ className: cn("text-fg-muted hover:text-fg", className),
119
+ ...props,
120
+ children: /* @__PURE__ */ jsx(Icon, {
121
+ icon,
122
+ size: 14
123
+ })
124
+ }) }), /* @__PURE__ */ jsx(TooltipContent, { children: label })] });
125
+ }
126
+ /**
127
+ * Two keys that stay down, thumbs up and thumbs down: at most one is on, and pressed again it
128
+ * is taken back. The symbol of the key that is turned on seats into it with a small nod.
129
+ */
130
+ function MessageFeedback({ value: valueProp, defaultValue = null, onValueChange, goodLabel = "Gute Antwort", badLabel = "Schlechte Antwort", className, ...props }) {
131
+ const [own, setOwn] = useState(defaultValue);
132
+ const value = valueProp === void 0 ? own : valueProp;
133
+ const live = useLive();
134
+ const choose = (next) => {
135
+ setOwn(next);
136
+ onValueChange?.(next);
137
+ };
138
+ const key = (verdict, label, icon) => {
139
+ const on = value === verdict;
140
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx(Toggle, {
141
+ iconOnly: true,
142
+ size: "sm",
143
+ variant: "quiet",
144
+ "aria-label": label,
145
+ pressed: on,
146
+ onPressedChange: (pressed) => choose(pressed ? verdict : null),
147
+ children: /* @__PURE__ */ jsx(Icon, {
148
+ icon,
149
+ size: 14,
150
+ "data-slot": "message-feedback-symbol",
151
+ className: cn("transition-[scale,rotate] spring-seat", on && (verdict === "good" ? "in-data-live:motion-safe:starting:scale-75 in-data-live:motion-safe:starting:-rotate-12" : "in-data-live:motion-safe:starting:scale-75 in-data-live:motion-safe:starting:rotate-12"))
152
+ }, on ? "on" : "off")
153
+ }) }), /* @__PURE__ */ jsx(TooltipContent, { children: label })] });
154
+ };
155
+ return /* @__PURE__ */ jsxs("div", {
156
+ role: "group",
157
+ "aria-label": `${goodLabel} oder ${badLabel}`,
158
+ "data-slot": "message-feedback",
159
+ "data-live": live ? "" : void 0,
160
+ className: cn("flex items-center gap-0.5", className),
161
+ ...props,
162
+ children: [key("good", goodLabel, ThumbsUpIcon), key("bad", badLabel, ThumbsDownIcon)]
163
+ });
164
+ }
165
+ /**
166
+ * An answer that failed: the danger symbol, what happened in a sentence, and the next step as
167
+ * a key. Nothing shakes and no colour flashes; the words carry it.
168
+ */
169
+ function MessageError({ children = "Die Antwort ist abgebrochen.", onRetry, retryLabel = "Noch einmal", className, ...props }) {
170
+ return /* @__PURE__ */ jsxs("div", {
171
+ role: "alert",
172
+ "data-slot": "message-error",
173
+ className: cn("flex items-start gap-2.5 text-control text-fg", className),
174
+ ...props,
175
+ children: [/* @__PURE__ */ jsx(Icon, {
176
+ icon: Alert02Icon,
177
+ size: 16,
178
+ className: "mt-[0.1875rem] shrink-0 text-danger"
179
+ }), /* @__PURE__ */ jsxs("div", {
180
+ className: "flex min-w-0 flex-col items-start gap-2.5",
181
+ children: [/* @__PURE__ */ jsx("p", {
182
+ className: "text-pretty",
183
+ children
184
+ }), onRetry && /* @__PURE__ */ jsxs(Button, {
185
+ size: "sm",
186
+ variant: "secondary",
187
+ onClick: onRetry,
188
+ children: [/* @__PURE__ */ jsx(Icon, {
189
+ icon: RefreshIcon,
190
+ size: 14
191
+ }), retryLabel]
192
+ })]
193
+ })]
194
+ });
195
+ }
196
+ export { Message, MessageAction, MessageActions, MessageContent, MessageError, MessageFeedback };
@@ -0,0 +1,37 @@
1
+ import { OTPField } from "@base-ui/react/otp-field";
2
+ export type OtpFieldProps = Omit<OTPField.Root.Props, "children" | "className" | "length" | "render"> & {
3
+ /** How many characters the code has. Six unless said otherwise. */
4
+ length?: number;
5
+ /**
6
+ * How many slots stand together before a short line sets the next ones apart: 3 writes six
7
+ * digits as "123 456", the way a code is read out. 0 keeps them in one row.
8
+ */
9
+ groupSize?: number;
10
+ /**
11
+ * `joined` (the default): the slots of a group share one socket, divided by hairlines.
12
+ * `separate`: every slot is a socket of its own.
13
+ */
14
+ variant?: "joined" | "separate";
15
+ /**
16
+ * The slots share the width of the field's place instead of keeping their own: for a dialog
17
+ * or a narrow card, where six small slots would leave half the line empty.
18
+ */
19
+ fill?: boolean;
20
+ /** What a slot after the first is called for assistive tech: "Ziffer 2 von 6". */
21
+ slotLabel?: (position: number, length: number) => string;
22
+ className?: string;
23
+ };
24
+ /**
25
+ * A one-time code: the six digits from a text message or an authenticator app. Every character
26
+ * has a slot, in threes, the way a code is read out. The slot that is being typed wears the
27
+ * field's halo, and a digit seats into its slot as it arrives. A pasted code, or one the phone
28
+ * offers from a message, fills every slot.
29
+ *
30
+ * Label it with a `FieldLabel` in a `Field` ("Bestätigungscode") and say in a
31
+ * `FieldDescription` where the code was sent. A wrong code is said in words under the field
32
+ * (`FieldError`); the field does not shake. `onValueComplete` tells when the last slot is
33
+ * filled, `autoSubmit` sends the form then.
34
+ *
35
+ * It takes digits. `validationType="alphanumeric"` lets letters in, for a recovery code.
36
+ */
37
+ export declare function OtpField({ length, groupSize, variant, fill, mask, slotLabel, className, onValueChange, onFocus, onBlur, ...props }: OtpFieldProps): import("react").JSX.Element;
@@ -0,0 +1,126 @@
1
+ "use client";
2
+ import { fieldFace } from "../../internal/field.js";
3
+ import { useLive } from "../../internal/presence.js";
4
+ import { cn } from "../../lib/cn.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Fragment as Fragment$1, useEffect, useRef, useState } from "react";
7
+ import { OTPField } from "@base-ui/react/otp-field";
8
+ // src/components/otp-field/otp-field.tsx
9
+ /** How long a halo takes to open (`snap`), after which it hops between slots at once. */
10
+ const ENTERED_MS = 140;
11
+ /** How long the slots count as filled in one go, so the digits of a paste seat one by one. */
12
+ const BURST_MS = 480;
13
+ /** A slot that is a socket of its own. */
14
+ const separateSlot = [
15
+ "rounded-md",
16
+ fieldFace,
17
+ "has-[input:focus]:depth-field-focus",
18
+ "has-[input[data-invalid]]:depth-field-invalid has-[input[data-invalid]:focus]:depth-field-invalid",
19
+ "has-[input[data-invalid]:not(:focus)]:[--depth-field-halo-danger:transparent]",
20
+ "has-[input[data-disabled]]:bg-disabled has-[input[data-disabled]]:depth-flat"
21
+ ].join(" ");
22
+ /**
23
+ * The socket that the slots of a group share. Invalid, it takes the danger edge without the
24
+ * halo, as the separate slots do: only the slot being typed opens one.
25
+ */
26
+ const joinedGroup = [
27
+ "rounded-md bg-surface depth-field",
28
+ "has-[input[data-invalid]]:[--depth-field-edge:var(--lf-danger)]",
29
+ "has-[input[data-disabled]]:bg-disabled has-[input[data-disabled]]:depth-flat"
30
+ ].join(" ");
31
+ /** A slot inside that socket: a hairline to its left, and the halo is its own. */
32
+ const joinedSlot = [
33
+ "border-hairline not-first:border-l first:rounded-l-md last:rounded-r-md",
34
+ "transition-[box-shadow] spring-snap has-[input:focus]:z-1 has-[input:focus]:shadow-field-focus",
35
+ "has-[input[data-invalid]:focus]:shadow-field-invalid"
36
+ ].join(" ");
37
+ /**
38
+ * A one-time code: the six digits from a text message or an authenticator app. Every character
39
+ * has a slot, in threes, the way a code is read out. The slot that is being typed wears the
40
+ * field's halo, and a digit seats into its slot as it arrives. A pasted code, or one the phone
41
+ * offers from a message, fills every slot.
42
+ *
43
+ * Label it with a `FieldLabel` in a `Field` ("Bestätigungscode") and say in a
44
+ * `FieldDescription` where the code was sent. A wrong code is said in words under the field
45
+ * (`FieldError`); the field does not shake. `onValueComplete` tells when the last slot is
46
+ * filled, `autoSubmit` sends the form then.
47
+ *
48
+ * It takes digits. `validationType="alphanumeric"` lets letters in, for a recovery code.
49
+ */
50
+ function OtpField({ length = 6, groupSize = 3, variant = "joined", fill = false, mask = false, slotLabel = (position, total) => `Ziffer ${position} von ${total}`, className, onValueChange, onFocus, onBlur, ...props }) {
51
+ const live = useLive();
52
+ const [entered, setEntered] = useState(false);
53
+ const entering = useRef(void 0);
54
+ const [burst, setBurst] = useState(false);
55
+ const bursting = useRef(void 0);
56
+ const lastLength = useRef((props.value ?? props.defaultValue ?? "").length);
57
+ useEffect(() => () => {
58
+ clearTimeout(entering.current);
59
+ clearTimeout(bursting.current);
60
+ }, []);
61
+ const groups = [];
62
+ for (let index = 0; index < length; index++) {
63
+ const group = groupSize > 0 ? Math.floor(index / groupSize) : 0;
64
+ (groups[group] ??= []).push(index);
65
+ }
66
+ return /* @__PURE__ */ jsx(OTPField.Root, {
67
+ "data-slot": "otp-field",
68
+ "data-variant": variant,
69
+ "data-live": live ? "" : void 0,
70
+ "data-entered": entered ? "" : void 0,
71
+ "data-burst": burst ? "" : void 0,
72
+ length,
73
+ mask,
74
+ "data-fill": fill ? "" : void 0,
75
+ className: cn("group/otp items-center gap-2", fill ? "flex w-full" : "inline-flex w-fit", className),
76
+ onValueChange: (value, details) => {
77
+ if (value.length - lastLength.current > 1) {
78
+ clearTimeout(bursting.current);
79
+ setBurst(true);
80
+ bursting.current = setTimeout(() => setBurst(false), BURST_MS);
81
+ }
82
+ lastLength.current = value.length;
83
+ onValueChange?.(value, details);
84
+ },
85
+ onFocus: (event) => {
86
+ clearTimeout(entering.current);
87
+ entering.current = setTimeout(() => setEntered(true), ENTERED_MS);
88
+ onFocus?.(event);
89
+ },
90
+ onBlur: (event) => {
91
+ if (!event.currentTarget.contains(event.relatedTarget)) {
92
+ clearTimeout(entering.current);
93
+ setEntered(false);
94
+ }
95
+ onBlur?.(event);
96
+ },
97
+ ...props,
98
+ children: groups.map((slots, group) => /* @__PURE__ */ jsxs(Fragment$1, { children: [group > 0 && /* @__PURE__ */ jsx(OTPField.Separator, {
99
+ "data-slot": "otp-field-separator",
100
+ className: "h-px w-2 shrink-0 bg-line forced-colors:bg-[CanvasText]"
101
+ }), /* @__PURE__ */ jsx("span", {
102
+ "data-slot": "otp-field-group",
103
+ className: cn("flex", variant === "joined" ? joinedGroup : "gap-1.5", fill && "min-w-0 flex-1"),
104
+ children: slots.map((index) => /* @__PURE__ */ jsx(OTPField.Input, {
105
+ "aria-label": index === 0 ? void 0 : slotLabel(index + 1, length),
106
+ render: (inputProps, state) => /* @__PURE__ */ jsxs("span", {
107
+ "data-slot": "otp-field-slot",
108
+ "data-filled": state.filled ? "" : void 0,
109
+ style: { "--slot": index },
110
+ className: cn("relative inline-grid h-(--control-lg) place-items-center", fill ? "min-w-0 flex-1" : "w-(--control-lg)", variant === "joined" ? joinedSlot : separateSlot, "group-data-entered/otp:transition-none"),
111
+ children: [/* @__PURE__ */ jsx("input", {
112
+ ...inputProps,
113
+ "data-slot": "otp-field-input",
114
+ className: "absolute inset-0 size-full rounded-[inherit] bg-transparent text-center text-lg text-transparent caret-accent selection:bg-transparent focus:outline-hidden forced-colors:text-[FieldText]"
115
+ }), state.value !== "" && /* @__PURE__ */ jsx("span", {
116
+ "aria-hidden": true,
117
+ "data-slot": "otp-field-digit",
118
+ className: cn("pointer-events-none relative text-lg font-medium text-fg tabular-nums forced-colors:hidden", "group-has-[input[data-disabled]]/otp:text-on-disabled", "transition-[scale,opacity] spring-seat in-data-live:starting:scale-90 in-data-live:starting:opacity-40", "in-data-burst:delay-[calc(var(--slot)*35ms)] in-data-burst:in-data-live:starting:opacity-0", mask && "size-2 rounded-full bg-current"),
119
+ children: mask ? null : state.value
120
+ }, state.value)]
121
+ })
122
+ }, index))
123
+ })] }, slots[0]))
124
+ });
125
+ }
126
+ export { OtpField };
@@ -0,0 +1,50 @@
1
+ import { ComponentProps, MouseEvent, ReactNode } from "react";
2
+ export type PaginationProps = Omit<ComponentProps<"nav">, "children"> & {
3
+ /** The page that shows, counted from 1. */
4
+ page: number;
5
+ /** How many pages there are. */
6
+ pages: number;
7
+ /**
8
+ * Where a page lives. With it every number is a real link, so a page can be opened in a new
9
+ * tab, sent to someone and found again with the Back button. Keep the page in the address.
10
+ *
11
+ * A pattern in which `{page}` stands for the number (`"/angebote?seite={page}"`), or a
12
+ * function. From a Server Component only the pattern can be handed in.
13
+ */
14
+ href?: string | ((page: number) => string);
15
+ /**
16
+ * Called with the page that was asked for. Without `href` the numbers are buttons and this is
17
+ * all that happens; with it, call `event.preventDefault()` here if a router takes over.
18
+ */
19
+ onPageChange?: (page: number, event: MouseEvent<HTMLElement>) => void;
20
+ /**
21
+ * `numbered` (the default): the pages as numbers, the current one on the tint. `compact`:
22
+ * "Seite 3 von 12" and two arrows, for a narrow place or a list nobody jumps around in.
23
+ */
24
+ variant?: "numbered" | "compact";
25
+ /** How many numbers stand to each side of the current one. */
26
+ siblings?: number;
27
+ /** The name of the navigation for assistive tech. */
28
+ "aria-label"?: string;
29
+ /** What a page number is called: "Seite 3". A pattern (`"Page {page}"`) or a function. */
30
+ pageLabel?: string | ((page: number) => string);
31
+ /**
32
+ * The line of the compact form: "Seite 3 von 12". A pattern (`"Page {page} of {pages}"`) or a
33
+ * function.
34
+ */
35
+ positionLabel?: string | ((page: number, pages: number) => ReactNode);
36
+ /** The name of the arrow that goes one page back. */
37
+ previousLabel?: string;
38
+ /** The name of the arrow that goes one page on. */
39
+ nextLabel?: string;
40
+ };
41
+ /**
42
+ * The pages of a long list. The page that shows stands on the tint, and the tint travels to
43
+ * the next number when the page changes. The row keeps its width from the first page to the
44
+ * last, so the arrows stay under the pointer while one pages through.
45
+ *
46
+ * Give it `href` wherever the page is part of the address, which is nearly always: the numbers
47
+ * are then links. Say beside it what the pages hold ("21 bis 40 von 248 Angeboten"); that
48
+ * line is yours to word.
49
+ */
50
+ export declare function Pagination({ page, pages, href, onPageChange, variant, siblings, "aria-label": label, pageLabel, positionLabel, previousLabel, nextLabel, className, ...props }: PaginationProps): import("react").JSX.Element;