@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
@@ -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,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", {
@@ -1,3 +1,4 @@
1
+ import { ChipVariant } from "../chip/chip-variants.js";
1
2
  import { IconSvgElement } from "../icon/icon.js";
2
3
  import { FieldSize } from "../../internal/field.js";
3
4
  import { ReactNode } from "react";
@@ -18,7 +19,17 @@ export type ComboboxOptionGroup<Value = string> = {
18
19
  value: string;
19
20
  items: ReadonlyArray<ComboboxOption<Value>>;
20
21
  };
21
- export type ComboboxProps<Option> = Combobox$1.Root.Props<Option, false>;
22
+ export type ComboboxProps<Value, Multiple extends boolean | undefined = false, Item = Value> = Combobox$1.Root.Props<Value, Multiple, Item> & {
23
+ /**
24
+ * Lets the reader make a value that is not in the list. While what they typed matches no
25
+ * option's name exactly, a last row offers to create it; choosing that row calls this with
26
+ * the typed text. Add the new option to your `items` and return it: it is chosen at once.
27
+ * Needs a flat list of options and a controlled `value`.
28
+ */
29
+ onCreate?: (label: string) => Value | undefined;
30
+ /** What the row that creates says: „Dringend“ anlegen. */
31
+ createLabel?: (label: string) => ReactNode;
32
+ };
22
33
  /**
23
34
  * A select you can type into: for lists too long to scan (a customer out of two hundred), where
24
35
  * people know what they are looking for. Typing filters the list; only an entry of the list can
@@ -28,11 +39,15 @@ export type ComboboxProps<Option> = Combobox$1.Root.Props<Option, false>;
28
39
  * object, is the value: `defaultValue={items[0]}`, `onValueChange={(option) => …}`. In a form
29
40
  * its `value` is what is submitted.
30
41
  *
42
+ * With `multiple` the value is a list of options and the field is a `ComboboxChips`: every
43
+ * chosen option is a chip in it. The list then stays open after a choice, so several can be
44
+ * taken in a row, and each is submitted under the field's name.
45
+ *
31
46
  * Typing ignores case and accents: "gart" finds "Gärtnerei" and "cafe" finds "Café". Pass
32
47
  * `locale` (`"de-DE"`) so that does not depend on the machine. The first match is highlighted
33
48
  * while typing, so Enter takes it.
34
49
  */
35
- export declare function Combobox<Option>({ autoHighlight, filter, locale, ...props }: ComboboxProps<Option>): import("react").JSX.Element;
50
+ export declare function Combobox<Value, Multiple extends boolean | undefined = false, Item = Value>({ autoHighlight, filter, locale, items, multiple, onCreate, createLabel, inputValue, defaultInputValue, onInputValueChange, onValueChange, onOpenChange, ...props }: ComboboxProps<Value, Multiple, Item>): import("react").JSX.Element;
36
51
  export type ComboboxInputProps = Omit<Combobox$1.Input.Props, "className" | "size"> & {
37
52
  /** The size of the field, from the density. */
38
53
  size?: FieldSize;
@@ -49,6 +64,39 @@ export type ComboboxInputProps = Omit<Combobox$1.Input.Props, "className" | "siz
49
64
  * placeholder is an example ("z. B. Schreinerei Huber"), not a label.
50
65
  */
51
66
  export declare function ComboboxInput({ className, size, clearLabel, openLabel, ...props }: ComboboxInputProps): import("react").JSX.Element;
67
+ export type ComboboxChipsProps = Omit<Combobox$1.Input.Props, "className" | "size"> & {
68
+ /** The size of the field, from the density. */
69
+ size?: FieldSize;
70
+ /** Classes for the field as a whole, e.g. its width. */
71
+ className?: string;
72
+ /**
73
+ * `flat` (the default): the chips are drawn like a `Badge`, quiet in the field. `plug`: raised
74
+ * plugs seated in it, like a `Chip` on its own, where the values are the field's point (the
75
+ * recipients of a message).
76
+ */
77
+ chipVariant?: ChipVariant;
78
+ /** The name of the row of chips, for assistive tech. */
79
+ chipsLabel?: string;
80
+ /** The verb of the key that takes a chip away. The chip's text is said before it. */
81
+ removeLabel?: string;
82
+ /** Said with the input once something is chosen: how many, and how to reach them. */
83
+ chipsHint?: (count: number) => string;
84
+ /** The accessible name of the button that clears every choice. */
85
+ clearLabel?: string;
86
+ /** The accessible name of the button that opens the list. */
87
+ openLabel?: string;
88
+ };
89
+ /**
90
+ * The field of a `Combobox multiple`: every chosen option is a chip in it, and the input stands
91
+ * after the last one. Backspace in the empty input takes the last chip, Arrow left walks into
92
+ * the chips, and each chip has a key that takes it away.
93
+ *
94
+ * A chip that joins seats into its place, one that leaves fades while its neighbours close up,
95
+ * and when the chips need another line the field eases to its new height, so what stands below
96
+ * is pushed and does not jump. Give it a name with a `FieldLabel` or an `aria-label`; the
97
+ * placeholder is an example and shows only while nothing is chosen.
98
+ */
99
+ export declare function ComboboxChips({ className, size, chipVariant, chipsLabel, removeLabel, chipsHint, clearLabel, openLabel, ...props }: ComboboxChipsProps): import("react").JSX.Element;
52
100
  export type ComboboxContentProps = Omit<Combobox$1.Popup.Props, "children"> & Pick<Combobox$1.Positioner.Props, "side" | "align" | "sideOffset" | "alignOffset"> & {
53
101
  /**
54
102
  * Said when nothing matches what was typed. Name what was looked for ("Kein Kunde