@lanfermann/ui 0.4.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 (177) 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-block-live.d.ts +13 -1
  33. package/dist/components/code-block/code-block-live.js +10 -4
  34. package/dist/components/code-block/code-block.d.ts +1 -0
  35. package/dist/components/code-block/code-copy.d.ts +3 -11
  36. package/dist/components/code-block/code-copy.js +15 -62
  37. package/dist/components/code-block/code-keys.js +10 -22
  38. package/dist/components/code-block/code-lines-live.d.ts +7 -0
  39. package/dist/components/code-block/code-lines-live.js +167 -0
  40. package/dist/components/code-block/code-lines-view.d.ts +1 -0
  41. package/dist/components/code-block/code-lines-view.js +50 -18
  42. package/dist/components/code-block/code-lines.d.ts +3 -0
  43. package/dist/components/code-block/code-tabs.d.ts +1 -0
  44. package/dist/components/code-block/highlight.d.ts +1 -0
  45. package/dist/components/code-block/line-diff.js +135 -0
  46. package/dist/components/combobox/combobox.d.ts +50 -2
  47. package/dist/components/combobox/combobox.js +178 -9
  48. package/dist/components/command/command.d.ts +131 -0
  49. package/dist/components/command/command.js +335 -0
  50. package/dist/components/consent/consent-card.js +365 -0
  51. package/dist/components/consent/consent-embed.d.ts +21 -0
  52. package/dist/components/consent/consent-embed.js +111 -0
  53. package/dist/components/consent/consent-labels.d.ts +70 -0
  54. package/dist/components/consent/consent-labels.js +61 -0
  55. package/dist/components/consent/consent-record.d.ts +95 -0
  56. package/dist/components/consent/consent-record.js +112 -0
  57. package/dist/components/consent/consent-store.d.ts +26 -0
  58. package/dist/components/consent/consent-store.js +240 -0
  59. package/dist/components/consent/consent.d.ts +86 -0
  60. package/dist/components/consent/consent.js +306 -0
  61. package/dist/components/container/container.d.ts +1 -1
  62. package/dist/components/context-menu/context-menu.d.ts +23 -0
  63. package/dist/components/context-menu/context-menu.js +50 -0
  64. package/dist/components/conversation/conversation.d.ts +45 -0
  65. package/dist/components/conversation/conversation.js +295 -0
  66. package/dist/components/conversation/stick.js +23 -0
  67. package/dist/components/copy-button/copy-button.d.ts +50 -0
  68. package/dist/components/copy-button/copy-button.js +65 -0
  69. package/dist/components/copy-page/copy-page.js +7 -17
  70. package/dist/components/copy-pill/copy-pill.js +1 -1
  71. package/dist/components/description-list/description-list.d.ts +32 -0
  72. package/dist/components/description-list/description-list.js +51 -0
  73. package/dist/components/empty/empty.d.ts +38 -0
  74. package/dist/components/empty/empty.js +57 -0
  75. package/dist/components/field/field.js +1 -1
  76. package/dist/components/file-upload/file-upload.d.ts +96 -0
  77. package/dist/components/file-upload/file-upload.js +347 -0
  78. package/dist/components/file-upload/files.d.ts +39 -0
  79. package/dist/components/file-upload/files.js +74 -0
  80. package/dist/components/grow/grow.d.ts +15 -3
  81. package/dist/components/grow/grow.js +31 -10
  82. package/dist/components/heading/heading.d.ts +1 -1
  83. package/dist/components/icon/icon.d.ts +1 -1
  84. package/dist/components/input/input.js +1 -1
  85. package/dist/components/message/message.d.ts +73 -0
  86. package/dist/components/message/message.js +196 -0
  87. package/dist/components/otp-field/otp-field.d.ts +37 -0
  88. package/dist/components/otp-field/otp-field.js +126 -0
  89. package/dist/components/pagination/pagination.d.ts +50 -0
  90. package/dist/components/pagination/pagination.js +188 -0
  91. package/dist/components/prompt-input/keys.js +15 -0
  92. package/dist/components/prompt-input/prompt-input.d.ts +89 -0
  93. package/dist/components/prompt-input/prompt-input.js +331 -0
  94. package/dist/components/radio-card/radio-card.d.ts +23 -0
  95. package/dist/components/radio-card/radio-card.js +48 -0
  96. package/dist/components/rolling-number/rolling-number.d.ts +30 -0
  97. package/dist/components/rolling-number/rolling-number.js +149 -0
  98. package/dist/components/seam/seam.d.ts +1 -1
  99. package/dist/components/secret-field/secret-field.d.ts +53 -0
  100. package/dist/components/secret-field/secret-field.js +121 -0
  101. package/dist/components/section/section.d.ts +1 -1
  102. package/dist/components/select/select.d.ts +1 -1
  103. package/dist/components/select/select.js +1 -1
  104. package/dist/components/shortcut/shortcut.d.ts +46 -0
  105. package/dist/components/shortcut/shortcut.js +87 -0
  106. package/dist/components/sidebar/sidebar-context.js +16 -0
  107. package/dist/components/sidebar/sidebar.d.ts +161 -0
  108. package/dist/components/sidebar/sidebar.js +588 -0
  109. package/dist/components/site-header/site-header.js +1 -1
  110. package/dist/components/skeleton/loaded.d.ts +21 -0
  111. package/dist/components/skeleton/loaded.js +57 -0
  112. package/dist/components/skeleton/skeleton.d.ts +43 -0
  113. package/dist/components/skeleton/skeleton.js +48 -0
  114. package/dist/components/sources/source-list.d.ts +17 -0
  115. package/dist/components/sources/source-list.js +26 -0
  116. package/dist/components/sources/sources.d.ts +45 -0
  117. package/dist/components/sources/sources.js +167 -0
  118. package/dist/components/stat/stat.d.ts +57 -0
  119. package/dist/components/stat/stat.js +110 -0
  120. package/dist/components/steps/steps.d.ts +57 -0
  121. package/dist/components/steps/steps.js +131 -0
  122. package/dist/components/table/table.d.ts +18 -9
  123. package/dist/components/table/table.js +21 -13
  124. package/dist/components/text/text.d.ts +1 -1
  125. package/dist/components/theme-switch/theme-switch.js +1 -1
  126. package/dist/components/time-field/time-field.js +1 -1
  127. package/dist/components/timeline/timeline.d.ts +45 -0
  128. package/dist/components/timeline/timeline.js +86 -0
  129. package/dist/components/toast/toast.js +10 -26
  130. package/dist/components/toggle/toggle.d.ts +24 -0
  131. package/dist/components/toggle/toggle.js +53 -0
  132. package/dist/components/toggle-group/toggle-group.d.ts +27 -0
  133. package/dist/components/toggle-group/toggle-group.js +38 -0
  134. package/dist/components/toolbar/toolbar-context.js +12 -0
  135. package/dist/components/toolbar/toolbar.d.ts +45 -0
  136. package/dist/components/toolbar/toolbar.js +92 -0
  137. package/dist/components/trace/trace.d.ts +2 -1
  138. package/dist/components/trace/trace.js +14 -26
  139. package/dist/index.d.ts +46 -3
  140. package/dist/index.js +44 -3
  141. package/dist/internal/arriving-pieces.js +56 -0
  142. package/dist/internal/arriving.js +171 -0
  143. package/dist/internal/avatar-cut.d.ts +15 -0
  144. package/dist/internal/avatar-cut.js +83 -0
  145. package/dist/internal/choice-card.d.ts +15 -0
  146. package/dist/internal/choice-card.js +65 -0
  147. package/dist/internal/clipboard.js +37 -0
  148. package/dist/internal/copy.js +58 -0
  149. package/dist/internal/field.js +24 -4
  150. package/dist/internal/glyphs.js +26 -1
  151. package/dist/internal/live-list.js +41 -0
  152. package/dist/internal/number-places.js +156 -0
  153. package/dist/internal/picker-sheet.js +1 -1
  154. package/dist/internal/presence-dot.js +24 -0
  155. package/dist/internal/presence.js +104 -0
  156. package/dist/internal/rail-mark.d.ts +3 -0
  157. package/dist/internal/rail-mark.js +33 -0
  158. package/dist/internal/status-icon.js +22 -0
  159. package/dist/internal/travelling-mark.js +204 -0
  160. package/dist/lib/cn.js +4 -0
  161. package/dist/lib/shortcut.d.ts +11 -0
  162. package/dist/lib/shortcut.js +165 -0
  163. package/package.json +1 -1
  164. package/src/styles/action-bar.css +28 -0
  165. package/src/styles/assistant.css +83 -0
  166. package/src/styles/avatar.css +24 -0
  167. package/src/styles/code.css +89 -1
  168. package/src/styles/consent.css +65 -0
  169. package/src/styles/copy.css +12 -11
  170. package/src/styles/depth.css +46 -2
  171. package/src/styles/marks.css +20 -2
  172. package/src/styles/rail.css +49 -0
  173. package/src/styles/rolling-number.css +94 -0
  174. package/src/styles/steps.css +98 -0
  175. package/src/styles/timeline.css +48 -0
  176. package/src/styles/travel.css +36 -0
  177. package/src/styles.css +9 -0
@@ -0,0 +1,100 @@
1
+ import { Csv01Icon, Doc01Icon, File01Icon, FileAudioIcon, FileVideoIcon, Image01Icon, Pdf01Icon, Xls01Icon, Zip01Icon } from "@hugeicons/core-free-icons";
2
+ // src/components/attachment/kinds.ts
3
+ /**
4
+ * What kind of file an attachment is, from its MIME type or else its name: the symbol it
5
+ * carries and the word that names it. Plain functions, so they can be tested and used anywhere.
6
+ */
7
+ const kindSymbols = {
8
+ pdf: Pdf01Icon,
9
+ image: Image01Icon,
10
+ sheet: Xls01Icon,
11
+ csv: Csv01Icon,
12
+ document: Doc01Icon,
13
+ archive: Zip01Icon,
14
+ audio: FileAudioIcon,
15
+ video: FileVideoIcon,
16
+ file: File01Icon
17
+ };
18
+ /** The word for a kind where the name has no extension to show. */
19
+ const kindWords = {
20
+ pdf: "PDF",
21
+ image: "Bild",
22
+ sheet: "Tabelle",
23
+ csv: "CSV",
24
+ document: "Dokument",
25
+ archive: "Archiv",
26
+ audio: "Audio",
27
+ video: "Video",
28
+ file: "Datei"
29
+ };
30
+ const byExtension = {
31
+ pdf: "pdf",
32
+ png: "image",
33
+ jpg: "image",
34
+ jpeg: "image",
35
+ gif: "image",
36
+ webp: "image",
37
+ avif: "image",
38
+ heic: "image",
39
+ svg: "image",
40
+ xls: "sheet",
41
+ xlsx: "sheet",
42
+ numbers: "sheet",
43
+ ods: "sheet",
44
+ csv: "csv",
45
+ doc: "document",
46
+ docx: "document",
47
+ pages: "document",
48
+ odt: "document",
49
+ rtf: "document",
50
+ txt: "document",
51
+ md: "document",
52
+ zip: "archive",
53
+ rar: "archive",
54
+ "7z": "archive",
55
+ gz: "archive",
56
+ tar: "archive",
57
+ mp3: "audio",
58
+ m4a: "audio",
59
+ wav: "audio",
60
+ mp4: "video",
61
+ mov: "video",
62
+ webm: "video"
63
+ };
64
+ /** The extension of a file name, lower case, without its dot: `pdf`. Empty if it has none. */
65
+ function extensionOf(name) {
66
+ const dot = name.lastIndexOf(".");
67
+ return dot > 0 && dot < name.length - 1 ? name.slice(dot + 1).toLowerCase() : "";
68
+ }
69
+ /** A name in the two parts that are drawn apart: what may be cut, and the end that stays. */
70
+ function splitName(name) {
71
+ const extension = extensionOf(name);
72
+ if (!extension || extension.length > 5) return {
73
+ stem: name,
74
+ end: ""
75
+ };
76
+ return {
77
+ stem: name.slice(0, -(extension.length + 1)),
78
+ end: `.${name.slice(-extension.length)}`
79
+ };
80
+ }
81
+ /** The kind of a file: its MIME type decides, and its extension where the type says too little. */
82
+ function kindOf({ name, type = "" }) {
83
+ const mime = type.toLowerCase();
84
+ if (mime === "application/pdf") return "pdf";
85
+ if (mime.startsWith("image/")) return "image";
86
+ if (mime.startsWith("audio/")) return "audio";
87
+ if (mime.startsWith("video/")) return "video";
88
+ if (mime === "text/csv") return "csv";
89
+ if (mime.includes("spreadsheet") || mime.includes("excel")) return "sheet";
90
+ if (mime.includes("wordprocessing") || mime === "application/msword") return "document";
91
+ if (mime.includes("zip") || mime.includes("compressed")) return "archive";
92
+ return byExtension[extensionOf(name)] ?? (mime.startsWith("text/") ? "document" : "file");
93
+ }
94
+ /** The word under a file's name: its extension as it is written (`PDF`), or its kind's word. */
95
+ function typeWord(file) {
96
+ const extension = extensionOf(file.name);
97
+ if (extension && extension.length <= 5) return extension.toUpperCase();
98
+ return kindWords[kindOf(file)];
99
+ }
100
+ export { extensionOf, kindOf, kindSymbols, kindWords, splitName, typeWord };
@@ -1,14 +1,24 @@
1
+ import { Presence } from "../avatar-group/people.js";
1
2
  import { VariantProps } from "class-variance-authority";
2
3
  import { Avatar as Avatar$1 } from "@base-ui/react/avatar";
3
4
  declare const avatarVariants: (props?: ({
4
5
  size?: "sm" | "md" | "lg" | "xl" | null | undefined;
5
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
- export type AvatarProps = Avatar$1.Root.Props & VariantProps<typeof avatarVariants>;
7
+ export type AvatarProps = Avatar$1.Root.Props & VariantProps<typeof avatarVariants> & {
8
+ /**
9
+ * Whether the person is there: a dot on the edge at the bottom end, cut out of the avatar
10
+ * with a gap, so it reads on every ground. It is said in words as well (`presenceLabel`).
11
+ */
12
+ presence?: Presence;
13
+ /** The word assistive tech hears for the presence. „Online“, „Abwesend“, „Offline“. */
14
+ presenceLabel?: string;
15
+ };
7
16
  /**
8
- * A person or a business, as a rounded square. Put an `AvatarImage` and an `AvatarFallback` with
9
- * one or two initials inside; the initials show until the picture has loaded, or if there is none.
17
+ * A person or a business, as a circle. Put an `AvatarImage` and an `AvatarFallback` with one or
18
+ * two initials inside; the initials show until the picture has loaded, or if there is none.
19
+ * Several people at once are an `AvatarGroup`.
10
20
  */
11
- export declare function Avatar({ className, size, ...props }: AvatarProps): import("react").JSX.Element;
21
+ export declare function Avatar({ className, size, presence, presenceLabel, style, ...props }: AvatarProps): import("react").JSX.Element;
12
22
  export declare function AvatarImage({ className, alt, ...props }: Avatar$1.Image.Props): import("react").JSX.Element;
13
23
  export declare function AvatarFallback({ className, ...props }: Avatar$1.Fallback.Props): import("react").JSX.Element;
14
24
  export {};
@@ -1,27 +1,71 @@
1
1
  "use client";
2
+ import { defaultPresenceLabels } from "../avatar-group/people.js";
3
+ import { avatarGeometry, cutMask } from "../../internal/avatar-cut.js";
4
+ import { PresenceDot } from "../../internal/presence-dot.js";
2
5
  import { mergeClassName } from "../../lib/cn.js";
3
- import { jsx } from "react/jsx-runtime";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
4
7
  import { cva } from "class-variance-authority";
5
8
  import { Avatar as Avatar$1 } from "@base-ui/react/avatar";
6
9
  // src/components/avatar/avatar.tsx
7
- const avatarVariants = cva("relative inline-flex shrink-0 items-center justify-center overflow-hidden bg-fg font-semibold text-ground select-none forced-colors:outline", {
10
+ const avatarVariants = cva("relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-fg font-semibold text-ground select-none forced-colors:outline", {
8
11
  variants: { size: {
9
- sm: "size-6 rounded-xs text-xs",
10
- md: "size-7 rounded-sm text-xs",
11
- lg: "size-9 rounded-md text-sm",
12
- xl: "size-12 rounded-lg text-base"
12
+ sm: "size-6 text-[0.625rem]",
13
+ md: "size-7 text-xs",
14
+ lg: "size-9 text-sm",
15
+ xl: "size-12 text-base"
13
16
  } },
14
17
  defaultVariants: { size: "md" }
15
18
  });
16
19
  /**
17
- * A person or a business, as a rounded square. Put an `AvatarImage` and an `AvatarFallback` with
18
- * one or two initials inside; the initials show until the picture has loaded, or if there is none.
20
+ * A person or a business, as a circle. Put an `AvatarImage` and an `AvatarFallback` with one or
21
+ * two initials inside; the initials show until the picture has loaded, or if there is none.
22
+ * Several people at once are an `AvatarGroup`.
19
23
  */
20
- function Avatar({ className, size, ...props }) {
21
- return /* @__PURE__ */ jsx(Avatar$1.Root, {
22
- "data-slot": "avatar",
23
- className: mergeClassName(avatarVariants({ size }), className),
24
- ...props
24
+ function Avatar({ className, size, presence, presenceLabel, style, ...props }) {
25
+ const root = (cut, cutRtl) => {
26
+ const vars = {
27
+ "--avatar-cut": cut,
28
+ "--avatar-cut-rtl": cutRtl
29
+ };
30
+ return /* @__PURE__ */ jsx(Avatar$1.Root, {
31
+ "data-slot": "avatar",
32
+ "data-cut": cut ? "" : void 0,
33
+ style: !cut ? style : typeof style === "function" ? (state) => ({
34
+ ...vars,
35
+ ...style(state)
36
+ }) : {
37
+ ...vars,
38
+ ...style
39
+ },
40
+ className: mergeClassName(avatarVariants({ size }), className),
41
+ ...props
42
+ });
43
+ };
44
+ if (!presence) return root();
45
+ const geometry = avatarGeometry[size ?? "md"];
46
+ const cut = {
47
+ size: geometry.size,
48
+ gap: 2,
49
+ dot: geometry.dot
50
+ };
51
+ return /* @__PURE__ */ jsxs("span", {
52
+ "data-slot": "avatar-place",
53
+ className: "relative inline-flex shrink-0",
54
+ children: [
55
+ root(cutMask(cut), cutMask({
56
+ ...cut,
57
+ rtl: true
58
+ })),
59
+ /* @__PURE__ */ jsx(PresenceDot, {
60
+ slot: "avatar-presence",
61
+ presence,
62
+ diameter: geometry.dot
63
+ }),
64
+ /* @__PURE__ */ jsx("span", {
65
+ className: "sr-only",
66
+ children: presenceLabel ?? defaultPresenceLabels[presence]
67
+ })
68
+ ]
25
69
  });
26
70
  }
27
71
  function AvatarImage({ className, alt = "", ...props }) {
@@ -0,0 +1,33 @@
1
+ import { AvatarSize } from "../../internal/avatar-cut.js";
2
+ import { AvatarPerson, Presence } from "./people.js";
3
+ import { ComponentProps } from "react";
4
+ export type AvatarGroupProps = Omit<ComponentProps<"div">, "children"> & {
5
+ /** Everyone, in the order of importance: the first stands in front. */
6
+ people: readonly AvatarPerson[];
7
+ /**
8
+ * How many tiles the stack has room for, the „+3“ tile included. Default 4: three people
9
+ * and the rest as a number.
10
+ */
11
+ max?: number;
12
+ size?: AvatarSize;
13
+ /**
14
+ * What the group is, before the names, for assistive tech: „Bearbeitet von“. The names follow
15
+ * it; without it they stand alone.
16
+ */
17
+ label?: string;
18
+ presenceLabels?: Partial<Record<Presence, string>>;
19
+ /** The language the names are joined in: „Anna, Jonas und Lena“. */
20
+ locale?: Intl.LocalesArgument;
21
+ };
22
+ /**
23
+ * Several people at once, as one stack of overlapping `Avatar`s: who is in a team, who works on
24
+ * a record, who has seen it. The first stands in front. Between two the gap is cut out of the
25
+ * one underneath, following the one in front at a constant distance, so the stack is right on
26
+ * every ground, on a washed table row and over a picture. More people than fit become a „+3“
27
+ * tile of the same shape.
28
+ *
29
+ * Each avatar names itself in a tooltip under the pointer (one tooltip, which moves along the
30
+ * stack without waiting again), the „+3“ tile names the rest, and assistive tech hears the whole
31
+ * group as one sentence. A presence dot carries its words in both.
32
+ */
33
+ export declare function AvatarGroup({ people, max, size, label, presenceLabels, locale, className, style, ...props }: AvatarGroupProps): import("react").JSX.Element;
@@ -0,0 +1,110 @@
1
+ "use client";
2
+ import { Avatar, AvatarFallback, AvatarImage } from "../avatar/avatar.js";
3
+ import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip/tooltip.js";
4
+ import { avatarGeometry, avatarOverlap, cutMask } from "../../internal/avatar-cut.js";
5
+ import { PresenceDot } from "../../internal/presence-dot.js";
6
+ import { cn } from "../../lib/cn.js";
7
+ import { defaultPresenceLabels, initialsOf, listOf, personLabel } from "./people.js";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import "react";
10
+ // src/components/avatar-group/avatar-group.tsx
11
+ /**
12
+ * Several people at once, as one stack of overlapping `Avatar`s: who is in a team, who works on
13
+ * a record, who has seen it. The first stands in front. Between two the gap is cut out of the
14
+ * one underneath, following the one in front at a constant distance, so the stack is right on
15
+ * every ground, on a washed table row and over a picture. More people than fit become a „+3“
16
+ * tile of the same shape.
17
+ *
18
+ * Each avatar names itself in a tooltip under the pointer (one tooltip, which moves along the
19
+ * stack without waiting again), the „+3“ tile names the rest, and assistive tech hears the whole
20
+ * group as one sentence. A presence dot carries its words in both.
21
+ */
22
+ function AvatarGroup({ people, max = 4, size = "md", label, presenceLabels, locale = "de-DE", className, style, ...props }) {
23
+ const words = {
24
+ ...defaultPresenceLabels,
25
+ ...presenceLabels
26
+ };
27
+ const room = Math.max(1, max);
28
+ const front = people.length > room ? people.slice(0, room - 1) : people;
29
+ const rest = people.slice(front.length);
30
+ const geometry = avatarGeometry[size];
31
+ const gap = 2;
32
+ const over = avatarOverlap[size];
33
+ const step = geometry.size - over;
34
+ /**
35
+ * The mask of a tile: cut by the one in front (and by its dot, which stands half outside it,
36
+ * over this one), and around its own dot.
37
+ */
38
+ const cut = (index, dot) => {
39
+ const before = index > 0 ? front[index - 1] : void 0;
40
+ const options = {
41
+ size: geometry.size,
42
+ gap,
43
+ step: index > 0 ? step : void 0,
44
+ dot: dot ? geometry.dot : void 0,
45
+ frontDot: before?.presence ? geometry.dot : void 0
46
+ };
47
+ const mask = cutMask(options);
48
+ if (!mask) return void 0;
49
+ return {
50
+ "data-cut": "",
51
+ style: {
52
+ "--avatar-cut": mask,
53
+ "--avatar-cut-rtl": cutMask({
54
+ ...options,
55
+ rtl: true
56
+ })
57
+ }
58
+ };
59
+ };
60
+ const everyone = listOf(people.map((person) => personLabel(person, words)), locale);
61
+ const centred = (first) => first ? void 0 : "ps-(--avatar-hidden)";
62
+ const tiles = front.map((person, index) => ({
63
+ key: `${index}:${person.name}`,
64
+ tip: personLabel(person, words),
65
+ content: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Avatar, {
66
+ size,
67
+ ...cut(index, person.presence !== void 0),
68
+ children: [person.src && /* @__PURE__ */ jsx(AvatarImage, { src: person.src }), /* @__PURE__ */ jsx(AvatarFallback, {
69
+ className: centred(index === 0),
70
+ children: person.initials ?? initialsOf(person.name)
71
+ })]
72
+ }), person.presence && /* @__PURE__ */ jsx(PresenceDot, {
73
+ slot: "avatar-group-presence",
74
+ presence: person.presence,
75
+ diameter: geometry.dot
76
+ })] })
77
+ }));
78
+ if (rest.length > 0) tiles.push({
79
+ key: "rest",
80
+ tip: listOf(rest.map((person) => personLabel(person, words)), locale),
81
+ content: /* @__PURE__ */ jsxs("span", {
82
+ "data-slot": "avatar-group-more",
83
+ ...cut(tiles.length, false),
84
+ className: cn("inline-flex shrink-0 items-center justify-center rounded-full bg-trough font-semibold text-fg tabular-nums select-none forced-colors:outline", centred(tiles.length === 0), size === "sm" && "size-6 text-[0.625rem]", size === "md" && "size-7 text-xs", size === "lg" && "size-9 text-sm", size === "xl" && "size-12 text-base"),
85
+ children: ["+", rest.length]
86
+ })
87
+ });
88
+ return /* @__PURE__ */ jsx("div", {
89
+ role: "img",
90
+ "aria-label": label ? `${label}: ${everyone}` : everyone,
91
+ "data-slot": "avatar-group",
92
+ "data-size": size,
93
+ style: {
94
+ "--avatar-step": `${-over / 16}rem`,
95
+ "--avatar-hidden": `${(over + gap) / 16}rem`,
96
+ ...style
97
+ },
98
+ className: cn("isolate inline-flex items-center", className),
99
+ ...props,
100
+ children: /* @__PURE__ */ jsx(Tooltip, { children: ({ payload }) => /* @__PURE__ */ jsxs(Fragment, { children: [tiles.map((tile, index) => /* @__PURE__ */ jsx(TooltipTrigger, {
101
+ payload: tile.tip,
102
+ render: /* @__PURE__ */ jsx("span", {}),
103
+ "data-slot": "avatar-group-item",
104
+ style: { zIndex: tiles.length - index },
105
+ className: "relative inline-flex shrink-0 not-first:ms-(--avatar-step)",
106
+ children: tile.content
107
+ }, tile.key)), /* @__PURE__ */ jsx(TooltipContent, { children: payload })] }) })
108
+ });
109
+ }
110
+ export { AvatarGroup };
@@ -0,0 +1,12 @@
1
+ /** Whether a person is there: shown as a dot on their avatar, and always said in words. */
2
+ export type Presence = "online" | "away" | "offline";
3
+ /** One person in an `AvatarGroup`. */
4
+ export type AvatarPerson = {
5
+ /** The full name, as the tooltip and assistive tech say it. */
6
+ name: string;
7
+ /** A picture; the initials show until it has loaded, or if there is none. */
8
+ src?: string;
9
+ /** One or two letters; by default the first letters of the first and the last name. */
10
+ initials?: string;
11
+ presence?: Presence;
12
+ };
@@ -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
- return /* @__PURE__ */ jsx("span", {
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": tone ?? "neutral",
23
- className: cn(badgeVariants({ tone }), className),
24
- ...props
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 };