@lanfermann/ui 0.5.0 → 0.7.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.
- package/dist/components/accordion/accordion.d.ts +11 -3
- package/dist/components/accordion/accordion.js +15 -10
- package/dist/components/action-bar/action-bar.d.ts +60 -0
- package/dist/components/action-bar/action-bar.js +117 -0
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +3 -17
- package/dist/components/alert-dialog/alert-dialog.d.ts +1 -1
- package/dist/components/app-shell/app-shell.d.ts +33 -0
- package/dist/components/app-shell/app-shell.js +93 -0
- package/dist/components/attachment/attachment.d.ts +51 -0
- package/dist/components/attachment/attachment.js +255 -0
- package/dist/components/attachment/kinds.d.ts +7 -0
- package/dist/components/attachment/kinds.js +142 -0
- package/dist/components/avatar/avatar.d.ts +14 -4
- package/dist/components/avatar/avatar.js +57 -13
- package/dist/components/avatar-group/avatar-group.d.ts +33 -0
- package/dist/components/avatar-group/avatar-group.js +110 -0
- package/dist/components/avatar-group/people.d.ts +12 -0
- package/dist/components/avatar-group/people.js +24 -0
- package/dist/components/badge/badge.d.ts +9 -3
- package/dist/components/badge/badge.js +21 -6
- package/dist/components/banner/banner.d.ts +39 -0
- package/dist/components/banner/banner.js +149 -0
- package/dist/components/button-group/button-group-variants.d.ts +4 -3
- package/dist/components/button-group/button-group-variants.js +13 -12
- package/dist/components/button-group/button-group.d.ts +3 -3
- package/dist/components/button-group/button-group.js +3 -3
- package/dist/components/card/card.d.ts +20 -4
- package/dist/components/card/card.js +32 -6
- package/dist/components/checkbox-card/checkbox-card.d.ts +21 -0
- package/dist/components/checkbox-card/checkbox-card.js +50 -0
- package/dist/components/chip/chip-group.d.ts +15 -0
- package/dist/components/chip/chip-group.js +44 -0
- package/dist/components/chip/chip-variants.d.ts +6 -0
- package/dist/components/chip/chip-variants.js +28 -0
- package/dist/components/chip/chip.d.ts +39 -0
- package/dist/components/chip/chip.js +71 -0
- package/dist/components/code-block/code-copy.d.ts +3 -11
- package/dist/components/code-block/code-copy.js +15 -62
- package/dist/components/code-block/code-keys.js +10 -22
- package/dist/components/collapsible/collapsible.js +7 -3
- package/dist/components/combobox/combobox.d.ts +53 -3
- package/dist/components/combobox/combobox.js +204 -20
- package/dist/components/command/command.d.ts +131 -0
- package/dist/components/command/command.js +335 -0
- package/dist/components/consent/consent-card.js +365 -0
- package/dist/components/consent/consent-embed.d.ts +21 -0
- package/dist/components/consent/consent-embed.js +111 -0
- package/dist/components/consent/consent-labels.d.ts +70 -0
- package/dist/components/consent/consent-labels.js +61 -0
- package/dist/components/consent/consent-record.d.ts +95 -0
- package/dist/components/consent/consent-record.js +112 -0
- package/dist/components/consent/consent-store.d.ts +26 -0
- package/dist/components/consent/consent-store.js +240 -0
- package/dist/components/consent/consent.d.ts +86 -0
- package/dist/components/consent/consent.js +306 -0
- package/dist/components/container/container.d.ts +1 -1
- package/dist/components/context-menu/context-menu.d.ts +23 -0
- package/dist/components/context-menu/context-menu.js +50 -0
- package/dist/components/conversation/conversation.d.ts +45 -0
- package/dist/components/conversation/conversation.js +295 -0
- package/dist/components/conversation/stick.js +23 -0
- package/dist/components/copy-button/copy-button.d.ts +50 -0
- package/dist/components/copy-button/copy-button.js +65 -0
- package/dist/components/copy-page/copy-page.d.ts +4 -4
- package/dist/components/copy-page/copy-page.js +16 -36
- package/dist/components/copy-pill/copy-pill.js +1 -1
- package/dist/components/description-list/description-list.d.ts +32 -0
- package/dist/components/description-list/description-list.js +51 -0
- package/dist/components/empty/empty.d.ts +38 -0
- package/dist/components/empty/empty.js +57 -0
- package/dist/components/field/field.js +1 -1
- package/dist/components/file-upload/file-upload.d.ts +96 -0
- package/dist/components/file-upload/file-upload.js +347 -0
- package/dist/components/file-upload/files.d.ts +39 -0
- package/dist/components/file-upload/files.js +74 -0
- package/dist/components/grow/grow.d.ts +15 -3
- package/dist/components/grow/grow.js +24 -9
- package/dist/components/heading/heading.d.ts +1 -1
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/menu/menu.d.ts +20 -8
- package/dist/components/menu/menu.js +51 -29
- package/dist/components/message/message.d.ts +81 -0
- package/dist/components/message/message.js +208 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +7 -1
- package/dist/components/navigation-menu/navigation-menu.js +11 -4
- package/dist/components/otp-field/otp-field.d.ts +37 -0
- package/dist/components/otp-field/otp-field.js +161 -0
- package/dist/components/pagination/pagination.d.ts +50 -0
- package/dist/components/pagination/pagination.js +188 -0
- package/dist/components/prompt-input/keys.js +15 -0
- package/dist/components/prompt-input/prompt-input.d.ts +89 -0
- package/dist/components/prompt-input/prompt-input.js +331 -0
- package/dist/components/radio-card/radio-card.d.ts +23 -0
- package/dist/components/radio-card/radio-card.js +49 -0
- package/dist/components/rolling-number/rolling-number.d.ts +30 -0
- package/dist/components/rolling-number/rolling-number.js +149 -0
- package/dist/components/seam/seam.d.ts +1 -1
- package/dist/components/secret-field/secret-field.d.ts +53 -0
- package/dist/components/secret-field/secret-field.js +121 -0
- package/dist/components/section/section.d.ts +1 -1
- package/dist/components/segmented-control/segmented-control.js +29 -16
- package/dist/components/select/select.d.ts +5 -4
- package/dist/components/select/select.js +16 -11
- package/dist/components/shortcut/shortcut.d.ts +46 -0
- package/dist/components/shortcut/shortcut.js +87 -0
- package/dist/components/sidebar/sidebar-context.js +16 -0
- package/dist/components/sidebar/sidebar.d.ts +161 -0
- package/dist/components/sidebar/sidebar.js +588 -0
- package/dist/components/site-header/site-header.js +1 -1
- package/dist/components/skeleton/loaded.d.ts +21 -0
- package/dist/components/skeleton/loaded.js +57 -0
- package/dist/components/skeleton/skeleton.d.ts +43 -0
- package/dist/components/skeleton/skeleton.js +48 -0
- package/dist/components/sources/source-list.d.ts +17 -0
- package/dist/components/sources/source-list.js +26 -0
- package/dist/components/sources/sources.d.ts +45 -0
- package/dist/components/sources/sources.js +167 -0
- package/dist/components/stat/stat.d.ts +59 -0
- package/dist/components/stat/stat.js +112 -0
- package/dist/components/steps/steps.d.ts +57 -0
- package/dist/components/steps/steps.js +134 -0
- package/dist/components/table/table.d.ts +18 -9
- package/dist/components/table/table.js +21 -13
- package/dist/components/text/text.d.ts +1 -1
- package/dist/components/theme-switch/theme-switch.js +1 -1
- package/dist/components/time-field/time-field.js +7 -6
- package/dist/components/timeline/timeline.d.ts +45 -0
- package/dist/components/timeline/timeline.js +86 -0
- package/dist/components/toast/toast.js +10 -26
- package/dist/components/toggle/toggle.d.ts +27 -0
- package/dist/components/toggle/toggle.js +61 -0
- package/dist/components/toggle-group/toggle-group.d.ts +27 -0
- package/dist/components/toggle-group/toggle-group.js +38 -0
- package/dist/components/toolbar/toolbar-context.js +12 -0
- package/dist/components/toolbar/toolbar.d.ts +52 -0
- package/dist/components/toolbar/toolbar.js +105 -0
- package/dist/components/trace/trace.d.ts +2 -1
- package/dist/components/trace/trace.js +15 -27
- package/dist/index.d.ts +46 -3
- package/dist/index.js +44 -3
- package/dist/internal/arriving-pieces.js +56 -0
- package/dist/internal/arriving.js +171 -0
- package/dist/internal/avatar-cut.d.ts +15 -0
- package/dist/internal/avatar-cut.js +83 -0
- package/dist/internal/choice-card.d.ts +15 -0
- package/dist/internal/choice-card.js +81 -0
- package/dist/internal/clipboard.js +37 -0
- package/dist/internal/copy.js +58 -0
- package/dist/internal/disclosure.js +15 -3
- package/dist/internal/field.js +24 -4
- package/dist/internal/glyphs.js +26 -1
- package/dist/internal/key-tip.js +18 -0
- package/dist/internal/list-mark.js +39 -0
- package/dist/internal/live-list.js +41 -0
- package/dist/internal/number-places.js +157 -0
- package/dist/internal/picker-sheet.js +1 -1
- package/dist/internal/presence-dot.js +24 -0
- package/dist/internal/presence.js +104 -0
- package/dist/internal/rail-mark.d.ts +3 -0
- package/dist/internal/rail-mark.js +33 -0
- package/dist/internal/rule.js +2 -1
- package/dist/internal/status-icon.js +22 -0
- package/dist/internal/tile.js +23 -0
- package/dist/internal/travelling-mark.js +204 -0
- package/dist/lib/cn.js +10 -0
- package/dist/lib/shortcut.d.ts +11 -0
- package/dist/lib/shortcut.js +165 -0
- package/package.json +1 -1
- package/src/styles/accordion.css +176 -0
- package/src/styles/action-bar.css +28 -0
- package/src/styles/assistant.css +83 -0
- package/src/styles/avatar.css +24 -0
- package/src/styles/consent.css +65 -0
- package/src/styles/copy.css +12 -11
- package/src/styles/depth.css +120 -4
- package/src/styles/marks.css +20 -2
- package/src/styles/motion.css +3 -0
- package/src/styles/rail.css +49 -0
- package/src/styles/rolling-number.css +94 -0
- package/src/styles/segmented.css +14 -7
- package/src/styles/steps.css +98 -0
- package/src/styles/timeline.css +48 -0
- package/src/styles/travel.css +36 -0
- package/src/styles.css +10 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { AttachmentVariantContext } from "../attachment/attachment.js";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
|
+
import { ChipGroup } from "../chip/chip-group.js";
|
|
5
|
+
import { sortFiles } from "../file-upload/files.js";
|
|
6
|
+
import { Grow } from "../grow/grow.js";
|
|
7
|
+
import { Icon } from "../icon/icon.js";
|
|
8
|
+
import { useScrollEdges } from "../scroll-fade/use-scroll-edges.js";
|
|
9
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../tooltip/tooltip.js";
|
|
10
|
+
import { fieldShellGrowing, focusFieldControl } from "../../internal/field.js";
|
|
11
|
+
import { StopGlyph } from "../../internal/glyphs.js";
|
|
12
|
+
import { cn } from "../../lib/cn.js";
|
|
13
|
+
import { TOUCH_ONLY, promptKey } from "./keys.js";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { Children, createContext, isValidElement, useCallback, useContext, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
16
|
+
import { ArrowUp02Icon, Attachment01Icon } from "@hugeicons/core-free-icons";
|
|
17
|
+
// src/components/prompt-input/prompt-input.tsx
|
|
18
|
+
const PromptContext = createContext(null);
|
|
19
|
+
function usePrompt(part) {
|
|
20
|
+
const context = useContext(PromptContext);
|
|
21
|
+
if (!context) throw new Error(`${part} belongs inside a PromptInput.`);
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
function subscribeTouch(notify) {
|
|
25
|
+
const query = window.matchMedia(TOUCH_ONLY);
|
|
26
|
+
query.addEventListener("change", notify);
|
|
27
|
+
return () => query.removeEventListener("change", notify);
|
|
28
|
+
}
|
|
29
|
+
/** Whether the screen is only touched (no mouse, no trackpad). False on the server. */
|
|
30
|
+
function useTouchOnly() {
|
|
31
|
+
return useSyncExternalStore(subscribeTouch, () => window.matchMedia(TOUCH_ONLY).matches, () => false);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The field a prompt to an assistant is written in: one socket that holds the text, the files
|
|
35
|
+
* attached to it, the attach key and the send key, so the halo goes around all of it. Put a
|
|
36
|
+
* `PromptInputAttachments`, a `PromptInputTextarea` and `PromptInputActions` (with a
|
|
37
|
+
* `PromptInputAttach` and a `PromptInputSubmit`) inside.
|
|
38
|
+
*
|
|
39
|
+
* The text stands on top and the keys in a row of their own under it, the paper clip at the
|
|
40
|
+
* left and send at the right, where there is room for more keys (Justin, 2026-11-19).
|
|
41
|
+
*
|
|
42
|
+
* Enter sends and Shift+Enter breaks the line; on a screen that is only touched, Enter breaks
|
|
43
|
+
* the line and the key sends. A word being composed (Japanese, Chinese) is never sent. While
|
|
44
|
+
* an answer is written (`running`) the send key is the stop key, in the same place, and the
|
|
45
|
+
* field stays open, so the next prompt can be written; Enter waits.
|
|
46
|
+
*
|
|
47
|
+
* The field grows with its text up to about ten lines and then scrolls; its height follows on
|
|
48
|
+
* `settle`, and the line being typed is readable from its first frame. Files come by the attach
|
|
49
|
+
* key, by a drop on the field (it wears the halo while one hangs over it) and by paste. It
|
|
50
|
+
* sorts them by kind and size and hands them on; it does not upload.
|
|
51
|
+
*/
|
|
52
|
+
function PromptInput({ value: valueProp, defaultValue = "", onValueChange, onSubmit, running = false, onStop, onFilesAdded, onReject, accept, maxSize, disabled = false, className, children, ...props }) {
|
|
53
|
+
const [own, setOwn] = useState(defaultValue);
|
|
54
|
+
const value = valueProp ?? own;
|
|
55
|
+
const setValue = (next) => {
|
|
56
|
+
setOwn(next);
|
|
57
|
+
onValueChange?.(next);
|
|
58
|
+
};
|
|
59
|
+
const [attachments, setAttachmentCount] = useState(0);
|
|
60
|
+
const removeLastRef = useRef(void 0);
|
|
61
|
+
const setAttachments = useCallback((count, removeLast) => {
|
|
62
|
+
setAttachmentCount(count);
|
|
63
|
+
removeLastRef.current = removeLast;
|
|
64
|
+
}, []);
|
|
65
|
+
const [dragging, setDragging] = useState(false);
|
|
66
|
+
const drags = useRef(0);
|
|
67
|
+
const touchOnly = useTouchOnly();
|
|
68
|
+
const textareaId = useId();
|
|
69
|
+
const canSend = !disabled && (value.trim() !== "" || attachments > 0);
|
|
70
|
+
const focusText = () => document.getElementById(textareaId)?.focus();
|
|
71
|
+
const send = () => {
|
|
72
|
+
if (running || !canSend) return;
|
|
73
|
+
const sent = value;
|
|
74
|
+
setValue("");
|
|
75
|
+
const result = onSubmit?.(sent.trim());
|
|
76
|
+
if (result instanceof Promise) result.catch(() => {
|
|
77
|
+
setOwn((now) => {
|
|
78
|
+
if (now !== "") return now;
|
|
79
|
+
onValueChange?.(sent);
|
|
80
|
+
return sent;
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const addFiles = (files) => {
|
|
85
|
+
if (disabled || files.length === 0) return;
|
|
86
|
+
const { accepted, rejected } = sortFiles(files, {
|
|
87
|
+
accept,
|
|
88
|
+
maxSize,
|
|
89
|
+
multiple: true
|
|
90
|
+
});
|
|
91
|
+
if (accepted.length > 0) onFilesAdded?.(accepted);
|
|
92
|
+
if (rejected.length > 0) onReject?.(rejected);
|
|
93
|
+
};
|
|
94
|
+
const context = {
|
|
95
|
+
value,
|
|
96
|
+
setValue,
|
|
97
|
+
running,
|
|
98
|
+
disabled,
|
|
99
|
+
canSend,
|
|
100
|
+
touchOnly,
|
|
101
|
+
textareaId,
|
|
102
|
+
send,
|
|
103
|
+
stop: () => onStop?.(),
|
|
104
|
+
addFiles,
|
|
105
|
+
accept,
|
|
106
|
+
setAttachments,
|
|
107
|
+
removeLast: () => {
|
|
108
|
+
if (!removeLastRef.current) return false;
|
|
109
|
+
removeLastRef.current();
|
|
110
|
+
return true;
|
|
111
|
+
},
|
|
112
|
+
focusText
|
|
113
|
+
};
|
|
114
|
+
const hasFiles = (event) => event.dataTransfer.types.includes("Files");
|
|
115
|
+
return /* @__PURE__ */ jsx(PromptContext, {
|
|
116
|
+
value: context,
|
|
117
|
+
children: /* @__PURE__ */ jsx("form", {
|
|
118
|
+
"data-slot": "prompt-input",
|
|
119
|
+
"data-running": running ? "" : void 0,
|
|
120
|
+
"data-dragging": dragging ? "" : void 0,
|
|
121
|
+
className: cn("w-full min-w-0", className),
|
|
122
|
+
onSubmit: (event) => {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
send();
|
|
125
|
+
},
|
|
126
|
+
onDragEnter: (event) => {
|
|
127
|
+
if (!hasFiles(event) || disabled) return;
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
drags.current += 1;
|
|
130
|
+
setDragging(true);
|
|
131
|
+
},
|
|
132
|
+
onDragOver: (event) => {
|
|
133
|
+
if (!hasFiles(event)) return;
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
event.dataTransfer.dropEffect = disabled ? "none" : "copy";
|
|
136
|
+
},
|
|
137
|
+
onDragLeave: (event) => {
|
|
138
|
+
if (!hasFiles(event)) return;
|
|
139
|
+
drags.current = Math.max(0, drags.current - 1);
|
|
140
|
+
if (drags.current === 0) setDragging(false);
|
|
141
|
+
},
|
|
142
|
+
onDrop: (event) => {
|
|
143
|
+
if (!hasFiles(event)) return;
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
drags.current = 0;
|
|
146
|
+
setDragging(false);
|
|
147
|
+
addFiles([...event.dataTransfer.files]);
|
|
148
|
+
focusText();
|
|
149
|
+
},
|
|
150
|
+
...props,
|
|
151
|
+
children: /* @__PURE__ */ jsx(Grow, {
|
|
152
|
+
"data-slot": "prompt-input-field",
|
|
153
|
+
className: cn(fieldShellGrowing, "flex flex-col justify-end rounded-xl [--field-pad:0.75rem] [--field-radius:var(--radius-xl)]", "in-data-dragging:depth-field-focus"),
|
|
154
|
+
contentClassName: "grid p-1",
|
|
155
|
+
onMouseDown: focusFieldControl,
|
|
156
|
+
children
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/** The text and its look, the same for the field and for the copy it is measured by. */
|
|
162
|
+
const textLook = "col-start-1 row-start-1 min-w-0 px-2 py-2 text-control leading-6 break-words whitespace-pre-wrap pointer-coarse:text-base";
|
|
163
|
+
/**
|
|
164
|
+
* The text of the prompt. It grows with what is written, measured from a copy of the text laid
|
|
165
|
+
* out beside it, so it grows the same in every browser, up to about ten lines; then it scrolls
|
|
166
|
+
* and fades at its top where more stands above.
|
|
167
|
+
*/
|
|
168
|
+
function PromptInputTextarea({ label = "Nachricht an die KI", className, onKeyDown, onPaste, placeholder, ...props }) {
|
|
169
|
+
const prompt = usePrompt("PromptInputTextarea");
|
|
170
|
+
const area = useRef(null);
|
|
171
|
+
useScrollEdges(area, "y");
|
|
172
|
+
const keyDown = (event) => {
|
|
173
|
+
onKeyDown?.(event);
|
|
174
|
+
if (event.defaultPrevented) return;
|
|
175
|
+
if (event.key === "Backspace" && prompt.value === "" && !event.repeat) {
|
|
176
|
+
if (prompt.removeLast()) event.preventDefault();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const outcome = promptKey(event.nativeEvent, {
|
|
180
|
+
touchOnly: prompt.touchOnly,
|
|
181
|
+
running: prompt.running
|
|
182
|
+
});
|
|
183
|
+
if (outcome === "type") return;
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
if (outcome === "send") prompt.send();
|
|
186
|
+
};
|
|
187
|
+
const paste = (event) => {
|
|
188
|
+
onPaste?.(event);
|
|
189
|
+
if (event.defaultPrevented) return;
|
|
190
|
+
const files = [...event.clipboardData.files];
|
|
191
|
+
if (files.length === 0) return;
|
|
192
|
+
event.preventDefault();
|
|
193
|
+
prompt.addFiles(files);
|
|
194
|
+
};
|
|
195
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
196
|
+
"data-slot": "prompt-input-text",
|
|
197
|
+
className: "grid min-w-0 [grid-area:text]",
|
|
198
|
+
children: [/* @__PURE__ */ jsx("textarea", {
|
|
199
|
+
ref: area,
|
|
200
|
+
id: prompt.textareaId,
|
|
201
|
+
"data-slot": "prompt-input-textarea",
|
|
202
|
+
"data-field-control": "",
|
|
203
|
+
"data-disabled": prompt.disabled ? "" : void 0,
|
|
204
|
+
"data-scroll-fade": "y",
|
|
205
|
+
"data-fade-edges": "start",
|
|
206
|
+
"aria-label": label,
|
|
207
|
+
rows: 1,
|
|
208
|
+
value: prompt.value,
|
|
209
|
+
disabled: prompt.disabled,
|
|
210
|
+
placeholder,
|
|
211
|
+
enterKeyHint: prompt.touchOnly ? "enter" : "send",
|
|
212
|
+
onChange: (event) => prompt.setValue(event.target.value),
|
|
213
|
+
onKeyDown: keyDown,
|
|
214
|
+
onPaste: paste,
|
|
215
|
+
className: cn(textLook, "h-full resize-none overflow-y-auto bg-transparent text-fg", "placeholder:text-fg-muted placeholder:italic focus:outline-hidden", "data-disabled:text-on-disabled", className),
|
|
216
|
+
...props
|
|
217
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
218
|
+
"aria-hidden": true,
|
|
219
|
+
"data-slot": "prompt-input-measure",
|
|
220
|
+
className: cn(textLook, "invisible max-h-60 overflow-hidden text-fg"),
|
|
221
|
+
children: [prompt.value || placeholder || " ", ""]
|
|
222
|
+
})]
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/** The keys of the prompt: attach, send, and whatever else belongs there. */
|
|
226
|
+
function PromptInputActions({ className, ...props }) {
|
|
227
|
+
return /* @__PURE__ */ jsx("div", {
|
|
228
|
+
"data-slot": "prompt-input-actions",
|
|
229
|
+
className: cn(className),
|
|
230
|
+
...props
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/** A quiet key inside the field, cut concentric to its corner. */
|
|
234
|
+
const innerKey = "rounded-[calc(var(--field-radius)-4px)]";
|
|
235
|
+
/**
|
|
236
|
+
* The paper clip: opens the file picker. What is chosen is sorted like a drop and handed to
|
|
237
|
+
* `onFilesAdded`; the same file can be chosen again.
|
|
238
|
+
*/
|
|
239
|
+
function PromptInputAttach({ label = "Datei anhängen", className }) {
|
|
240
|
+
const prompt = usePrompt("PromptInputAttach");
|
|
241
|
+
const input = useRef(null);
|
|
242
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx(Button, {
|
|
243
|
+
iconOnly: true,
|
|
244
|
+
variant: "quiet",
|
|
245
|
+
"aria-label": label,
|
|
246
|
+
"data-slot": "prompt-input-attach",
|
|
247
|
+
disabled: prompt.disabled,
|
|
248
|
+
onClick: () => input.current?.click(),
|
|
249
|
+
className: cn(innerKey, "text-fg-muted hover:text-fg", className),
|
|
250
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
251
|
+
icon: Attachment01Icon,
|
|
252
|
+
size: 16
|
|
253
|
+
})
|
|
254
|
+
}) }), /* @__PURE__ */ jsx(TooltipContent, { children: label })] }), /* @__PURE__ */ jsx("input", {
|
|
255
|
+
ref: input,
|
|
256
|
+
type: "file",
|
|
257
|
+
multiple: true,
|
|
258
|
+
hidden: true,
|
|
259
|
+
tabIndex: -1,
|
|
260
|
+
accept: prompt.accept,
|
|
261
|
+
"data-slot": "prompt-input-file",
|
|
262
|
+
onChange: (event) => {
|
|
263
|
+
prompt.addFiles([...event.target.files ?? []]);
|
|
264
|
+
event.target.value = "";
|
|
265
|
+
prompt.focusText();
|
|
266
|
+
}
|
|
267
|
+
})] });
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* The send key, the committed key of the prompt. With nothing to send it lies flat and stands
|
|
271
|
+
* up with the first word. While an answer is written it is the stop key, in the same place and
|
|
272
|
+
* size: the arrow shrinks away and the square seats. Pressing it keeps the keyboard in the text.
|
|
273
|
+
*/
|
|
274
|
+
function PromptInputSubmit({ sendLabel = "Senden", stopLabel = "Anhalten", className }) {
|
|
275
|
+
const prompt = usePrompt("PromptInputSubmit");
|
|
276
|
+
const label = prompt.running ? stopLabel : sendLabel;
|
|
277
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx(Button, {
|
|
278
|
+
iconOnly: true,
|
|
279
|
+
variant: "primary",
|
|
280
|
+
"aria-label": label,
|
|
281
|
+
"data-slot": "prompt-input-submit",
|
|
282
|
+
type: prompt.running ? "button" : "submit",
|
|
283
|
+
disabled: !prompt.running && !prompt.canSend,
|
|
284
|
+
focusableWhenDisabled: true,
|
|
285
|
+
onClick: prompt.running ? prompt.stop : void 0,
|
|
286
|
+
onMouseDown: (event) => {
|
|
287
|
+
if (document.activeElement?.id === prompt.textareaId) event.preventDefault();
|
|
288
|
+
},
|
|
289
|
+
className: cn(innerKey, className),
|
|
290
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
291
|
+
className: "grid place-items-center *:col-start-1 *:row-start-1",
|
|
292
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
293
|
+
icon: ArrowUp02Icon,
|
|
294
|
+
size: 16,
|
|
295
|
+
"data-slot": "prompt-input-send-symbol"
|
|
296
|
+
}), /* @__PURE__ */ jsx(StopGlyph, {
|
|
297
|
+
width: 12,
|
|
298
|
+
height: 12,
|
|
299
|
+
"data-slot": "prompt-input-stop-symbol"
|
|
300
|
+
})]
|
|
301
|
+
})
|
|
302
|
+
}) }), /* @__PURE__ */ jsx(TooltipContent, { children: label })] });
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* The files attached to the prompt, as chips above the text. One that joins opens its place
|
|
306
|
+
* and seats; one taken away fades while its place closes. Backspace in the empty text takes the
|
|
307
|
+
* last one away. Empty, the row takes no room.
|
|
308
|
+
*/
|
|
309
|
+
function PromptInputAttachments({ label = "Anhänge", className, children, ...props }) {
|
|
310
|
+
const prompt = usePrompt("PromptInputAttachments");
|
|
311
|
+
const items = useMemo(() => Children.toArray(children).filter(isValidElement), [children]);
|
|
312
|
+
const last = items.at(-1)?.props.onRemove;
|
|
313
|
+
const { setAttachments } = prompt;
|
|
314
|
+
useLayoutEffect(() => setAttachments(items.length, last), [
|
|
315
|
+
setAttachments,
|
|
316
|
+
items.length,
|
|
317
|
+
last
|
|
318
|
+
]);
|
|
319
|
+
useLayoutEffect(() => () => setAttachments(0, void 0), [setAttachments]);
|
|
320
|
+
return /* @__PURE__ */ jsx(AttachmentVariantContext, {
|
|
321
|
+
value: "chip",
|
|
322
|
+
children: /* @__PURE__ */ jsx(ChipGroup, {
|
|
323
|
+
"aria-label": label,
|
|
324
|
+
"data-slot": "prompt-input-attachments",
|
|
325
|
+
className: cn("px-1 pt-1 pb-0.5 empty:hidden", className),
|
|
326
|
+
...props,
|
|
327
|
+
children: items
|
|
328
|
+
})
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
export { PromptInput, PromptInputActions, PromptInputAttach, PromptInputAttachments, PromptInputSubmit, PromptInputTextarea };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ChoiceCardText } from "../../internal/choice-card.js";
|
|
2
|
+
import { Radio } from "@base-ui/react/radio";
|
|
3
|
+
export type RadioCardProps = Omit<Radio.Root.Props, "children" | "className" | "render" | "title"> & ChoiceCardText & {
|
|
4
|
+
/**
|
|
5
|
+
* How the chosen card shows it. `edge` (the default): the accent as its edge, and the mark
|
|
6
|
+
* closed to a disc. `mark`: the mark alone, for a place where coloured edges would be too
|
|
7
|
+
* much.
|
|
8
|
+
*/
|
|
9
|
+
chosen?: "edge" | "mark";
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* One choice out of a few whose options need a sentence each: a plan, an answer in a set-up.
|
|
14
|
+
* The whole card is the control and the target. It is a softly raised sheet that stands still:
|
|
15
|
+
* a press anywhere on it dips its radio. Chosen, it takes the accent as its edge and the disc
|
|
16
|
+
* seats into its radio's socket, as in a plain `Radio`.
|
|
17
|
+
*
|
|
18
|
+
* Put the cards into a `RadioGroup` and lay them out with a class on it (`grid sm:grid-cols-3`
|
|
19
|
+
* with `gap-3`). The title names the choice, the sentence says what it means; keep both the
|
|
20
|
+
* same length from card to card. For options that are a word each, plain `Radio`s in rows are
|
|
21
|
+
* calmer.
|
|
22
|
+
*/
|
|
23
|
+
export declare function RadioCard({ title, description, detail, icon, chosen, className, children, ...props }: RadioCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ChoiceCardBody, choiceCard, choiceControl, followPointer } from "../../internal/choice-card.js";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useId } from "react";
|
|
6
|
+
import { Radio } from "@base-ui/react/radio";
|
|
7
|
+
// src/components/radio-card/radio-card.tsx
|
|
8
|
+
/**
|
|
9
|
+
* One choice out of a few whose options need a sentence each: a plan, an answer in a set-up.
|
|
10
|
+
* The whole card is the control and the target. It is a softly raised sheet that stands still:
|
|
11
|
+
* a press anywhere on it dips its radio. Chosen, it takes the accent as its edge and the disc
|
|
12
|
+
* seats into its radio's socket, as in a plain `Radio`.
|
|
13
|
+
*
|
|
14
|
+
* Put the cards into a `RadioGroup` and lay them out with a class on it (`grid sm:grid-cols-3`
|
|
15
|
+
* with `gap-3`). The title names the choice, the sentence says what it means; keep both the
|
|
16
|
+
* same length from card to card. For options that are a word each, plain `Radio`s in rows are
|
|
17
|
+
* calmer.
|
|
18
|
+
*/
|
|
19
|
+
function RadioCard({ 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": "radio-card",
|
|
24
|
+
onPointerMove: followPointer,
|
|
25
|
+
className: cn(choiceCard, chosen === "edge" && "has-[[data-slot=choice-control][data-checked]]:depth-bevel-chosen", className),
|
|
26
|
+
children: [/* @__PURE__ */ jsx(Radio.Root, {
|
|
27
|
+
"data-slot": "choice-control",
|
|
28
|
+
"aria-labelledby": titleId,
|
|
29
|
+
"aria-describedby": description === void 0 ? void 0 : descriptionId,
|
|
30
|
+
className: cn(choiceControl, "rounded-full bg-surface depth-socket transition-[box-shadow,scale]", "data-disabled:bg-disabled data-disabled:depth-flat"),
|
|
31
|
+
...props,
|
|
32
|
+
children: /* @__PURE__ */ jsx(Radio.Indicator, {
|
|
33
|
+
keepMounted: true,
|
|
34
|
+
"data-slot": "radio-card-indicator",
|
|
35
|
+
className: "size-(--radio-dot) scale-0 rounded-full bg-accent transition-[scale] spring-leave group-data-checked/control:scale-100 group-data-checked/control:spring-seat group-data-disabled/control:bg-on-disabled forced-colors:bg-[color:CanvasText]"
|
|
36
|
+
})
|
|
37
|
+
}), /* @__PURE__ */ jsx(ChoiceCardBody, {
|
|
38
|
+
slot: "radio-card",
|
|
39
|
+
titleId,
|
|
40
|
+
descriptionId,
|
|
41
|
+
title,
|
|
42
|
+
description,
|
|
43
|
+
detail,
|
|
44
|
+
icon,
|
|
45
|
+
children
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export { RadioCard };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
export type RollingNumberProps = Omit<ComponentProps<"span">, "children"> & {
|
|
3
|
+
value: number;
|
|
4
|
+
/** The language the number is written in. German by default: „1.234,50 €“. */
|
|
5
|
+
locale?: Intl.LocalesArgument;
|
|
6
|
+
/**
|
|
7
|
+
* How it is written: `{ style: "currency", currency: "EUR" }`, `{ style: "percent" }`,
|
|
8
|
+
* `{ notation: "compact" }`, a number of decimals. A value that rounds to zero never shows a
|
|
9
|
+
* minus. To keep decimals from coming and going, give `minimumFractionDigits`.
|
|
10
|
+
*/
|
|
11
|
+
format?: Intl.NumberFormatOptions;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A number whose digits roll to a new value instead of being swapped: a total, a count, a price
|
|
15
|
+
* that changes while it is on screen. Each digit is a column of the ten digits moved by
|
|
16
|
+
* `translate`, and every column rolls the way the number moves (9 rolls forward into 0, as on an
|
|
17
|
+
* odometer). Tabular digits keep every column the same width. Grouping dots, the decimal comma,
|
|
18
|
+
* the currency sign and the percent sign stand still between the columns; a place that joins
|
|
19
|
+
* opens and fades in, one that leaves fades and closes, so what stands beside the number slides
|
|
20
|
+
* aside instead of jumping. A change that arrives while the digits still move takes them on
|
|
21
|
+
* from where they are.
|
|
22
|
+
*
|
|
23
|
+
* It does not count up on page load: what shows first is the plain number, and it rolls only
|
|
24
|
+
* when the value changes afterwards. Assistive tech reads the formatted value, not the columns;
|
|
25
|
+
* announce a change with a live region around it where the change is the news. Under reduced
|
|
26
|
+
* motion the digits change at once.
|
|
27
|
+
*
|
|
28
|
+
* German by default; `format` takes `Intl.NumberFormat` options.
|
|
29
|
+
*/
|
|
30
|
+
export declare function RollingNumber({ value, locale, format, className, style, ref, ...props }: RollingNumberProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { mergePlaces, nextRolls, numberFormat, toPlaces } from "../../internal/number-places.js";
|
|
3
|
+
import { useLive } from "../../internal/presence.js";
|
|
4
|
+
import { cn } from "../../lib/cn.js";
|
|
5
|
+
import { mergeRefs } from "../../lib/merge-refs.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
// src/components/rolling-number/rolling-number.tsx
|
|
9
|
+
/** Formats are cached by what they are, so a `format` written inline costs nothing per render. */
|
|
10
|
+
const formats = /* @__PURE__ */ new Map();
|
|
11
|
+
function formatFor(locale, options) {
|
|
12
|
+
const key = JSON.stringify([locale, options]);
|
|
13
|
+
let format = formats.get(key);
|
|
14
|
+
if (!format) {
|
|
15
|
+
format = numberFormat(locale, options);
|
|
16
|
+
formats.set(key, format);
|
|
17
|
+
}
|
|
18
|
+
return format;
|
|
19
|
+
}
|
|
20
|
+
/** The ten digits of a format's numbering system, for the columns, when they are not 0 to 9. */
|
|
21
|
+
function digitsOf(format) {
|
|
22
|
+
const zero = format.formatToParts(0).find((part) => part.type === "integer")?.value ?? "0";
|
|
23
|
+
if (zero === "0") return void 0;
|
|
24
|
+
const code = zero.codePointAt(0) ?? 48;
|
|
25
|
+
return `"${[...Array.from({ length: 10 }, (_, digit) => digit), 0].map((digit) => String.fromCodePoint(code + digit)).join("\\A ")}"`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A number whose digits roll to a new value instead of being swapped: a total, a count, a price
|
|
29
|
+
* that changes while it is on screen. Each digit is a column of the ten digits moved by
|
|
30
|
+
* `translate`, and every column rolls the way the number moves (9 rolls forward into 0, as on an
|
|
31
|
+
* odometer). Tabular digits keep every column the same width. Grouping dots, the decimal comma,
|
|
32
|
+
* the currency sign and the percent sign stand still between the columns; a place that joins
|
|
33
|
+
* opens and fades in, one that leaves fades and closes, so what stands beside the number slides
|
|
34
|
+
* aside instead of jumping. A change that arrives while the digits still move takes them on
|
|
35
|
+
* from where they are.
|
|
36
|
+
*
|
|
37
|
+
* It does not count up on page load: what shows first is the plain number, and it rolls only
|
|
38
|
+
* when the value changes afterwards. Assistive tech reads the formatted value, not the columns;
|
|
39
|
+
* announce a change with a live region around it where the change is the news. Under reduced
|
|
40
|
+
* motion the digits change at once.
|
|
41
|
+
*
|
|
42
|
+
* German by default; `format` takes `Intl.NumberFormat` options.
|
|
43
|
+
*/
|
|
44
|
+
function RollingNumber({ value, locale = "de-DE", format, className, style, ref, ...props }) {
|
|
45
|
+
const formatter = formatFor(locale, format);
|
|
46
|
+
const parts = toPlaces(formatter, value);
|
|
47
|
+
const [model, setModel] = useState(() => ({
|
|
48
|
+
value,
|
|
49
|
+
text: parts.text,
|
|
50
|
+
unit: parts.unit,
|
|
51
|
+
shown: mergePlaces([], parts.places),
|
|
52
|
+
rolls: nextRolls({}, parts.places, 0),
|
|
53
|
+
swaps: 0
|
|
54
|
+
}));
|
|
55
|
+
if (model.value !== value || model.text !== parts.text) {
|
|
56
|
+
const swap = model.unit !== parts.unit;
|
|
57
|
+
setModel({
|
|
58
|
+
value,
|
|
59
|
+
text: parts.text,
|
|
60
|
+
unit: parts.unit,
|
|
61
|
+
shown: mergePlaces(swap ? [] : model.shown, parts.places),
|
|
62
|
+
rolls: swap ? nextRolls({}, parts.places, 0) : {
|
|
63
|
+
...model.rolls,
|
|
64
|
+
...nextRolls(model.rolls, parts.places, Math.sign(value - model.value))
|
|
65
|
+
},
|
|
66
|
+
swaps: swap ? model.swaps + 1 : model.swaps
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const columns = useLive();
|
|
70
|
+
const [live, setLive] = useState(false);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!columns) return;
|
|
73
|
+
const frame = requestAnimationFrame(() => setLive(true));
|
|
74
|
+
return () => cancelAnimationFrame(frame);
|
|
75
|
+
}, [columns]);
|
|
76
|
+
const root = useRef(null);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (!model.shown.some((place) => place.leaving)) return;
|
|
79
|
+
const frame = requestAnimationFrame(() => {
|
|
80
|
+
const still = [...root.current?.querySelectorAll("[data-leaving]") ?? []].filter((element) => element.getAnimations().length === 0).map((element) => element.dataset.key);
|
|
81
|
+
if (still.length > 0) setModel((current) => drop(current, (place) => still.includes(place.key)));
|
|
82
|
+
});
|
|
83
|
+
return () => cancelAnimationFrame(frame);
|
|
84
|
+
}, [model.shown]);
|
|
85
|
+
const settled = (event, key) => {
|
|
86
|
+
if (event.target !== event.currentTarget) return;
|
|
87
|
+
if (event.currentTarget.getAnimations().length > 0) return;
|
|
88
|
+
setModel((current) => drop(current, (place) => place.key === key));
|
|
89
|
+
};
|
|
90
|
+
const digits = digitsOf(formatter);
|
|
91
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
92
|
+
ref: mergeRefs(root, ref),
|
|
93
|
+
"data-slot": "rolling-number",
|
|
94
|
+
"data-live": live ? "" : void 0,
|
|
95
|
+
className: cn("inline-flex tabular-nums", className),
|
|
96
|
+
style: digits ? {
|
|
97
|
+
"--rolling-digits": digits,
|
|
98
|
+
...style
|
|
99
|
+
} : style,
|
|
100
|
+
...props,
|
|
101
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
102
|
+
className: "sr-only",
|
|
103
|
+
suppressHydrationWarning: true,
|
|
104
|
+
children: model.text
|
|
105
|
+
}), columns ? /* @__PURE__ */ jsx("span", {
|
|
106
|
+
"aria-hidden": true,
|
|
107
|
+
className: "inline-flex select-none",
|
|
108
|
+
children: model.shown.map((place) => /* @__PURE__ */ jsx("span", {
|
|
109
|
+
"data-slot": "rolling-number-place",
|
|
110
|
+
"data-key": place.key,
|
|
111
|
+
"data-leaving": place.leaving ? "" : void 0,
|
|
112
|
+
onTransitionEnd: (event) => {
|
|
113
|
+
if (place.leaving) settled(event, place.key);
|
|
114
|
+
},
|
|
115
|
+
onTransitionCancel: (event) => {
|
|
116
|
+
if (place.leaving) settled(event, place.key);
|
|
117
|
+
},
|
|
118
|
+
children: place.kind === "digit" ? /* @__PURE__ */ jsx("span", {
|
|
119
|
+
"data-slot": "rolling-number-window",
|
|
120
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
121
|
+
"data-slot": "rolling-number-column",
|
|
122
|
+
style: { "--roll": model.rolls[place.key] ?? place.digit }
|
|
123
|
+
})
|
|
124
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
125
|
+
"data-slot": "rolling-number-symbol",
|
|
126
|
+
children: place.text
|
|
127
|
+
})
|
|
128
|
+
}, place.key))
|
|
129
|
+
}, model.swaps) : /* @__PURE__ */ jsx("span", {
|
|
130
|
+
"aria-hidden": true,
|
|
131
|
+
suppressHydrationWarning: true,
|
|
132
|
+
className: "whitespace-pre",
|
|
133
|
+
children: model.text
|
|
134
|
+
})]
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/** The model without the leaving places that `which` names, and without their columns. */
|
|
138
|
+
function drop(model, which) {
|
|
139
|
+
const gone = model.shown.filter((place) => place.leaving && which(place));
|
|
140
|
+
if (gone.length === 0) return model;
|
|
141
|
+
const rolls = { ...model.rolls };
|
|
142
|
+
for (const place of gone) delete rolls[place.key];
|
|
143
|
+
return {
|
|
144
|
+
...model,
|
|
145
|
+
shown: model.shown.filter((place) => !gone.includes(place)),
|
|
146
|
+
rolls
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export { RollingNumber };
|
|
@@ -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
|
declare const seamVariants: (props?: ({
|
|
4
4
|
direction?: "down" | "up" | null | undefined;
|
|
5
5
|
above?: "ground" | "well" | "surface" | null | undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { InputProps } from "../input/input.js";
|
|
2
|
+
import { FieldSize } from "../../internal/field.js";
|
|
3
|
+
export type SecretFieldProps = Omit<InputProps, "value" | "defaultValue" | "onChange" | "readOnly" | "type" | "size"> & {
|
|
4
|
+
/** The value: an API key, a webhook's secret, an invitation link. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** The size of the field, from the density. */
|
|
7
|
+
size?: FieldSize;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the value can be hidden at all. `false` for something that is not a secret (an
|
|
10
|
+
* address, a link): the field then only shows and copies it.
|
|
11
|
+
*/
|
|
12
|
+
hideable?: boolean;
|
|
13
|
+
/** Whether the value is shown (controlled). Hidden unless said otherwise. */
|
|
14
|
+
revealed?: boolean;
|
|
15
|
+
/** Whether the value is shown at first. */
|
|
16
|
+
defaultRevealed?: boolean;
|
|
17
|
+
onRevealedChange?: (revealed: boolean) => void;
|
|
18
|
+
/**
|
|
19
|
+
* How many characters at the start stay readable while the value is hidden: the prefix that
|
|
20
|
+
* says what kind of key it is (`lf_live_`).
|
|
21
|
+
*/
|
|
22
|
+
visibleStart?: number;
|
|
23
|
+
/** Called once the value has reached the clipboard. */
|
|
24
|
+
onCopied?: () => void;
|
|
25
|
+
/** The name of the key that shows the value; it is a toggle. Also its tooltip while hidden. */
|
|
26
|
+
revealLabel?: string;
|
|
27
|
+
/** The tooltip of that key while the value is shown. */
|
|
28
|
+
hideLabel?: string;
|
|
29
|
+
/** The name of the copy key and its tooltip. */
|
|
30
|
+
copyLabel?: string;
|
|
31
|
+
/** The tooltip once the value is on the clipboard. */
|
|
32
|
+
copiedLabel?: string;
|
|
33
|
+
/** Read out once the value is on the clipboard: a full sentence. */
|
|
34
|
+
copiedMessage?: string;
|
|
35
|
+
/** The tooltip when the clipboard refused; the value is then shown and selected. */
|
|
36
|
+
failedLabel?: string;
|
|
37
|
+
/** Read out when the clipboard refused. */
|
|
38
|
+
failedMessage?: string;
|
|
39
|
+
/** Classes for the field as a whole, e.g. its width. */
|
|
40
|
+
className?: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A value that is read by machines and must not be read over a shoulder: an API key, the
|
|
44
|
+
* secret of a webhook. It stands in a field in mono, hidden behind discs until the key with
|
|
45
|
+
* the eye is pressed, and a second key copies it. The copy always takes the real value,
|
|
46
|
+
* hidden or not, and confirms with the drawn tick.
|
|
47
|
+
*
|
|
48
|
+
* The field cannot be typed into. Label it with a `FieldLabel` ("Geheimer Schlüssel") and say
|
|
49
|
+
* in a `FieldDescription` what the reader should do with it ("Er wird nur dieses eine Mal
|
|
50
|
+
* angezeigt."). While it is hidden the value is not in the page; when the browser refuses the
|
|
51
|
+
* clipboard, the value is shown and selected instead, so ⌘C still works.
|
|
52
|
+
*/
|
|
53
|
+
export declare function SecretField({ value, size, hideable, revealed: revealedProp, defaultRevealed, onRevealedChange, visibleStart, onCopied, revealLabel, hideLabel, copyLabel, copiedLabel, copiedMessage, failedLabel, failedMessage, className, ref, ...props }: SecretFieldProps): import("react").JSX.Element;
|