@lanfermann/ui 0.0.0-stage → 0.1.1

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 (216) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +17 -2
  3. package/TRADEMARK.md +10 -0
  4. package/brand/app-icon.svg +1 -0
  5. package/brand/avatar.svg +1 -0
  6. package/brand/favicon.svg +1 -0
  7. package/dist/components/accordion/accordion.d.ts +26 -0
  8. package/dist/components/accordion/accordion.js +78 -0
  9. package/dist/components/alert/alert.d.ts +19 -0
  10. package/dist/components/alert/alert.js +68 -0
  11. package/dist/components/alert-dialog/alert-dialog.d.ts +20 -0
  12. package/dist/components/alert-dialog/alert-dialog.js +75 -0
  13. package/dist/components/anchor-heading/anchor-heading.d.ts +19 -0
  14. package/dist/components/anchor-heading/anchor-heading.js +39 -0
  15. package/dist/components/avatar/avatar.d.ts +14 -0
  16. package/dist/components/avatar/avatar.js +42 -0
  17. package/dist/components/badge/badge.d.ts +12 -0
  18. package/dist/components/badge/badge.js +27 -0
  19. package/dist/components/breadcrumbs/breadcrumbs.d.ts +23 -0
  20. package/dist/components/breadcrumbs/breadcrumbs.js +63 -0
  21. package/dist/components/button/button-variants.d.ts +15 -0
  22. package/dist/components/button/button-variants.js +76 -0
  23. package/dist/components/button/button.d.ts +25 -0
  24. package/dist/components/button/button.js +50 -0
  25. package/dist/components/calendar/calendar-selection.js +216 -0
  26. package/dist/components/calendar/calendar.d.ts +44 -0
  27. package/dist/components/calendar/calendar.js +208 -0
  28. package/dist/components/callout/callout.d.ts +21 -0
  29. package/dist/components/callout/callout.js +75 -0
  30. package/dist/components/card/card.d.ts +16 -0
  31. package/dist/components/card/card.js +53 -0
  32. package/dist/components/checkbox/checkbox.d.ts +9 -0
  33. package/dist/components/checkbox/checkbox.js +33 -0
  34. package/dist/components/checkbox-group/checkbox-group.d.ts +18 -0
  35. package/dist/components/checkbox-group/checkbox-group.js +33 -0
  36. package/dist/components/code/code.d.ts +7 -0
  37. package/dist/components/code/code.js +16 -0
  38. package/dist/components/code-block/code-block-frame.js +146 -0
  39. package/dist/components/code-block/code-block-live.d.ts +45 -0
  40. package/dist/components/code-block/code-block-live.js +51 -0
  41. package/dist/components/code-block/code-block.d.ts +36 -0
  42. package/dist/components/code-block/code-block.js +51 -0
  43. package/dist/components/code-block/code-copy.d.ts +12 -0
  44. package/dist/components/code-block/code-copy.js +71 -0
  45. package/dist/components/code-block/code-lines-view.d.ts +16 -0
  46. package/dist/components/code-block/code-lines-view.js +48 -0
  47. package/dist/components/code-block/code-lines.js +17 -0
  48. package/dist/components/code-block/code-scroll.js +29 -0
  49. package/dist/components/code-block/code-surface.js +13 -0
  50. package/dist/components/code-block/code-tabs-frame.js +85 -0
  51. package/dist/components/code-block/code-tabs-store.js +25 -0
  52. package/dist/components/code-block/code-tabs.d.ts +28 -0
  53. package/dist/components/code-block/code-tabs.js +29 -0
  54. package/dist/components/code-block/highlight.d.ts +34 -0
  55. package/dist/components/code-block/highlight.js +258 -0
  56. package/dist/components/code-block/lines.d.ts +5 -0
  57. package/dist/components/code-block/lines.js +40 -0
  58. package/dist/components/collapsible/collapsible.d.ts +19 -0
  59. package/dist/components/collapsible/collapsible.js +54 -0
  60. package/dist/components/combobox/combobox.d.ts +84 -0
  61. package/dist/components/combobox/combobox.js +169 -0
  62. package/dist/components/container/container.d.ts +16 -0
  63. package/dist/components/container/container.js +30 -0
  64. package/dist/components/copy-pill/copy-pill.d.ts +52 -0
  65. package/dist/components/copy-pill/copy-pill.js +232 -0
  66. package/dist/components/cta/cta.d.ts +109 -0
  67. package/dist/components/cta/cta.js +375 -0
  68. package/dist/components/date-field/date-field.d.ts +40 -0
  69. package/dist/components/date-field/date-field.js +99 -0
  70. package/dist/components/date-range-field/date-range-field.d.ts +41 -0
  71. package/dist/components/date-range-field/date-range-field.js +155 -0
  72. package/dist/components/dialog/dialog.d.ts +29 -0
  73. package/dist/components/dialog/dialog.js +96 -0
  74. package/dist/components/docs-layout/docs-layout.d.ts +17 -0
  75. package/dist/components/docs-layout/docs-layout.js +46 -0
  76. package/dist/components/drawer/drawer.d.ts +39 -0
  77. package/dist/components/drawer/drawer.js +181 -0
  78. package/dist/components/field/field.d.ts +18 -0
  79. package/dist/components/field/field.js +77 -0
  80. package/dist/components/fieldset/fieldset.d.ts +8 -0
  81. package/dist/components/fieldset/fieldset.js +25 -0
  82. package/dist/components/figure/figure.d.ts +14 -0
  83. package/dist/components/figure/figure.js +35 -0
  84. package/dist/components/form/form.d.ts +31 -0
  85. package/dist/components/form/form.js +55 -0
  86. package/dist/components/ground/ground.d.ts +20 -0
  87. package/dist/components/ground/ground.js +31 -0
  88. package/dist/components/heading/heading.d.ts +16 -0
  89. package/dist/components/heading/heading.js +36 -0
  90. package/dist/components/icon/icon.d.ts +22 -0
  91. package/dist/components/icon/icon.js +24 -0
  92. package/dist/components/input/input.d.ts +19 -0
  93. package/dist/components/input/input.js +46 -0
  94. package/dist/components/input-group/input-group.d.ts +34 -0
  95. package/dist/components/input-group/input-group.js +61 -0
  96. package/dist/components/kbd/kbd.d.ts +6 -0
  97. package/dist/components/kbd/kbd.js +15 -0
  98. package/dist/components/link/link-variants.d.ts +13 -0
  99. package/dist/components/link/link-variants.js +27 -0
  100. package/dist/components/link/link.d.ts +9 -0
  101. package/dist/components/link/link.js +18 -0
  102. package/dist/components/logo/logo-paths.js +22 -0
  103. package/dist/components/logo/logomark.d.ts +19 -0
  104. package/dist/components/logo/logomark.js +49 -0
  105. package/dist/components/logo/wordmark.d.ts +35 -0
  106. package/dist/components/logo/wordmark.js +48 -0
  107. package/dist/components/menu/menu.d.ts +26 -0
  108. package/dist/components/menu/menu.js +132 -0
  109. package/dist/components/meter/meter.d.ts +29 -0
  110. package/dist/components/meter/meter.js +68 -0
  111. package/dist/components/navigation-menu/navigation-menu-variants.d.ts +12 -0
  112. package/dist/components/navigation-menu/navigation-menu-variants.js +18 -0
  113. package/dist/components/navigation-menu/navigation-menu.d.ts +42 -0
  114. package/dist/components/navigation-menu/navigation-menu.js +128 -0
  115. package/dist/components/number-field/number-field.d.ts +32 -0
  116. package/dist/components/number-field/number-field.js +85 -0
  117. package/dist/components/page-header/page-header.d.ts +27 -0
  118. package/dist/components/page-header/page-header.js +48 -0
  119. package/dist/components/pager/pager.d.ts +24 -0
  120. package/dist/components/pager/pager.js +51 -0
  121. package/dist/components/parameter-list/parameter-list.d.ts +34 -0
  122. package/dist/components/parameter-list/parameter-list.js +70 -0
  123. package/dist/components/popover/popover.d.ts +15 -0
  124. package/dist/components/popover/popover.js +64 -0
  125. package/dist/components/progress/progress.d.ts +19 -0
  126. package/dist/components/progress/progress.js +67 -0
  127. package/dist/components/prose/prose.d.ts +13 -0
  128. package/dist/components/prose/prose.js +22 -0
  129. package/dist/components/quote/quote.d.ts +21 -0
  130. package/dist/components/quote/quote.js +46 -0
  131. package/dist/components/radio/radio.d.ts +12 -0
  132. package/dist/components/radio/radio.js +37 -0
  133. package/dist/components/reference-entry/reference-entry.d.ts +25 -0
  134. package/dist/components/reference-entry/reference-entry.js +66 -0
  135. package/dist/components/section/section.d.ts +13 -0
  136. package/dist/components/section/section.js +30 -0
  137. package/dist/components/segmented-control/segmented-control.d.ts +42 -0
  138. package/dist/components/segmented-control/segmented-control.js +413 -0
  139. package/dist/components/select/select.d.ts +70 -0
  140. package/dist/components/select/select.js +189 -0
  141. package/dist/components/separator/separator.d.ts +12 -0
  142. package/dist/components/separator/separator.js +29 -0
  143. package/dist/components/side-nav/side-nav.d.ts +48 -0
  144. package/dist/components/side-nav/side-nav.js +89 -0
  145. package/dist/components/site-footer/site-footer-floor.js +48 -0
  146. package/dist/components/site-footer/site-footer.d.ts +38 -0
  147. package/dist/components/site-footer/site-footer.js +96 -0
  148. package/dist/components/site-header/site-header.d.ts +77 -0
  149. package/dist/components/site-header/site-header.js +214 -0
  150. package/dist/components/slider/slider.d.ts +42 -0
  151. package/dist/components/slider/slider.js +279 -0
  152. package/dist/components/spinner/spinner.d.ts +15 -0
  153. package/dist/components/spinner/spinner.js +34 -0
  154. package/dist/components/switch/switch.d.ts +8 -0
  155. package/dist/components/switch/switch.js +28 -0
  156. package/dist/components/table/table.d.ts +83 -0
  157. package/dist/components/table/table.js +123 -0
  158. package/dist/components/table-of-contents/table-of-contents.d.ts +32 -0
  159. package/dist/components/table-of-contents/table-of-contents.js +187 -0
  160. package/dist/components/tabs/tabs.d.ts +28 -0
  161. package/dist/components/tabs/tabs.js +124 -0
  162. package/dist/components/text/text.d.ts +16 -0
  163. package/dist/components/text/text.js +63 -0
  164. package/dist/components/textarea/textarea.d.ts +19 -0
  165. package/dist/components/textarea/textarea.js +30 -0
  166. package/dist/components/time-field/time-field.d.ts +40 -0
  167. package/dist/components/time-field/time-field.js +123 -0
  168. package/dist/components/toast/toast.d.ts +55 -0
  169. package/dist/components/toast/toast.js +129 -0
  170. package/dist/components/tooltip/tooltip.d.ts +16 -0
  171. package/dist/components/tooltip/tooltip.js +41 -0
  172. package/dist/index.d.ts +79 -0
  173. package/dist/index.js +77 -0
  174. package/dist/internal/arrow.js +41 -0
  175. package/dist/internal/disclosure.js +20 -0
  176. package/dist/internal/field-context.js +21 -0
  177. package/dist/internal/field.d.ts +23 -0
  178. package/dist/internal/field.js +49 -0
  179. package/dist/internal/glyphs.js +84 -0
  180. package/dist/internal/iso-date.d.ts +2 -0
  181. package/dist/internal/iso-date.js +268 -0
  182. package/dist/internal/overlay.js +40 -0
  183. package/dist/internal/picker-sheet.js +74 -0
  184. package/dist/internal/popup.js +37 -0
  185. package/dist/internal/range-shape.js +295 -0
  186. package/dist/internal/reduced-motion.js +19 -0
  187. package/dist/internal/scroll-edges.js +45 -0
  188. package/dist/internal/trough.js +39 -0
  189. package/dist/internal/typed-input.d.ts +16 -0
  190. package/dist/internal/typed-input.js +133 -0
  191. package/dist/lib/cn.d.ts +11 -0
  192. package/dist/lib/cn.js +98 -0
  193. package/dist/motion/inertia.js +111 -0
  194. package/dist/motion/spring-step.js +35 -0
  195. package/dist/motion/springs.d.ts +78 -0
  196. package/dist/motion/springs.js +81 -0
  197. package/package.json +107 -4
  198. package/src/styles/base.css +93 -0
  199. package/src/styles/calendar.css +117 -0
  200. package/src/styles/code.css +252 -0
  201. package/src/styles/density.css +53 -0
  202. package/src/styles/depth.css +501 -0
  203. package/src/styles/grounds.css +191 -0
  204. package/src/styles/marks.css +50 -0
  205. package/src/styles/motion.css +55 -0
  206. package/src/styles/motion.generated.css +101 -0
  207. package/src/styles/prose.css +252 -0
  208. package/src/styles/radius.css +20 -0
  209. package/src/styles/segmented.css +208 -0
  210. package/src/styles/slider.css +110 -0
  211. package/src/styles/status.css +108 -0
  212. package/src/styles/tabs.css +39 -0
  213. package/src/styles/toast.css +106 -0
  214. package/src/styles/touch.css +41 -0
  215. package/src/styles/type.css +54 -0
  216. package/src/styles.css +38 -0
@@ -0,0 +1,375 @@
1
+ "use client";
2
+ import { Avatar, AvatarFallback } from "../avatar/avatar.js";
3
+ import { Button } from "../button/button.js";
4
+ import { buttonVariants } from "../button/button-variants.js";
5
+ import { Form } from "../form/form.js";
6
+ import { Heading } from "../heading/heading.js";
7
+ import { Text } from "../text/text.js";
8
+ import { ActionArrow } from "../../internal/arrow.js";
9
+ import { TickGlyph } from "../../internal/glyphs.js";
10
+ import { cn } from "../../lib/cn.js";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ import { createContext, useContext, useLayoutEffect, useRef, useState, useTransition } from "react";
13
+ // src/components/cta/cta.tsx
14
+ const KindContext = createContext("joint");
15
+ /**
16
+ * The colours a Cta's block can take: a fitting's tones from depth.css, so its edge, light, shade
17
+ * and shadow follow the face on every ground.
18
+ * accent the ask: Indigo on Paper, the light violet on Ink, white on an Indigo page
19
+ * key the committed key: charcoal, a Paper face on Ink
20
+ * raised the neutral fitting: a white face (a deeper Indigo on an Indigo page)
21
+ */
22
+ const tones = {
23
+ accent: {
24
+ knobs: "depth-tone-accent",
25
+ fill: "bg-accent",
26
+ text: "text-on-accent"
27
+ },
28
+ key: {
29
+ knobs: "depth-tone-key",
30
+ fill: "bg-key",
31
+ text: "text-on-key"
32
+ },
33
+ raised: {
34
+ knobs: "",
35
+ fill: "bg-raised",
36
+ text: "text-fg"
37
+ }
38
+ };
39
+ const ToneContext = createContext("accent");
40
+ const SeatContext = createContext(null);
41
+ /** Room between the block and what is seated in its cut, in px. */
42
+ const GAP = 10;
43
+ /** The block's own corners, and the bend where the cut meets its edges, in px. */
44
+ const OUTER = 20;
45
+ const BEND = 14;
46
+ /**
47
+ * The block's outline with the cut, as one path. `grow` lays it 1px further out (the edge), `dy`
48
+ * moves it down or up (the light and the shade). It is drawn in a box 1px larger on every side,
49
+ * so the edge has room.
50
+ */
51
+ function outline({ w, h, nw, nh, k }, grow = 0, dy = 0) {
52
+ const x0 = 1 - grow;
53
+ const y0 = 1 - grow + dy;
54
+ const x1 = 1 + w + grow;
55
+ const y1 = 1 + h + grow + dy;
56
+ const r = OUTER + grow;
57
+ if (nw <= 0 || nh <= 0) return [
58
+ `M${x0 + r} ${y0}`,
59
+ `H${x1 - r}`,
60
+ `A${r} ${r} 0 0 1 ${x1} ${y0 + r}`,
61
+ `V${y1 - r}`,
62
+ `A${r} ${r} 0 0 1 ${x1 - r} ${y1}`,
63
+ `H${x0 + r}`,
64
+ `A${r} ${r} 0 0 1 ${x0} ${y1 - r}`,
65
+ `V${y0 + r}`,
66
+ `A${r} ${r} 0 0 1 ${x0 + r} ${y0}`,
67
+ "Z"
68
+ ].join(" ");
69
+ const c = Math.min(BEND, nh / 2, nw / 2) + grow;
70
+ const kk = k - grow;
71
+ const nx = x1 - nw;
72
+ const ny = y1 - nh;
73
+ return [
74
+ `M${x0 + r} ${y0}`,
75
+ `H${x1 - r}`,
76
+ `A${r} ${r} 0 0 1 ${x1} ${y0 + r}`,
77
+ `V${ny - c}`,
78
+ `A${c} ${c} 0 0 1 ${x1 - c} ${ny}`,
79
+ `H${nx + kk}`,
80
+ `A${kk} ${kk} 0 0 0 ${nx} ${ny + kk}`,
81
+ `V${y1 - c}`,
82
+ `A${c} ${c} 0 0 1 ${nx - c} ${y1}`,
83
+ `H${x0 + r}`,
84
+ `A${r} ${r} 0 0 1 ${x0} ${y1 - r}`,
85
+ `V${y0 + r}`,
86
+ `A${r} ${r} 0 0 1 ${x0 + r} ${y0}`,
87
+ "Z"
88
+ ].join(" ");
89
+ }
90
+ /**
91
+ * The block's face, cut to the outline in the Fase recipe of a raised part, each layer clipped
92
+ * to the shape as the calendar's selection is:
93
+ * edge the outline grown by a pixel, in the fill's own darker hue, under everything
94
+ * face the accent with its gloss
95
+ * light a pixel along every edge that faces up: the shape, less itself moved down by one
96
+ * shade the same along every edge that faces down, the cut's top among them
97
+ * and a short contact shadow under all of it, which follows the outline (`drop-shadow`). Every
98
+ * colour is a knob of the block's tone (`depth-tone-*`, the neutral surface without one), so
99
+ * every ground is right. The knobs do not inherit, so every layer carries the tone itself.
100
+ */
101
+ function JointFace({ notch, tone }) {
102
+ const { knobs, fill } = tones[tone];
103
+ const face = outline(notch);
104
+ const clip = (d) => ({ clipPath: `path("${d}")` });
105
+ const strip = (dy) => ({ clipPath: `path(evenodd, "${face} ${outline(notch, 0, dy)}")` });
106
+ return /* @__PURE__ */ jsxs("div", {
107
+ "aria-hidden": true,
108
+ "data-slot": "cta-face",
109
+ className: cn("absolute -inset-px -z-10", "[filter:drop-shadow(0_1px_2px_var(--d-contact,var(--depth-surface-contact)))_drop-shadow(0_6px_14px_var(--d-ambient,var(--depth-surface-ambient)))]", knobs),
110
+ children: [
111
+ /* @__PURE__ */ jsx("div", {
112
+ className: cn("absolute inset-0 bg-[var(--d-edge,var(--depth-surface-edge))]", knobs),
113
+ style: clip(outline(notch, 1))
114
+ }),
115
+ /* @__PURE__ */ jsx("div", {
116
+ className: cn("absolute inset-0 [background-image:var(--d-face,var(--depth-surface-face))]", fill, knobs),
117
+ style: clip(face)
118
+ }),
119
+ /* @__PURE__ */ jsxs("div", {
120
+ className: "absolute inset-0",
121
+ style: clip(face),
122
+ children: [/* @__PURE__ */ jsx("div", {
123
+ className: cn("absolute inset-0 bg-[var(--d-hi,var(--depth-surface-hi))]", knobs),
124
+ style: strip(1)
125
+ }), /* @__PURE__ */ jsx("div", {
126
+ className: cn("absolute inset-0 bg-[var(--d-lo,var(--depth-surface-lo))]", knobs),
127
+ style: strip(-1)
128
+ })]
129
+ })
130
+ ]
131
+ });
132
+ }
133
+ /**
134
+ * The closing ask of a page, as a joint: a block in a button's recipe (by default the `ask`'s:
135
+ * Indigo on Paper, the light violet on Ink, white on an Indigo page; or `tone` `key` or
136
+ * `raised`) whose lower right corner is cut away, with
137
+ * the actions seated in the cut on the page's own ground. The cut's inner corner is concentric
138
+ * with the first button in it, so block and buttons read as two parts of one joint. Where the
139
+ * block is narrow (below 42rem, a phone) there is no cut: the buttons stand inside the block at
140
+ * its foot, one over the other at its full width.
141
+ *
142
+ * Put it last on a page, above the footer, once. Word the title as what to send („Erzähl mir von
143
+ * deinem Produkt."), the text as what happens next. One action, or two: the second is quieter.
144
+ */
145
+ function Cta({ tone = "accent", className, children, ...props }) {
146
+ const block = useRef(null);
147
+ const [seat, setSeat] = useState(null);
148
+ const [notch, setNotch] = useState(null);
149
+ const [clear, setClear] = useState(null);
150
+ useLayoutEffect(() => {
151
+ const outer = block.current;
152
+ if (!outer || !seat) return;
153
+ const measure = () => {
154
+ if (getComputedStyle(seat).position === "static") {
155
+ setNotch({
156
+ w: outer.offsetWidth,
157
+ h: outer.offsetHeight,
158
+ nw: 0,
159
+ nh: 0,
160
+ k: 0
161
+ });
162
+ setClear(true);
163
+ return;
164
+ }
165
+ const first = seat.firstElementChild;
166
+ const radius = first ? Number.parseFloat(getComputedStyle(first).borderTopLeftRadius) || 0 : 0;
167
+ const next = {
168
+ w: outer.offsetWidth,
169
+ h: outer.offsetHeight,
170
+ nw: seat.offsetWidth + GAP,
171
+ nh: seat.offsetHeight + GAP,
172
+ k: radius + GAP
173
+ };
174
+ setNotch(next);
175
+ const box = outer.getBoundingClientRect();
176
+ const scale = box.width / outer.offsetWidth || 1;
177
+ const top = Number.parseFloat(getComputedStyle(outer).paddingTop) || 0;
178
+ let bottom = 0;
179
+ const lines = [];
180
+ const range = document.createRange();
181
+ for (const child of outer.children) {
182
+ if (child === seat || child.getAttribute("data-slot") === "cta-face") continue;
183
+ const element = child;
184
+ bottom = Math.max(bottom, element.offsetTop + element.offsetHeight);
185
+ range.selectNodeContents(element);
186
+ lines.push(...range.getClientRects());
187
+ }
188
+ const cutTop = bottom + top - next.nh;
189
+ const cutLeft = next.w - next.nw - 20;
190
+ setClear(lines.every((line) => (line.bottom - box.top) / scale <= cutTop || (line.right - box.left) / scale <= cutLeft));
191
+ };
192
+ measure();
193
+ const observer = new ResizeObserver(measure);
194
+ observer.observe(outer);
195
+ observer.observe(seat);
196
+ return () => observer.disconnect();
197
+ }, [seat]);
198
+ return /* @__PURE__ */ jsx(KindContext, {
199
+ value: "joint",
200
+ children: /* @__PURE__ */ jsx(ToneContext, {
201
+ value: tone,
202
+ children: /* @__PURE__ */ jsx(SeatContext, {
203
+ value: setSeat,
204
+ children: /* @__PURE__ */ jsxs("div", {
205
+ ref: block,
206
+ "data-slot": "cta",
207
+ "data-tone": tone,
208
+ className: cn("@container relative isolate flex flex-col gap-3 px-7 pt-7 sm:px-10 sm:pt-8", tones[tone].text, clear === null ? "pb-[calc(var(--cta-notch,3.5rem)+1.25rem)] @max-2xl:pb-7 @max-2xl:sm:pb-8 @4xl:pb-7 @4xl:sm:pb-8" : clear ? "pb-7 sm:pb-8" : "pb-[calc(var(--cta-notch,3.5rem)+1.25rem)]", !notch && ["rounded-[20px]", tones[tone].fill], className),
209
+ style: { "--cta-notch": notch ? `${notch.nh}px` : void 0 },
210
+ ...props,
211
+ children: [notch && /* @__PURE__ */ jsx(JointFace, {
212
+ notch,
213
+ tone
214
+ }), children]
215
+ })
216
+ })
217
+ })
218
+ });
219
+ }
220
+ /** The title: a sentence with a full stop that says what to send. */
221
+ function CtaTitle({ className, ...props }) {
222
+ const kind = useContext(KindContext);
223
+ const tone = useContext(ToneContext);
224
+ return /* @__PURE__ */ jsx(Heading, {
225
+ "data-slot": "cta-title",
226
+ level: 2,
227
+ size: kind === "joint" ? "title" : "sub",
228
+ className: cn("max-w-[40rem]", kind === "joint" ? [tones[tone].text, "max-sm:text-xl"] : "text-fg", className),
229
+ ...props
230
+ });
231
+ }
232
+ /** One or two sentences: that the first conversation costs nothing, that he answers. */
233
+ function CtaText({ className, ...props }) {
234
+ const kind = useContext(KindContext);
235
+ const tone = useContext(ToneContext);
236
+ return /* @__PURE__ */ jsx(Text, {
237
+ "data-slot": "cta-text",
238
+ size: kind === "joint" ? "lg" : "base",
239
+ className: cn("max-w-[34rem] text-pretty", kind === "joint" ? tones[tone].text : "-mt-3 text-fg-muted", className),
240
+ ...props
241
+ });
242
+ }
243
+ /**
244
+ * The actions of a Cta, seated in its cut: the first at the outer edge, a second, quieter one
245
+ * beside it. Where the block is narrower than 42rem there is no cut: they stand inside the block
246
+ * at its foot, one over the other at its full width.
247
+ */
248
+ function CtaActions({ className, ...props }) {
249
+ const seat = useContext(SeatContext);
250
+ return /* @__PURE__ */ jsx("div", {
251
+ ref: seat ?? void 0,
252
+ "data-slot": "cta-actions",
253
+ className: cn("flex flex-col gap-2.5 @max-2xl:mt-3 @2xl:absolute @2xl:right-0 @2xl:bottom-0 @2xl:flex-row-reverse", className),
254
+ ...props
255
+ });
256
+ }
257
+ /**
258
+ * One action of a Cta or a CtaMessage: a link that looks like a button. The first carries the
259
+ * arrow, which grows from a chevron when it is pointed at. Word it as what happens
260
+ * („Nachricht schreiben"). Where two actions lead to different kinds of place, give each its
261
+ * `icon`, so they are told apart before they are read.
262
+ */
263
+ function CtaAction({ variant = "primary", icon, arrow, className, children, ...props }) {
264
+ const kind = useContext(KindContext);
265
+ const direction = arrow ?? (variant === "primary" || variant === "ask" ? "right" : false);
266
+ return /* @__PURE__ */ jsxs("a", {
267
+ "data-slot": "cta-action",
268
+ "data-variant": variant,
269
+ className: cn(buttonVariants({
270
+ variant,
271
+ size: kind === "joint" ? "lg" : "md"
272
+ }), className),
273
+ ...props,
274
+ children: [
275
+ icon,
276
+ children,
277
+ direction && /* @__PURE__ */ jsx(ActionArrow, {
278
+ direction,
279
+ size: kind === "joint" ? 18 : 16
280
+ })
281
+ ]
282
+ });
283
+ }
284
+ /**
285
+ * The closing ask as a letter already begun: a resting sheet with the title, the first fields
286
+ * of a message (pass `Field`s as children, with their `name`s), whom it goes to, and the send
287
+ * key. Sent, the sheet says so in place, with a drawn tick, and keeps its height. Not sent, it
288
+ * says so above the key and keeps what was typed.
289
+ *
290
+ * For a contact page, or wherever the first step can happen on the page itself.
291
+ */
292
+ function CtaMessage({ action, recipient, initials, sendLabel = "Nachricht senden", secondAction, sentTitle = "Die Nachricht wurde gesendet.", sentText, failedText = "Die Nachricht wurde nicht gesendet. Bitte versuche es noch einmal.", sent: sentProp = false, className, children, ...props }) {
293
+ const [state, setState] = useState(sentProp ? "sent" : "draft");
294
+ const [pending, startTransition] = useTransition();
295
+ const sent = state === "sent";
296
+ function send(form) {
297
+ const data = new FormData(form);
298
+ startTransition(async () => {
299
+ try {
300
+ await action(data);
301
+ setState("sent");
302
+ } catch {
303
+ setState("failed");
304
+ }
305
+ });
306
+ }
307
+ return /* @__PURE__ */ jsx(KindContext, {
308
+ value: "message",
309
+ children: /* @__PURE__ */ jsx("div", {
310
+ "data-slot": "cta-message",
311
+ className: cn("flex w-full max-w-[42rem] flex-col overflow-hidden rounded-xl bg-surface depth-card", className),
312
+ ...props,
313
+ children: /* @__PURE__ */ jsxs(Form, {
314
+ className: "gap-0",
315
+ onFormSubmit: (_values, details) => send(details.event.target),
316
+ children: [/* @__PURE__ */ jsxs("div", {
317
+ className: "grid *:col-start-1 *:row-start-1",
318
+ children: [/* @__PURE__ */ jsx("div", {
319
+ "aria-hidden": sent,
320
+ inert: sent,
321
+ className: cn("flex flex-col gap-4 p-6 transition-opacity spring-settle", sent && "opacity-0 spring-leave"),
322
+ children
323
+ }), /* @__PURE__ */ jsxs("div", {
324
+ "aria-hidden": !sent,
325
+ inert: !sent,
326
+ role: "status",
327
+ className: cn("flex flex-col items-center justify-center gap-2 px-6 text-center opacity-0 transition-opacity spring-leave", sent && "opacity-100 spring-settle"),
328
+ children: [/* @__PURE__ */ jsx("span", {
329
+ className: "mb-1 grid size-10 place-items-center rounded-full bg-success-soft text-success",
330
+ children: /* @__PURE__ */ jsx(TickGlyph, {
331
+ width: 18,
332
+ height: 18,
333
+ strokeWidth: 1.5,
334
+ className: cn("transition-[stroke-dashoffset] delay-150 duration-300 ease-out [stroke-dasharray:1] [stroke-dashoffset:1]", sent && "[stroke-dashoffset:0]")
335
+ })
336
+ }), sent && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
337
+ className: "text-lg font-semibold text-fg",
338
+ children: sentTitle
339
+ }), sentText && /* @__PURE__ */ jsx("p", {
340
+ className: "text-fg-muted",
341
+ children: sentText
342
+ })] })]
343
+ })]
344
+ }), /* @__PURE__ */ jsxs("div", {
345
+ "data-slot": "cta-message-footer",
346
+ className: "flex flex-wrap items-center justify-between gap-3 border-t border-hairline bg-well px-6 py-3 text-sm text-fg-muted",
347
+ children: [/* @__PURE__ */ jsxs("span", {
348
+ className: "flex items-center gap-2.5",
349
+ children: [initials && /* @__PURE__ */ jsx(Avatar, {
350
+ size: "sm",
351
+ children: /* @__PURE__ */ jsx(AvatarFallback, { children: initials })
352
+ }), recipient]
353
+ }), /* @__PURE__ */ jsxs("span", {
354
+ className: "ml-auto flex flex-wrap items-center justify-end gap-2",
355
+ children: [
356
+ state === "failed" && /* @__PURE__ */ jsx("span", {
357
+ role: "alert",
358
+ className: "basis-full text-right text-danger",
359
+ children: failedText
360
+ }),
361
+ !sent && secondAction,
362
+ !sent && /* @__PURE__ */ jsxs(Button, {
363
+ type: "submit",
364
+ variant: "primary",
365
+ loading: pending,
366
+ children: [sendLabel, /* @__PURE__ */ jsx(ActionArrow, { size: 16 })]
367
+ })
368
+ ]
369
+ })]
370
+ })]
371
+ })
372
+ })
373
+ });
374
+ }
375
+ export { Cta, CtaAction, CtaActions, CtaMessage, CtaText, CtaTitle };
@@ -0,0 +1,40 @@
1
+ import { FieldSize } from "../../internal/field.js";
2
+ import { HourCycle } from "../../internal/iso-date.js";
3
+ import { TypedInputProps } from "../../internal/typed-input.js";
4
+ export type DateFieldProps = Omit<TypedInputProps, "text" | "onTextChange" | "onCommit" | "formValue" | "problem" | "size" | "min" | "max"> & {
5
+ /** Classes for the field as a whole, e.g. its width. */
6
+ className?: string;
7
+ /**
8
+ * The date as an ISO string (`2026-11-14`, with `time` `2026-11-14T09:30`), or `""` for none
9
+ * (controlled).
10
+ */
11
+ value?: string;
12
+ /** The date at first (uncontrolled). */
13
+ defaultValue?: string;
14
+ /** Reports the date as an ISO string, `""` when the field is empty or cannot be read. */
15
+ onValueChange?: (value: string) => void;
16
+ /** The first and the last day that can be chosen, as ISO dates. */
17
+ min?: string;
18
+ max?: string;
19
+ /** Also take a time of day: an appointment, not only a day. */
20
+ time?: boolean;
21
+ /** With `time`: the clock it is written on, 24 hours (the default) or 12 with AM and PM. */
22
+ hourCycle?: HourCycle;
23
+ /** The size of the field, from the density. */
24
+ size?: FieldSize;
25
+ /** The day that counts as today, as an ISO date. The real one unless given. */
26
+ today?: string;
27
+ };
28
+ /**
29
+ * A date: "gültig bis", "fällig am". With `time`, a date and a time of day: "Termin am".
30
+ *
31
+ * It is typed the German way and read when the field is left: `30.11.2026`, `30.11.`, `301126`;
32
+ * with a time `30.11. 9:30`, `30.11.2026, 9 Uhr`, `30.11. 9 pm`. A date without a time gets
33
+ * 09:00. The button opens our calendar, on a phone as well: it looks and works the same
34
+ * everywhere. Under the calendar the time is a small `TimeField`, typed or picked.
35
+ *
36
+ * The value is an ISO string, without a time zone: `2026-11-30`, or `2026-11-30T09:30`. Inside
37
+ * a `Form`, `name` submits exactly that. Text that is not a date stays in the field to be
38
+ * corrected, the value is empty meanwhile, and a `FieldError` says what is wrong.
39
+ */
40
+ export declare function DateField({ value, defaultValue, onValueChange, min, max, time, hourCycle, size, className, today, disabled, ...props }: DateFieldProps): import("react").JSX.Element;
@@ -0,0 +1,99 @@
1
+ "use client";
2
+ import { Calendar } from "../calendar/calendar.js";
3
+ import { InputGroup } from "../input-group/input-group.js";
4
+ import { Popover } from "../popover/popover.js";
5
+ import { DEFAULT_TIME, formatGermanMoment, outsideLimits, parseGermanMoment, parseIsoDate, splitIsoMoment } from "../../internal/iso-date.js";
6
+ import { PickerButton, PickerSheet, PickerTime } from "../../internal/picker-sheet.js";
7
+ import { TypedInput, useTypedValue } from "../../internal/typed-input.js";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { useRef, useState } from "react";
10
+ // src/components/date-field/date-field.tsx
11
+ /**
12
+ * A date: "gültig bis", "fällig am". With `time`, a date and a time of day: "Termin am".
13
+ *
14
+ * It is typed the German way and read when the field is left: `30.11.2026`, `30.11.`, `301126`;
15
+ * with a time `30.11. 9:30`, `30.11.2026, 9 Uhr`, `30.11. 9 pm`. A date without a time gets
16
+ * 09:00. The button opens our calendar, on a phone as well: it looks and works the same
17
+ * everywhere. Under the calendar the time is a small `TimeField`, typed or picked.
18
+ *
19
+ * The value is an ISO string, without a time zone: `2026-11-30`, or `2026-11-30T09:30`. Inside
20
+ * a `Form`, `name` submits exactly that. Text that is not a date stays in the field to be
21
+ * corrected, the value is empty meanwhile, and a `FieldError` says what is wrong.
22
+ */
23
+ function DateField({ value, defaultValue, onValueChange, min, max, time = false, hourCycle = 24, size, className, today, disabled, ...props }) {
24
+ const now = parseIsoDate(today);
25
+ const typed = useTypedValue({
26
+ value,
27
+ defaultValue,
28
+ onValueChange,
29
+ show: (moment) => formatGermanMoment(moment, hourCycle),
30
+ read: (text) => {
31
+ const read = parseGermanMoment(text, now);
32
+ if (!read) return { problem: time ? "Bitte geben Sie Datum und Uhrzeit ein, zum Beispiel 30.11.2026, 09:30." : "Bitte geben Sie ein Datum ein, zum Beispiel 30.11.2026." };
33
+ const outside = outsideLimits(read.date, min, max);
34
+ if (outside) return { problem: outside };
35
+ return time ? `${read.date}T${read.time || "09:00"}` : read.date;
36
+ }
37
+ });
38
+ const [open, setOpen] = useState(false);
39
+ const field = useRef(null);
40
+ const chosen = splitIsoMoment(typed.value);
41
+ const [waiting, setWaiting] = useState(DEFAULT_TIME);
42
+ const clock = chosen?.time || waiting;
43
+ return /* @__PURE__ */ jsxs(Popover, {
44
+ open,
45
+ onOpenChange: setOpen,
46
+ children: [/* @__PURE__ */ jsxs(InputGroup, {
47
+ ref: field,
48
+ "data-slot": "date-field",
49
+ size,
50
+ className,
51
+ children: [/* @__PURE__ */ jsx(TypedInput, {
52
+ inputMode: time ? void 0 : "numeric",
53
+ placeholder: time ? `z. B. ${formatGermanMoment("2026-11-30T09:30", hourCycle)}` : "z. B. 30.11.2026",
54
+ text: typed.text,
55
+ onTextChange: typed.setText,
56
+ onCommit: typed.commit,
57
+ formValue: typed.value,
58
+ problem: typed.problem,
59
+ disabled,
60
+ className: "tabular-nums",
61
+ ...props,
62
+ "data-slot": "date-field-input"
63
+ }), /* @__PURE__ */ jsx(PickerButton, {
64
+ size,
65
+ disabled: disabled || props.readOnly
66
+ })]
67
+ }), /* @__PURE__ */ jsxs(PickerSheet, {
68
+ anchor: field,
69
+ label: time ? "Datum und Uhrzeit wählen" : "Datum wählen",
70
+ done: time,
71
+ children: [/* @__PURE__ */ jsx(Calendar, {
72
+ value: chosen?.date ?? "",
73
+ min,
74
+ max,
75
+ today,
76
+ onValueChange: (date) => {
77
+ typed.set(time ? `${date}T${clock}` : date);
78
+ if (!time) setOpen(false);
79
+ }
80
+ }), time && /* @__PURE__ */ jsx("div", {
81
+ className: "flex items-center justify-between gap-3 border-t border-hairline pt-3 text-control text-fg-body",
82
+ children: /* @__PURE__ */ jsx(PickerTime, {
83
+ label: "Uhrzeit",
84
+ hourCycle,
85
+ value: clock,
86
+ onValueChange: (next) => {
87
+ if (next === "") return;
88
+ setWaiting(next);
89
+ if (chosen) typed.set(`${chosen.date}T${next}`);
90
+ },
91
+ onKeyDown: (event) => {
92
+ if (event.key === "Enter") setOpen(false);
93
+ }
94
+ })
95
+ })]
96
+ })]
97
+ });
98
+ }
99
+ export { DateField };
@@ -0,0 +1,41 @@
1
+ import { DateRange } from "../calendar/calendar.js";
2
+ import { FieldSize } from "../../internal/field.js";
3
+ import { HourCycle } from "../../internal/iso-date.js";
4
+ import { TypedInputProps } from "../../internal/typed-input.js";
5
+ export type DateRangeFieldProps = Omit<TypedInputProps, "text" | "onTextChange" | "onCommit" | "formValue" | "problem" | "size" | "min" | "max"> & {
6
+ /** Classes for the field as a whole, e.g. its width. */
7
+ className?: string;
8
+ /**
9
+ * The range as two ISO strings (`{ from: "2026-11-14", to: "2026-11-30" }`, with `time`
10
+ * `2026-11-14T09:00`), both `""` for none (controlled).
11
+ */
12
+ value?: DateRange;
13
+ /** The range at first (uncontrolled). */
14
+ defaultValue?: DateRange;
15
+ /** Reports the range, both ends `""` when the field is empty or cannot be read. */
16
+ onValueChange?: (value: DateRange) => void;
17
+ /** The first and the last day that can be chosen, as ISO dates. */
18
+ min?: string;
19
+ max?: string;
20
+ /** Each end also takes a time of day: a booking, not only a span of days. */
21
+ time?: boolean;
22
+ /** With `time`: the clock they are written on, 24 hours (the default) or 12 with AM and PM. */
23
+ hourCycle?: HourCycle;
24
+ /** The size of the field, from the density. */
25
+ size?: FieldSize;
26
+ /** The day that counts as today, as an ISO date. The real one unless given. */
27
+ today?: string;
28
+ };
29
+ /**
30
+ * A span of days: "Urlaub vom … bis", "Leistungszeitraum". With `time`, from a moment to a
31
+ * moment: a booking.
32
+ *
33
+ * It is typed the German way and read when the field is left: `14.11. – 30.11.2026`,
34
+ * `14.–30.11.`, `14.11.2026 bis 30.11.2026`; with times `14.11., 9:00 – 16.11., 17:00` or, on one
35
+ * day, `14.11. 9–17 Uhr`. One date alone is a range of that day. In the calendar the first press
36
+ * sets one end and the second the other; with times, each end has a small `TimeField` under it.
37
+ *
38
+ * The value is `{ from, to }` in ISO strings. Inside a `Form`, `name` submits both as one ISO
39
+ * interval, `2026-11-14/2026-11-30`: split it at the slash.
40
+ */
41
+ export declare function DateRangeField({ value, defaultValue, onValueChange, min, max, time, hourCycle, size, className, today, disabled, ...props }: DateRangeFieldProps): import("react").JSX.Element;