@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
@@ -1,12 +1,20 @@
1
1
  import { ComponentProps } from "react";
2
2
  type DivProps = ComponentProps<"div">;
3
3
  /**
4
- * A container for one object you act on: a form you submit, a plan you choose, an account. It is
5
- * a softly raised sheet. Do not use it to chop a page into boxes: content that is only read
6
- * stands on the ground under a rule (`Separator`).
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`).
7
9
  */
8
10
  export declare function Card({ className, ...props }: DivProps): import("react").JSX.Element;
9
11
  export declare function CardHeader({ className, ...props }: DivProps): import("react").JSX.Element;
12
+ /**
13
+ * The bar across the top of a card that holds a list, a table or a feed: its name (a `Heading`
14
+ * of `size="label"`) and, at the end, a way to all of it („Alle Angebote“) or one action. A
15
+ * hairline under it; what follows runs to the card's edges, its text 20px in as the bar's is.
16
+ */
17
+ export declare function CardBar({ className, ...props }: DivProps): import("react").JSX.Element;
10
18
  /** A sentence, like every title in the kit. */
11
19
  export declare function CardTitle({ className, ...props }: ComponentProps<"h3">): import("react").JSX.Element;
12
20
  export declare function CardDescription({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
@@ -2,9 +2,11 @@ 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 container for one object you act on: a form you submit, a plan you choose, an account. It is
6
- * a softly raised sheet. Do not use it to chop a page into boxes: content that is only read
7
- * stands on the ground under a rule (`Separator`).
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`).
8
10
  */
9
11
  function Card({ className, ...props }) {
10
12
  return /* @__PURE__ */ jsx("div", {
@@ -20,6 +22,18 @@ function CardHeader({ className, ...props }) {
20
22
  ...props
21
23
  });
22
24
  }
25
+ /**
26
+ * The bar across the top of a card that holds a list, a table or a feed: its name (a `Heading`
27
+ * of `size="label"`) and, at the end, a way to all of it („Alle Angebote“) or one action. A
28
+ * hairline under it; what follows runs to the card's edges, its text 20px in as the bar's is.
29
+ */
30
+ function CardBar({ className, ...props }) {
31
+ return /* @__PURE__ */ jsx("div", {
32
+ "data-slot": "card-bar",
33
+ 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),
34
+ ...props
35
+ });
36
+ }
23
37
  /** A sentence, like every title in the kit. */
24
38
  function CardTitle({ className, ...props }) {
25
39
  return /* @__PURE__ */ jsx("h3", {
@@ -50,4 +64,4 @@ function CardFooter({ className, ...props }) {
50
64
  ...props
51
65
  });
52
66
  }
53
- export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
67
+ 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,49 @@
1
+ "use client";
2
+ import { ChoiceCardBody, choiceCard, choiceControl } 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
+ className: cn(choiceCard, chosen === "edge" && "has-[[data-slot=choice-control][data-checked]]:depth-card-chosen", className),
25
+ children: [/* @__PURE__ */ jsx(Checkbox.Root, {
26
+ "data-slot": "choice-control",
27
+ "aria-labelledby": titleId,
28
+ "aria-describedby": description === void 0 ? void 0 : descriptionId,
29
+ 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"),
30
+ ...props,
31
+ children: /* @__PURE__ */ jsx(Checkbox.Indicator, {
32
+ keepMounted: true,
33
+ "data-slot": "checkbox-card-indicator",
34
+ className: "flex items-center justify-center",
35
+ 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]" })
36
+ })
37
+ }), /* @__PURE__ */ jsx(ChoiceCardBody, {
38
+ slot: "checkbox-card",
39
+ titleId,
40
+ descriptionId,
41
+ title,
42
+ description,
43
+ detail,
44
+ icon,
45
+ children
46
+ })]
47
+ });
48
+ }
49
+ 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;
@@ -0,0 +1,28 @@
1
+ // src/components/chip/chip-variants.ts
2
+ /**
3
+ * The look of a chip as class names, for the two places that draw one: `Chip`, and the field of
4
+ * a multi-select, whose chips are Base UI's own parts. Server-safe, like `buttonVariants`.
5
+ */
6
+ /**
7
+ * As wide as its text. Where a chip may be too long for its row, give it a `max-w-*`: the text
8
+ * then ends in an ellipsis.
9
+ */
10
+ const chipShape = "inline-flex h-[1.375rem] w-max items-center gap-1 rounded-sm px-2 align-middle text-sm font-medium whitespace-nowrap";
11
+ /** `plug`: raised, a small fitting. `flat`: a quiet wash with a faint edge, like a `Badge`. */
12
+ const chipFace = {
13
+ plug: "bg-raised depth-plug text-fg",
14
+ flat: "bg-surface-quiet text-fg-body inset-ring inset-ring-current/15 forced-colors:outline"
15
+ };
16
+ const chipDisabledLook = "data-disabled:bg-disabled data-disabled:depth-flat data-disabled:text-on-disabled";
17
+ /**
18
+ * In a row that is live it seats into its place once that has begun to open, and leaves by
19
+ * fading before the place closes: an exit does not scale back.
20
+ */
21
+ const chipMotion = ["transition-[opacity,scale] delay-75 spring-seat in-data-live:starting:scale-90 in-data-live:starting:opacity-0", "in-data-leaving:opacity-0 in-data-leaving:delay-0 in-data-leaving:spring-leave"].join(" ");
22
+ /** The key that takes the chip away: 18px in the chip, a finger's target around it. */
23
+ const chipRemoveKey = [
24
+ "touch-target relative flex size-[1.125rem] shrink-0 items-center justify-center rounded-xs text-fg-muted select-none",
25
+ "hover:bg-hover hover:text-fg",
26
+ "focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-accent"
27
+ ].join(" ");
28
+ export { chipDisabledLook, chipFace, chipMotion, chipRemoveKey, chipShape };
@@ -0,0 +1,39 @@
1
+ import { IconSvgElement } from "../icon/icon.js";
2
+ import { ChipVariant } from "./chip-variants.js";
3
+ import { ComponentProps, ReactNode } from "react";
4
+ export type ChipProps = Omit<ComponentProps<"span">, "children"> & {
5
+ /** What the chip stands for, in a word or two: "Bezahlt", "Schreinerei Huber". */
6
+ children: ReactNode;
7
+ /** A 12px symbol before the text. */
8
+ icon?: IconSvgElement;
9
+ /**
10
+ * Something drawn before the text in place of `icon`: a mark that changes (a file on its way),
11
+ * a small picture. As tall as the chip's text at most.
12
+ */
13
+ lead?: ReactNode;
14
+ /** With it the chip carries a key that takes it away. Remove it from your list here. */
15
+ onRemove?: () => void;
16
+ /**
17
+ * What the key that takes the chip away is called, as one verb. The chip's own text is said
18
+ * before it: "Bezahlt entfernen".
19
+ */
20
+ removeLabel?: string;
21
+ /** It cannot be taken away right now, and lies flat. */
22
+ disabled?: boolean;
23
+ /**
24
+ * `plug` (the default): raised, a small fitting. `flat`: a quiet wash with a faint edge, the
25
+ * way a `Badge` is drawn, for a row where raised chips would be too much.
26
+ */
27
+ variant?: ChipVariant;
28
+ };
29
+ /**
30
+ * Something that was chosen and can be taken away again: a filter that is applied, a value in
31
+ * a field, a recipient. It is a small fitting seated in its surroundings, a plug: raised, with
32
+ * an edge, but without a shadow of its own. A state that is only read ("Bezahlt" on a row) is
33
+ * a `Badge`, which is flat.
34
+ *
35
+ * Give it `onRemove` and it carries a key that takes it away. Put the chips of a row into a
36
+ * `ChipGroup`: there a chip that leaves fades while the row closes its place, one that joins
37
+ * opens its place first, and the keyboard focus goes to the chip beside the one that left.
38
+ */
39
+ export declare function Chip({ icon, lead, onRemove, removeLabel, disabled, variant, className, children, ...props }: ChipProps): import("react").JSX.Element;
@@ -0,0 +1,71 @@
1
+ import { Icon } from "../icon/icon.js";
2
+ import { CloseGlyph } from "../../internal/glyphs.js";
3
+ import { cn } from "../../lib/cn.js";
4
+ import { chipDisabledLook, chipFace, chipMotion, chipRemoveKey, chipShape } from "./chip-variants.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { useId } from "react";
7
+ // src/components/chip/chip.tsx
8
+ /** The key of the chip beside this one, the next if there is one, that can take the focus. */
9
+ function keyBeside(key) {
10
+ const place = key.closest("[data-slot=\"chip-place\"]");
11
+ const find = (step) => {
12
+ for (let other = place?.[step]; other; other = other[step]) {
13
+ const found = other.matches("[data-leaving]") ? null : other.querySelector("[data-slot=\"chip-remove\"]");
14
+ if (found) return found;
15
+ }
16
+ return null;
17
+ };
18
+ return find("nextElementSibling") ?? find("previousElementSibling");
19
+ }
20
+ /**
21
+ * Something that was chosen and can be taken away again: a filter that is applied, a value in
22
+ * a field, a recipient. It is a small fitting seated in its surroundings, a plug: raised, with
23
+ * an edge, but without a shadow of its own. A state that is only read ("Bezahlt" on a row) is
24
+ * a `Badge`, which is flat.
25
+ *
26
+ * Give it `onRemove` and it carries a key that takes it away. Put the chips of a row into a
27
+ * `ChipGroup`: there a chip that leaves fades while the row closes its place, one that joins
28
+ * opens its place first, and the keyboard focus goes to the chip beside the one that left.
29
+ */
30
+ function Chip({ icon, lead, onRemove, removeLabel = "Entfernen", disabled = false, variant = "plug", className, children, ...props }) {
31
+ const labelId = useId();
32
+ const removeId = useId();
33
+ const removable = onRemove !== void 0 && !disabled;
34
+ return /* @__PURE__ */ jsxs("span", {
35
+ "data-slot": "chip",
36
+ "data-variant": variant,
37
+ "data-disabled": disabled ? "" : void 0,
38
+ className: cn(chipShape, chipFace[variant], chipDisabledLook, chipMotion, removable && "pr-0.5", className),
39
+ ...props,
40
+ children: [
41
+ lead ?? (icon && /* @__PURE__ */ jsx(Icon, {
42
+ icon,
43
+ size: 12,
44
+ className: "-ml-0.5 text-fg-muted"
45
+ })),
46
+ /* @__PURE__ */ jsx("span", {
47
+ id: labelId,
48
+ "data-slot": "chip-label",
49
+ className: "truncate",
50
+ children
51
+ }),
52
+ removable && /* @__PURE__ */ jsx("button", {
53
+ type: "button",
54
+ id: removeId,
55
+ "data-slot": "chip-remove",
56
+ "aria-label": removeLabel,
57
+ "aria-labelledby": `${labelId} ${removeId}`,
58
+ onClick: (event) => {
59
+ if (event.currentTarget === document.activeElement) keyBeside(event.currentTarget)?.focus();
60
+ onRemove();
61
+ },
62
+ className: chipRemoveKey,
63
+ children: /* @__PURE__ */ jsx(CloseGlyph, {
64
+ width: 8,
65
+ height: 8
66
+ })
67
+ })
68
+ ]
69
+ });
70
+ }
71
+ export { Chip };
@@ -1,5 +1,6 @@
1
1
  import { IconSvgElement } from "../icon/icon.js";
2
2
  import { CodeKeyOptions } from "./code-keys.js";
3
+ import { CodeChangeMotion } from "./code-lines-live.js";
3
4
  import { CodeLinesOptions } from "./code-lines-view.js";
4
5
  import { ReactNode } from "react";
5
6
  /**
@@ -29,6 +30,12 @@ export type CodeBlockLiveProps = CodeLinesOptions & CodeKeyOptions & {
29
30
  fold?: number;
30
31
  foldLabel?: (hidden: number) => string;
31
32
  className?: string;
33
+ /**
34
+ * How what a change put into a line (a value, a comma) shows: it fades in (`fade`, the
35
+ * default), or also lights up in the accent for a moment (`glow`), for a change the reader
36
+ * should not miss.
37
+ */
38
+ changeMotion?: CodeChangeMotion;
32
39
  };
33
40
  /**
34
41
  * A `CodeBlock` for code that is put together in the browser: a configuration generated from the
@@ -41,5 +48,10 @@ export type CodeBlockLiveProps = CodeLinesOptions & CodeKeyOptions & {
41
48
  * along, about a megabyte for a few lines. So: `CodeBlock` for code that is known when the page
42
49
  * is built, `CodeBlockLive` for code that changes under the reader's hand. Mark the lines their
43
50
  * choice put there (`marked`), so they see what it changed.
51
+ *
52
+ * When the code changes, the block shows the change: a line that joins opens like a fold (its
53
+ * row opens and the lines below make room while its text fades in), a line that goes fades and
54
+ * its row closes, and what a change put into a line arrives as new (`changeMotion`). The block's
55
+ * height follows, so a `Grow` around it needs nothing more.
44
56
  */
45
- export declare function CodeBlockLive({ lines, title, icon, mark, label, prompt, fold, foldLabel, className, lineNumbers, marked, added, removed, wrap, addedLabel, removedLabel, ...keyOptions }: CodeBlockLiveProps): import("react").JSX.Element;
57
+ export declare function CodeBlockLive({ lines, title, icon, mark, label, prompt, fold, foldLabel, className, lineNumbers, marked, added, removed, wrap, addedLabel, removedLabel, changeMotion, ...keyOptions }: CodeBlockLiveProps): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { CodeBlockFrame } from "./code-block-frame.js";
2
- import { CodeLinesView } from "./code-lines-view.js";
2
+ import { CodeLinesLive } from "./code-lines-live.js";
3
3
  import { codeFileName, parseLines } from "./lines.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  import { FileCodeIcon } from "@hugeicons/core-free-icons";
@@ -15,8 +15,13 @@ import { FileCodeIcon } from "@hugeicons/core-free-icons";
15
15
  * along, about a megabyte for a few lines. So: `CodeBlock` for code that is known when the page
16
16
  * is built, `CodeBlockLive` for code that changes under the reader's hand. Mark the lines their
17
17
  * choice put there (`marked`), so they see what it changed.
18
+ *
19
+ * When the code changes, the block shows the change: a line that joins opens like a fold (its
20
+ * row opens and the lines below make room while its text fades in), a line that goes fades and
21
+ * its row closes, and what a change put into a line arrives as new (`changeMotion`). The block's
22
+ * height follows, so a `Grow` around it needs nothing more.
18
23
  */
19
- function CodeBlockLive({ lines, title, icon = FileCodeIcon, mark, label = "Code", prompt = false, fold, foldLabel = (hidden) => `${hidden} weitere Zeilen`, className, lineNumbers, marked, added, removed, wrap, addedLabel, removedLabel, ...keyOptions }) {
24
+ function CodeBlockLive({ lines, title, icon = FileCodeIcon, mark, label = "Code", prompt = false, fold, foldLabel = (hidden) => `${hidden} weitere Zeilen`, className, lineNumbers, marked, added, removed, wrap, addedLabel, removedLabel, changeMotion, ...keyOptions }) {
20
25
  const coloured = lines.map((line) => line.map((piece) => ({
21
26
  content: piece.text,
22
27
  color: `var(--lf-code-${piece.role ?? "text"})`,
@@ -38,7 +43,7 @@ function CodeBlockLive({ lines, title, icon = FileCodeIcon, mark, label = "Code"
38
43
  fileName: codeFileName(title),
39
44
  wrap,
40
45
  ...keyOptions,
41
- children: /* @__PURE__ */ jsx(CodeLinesView, {
46
+ children: /* @__PURE__ */ jsx(CodeLinesLive, {
42
47
  lines: coloured,
43
48
  lineNumbers,
44
49
  marked,
@@ -46,7 +51,8 @@ function CodeBlockLive({ lines, title, icon = FileCodeIcon, mark, label = "Code"
46
51
  removed,
47
52
  wrap,
48
53
  addedLabel,
49
- removedLabel
54
+ removedLabel,
55
+ changeMotion
50
56
  })
51
57
  });
52
58
  }
@@ -1,6 +1,7 @@
1
1
  import { IconSvgElement } from "../icon/icon.js";
2
2
  import { CodeKeyOptions } from "./code-keys.js";
3
3
  import { CodeLinesOptions } from "./code-lines-view.js";
4
+ import "./code-lines.js";
4
5
  import { CodeLanguage } from "./highlight.js";
5
6
  import { ReactNode } from "react";
6
7
  export type CodeBlockProps = CodeLinesOptions & CodeKeyOptions & {
@@ -1,12 +1,4 @@
1
+ import { CopyButtonLabels } from "../copy-button/copy-button.js";
1
2
  import "react";
2
- export type CodeCopyLabels = {
3
- /** The button's name and its tooltip: worded like a button. */
4
- copyLabel?: string;
5
- /** The tooltip once the code is on the clipboard. */
6
- copiedLabel?: string;
7
- /** Read out once the code is on the clipboard: a full sentence. */
8
- copiedMessage?: string;
9
- /** Read out and shown when the clipboard refused; the code is then selected instead. */
10
- failedLabel?: string;
11
- failedMessage?: string;
12
- };
3
+ /** The words of the copy key of a code block. */
4
+ export type CodeCopyLabels = CopyButtonLabels;
@@ -1,71 +1,24 @@
1
1
  "use client";
2
- import { Button } from "../button/button.js";
3
- import { Icon } from "../icon/icon.js";
4
- import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip/tooltip.js";
5
- import { TickGlyph } from "../../internal/glyphs.js";
2
+ import { CopyButton } from "../copy-button/copy-button.js";
6
3
  import { cn } from "../../lib/cn.js";
7
- import { jsx, jsxs } from "react/jsx-runtime";
8
- import { Copy01Icon } from "@hugeicons/core-free-icons";
9
- import { useEffect, useRef, useState } from "react";
4
+ import { jsx } from "react/jsx-runtime";
10
5
  // src/components/code-block/code-copy.tsx
11
- /** How long the tick stands before the copy symbol comes back. */
12
- const SHOWN_MS = 1600;
13
6
  /**
14
- * The copy button of a code block: the copy symbol shrinks away and a tick is drawn in its
15
- * place, the tooltip says that it worked, and a screen reader hears it once. After a moment the
16
- * symbol seats back. If the browser refuses the clipboard, the code is selected instead.
7
+ * The copy key of a code block: a small `CopyButton` worded for code. It takes its five labels
8
+ * by name, because a block hands it all of its key options at once.
17
9
  */
18
- function CodeCopy({ text, codeRef, copyLabel = "Code kopieren", copiedLabel = "Kopiert", copiedMessage = "Der Code wurde kopiert.", failedLabel = "Markiert", failedMessage = "Der Code wurde nicht kopiert. Er ist markiert und kann mit ⌘C kopiert werden.", className }) {
19
- const [state, setState] = useState("idle");
20
- const timer = useRef(void 0);
21
- useEffect(() => () => clearTimeout(timer.current), []);
22
- async function copy() {
23
- clearTimeout(timer.current);
24
- try {
25
- await navigator.clipboard.writeText(text);
26
- setState("copied");
27
- } catch {
28
- const code = codeRef.current;
29
- if (code) window.getSelection()?.selectAllChildren(code);
30
- setState("failed");
31
- }
32
- timer.current = setTimeout(() => setState("idle"), SHOWN_MS);
33
- }
34
- const copied = state === "copied";
35
- const word = state === "failed" ? failedLabel : copiedLabel;
36
- return /* @__PURE__ */ jsxs("div", {
10
+ function CodeCopy({ text, codeRef, copyLabel = "Code kopieren", copiedLabel, copiedMessage = "Der Code wurde kopiert.", failedLabel, failedMessage = "Der Code wurde nicht kopiert. Er ist markiert und kann mit ⌘C kopiert werden.", className }) {
11
+ return /* @__PURE__ */ jsx(CopyButton, {
37
12
  "data-slot": "code-copy",
38
- className: cn("relative flex items-center", className),
39
- children: [/* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
40
- closeOnClick: false,
41
- render: /* @__PURE__ */ jsx(Button, {
42
- iconOnly: true,
43
- size: "sm",
44
- variant: "quiet",
45
- "aria-label": copyLabel,
46
- onClick: () => void copy(),
47
- className: "text-fg-muted hover:text-fg",
48
- children: /* @__PURE__ */ jsxs("span", {
49
- "data-slot": "code-copy-marks",
50
- "data-copied": copied ? "" : void 0,
51
- className: "grid place-items-center *:col-start-1 *:row-start-1",
52
- children: [/* @__PURE__ */ jsx(Icon, {
53
- "data-slot": "code-copy-symbol",
54
- icon: Copy01Icon,
55
- size: 14
56
- }), /* @__PURE__ */ jsx(TickGlyph, {
57
- "data-slot": "code-copy-tick",
58
- width: 14,
59
- height: 14,
60
- strokeWidth: 1.5
61
- })]
62
- })
63
- })
64
- }), /* @__PURE__ */ jsx(TooltipContent, { children: state === "idle" ? copyLabel : word })] }), /* @__PURE__ */ jsx("span", {
65
- role: "status",
66
- className: "sr-only",
67
- children: state === "copied" ? copiedMessage : state === "failed" ? failedMessage : ""
68
- })]
13
+ size: "sm",
14
+ text,
15
+ selectTarget: codeRef,
16
+ copyLabel,
17
+ copiedLabel,
18
+ copiedMessage,
19
+ failedLabel,
20
+ failedMessage,
21
+ className: cn("flex", className)
69
22
  });
70
23
  }
71
24
  export { CodeCopy };
@@ -1,16 +1,15 @@
1
1
  "use client";
2
2
  import { Button } from "../button/button.js";
3
3
  import { Icon } from "../icon/icon.js";
4
+ import { Toggle } from "../toggle/toggle.js";
4
5
  import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip/tooltip.js";
5
- import { TickGlyph } from "../../internal/glyphs.js";
6
+ import { COPY_SHOWN_MS, CopyMarks } from "../../internal/copy.js";
6
7
  import { cn } from "../../lib/cn.js";
7
8
  import { CodeCopy } from "./code-copy.js";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
- import { Download01Icon, TextWrapIcon } from "@hugeicons/core-free-icons";
10
10
  import { useEffect, useRef, useState } from "react";
11
+ import { Download01Icon, TextWrapIcon } from "@hugeicons/core-free-icons";
11
12
  // src/components/code-block/code-keys.tsx
12
- /** How long the tick stands before the symbol comes back (as in `CodeCopy`). */
13
- const SHOWN_MS = 1600;
14
13
  /**
15
14
  * The keys of a block of code, at the end of its header or in its top corner: line wrap, the
16
15
  * download, and last the copy, which every block has and which so keeps its place.
@@ -20,15 +19,14 @@ function CodeKeys({ text, codeRef, fileName = "code.txt", download, downloadLabe
20
19
  "data-slot": "code-keys",
21
20
  className: cn("flex items-center gap-0.5", className),
22
21
  children: [
23
- wrapToggle && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx(Button, {
22
+ wrapToggle && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx(Toggle, {
24
23
  iconOnly: true,
25
24
  size: "sm",
26
25
  variant: "quiet",
27
26
  "aria-label": wrapLabel,
28
- "aria-pressed": wrapped,
29
27
  "data-slot": "code-wrap",
30
- onClick: () => onWrappedChange(!wrapped),
31
- className: "text-fg-muted hover:text-fg aria-pressed:bg-hover aria-pressed:text-fg",
28
+ pressed: wrapped,
29
+ onPressedChange: onWrappedChange,
32
30
  children: /* @__PURE__ */ jsx(Icon, {
33
31
  icon: TextWrapIcon,
34
32
  size: 14
@@ -68,7 +66,7 @@ function CodeDownload({ text, fileName, downloadLabel = "Herunterladen", downloa
68
66
  setTimeout(() => URL.revokeObjectURL(url), 0);
69
67
  clearTimeout(timer.current);
70
68
  setDone(true);
71
- timer.current = setTimeout(() => setDone(false), SHOWN_MS);
69
+ timer.current = setTimeout(() => setDone(false), COPY_SHOWN_MS);
72
70
  }
73
71
  return /* @__PURE__ */ jsxs("div", {
74
72
  "data-slot": "code-download",
@@ -82,19 +80,9 @@ function CodeDownload({ text, fileName, downloadLabel = "Herunterladen", downloa
82
80
  "aria-label": downloadLabel,
83
81
  onClick: save,
84
82
  className: "text-fg-muted hover:text-fg",
85
- children: /* @__PURE__ */ jsxs("span", {
86
- "data-copied": done ? "" : void 0,
87
- className: "grid place-items-center *:col-start-1 *:row-start-1",
88
- children: [/* @__PURE__ */ jsx(Icon, {
89
- "data-slot": "code-copy-symbol",
90
- icon: Download01Icon,
91
- size: 14
92
- }), /* @__PURE__ */ jsx(TickGlyph, {
93
- "data-slot": "code-copy-tick",
94
- width: 14,
95
- height: 14,
96
- strokeWidth: 1.5
97
- })]
83
+ children: /* @__PURE__ */ jsx(CopyMarks, {
84
+ copied: done,
85
+ icon: Download01Icon
98
86
  })
99
87
  })
100
88
  }), /* @__PURE__ */ jsx(TooltipContent, { children: done ? downloadedLabel : downloadLabel })] }), /* @__PURE__ */ jsx("span", {
@@ -0,0 +1,7 @@
1
+ import "./code-lines-view.js";
2
+ /**
3
+ * How the part of a line that a change put in shows (a value, a comma): it fades in (`fade`),
4
+ * or also lights up in the accent and lets the light go (`glow`), for a change the reader should
5
+ * not miss.
6
+ */
7
+ export type CodeChangeMotion = "fade" | "glow";