@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
@@ -0,0 +1,306 @@
1
+ "use client";
2
+ import { useGround } from "../ground/ground.js";
3
+ import { linkVariants } from "../link/link-variants.js";
4
+ import { cn, mergeClassName } from "../../lib/cn.js";
5
+ import { ConsentCard } from "./consent-card.js";
6
+ import { consentLabels } from "./consent-labels.js";
7
+ import { consentAllows, consentConfigProblems, consentFingerprint } from "./consent-record.js";
8
+ import { createConsentStore } from "./consent-store.js";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { createContext, use, useCallback, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
11
+ import { Dialog } from "@base-ui/react/dialog";
12
+ // src/components/consent/consent.tsx
13
+ const ConsentContext = createContext(null);
14
+ function useConsentContext(part) {
15
+ const context = use(ConsentContext);
16
+ if (!context) throw new Error(`${part} must be placed inside a ConsentProvider.`);
17
+ return context;
18
+ }
19
+ /**
20
+ * Asks for consent before any service that stores or reads data in the browser is loaded, and
21
+ * keeps the answer. Put it once around the app, in the root layout; it renders the banner
22
+ * itself. On the first visit the banner stands at the foot of the window without covering the
23
+ * page: „Alle ablehnen“ and „Alle akzeptieren“ side by side, equal in every way, and the
24
+ * settings one step away in the same card. Gate what needs consent with `ConsentGate` or
25
+ * `ConsentEmbed`, and put a `ConsentSettingsTrigger` in the footer of every page so the answer
26
+ * can be changed as easily as it was given.
27
+ *
28
+ * It frames the legal requirements (DSK, OH Digitale Dienste; § 25 TDDDG); the site still states
29
+ * its services truthfully in `config` and in its privacy policy.
30
+ */
31
+ function ConsentProvider({ config, privacyHref, imprintHref, intro, labels, onChange, persist, jar, children }) {
32
+ const key = `${consentFingerprint(config)}|${config.cookieName ?? ""}|${config.maxAgeDays ?? ""}`;
33
+ const [current, setCurrent] = useState(() => ({
34
+ key,
35
+ jar,
36
+ store: createConsentStore(config, { jar })
37
+ }));
38
+ if (current.key !== key || current.jar !== jar) setCurrent({
39
+ key,
40
+ jar,
41
+ store: createConsentStore(config, { jar })
42
+ });
43
+ const { store } = current;
44
+ const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
45
+ const latest = useRef({
46
+ onChange,
47
+ persist
48
+ });
49
+ useEffect(() => {
50
+ latest.current = {
51
+ onChange,
52
+ persist
53
+ };
54
+ });
55
+ useEffect(() => {
56
+ store.setOnChange((record, change) => latest.current.onChange?.(record, change));
57
+ store.setPersist((value, maxAge) => latest.current.persist?.(value, maxAge));
58
+ store.announce();
59
+ }, [store]);
60
+ useEffect(() => {
61
+ for (const problem of consentConfigProblems(config)) console.error(problem);
62
+ }, [key]);
63
+ const [handle] = useState(() => Dialog.createHandle());
64
+ const [panel, setPanel] = useState({
65
+ open: false,
66
+ triggerId: null
67
+ });
68
+ /** The card stays a moment after a decision in the settings, while its switches settle. */
69
+ const [holding, setHolding] = useState(false);
70
+ const reloadAfterClose = useRef(false);
71
+ /**
72
+ * The banner waits one frame after mounting. Hydrated from the server it would open after
73
+ * hydration anyway; mounted in the browser it would otherwise be open from its first frame and
74
+ * arrive without its entrance.
75
+ */
76
+ const [arrived, setArrived] = useState(false);
77
+ useEffect(() => {
78
+ const frame = requestAnimationFrame(() => setArrived(true));
79
+ return () => cancelAnimationFrame(frame);
80
+ }, []);
81
+ const merged = useMemo(() => ({
82
+ ...consentLabels,
83
+ ...labels
84
+ }), [labels]);
85
+ const undecided = snapshot.status === "undecided";
86
+ const open = arrived && (undecided || panel.open || holding);
87
+ const allows = useCallback((id) => {
88
+ if (snapshot.status === "unknown") return false;
89
+ const category = config.categories.find((entry) => entry.id === id);
90
+ const ids = category ? category.services.map((service) => service.id) : [id];
91
+ const granted = [...snapshot.record?.granted ?? [], ...snapshot.session];
92
+ return consentAllows({ granted }, id, config) || ids.length > 0 && ids.every((each) => snapshot.session.has(each));
93
+ }, [config, snapshot]);
94
+ const decide = useCallback((granted, hold = 0) => {
95
+ const { reload } = store.decide(granted);
96
+ setPanel((previous) => ({
97
+ ...previous,
98
+ open: false
99
+ }));
100
+ if (hold > 0) {
101
+ setHolding(true);
102
+ window.setTimeout(() => setHolding(false), hold);
103
+ }
104
+ if (reload) {
105
+ if (open) reloadAfterClose.current = true;
106
+ else window.location.reload();
107
+ }
108
+ }, [store, open]);
109
+ const openSettings = useCallback(() => setPanel({
110
+ open: true,
111
+ triggerId: null
112
+ }), []);
113
+ const value = useMemo(() => ({
114
+ config,
115
+ labels: merged,
116
+ store,
117
+ snapshot,
118
+ handle,
119
+ open,
120
+ allows,
121
+ decide: (granted) => decide(granted),
122
+ openSettings
123
+ }), [
124
+ config,
125
+ merged,
126
+ store,
127
+ snapshot,
128
+ handle,
129
+ open,
130
+ allows,
131
+ decide,
132
+ openSettings
133
+ ]);
134
+ const [opening, setOpening] = useState({
135
+ count: 0,
136
+ view: "intro",
137
+ revisiting: false
138
+ });
139
+ const [wasOpen, setWasOpen] = useState(open);
140
+ if (open !== wasOpen) {
141
+ setWasOpen(open);
142
+ if (open) setOpening({
143
+ count: opening.count + 1,
144
+ view: undecided ? "intro" : "settings",
145
+ revisiting: !undecided
146
+ });
147
+ }
148
+ return /* @__PURE__ */ jsxs(ConsentContext, {
149
+ value,
150
+ children: [children, /* @__PURE__ */ jsx(Dialog.Root, {
151
+ handle,
152
+ open,
153
+ triggerId: panel.triggerId,
154
+ modal: false,
155
+ disablePointerDismissal: undecided || holding,
156
+ onOpenChange: (next, details) => {
157
+ if (next) setPanel({
158
+ open: true,
159
+ triggerId: details.trigger?.id ?? null
160
+ });
161
+ else if (undecided || holding) {
162
+ details.cancel();
163
+ details.allowPropagation();
164
+ } else setPanel((previous) => ({
165
+ ...previous,
166
+ open: false
167
+ }));
168
+ },
169
+ onOpenChangeComplete: (isOpen) => {
170
+ if (!isOpen && reloadAfterClose.current) window.location.reload();
171
+ },
172
+ children: /* @__PURE__ */ jsx(ConsentBanner, {
173
+ config,
174
+ labels: merged,
175
+ intro,
176
+ privacyHref,
177
+ imprintHref,
178
+ granted: snapshot.record?.granted ?? [],
179
+ defaultView: opening.view,
180
+ revisiting: opening.revisiting,
181
+ onDecide: decide,
182
+ onClose: () => setPanel((previous) => ({
183
+ ...previous,
184
+ open: false
185
+ }))
186
+ }, opening.count)
187
+ })]
188
+ });
189
+ }
190
+ function DialogTitle(props) {
191
+ return /* @__PURE__ */ jsx(Dialog.Title, { ...props });
192
+ }
193
+ function DialogDescription(props) {
194
+ return /* @__PURE__ */ jsx(Dialog.Description, { ...props });
195
+ }
196
+ /** The card at the foot of the window, in a dialog that does not take the page away. */
197
+ function ConsentBanner({ defaultView, ...card }) {
198
+ const pageGround = useGround();
199
+ const popup = useRef(null);
200
+ const watch = useCallback((element) => {
201
+ popup.current = element;
202
+ if (!element) return;
203
+ const root = document.documentElement;
204
+ const before = root.style.scrollPaddingBottom;
205
+ const update = () => {
206
+ const fromBottom = window.innerHeight - element.getBoundingClientRect().top;
207
+ root.style.scrollPaddingBottom = `${Math.max(0, fromBottom) + 16}px`;
208
+ };
209
+ const frame = requestAnimationFrame(update);
210
+ element.addEventListener("transitionend", update);
211
+ window.addEventListener("resize", update);
212
+ return () => {
213
+ cancelAnimationFrame(frame);
214
+ element.removeEventListener("transitionend", update);
215
+ window.removeEventListener("resize", update);
216
+ root.style.scrollPaddingBottom = before;
217
+ popup.current = null;
218
+ };
219
+ }, []);
220
+ return /* @__PURE__ */ jsx(Dialog.Portal, { children: /* @__PURE__ */ jsx(Dialog.Viewport, {
221
+ "data-slot": "consent-anchor",
222
+ className: consentAnchor,
223
+ children: /* @__PURE__ */ jsx(Dialog.Popup, {
224
+ ref: watch,
225
+ "data-slot": "consent-banner",
226
+ "data-theme": pageGround,
227
+ initialFocus: () => (defaultView === "settings" ? popup.current?.querySelector("[data-slot=\"consent-settings-title\"]") : popup.current) ?? true,
228
+ className: consentSurface,
229
+ children: /* @__PURE__ */ jsx(ConsentCard, {
230
+ ...card,
231
+ defaultView,
232
+ Title: DialogTitle,
233
+ Description: DialogDescription
234
+ })
235
+ })
236
+ }) });
237
+ }
238
+ /**
239
+ * Where the card stands: a line at the foot of the window, with no height and no colour. On a
240
+ * phone it spans the width above the home indicator; on a wider window it is the card's width in
241
+ * the bottom right corner.
242
+ *
243
+ * Safari 26 paints its toolbar in the background colour of a fixed layer it finds at the
244
+ * window's foot, and keeps the toolbar out while one stands there (Justin's iPhone, 2026-11-18:
245
+ * the bar came back, white). It passes over what a fixed layer holds in absolute position, so
246
+ * the fixed part here is this empty line and the card stands on it (`consentSurface`).
247
+ */
248
+ const consentAnchor = cn("fixed inset-x-2 bottom-[max(0.5rem,env(safe-area-inset-bottom))] z-50 h-0", "sm:right-[max(1rem,env(safe-area-inset-right))] sm:bottom-[max(1rem,env(safe-area-inset-bottom))] sm:left-auto sm:w-108");
249
+ /**
250
+ * The card: a sheet on the page's ground (white on a light page, dark on a dark one), standing on
251
+ * `consentAnchor` and growing upwards. It rises 8px into place on `sheet` and leaves by fading.
252
+ */
253
+ const consentSurface = cn("absolute inset-x-0 bottom-0 flex max-h-[calc(100dvh-1rem)] flex-col", "rounded-2xl bg-sheet p-5 text-fg-body depth-floating outline-hidden contain-layout", "transition-[opacity,scale,translate] spring-sheet", "data-starting-style:translate-y-2 data-starting-style:scale-(--motion-enter-scale) data-starting-style:opacity-0", "data-ending-style:opacity-0 data-ending-style:spring-leave");
254
+ /** The answer, and the ways to change it, for code that loads a script itself. */
255
+ function useConsent() {
256
+ const { config, snapshot, allows, decide, openSettings } = useConsentContext("useConsent");
257
+ return {
258
+ status: snapshot.status,
259
+ record: snapshot.record,
260
+ allows,
261
+ acceptAll: () => decide(config.categories.flatMap((category) => category.services.map((s) => s.id))),
262
+ rejectAll: () => decide([]),
263
+ save: decide,
264
+ openSettings
265
+ };
266
+ }
267
+ /**
268
+ * Renders what needs consent (a script, a pixel, an embed) only once it is given, and never on
269
+ * the server. Revoking a service whose content ran here loads the page again, since a script
270
+ * cannot be taken back.
271
+ */
272
+ function ConsentGate({ service, category, fallback = null, children }) {
273
+ const { allows, store, config } = useConsentContext("ConsentGate");
274
+ const id = service ?? category ?? "";
275
+ const allowed = allows(id);
276
+ useEffect(() => {
277
+ if (!allowed) return;
278
+ const entry = config.categories.find((each) => each.id === id);
279
+ store.markRendered(entry ? entry.services.map((each) => each.id) : [id]);
280
+ }, [
281
+ allowed,
282
+ config,
283
+ id,
284
+ store
285
+ ]);
286
+ return allowed ? children : fallback;
287
+ }
288
+ /**
289
+ * Opens the banner on its settings, so an answer can be changed as easily as it was given
290
+ * (Art. 7 (3) GDPR; Rn. 62). Put it among the legal links in the footer of every page. It is
291
+ * dressed like those links; in a `SiteFooter`, pass `siteFooterLinkClass`, whose underline waits
292
+ * for the pointer.
293
+ */
294
+ function ConsentSettingsTrigger({ id, className, children, ...props }) {
295
+ const { handle, labels } = useConsentContext("ConsentSettingsTrigger");
296
+ const ownId = useId();
297
+ return /* @__PURE__ */ jsx(Dialog.Trigger, {
298
+ handle,
299
+ id: id ?? ownId,
300
+ "data-slot": "consent-trigger",
301
+ className: mergeClassName([linkVariants({ variant: "quiet" }), "text-left"], className),
302
+ ...props,
303
+ children: children ?? labels.trigger
304
+ });
305
+ }
306
+ export { ConsentGate, ConsentProvider, ConsentSettingsTrigger, consentAnchor, consentSurface, useConsent, useConsentContext };
@@ -1,5 +1,5 @@
1
- import { VariantProps } from "class-variance-authority";
2
1
  import { ComponentProps } from "react";
2
+ import { VariantProps } from "class-variance-authority";
3
3
  /**
4
4
  * The width of a page as class names, so the bar of a `SiteHeader` and the rows of a `SiteFooter`
5
5
  * line up with the content between them. The gutter is added to the width: the content is as wide
@@ -0,0 +1,23 @@
1
+ import { ContextMenu as ContextMenu$1 } from "@base-ui/react/context-menu";
2
+ /**
3
+ * The menu of the thing under the pointer: a right click on a row, a long press on a phone. It
4
+ * is a shortcut, never the only way. The keyboard cannot open it, and nobody can see that it is
5
+ * there, so everything in it must also be reachable another way, usually the row's own `Menu`
6
+ * behind a key ("Weitere Aktionen"). Build both from one list of entries.
7
+ *
8
+ * Its rows are the menu's: put `MenuItem`, `MenuSeparator`, `MenuCheckboxItem`, `MenuGroup` and
9
+ * `MenuSub` into the `ContextMenuContent`.
10
+ */
11
+ export declare const ContextMenu: typeof ContextMenu$1.Root;
12
+ /**
13
+ * The area the menu belongs to. It is a plain block around its children; make it the thing
14
+ * itself with `render` (a table row, a card). While the menu is open it carries
15
+ * `data-popup-open`, so the thing it is about can stay marked.
16
+ */
17
+ export declare function ContextMenuTrigger(props: ContextMenu$1.Trigger.Props): import("react").JSX.Element;
18
+ export type ContextMenuContentProps = ContextMenu$1.Popup.Props;
19
+ /**
20
+ * The sheet, where the pointer is. It opens many times a day and under the hand, so it only
21
+ * fades in, fast, and does not grow or travel; it leaves like every sheet.
22
+ */
23
+ export declare function ContextMenuContent({ className, ...props }: ContextMenuContentProps): import("react").JSX.Element;
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { useGround } from "../ground/ground.js";
3
+ import { listSheet } from "../../internal/popup.js";
4
+ import { mergeClassName } from "../../lib/cn.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { ContextMenu as ContextMenu$1 } from "@base-ui/react/context-menu";
7
+ // src/components/context-menu/context-menu.tsx
8
+ /**
9
+ * The menu of the thing under the pointer: a right click on a row, a long press on a phone. It
10
+ * is a shortcut, never the only way. The keyboard cannot open it, and nobody can see that it is
11
+ * there, so everything in it must also be reachable another way, usually the row's own `Menu`
12
+ * behind a key ("Weitere Aktionen"). Build both from one list of entries.
13
+ *
14
+ * Its rows are the menu's: put `MenuItem`, `MenuSeparator`, `MenuCheckboxItem`, `MenuGroup` and
15
+ * `MenuSub` into the `ContextMenuContent`.
16
+ */
17
+ const ContextMenu = ContextMenu$1.Root;
18
+ /**
19
+ * The area the menu belongs to. It is a plain block around its children; make it the thing
20
+ * itself with `render` (a table row, a card). While the menu is open it carries
21
+ * `data-popup-open`, so the thing it is about can stay marked.
22
+ */
23
+ function ContextMenuTrigger(props) {
24
+ return /* @__PURE__ */ jsx(ContextMenu$1.Trigger, {
25
+ "data-slot": "context-menu-trigger",
26
+ ...props
27
+ });
28
+ }
29
+ /**
30
+ * The sheet, where the pointer is. It opens many times a day and under the hand, so it only
31
+ * fades in, fast, and does not grow or travel; it leaves like every sheet.
32
+ */
33
+ function ContextMenuContent({ className, ...props }) {
34
+ const ground = useGround();
35
+ return /* @__PURE__ */ jsx(ContextMenu$1.Portal, { children: /* @__PURE__ */ jsx(ContextMenu$1.Positioner, {
36
+ "data-slot": "context-menu-positioner",
37
+ className: "z-50 outline-none",
38
+ children: /* @__PURE__ */ jsx(ContextMenu$1.Popup, {
39
+ "data-slot": "context-menu-content",
40
+ "data-theme": ground,
41
+ className: mergeClassName([
42
+ listSheet,
43
+ "min-w-48 transition-opacity spring-snap data-starting-style:opacity-0",
44
+ "data-ending-style:opacity-0 data-ending-style:spring-leave"
45
+ ], className),
46
+ ...props
47
+ })
48
+ }) });
49
+ }
50
+ export { ContextMenu, ContextMenuContent, ContextMenuTrigger };
@@ -0,0 +1,45 @@
1
+ import { ComponentProps } from "react";
2
+ /** What the parts inside a conversation may ask of it. */
3
+ export type ConversationApi = {
4
+ /** Back to the newest message, and keep to the foot again. */
5
+ toLatest: () => void;
6
+ /** Says a finished answer once, politely, to assistive tech. */
7
+ announce: (text: string) => void;
8
+ /** Whether the conversation has stood for a frame: what joins after that may move. */
9
+ live: boolean;
10
+ };
11
+ /** The conversation around a part, if there is one. */
12
+ export declare function useConversation(): ConversationApi | null;
13
+ export type ConversationProps = ComponentProps<"div">;
14
+ /**
15
+ * A conversation with an assistant: the messages in a scroller that keeps to its foot while an
16
+ * answer is written, and the key that leads back there. Put a `ConversationContent` inside with
17
+ * the `Message`s, and a `ConversationLatest` after it. Give the conversation its height (`h-full`
18
+ * in a column, `flex-1`); the prompt stands below it, outside.
19
+ *
20
+ * At the foot, what joins is followed: the view glides down with the answer as it grows. The
21
+ * reader who scrolls up, presses a scroll key or opens a fold inside an answer is left where
22
+ * they are, and the key „Neueste“ appears; it leads back and keeps to the foot again, and so
23
+ * does sending a prompt. A finished answer is announced once, not word by word.
24
+ */
25
+ export declare function Conversation({ className, children, ...props }: ConversationProps): import("react").JSX.Element;
26
+ export type ConversationContentProps = ComponentProps<"div"> & {
27
+ /** The name of the scrolling region for assistive tech. */
28
+ label?: string;
29
+ };
30
+ /**
31
+ * The messages, in a box that scrolls. `className` lays out what it holds (the column's width,
32
+ * its padding, the room between messages); the box itself fills the conversation.
33
+ */
34
+ export declare function ConversationContent({ label, className, children, ...props }: ConversationContentProps): import("react").JSX.Element;
35
+ export type ConversationLatestProps = Omit<ComponentProps<"span">, "children"> & {
36
+ /** The key's words. */
37
+ label?: string;
38
+ };
39
+ /**
40
+ * The key that leads back to the newest message. It stands centred above the conversation's
41
+ * foot and only while the reader has left it: it rises in on `settle` and leaves by fading.
42
+ * Pressed, the view glides back down (from far up it jumps closer first), keeps to the foot
43
+ * again, and the keyboard focus goes to the conversation.
44
+ */
45
+ export declare function ConversationLatest({ label, className, ...props }: ConversationLatestProps): import("react").JSX.Element;