@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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useGround } from "../ground/ground.js";
|
|
3
3
|
import { ChevronDownGlyph } from "../../internal/glyphs.js";
|
|
4
|
+
import { Tile } from "../../internal/tile.js";
|
|
4
5
|
import { cn, mergeClassName } from "../../lib/cn.js";
|
|
5
6
|
import { navigationMenuEntryVariants } from "./navigation-menu-variants.js";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { NavigationMenu as NavigationMenu$1 } from "@base-ui/react/navigation-menu";
|
|
8
9
|
// src/components/navigation-menu/navigation-menu.tsx
|
|
9
10
|
/**
|
|
@@ -98,15 +99,21 @@ function NavigationMenuContent({ className, ...props }) {
|
|
|
98
99
|
* A link in the navigation menu. Mark the page the reader is on with `active`. For a router's
|
|
99
100
|
* link, pass it as `render`: `<NavigationMenuLink render={<NextLink href="/preise" />}>`.
|
|
100
101
|
*/
|
|
101
|
-
function NavigationMenuLink({ kind = "page", className, ...props }) {
|
|
102
|
+
function NavigationMenuLink({ kind = "page", icon, className, children, ...props }) {
|
|
103
|
+
const tiled = kind === "page" && icon !== void 0;
|
|
102
104
|
return /* @__PURE__ */ jsx(NavigationMenu$1.Link, {
|
|
103
105
|
"data-slot": "navigation-menu-link",
|
|
104
106
|
className: mergeClassName(kind === "entry" ? navigationMenuEntryVariants() : [
|
|
105
|
-
"
|
|
107
|
+
"group/row flex rounded-md text-fg-body",
|
|
108
|
+
tiled ? "flex-row items-center gap-3 px-2 py-2" : "flex-col gap-0.5 px-3 py-2.5",
|
|
106
109
|
"transition-colors duration-150 ease-out hover:bg-hover data-active:bg-tint",
|
|
107
110
|
"focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent"
|
|
108
111
|
], className),
|
|
109
|
-
...props
|
|
112
|
+
...props,
|
|
113
|
+
children: tiled ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Tile, { icon }), /* @__PURE__ */ jsx("span", {
|
|
114
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
115
|
+
children
|
|
116
|
+
})] }) : children
|
|
110
117
|
});
|
|
111
118
|
}
|
|
112
119
|
/** The name of the page a row leads to. */
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { OTPField } from "@base-ui/react/otp-field";
|
|
2
|
+
export type OtpFieldProps = Omit<OTPField.Root.Props, "children" | "className" | "length" | "render"> & {
|
|
3
|
+
/** How many characters the code has. Six unless said otherwise. */
|
|
4
|
+
length?: number;
|
|
5
|
+
/**
|
|
6
|
+
* How many slots stand together before a short line sets the next ones apart: 3 writes six
|
|
7
|
+
* digits as "123 456", the way a code is read out. 0 keeps them in one row.
|
|
8
|
+
*/
|
|
9
|
+
groupSize?: number;
|
|
10
|
+
/**
|
|
11
|
+
* `joined` (the default): the slots of a group share one socket, divided by hairlines.
|
|
12
|
+
* `separate`: every slot is a socket of its own.
|
|
13
|
+
*/
|
|
14
|
+
variant?: "joined" | "separate";
|
|
15
|
+
/**
|
|
16
|
+
* The slots share the width of the field's place instead of keeping their own: for a dialog
|
|
17
|
+
* or a narrow card, where six small slots would leave half the line empty.
|
|
18
|
+
*/
|
|
19
|
+
fill?: boolean;
|
|
20
|
+
/** What a slot after the first is called for assistive tech: "Ziffer 2 von 6". */
|
|
21
|
+
slotLabel?: (position: number, length: number) => string;
|
|
22
|
+
className?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A one-time code: the six digits from a text message or an authenticator app. Every character
|
|
26
|
+
* has a slot, in threes, the way a code is read out. The slot that is being typed wears the
|
|
27
|
+
* field's halo, and a digit seats into its slot as it arrives. A pasted code, or one the phone
|
|
28
|
+
* offers from a message, fills every slot.
|
|
29
|
+
*
|
|
30
|
+
* Label it with a `FieldLabel` in a `Field` ("Bestätigungscode") and say in a
|
|
31
|
+
* `FieldDescription` where the code was sent. A wrong code is said in words under the field
|
|
32
|
+
* (`FieldError`); the field does not shake. `onValueComplete` tells when the last slot is
|
|
33
|
+
* filled, `autoSubmit` sends the form then.
|
|
34
|
+
*
|
|
35
|
+
* It takes digits. `validationType="alphanumeric"` lets letters in, for a recovery code.
|
|
36
|
+
*/
|
|
37
|
+
export declare function OtpField({ length, groupSize, variant, fill, mask, slotLabel, className, onValueChange, onFocus, onBlur, ...props }: OtpFieldProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { fieldFace } from "../../internal/field.js";
|
|
3
|
+
import { useLive } from "../../internal/presence.js";
|
|
4
|
+
import { cn } from "../../lib/cn.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment as Fragment$1, useEffect, useRef, useState } from "react";
|
|
7
|
+
import { OTPField } from "@base-ui/react/otp-field";
|
|
8
|
+
// src/components/otp-field/otp-field.tsx
|
|
9
|
+
/**
|
|
10
|
+
* In separate slots, how long a slot's own halo takes to open (`snap`), after which it hops
|
|
11
|
+
* between them at once. A joined field's one halo glides instead (`otp-field-halo`).
|
|
12
|
+
*/
|
|
13
|
+
const ENTERED_MS = 140;
|
|
14
|
+
/** How long the slots count as filled in one go, so the digits of a paste seat one by one. */
|
|
15
|
+
const BURST_MS = 480;
|
|
16
|
+
/** A slot that is a socket of its own. */
|
|
17
|
+
const separateSlot = [
|
|
18
|
+
"rounded-md",
|
|
19
|
+
fieldFace,
|
|
20
|
+
"has-[input:focus]:depth-field-focus",
|
|
21
|
+
"has-[input[data-invalid]]:depth-field-invalid has-[input[data-invalid]:focus]:depth-field-invalid",
|
|
22
|
+
"has-[input[data-invalid]:not(:focus)]:[--depth-field-halo-danger:transparent]",
|
|
23
|
+
"has-[input[data-disabled]]:bg-disabled has-[input[data-disabled]]:depth-flat"
|
|
24
|
+
].join(" ");
|
|
25
|
+
/**
|
|
26
|
+
* The socket that the slots of a group share. Invalid, it takes the danger edge without the
|
|
27
|
+
* halo, as the separate slots do: only the slot being typed opens one.
|
|
28
|
+
*/
|
|
29
|
+
const joinedGroup = [
|
|
30
|
+
"rounded-md bg-surface depth-field",
|
|
31
|
+
"has-[input[data-invalid]]:[--depth-field-edge:var(--lf-danger)]",
|
|
32
|
+
"has-[input[data-disabled]]:bg-disabled has-[input[data-disabled]]:depth-flat"
|
|
33
|
+
].join(" ");
|
|
34
|
+
/** A slot inside that socket: a hairline to its left. The halo is the field's own piece. */
|
|
35
|
+
const joinedSlot = "border-hairline not-first:border-l first:rounded-l-md last:rounded-r-md";
|
|
36
|
+
/**
|
|
37
|
+
* A one-time code: the six digits from a text message or an authenticator app. Every character
|
|
38
|
+
* has a slot, in threes, the way a code is read out. The slot that is being typed wears the
|
|
39
|
+
* field's halo, and a digit seats into its slot as it arrives. A pasted code, or one the phone
|
|
40
|
+
* offers from a message, fills every slot.
|
|
41
|
+
*
|
|
42
|
+
* Label it with a `FieldLabel` in a `Field` ("Bestätigungscode") and say in a
|
|
43
|
+
* `FieldDescription` where the code was sent. A wrong code is said in words under the field
|
|
44
|
+
* (`FieldError`); the field does not shake. `onValueComplete` tells when the last slot is
|
|
45
|
+
* filled, `autoSubmit` sends the form then.
|
|
46
|
+
*
|
|
47
|
+
* It takes digits. `validationType="alphanumeric"` lets letters in, for a recovery code.
|
|
48
|
+
*/
|
|
49
|
+
function OtpField({ length = 6, groupSize = 3, variant = "joined", fill = false, mask = false, slotLabel = (position, total) => `Ziffer ${position} von ${total}`, className, onValueChange, onFocus, onBlur, ...props }) {
|
|
50
|
+
const live = useLive();
|
|
51
|
+
const [entered, setEntered] = useState(false);
|
|
52
|
+
const entering = useRef(void 0);
|
|
53
|
+
const [burst, setBurst] = useState(false);
|
|
54
|
+
const bursting = useRef(void 0);
|
|
55
|
+
const lastLength = useRef((props.value ?? props.defaultValue ?? "").length);
|
|
56
|
+
useEffect(() => () => {
|
|
57
|
+
clearTimeout(entering.current);
|
|
58
|
+
clearTimeout(bursting.current);
|
|
59
|
+
}, []);
|
|
60
|
+
const halo = useRef(null);
|
|
61
|
+
const joined = variant === "joined";
|
|
62
|
+
const placeHalo = (slot, arriving) => {
|
|
63
|
+
const piece = halo.current;
|
|
64
|
+
if (!piece || !slot) return;
|
|
65
|
+
if (arriving) piece.dataset.instant = "";
|
|
66
|
+
piece.style.setProperty("--halo-x", String(slot.offsetLeft));
|
|
67
|
+
piece.style.setProperty("--halo-y", String(slot.offsetTop));
|
|
68
|
+
piece.style.setProperty("--halo-w", String(slot.offsetWidth));
|
|
69
|
+
piece.style.setProperty("--halo-h", String(slot.offsetHeight));
|
|
70
|
+
piece.dataset.shown = "";
|
|
71
|
+
if (arriving) requestAnimationFrame(() => delete piece.dataset.instant);
|
|
72
|
+
};
|
|
73
|
+
const slotOf = (target) => target instanceof HTMLElement ? target.closest("[data-slot=\"otp-field-slot\"]") : null;
|
|
74
|
+
const root = useRef(null);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const box = root.current;
|
|
77
|
+
if (!joined || !box) return;
|
|
78
|
+
const observer = new ResizeObserver(() => {
|
|
79
|
+
if (halo.current?.dataset.shown === void 0) return;
|
|
80
|
+
placeHalo(slotOf(document.activeElement), true);
|
|
81
|
+
});
|
|
82
|
+
observer.observe(box);
|
|
83
|
+
return () => observer.disconnect();
|
|
84
|
+
}, [joined]);
|
|
85
|
+
const groups = [];
|
|
86
|
+
for (let index = 0; index < length; index++) {
|
|
87
|
+
const group = groupSize > 0 ? Math.floor(index / groupSize) : 0;
|
|
88
|
+
(groups[group] ??= []).push(index);
|
|
89
|
+
}
|
|
90
|
+
return /* @__PURE__ */ jsxs(OTPField.Root, {
|
|
91
|
+
ref: root,
|
|
92
|
+
"data-slot": "otp-field",
|
|
93
|
+
"data-variant": variant,
|
|
94
|
+
"data-live": live ? "" : void 0,
|
|
95
|
+
"data-entered": entered ? "" : void 0,
|
|
96
|
+
"data-burst": burst ? "" : void 0,
|
|
97
|
+
length,
|
|
98
|
+
mask,
|
|
99
|
+
"data-fill": fill ? "" : void 0,
|
|
100
|
+
className: cn("group/otp relative items-center gap-2", fill ? "flex w-full" : "inline-flex w-fit", className),
|
|
101
|
+
onValueChange: (value, details) => {
|
|
102
|
+
if (value.length - lastLength.current > 1) {
|
|
103
|
+
clearTimeout(bursting.current);
|
|
104
|
+
setBurst(true);
|
|
105
|
+
bursting.current = setTimeout(() => setBurst(false), BURST_MS);
|
|
106
|
+
}
|
|
107
|
+
lastLength.current = value.length;
|
|
108
|
+
onValueChange?.(value, details);
|
|
109
|
+
},
|
|
110
|
+
onFocus: (event) => {
|
|
111
|
+
clearTimeout(entering.current);
|
|
112
|
+
entering.current = setTimeout(() => setEntered(true), ENTERED_MS);
|
|
113
|
+
if (joined) {
|
|
114
|
+
const from = event.relatedTarget;
|
|
115
|
+
placeHalo(slotOf(event.target), !(from instanceof Node && event.currentTarget.contains(from)));
|
|
116
|
+
}
|
|
117
|
+
onFocus?.(event);
|
|
118
|
+
},
|
|
119
|
+
onBlur: (event) => {
|
|
120
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
121
|
+
clearTimeout(entering.current);
|
|
122
|
+
setEntered(false);
|
|
123
|
+
if (halo.current) delete halo.current.dataset.shown;
|
|
124
|
+
}
|
|
125
|
+
onBlur?.(event);
|
|
126
|
+
},
|
|
127
|
+
...props,
|
|
128
|
+
children: [groups.map((slots, group) => /* @__PURE__ */ jsxs(Fragment$1, { children: [group > 0 && /* @__PURE__ */ jsx(OTPField.Separator, {
|
|
129
|
+
"data-slot": "otp-field-separator",
|
|
130
|
+
className: "h-px w-2 shrink-0 bg-line forced-colors:bg-[CanvasText]"
|
|
131
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
132
|
+
"data-slot": "otp-field-group",
|
|
133
|
+
className: cn("flex", variant === "joined" ? joinedGroup : "gap-1.5", fill && "min-w-0 flex-1"),
|
|
134
|
+
children: slots.map((index) => /* @__PURE__ */ jsx(OTPField.Input, {
|
|
135
|
+
"aria-label": index === 0 ? void 0 : slotLabel(index + 1, length),
|
|
136
|
+
render: (inputProps, state) => /* @__PURE__ */ jsxs("span", {
|
|
137
|
+
"data-slot": "otp-field-slot",
|
|
138
|
+
"data-filled": state.filled ? "" : void 0,
|
|
139
|
+
style: { "--slot": index },
|
|
140
|
+
className: cn("relative inline-grid h-(--control-lg) place-items-center", fill ? "min-w-0 flex-1" : "w-(--control-lg)", variant === "joined" ? joinedSlot : separateSlot, "group-data-entered/otp:transition-none"),
|
|
141
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
142
|
+
...inputProps,
|
|
143
|
+
"data-slot": "otp-field-input",
|
|
144
|
+
className: "absolute inset-0 size-full rounded-[inherit] bg-transparent text-center text-lg text-transparent caret-accent selection:bg-transparent focus:outline-hidden forced-colors:text-[FieldText]"
|
|
145
|
+
}), state.value !== "" && /* @__PURE__ */ jsx("span", {
|
|
146
|
+
"aria-hidden": true,
|
|
147
|
+
"data-slot": "otp-field-digit",
|
|
148
|
+
className: cn("pointer-events-none relative text-lg font-medium text-fg tabular-nums forced-colors:hidden", "group-has-[input[data-disabled]]/otp:text-on-disabled", "transition-[scale,opacity] spring-seat in-data-live:starting:scale-90 in-data-live:starting:opacity-40", "in-data-burst:delay-[calc(var(--slot)*35ms)] in-data-burst:in-data-live:starting:opacity-0", mask && "size-2 rounded-full bg-current"),
|
|
149
|
+
children: mask ? null : state.value
|
|
150
|
+
}, state.value)]
|
|
151
|
+
})
|
|
152
|
+
}, index))
|
|
153
|
+
})] }, slots[0])), joined && /* @__PURE__ */ jsx("span", {
|
|
154
|
+
ref: halo,
|
|
155
|
+
"aria-hidden": true,
|
|
156
|
+
"data-slot": "otp-field-halo",
|
|
157
|
+
className: cn("pointer-events-none absolute top-0 left-0 z-1 rounded-md opacity-0 shadow-field-focus", "h-[calc(var(--halo-h,0)*1px)] w-[calc(var(--halo-w,0)*1px)]", "[translate:calc(var(--halo-x,0)*1px)_calc(var(--halo-y,0)*1px)]", "group-has-[input[data-invalid]]/otp:shadow-field-invalid", "[transition:translate_var(--transition-duration-spring-snap)_var(--ease-spring-snap),opacity_var(--transition-duration-spring-snap)_var(--ease-spring-snap)]", "data-instant:[transition:opacity_var(--transition-duration-spring-snap)_var(--ease-spring-snap)]", "motion-reduce:[transition:opacity_var(--transition-duration-spring-snap)_var(--ease-spring-snap)]", "data-shown:opacity-100", "forced-colors:hidden")
|
|
158
|
+
})]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
export { OtpField };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ComponentProps, MouseEvent, ReactNode } from "react";
|
|
2
|
+
export type PaginationProps = Omit<ComponentProps<"nav">, "children"> & {
|
|
3
|
+
/** The page that shows, counted from 1. */
|
|
4
|
+
page: number;
|
|
5
|
+
/** How many pages there are. */
|
|
6
|
+
pages: number;
|
|
7
|
+
/**
|
|
8
|
+
* Where a page lives. With it every number is a real link, so a page can be opened in a new
|
|
9
|
+
* tab, sent to someone and found again with the Back button. Keep the page in the address.
|
|
10
|
+
*
|
|
11
|
+
* A pattern in which `{page}` stands for the number (`"/angebote?seite={page}"`), or a
|
|
12
|
+
* function. From a Server Component only the pattern can be handed in.
|
|
13
|
+
*/
|
|
14
|
+
href?: string | ((page: number) => string);
|
|
15
|
+
/**
|
|
16
|
+
* Called with the page that was asked for. Without `href` the numbers are buttons and this is
|
|
17
|
+
* all that happens; with it, call `event.preventDefault()` here if a router takes over.
|
|
18
|
+
*/
|
|
19
|
+
onPageChange?: (page: number, event: MouseEvent<HTMLElement>) => void;
|
|
20
|
+
/**
|
|
21
|
+
* `numbered` (the default): the pages as numbers, the current one on the tint. `compact`:
|
|
22
|
+
* "Seite 3 von 12" and two arrows, for a narrow place or a list nobody jumps around in.
|
|
23
|
+
*/
|
|
24
|
+
variant?: "numbered" | "compact";
|
|
25
|
+
/** How many numbers stand to each side of the current one. */
|
|
26
|
+
siblings?: number;
|
|
27
|
+
/** The name of the navigation for assistive tech. */
|
|
28
|
+
"aria-label"?: string;
|
|
29
|
+
/** What a page number is called: "Seite 3". A pattern (`"Page {page}"`) or a function. */
|
|
30
|
+
pageLabel?: string | ((page: number) => string);
|
|
31
|
+
/**
|
|
32
|
+
* The line of the compact form: "Seite 3 von 12". A pattern (`"Page {page} of {pages}"`) or a
|
|
33
|
+
* function.
|
|
34
|
+
*/
|
|
35
|
+
positionLabel?: string | ((page: number, pages: number) => ReactNode);
|
|
36
|
+
/** The name of the arrow that goes one page back. */
|
|
37
|
+
previousLabel?: string;
|
|
38
|
+
/** The name of the arrow that goes one page on. */
|
|
39
|
+
nextLabel?: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The pages of a long list. The page that shows stands on the tint, and the tint travels to
|
|
43
|
+
* the next number when the page changes. The row keeps its width from the first page to the
|
|
44
|
+
* last, so the arrows stay under the pointer while one pages through.
|
|
45
|
+
*
|
|
46
|
+
* Give it `href` wherever the page is part of the address, which is nearly always: the numbers
|
|
47
|
+
* are then links. Say beside it what the pages hold ("21 bis 40 von 248 Angeboten"); that
|
|
48
|
+
* line is yours to word.
|
|
49
|
+
*/
|
|
50
|
+
export declare function Pagination({ page, pages, href, onPageChange, variant, siblings, "aria-label": label, pageLabel, positionLabel, previousLabel, nextLabel, className, ...props }: PaginationProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { ButtonGroup } from "../button-group/button-group.js";
|
|
4
|
+
import { buttonGroupKeyDisabledLook, buttonGroupKeyVariants } from "../button-group/button-group-variants.js";
|
|
5
|
+
import { ChevronLeftGlyph, ChevronRightGlyph, GapGlyph } from "../../internal/glyphs.js";
|
|
6
|
+
import { useTravellingMark } from "../../internal/travelling-mark.js";
|
|
7
|
+
import { cn } from "../../lib/cn.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useRef } from "react";
|
|
10
|
+
// src/components/pagination/pagination.tsx
|
|
11
|
+
/** A gap between page numbers, where pages were left out. */
|
|
12
|
+
const GAP = "gap";
|
|
13
|
+
/**
|
|
14
|
+
* The page numbers to show: the first and the last, the current one with its neighbours, and a
|
|
15
|
+
* gap where pages are left out. The row always has the same number of places, whatever page is
|
|
16
|
+
* current, so it never changes its width while one pages through.
|
|
17
|
+
*/
|
|
18
|
+
function pageRange(page, pages, siblings = 1) {
|
|
19
|
+
const places = siblings * 2 + 5;
|
|
20
|
+
if (pages <= places) return Array.from({ length: pages }, (_, index) => index + 1);
|
|
21
|
+
const run = (from, to) => Array.from({ length: to - from + 1 }, (_, index) => from + index);
|
|
22
|
+
if (page <= siblings + 3) return [
|
|
23
|
+
...run(1, places - 2),
|
|
24
|
+
GAP,
|
|
25
|
+
pages
|
|
26
|
+
];
|
|
27
|
+
if (page >= pages - siblings - 2) return [
|
|
28
|
+
1,
|
|
29
|
+
GAP,
|
|
30
|
+
...run(pages - places + 3, pages)
|
|
31
|
+
];
|
|
32
|
+
return [
|
|
33
|
+
1,
|
|
34
|
+
GAP,
|
|
35
|
+
...run(page - siblings, page + siblings),
|
|
36
|
+
GAP,
|
|
37
|
+
pages
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent";
|
|
41
|
+
const place = "flex size-(--control-md) items-center justify-center rounded-md text-control tabular-nums select-none";
|
|
42
|
+
/**
|
|
43
|
+
* On a touch screen a place grows to 44px up and down, never sideways: its neighbours stand
|
|
44
|
+
* 2px beside it, and two places must not take each other's taps.
|
|
45
|
+
*/
|
|
46
|
+
const reach = "relative pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:top-1/2 pointer-coarse:after:h-11 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']";
|
|
47
|
+
/** A pattern with its numbers put in: `{page}` and `{pages}`. */
|
|
48
|
+
function fill(pattern, page, pages) {
|
|
49
|
+
return pattern.replaceAll("{page}", String(page)).replaceAll("{pages}", String(pages));
|
|
50
|
+
}
|
|
51
|
+
/** An arrow leans a pixel the way it leads while the pointer is on it. */
|
|
52
|
+
const lean = "transition-[translate] spring-seat group-hover/arrow:spring-snap";
|
|
53
|
+
/**
|
|
54
|
+
* The pages of a long list. The page that shows stands on the tint, and the tint travels to
|
|
55
|
+
* the next number when the page changes. The row keeps its width from the first page to the
|
|
56
|
+
* last, so the arrows stay under the pointer while one pages through.
|
|
57
|
+
*
|
|
58
|
+
* Give it `href` wherever the page is part of the address, which is nearly always: the numbers
|
|
59
|
+
* are then links. Say beside it what the pages hold ("21 bis 40 von 248 Angeboten"); that
|
|
60
|
+
* line is yours to word.
|
|
61
|
+
*/
|
|
62
|
+
function Pagination({ page, pages, href, onPageChange, variant = "numbered", siblings = 1, "aria-label": label = "Seiten", pageLabel = "Seite {page}", positionLabel = "Seite {page} von {pages}", previousLabel = "Vorherige Seite", nextLabel = "Nächste Seite", className, ...props }) {
|
|
63
|
+
const list = useRef(null);
|
|
64
|
+
const mark = useRef(null);
|
|
65
|
+
useTravellingMark(list, mark, { enabled: variant === "numbered" });
|
|
66
|
+
const hrefOf = (to) => typeof href === "string" ? fill(href, to, pages) : href?.(to);
|
|
67
|
+
const nameOf = (to) => typeof pageLabel === "string" ? fill(pageLabel, to, pages) : pageLabel(to);
|
|
68
|
+
/**
|
|
69
|
+
* What an arrow or a number says and does. One that leads nowhere (back from the first page,
|
|
70
|
+
* on from the last) keeps its place, so nothing shifts, and stays in reach of the keyboard:
|
|
71
|
+
* whoever pages to the end with Enter still holds the focus there and hears that it ends.
|
|
72
|
+
*/
|
|
73
|
+
const leads = (to, name) => {
|
|
74
|
+
const off = to < 1 || to > pages;
|
|
75
|
+
return {
|
|
76
|
+
off,
|
|
77
|
+
"aria-label": name,
|
|
78
|
+
"aria-current": to === page ? "page" : void 0,
|
|
79
|
+
"aria-disabled": off || void 0,
|
|
80
|
+
onClick: (event) => {
|
|
81
|
+
if (off) event.preventDefault();
|
|
82
|
+
else onPageChange?.(to, event);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/** What makes it a link while it leads somewhere, and says it is one while it does not. */
|
|
87
|
+
const address = (to, off) => off ? {
|
|
88
|
+
role: "link",
|
|
89
|
+
tabIndex: 0
|
|
90
|
+
} : { href: hrefOf(to) };
|
|
91
|
+
if (variant === "compact") {
|
|
92
|
+
const step = (to, name, glyph) => {
|
|
93
|
+
const { off, ...says } = leads(to, name);
|
|
94
|
+
return href ? /* @__PURE__ */ jsx("a", {
|
|
95
|
+
...address(to, off),
|
|
96
|
+
...says,
|
|
97
|
+
"data-slot": "button",
|
|
98
|
+
"data-group-key": "",
|
|
99
|
+
"data-disabled": off ? "" : void 0,
|
|
100
|
+
className: cn(buttonGroupKeyVariants({
|
|
101
|
+
size: "sm",
|
|
102
|
+
iconOnly: true
|
|
103
|
+
}), buttonGroupKeyDisabledLook),
|
|
104
|
+
children: glyph
|
|
105
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
106
|
+
iconOnly: true,
|
|
107
|
+
disabled: off,
|
|
108
|
+
focusableWhenDisabled: true,
|
|
109
|
+
...says,
|
|
110
|
+
"aria-label": name,
|
|
111
|
+
children: glyph
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
115
|
+
"data-slot": "pagination",
|
|
116
|
+
"data-variant": "compact",
|
|
117
|
+
"aria-label": label,
|
|
118
|
+
className: cn("flex items-center gap-3", className),
|
|
119
|
+
...props,
|
|
120
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
121
|
+
"data-slot": "pagination-position",
|
|
122
|
+
className: "text-sm text-fg-muted tabular-nums",
|
|
123
|
+
children: typeof positionLabel === "string" ? fill(positionLabel, page, pages) : positionLabel(page, pages)
|
|
124
|
+
}), /* @__PURE__ */ jsxs(ButtonGroup, {
|
|
125
|
+
size: "sm",
|
|
126
|
+
"aria-label": label,
|
|
127
|
+
children: [step(page - 1, previousLabel, /* @__PURE__ */ jsx(ChevronLeftGlyph, {})), step(page + 1, nextLabel, /* @__PURE__ */ jsx(ChevronRightGlyph, {}))]
|
|
128
|
+
})]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/** A link where the page has an address, a button where it has none. */
|
|
132
|
+
const go = (to, more) => {
|
|
133
|
+
const { off, ...says } = leads(to, more.label);
|
|
134
|
+
return href ? /* @__PURE__ */ jsx("a", {
|
|
135
|
+
...address(to, off),
|
|
136
|
+
...says,
|
|
137
|
+
className: more.className,
|
|
138
|
+
children: more.children
|
|
139
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
140
|
+
type: "button",
|
|
141
|
+
...says,
|
|
142
|
+
className: more.className,
|
|
143
|
+
children: more.children
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const arrow = cn(place, reach, "group/arrow text-fg-muted hover:bg-hover hover:text-fg", "aria-disabled:pointer-events-none aria-disabled:text-on-disabled", focusRing);
|
|
147
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
148
|
+
"data-slot": "pagination",
|
|
149
|
+
"data-variant": "numbered",
|
|
150
|
+
"aria-label": label,
|
|
151
|
+
className,
|
|
152
|
+
...props,
|
|
153
|
+
children: /* @__PURE__ */ jsxs("ul", {
|
|
154
|
+
ref: list,
|
|
155
|
+
"data-slot": "pagination-list",
|
|
156
|
+
className: "relative isolate flex items-center gap-0.5 [--pagination-current:var(--lf-tint)] data-placed:[--pagination-current:transparent]",
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx("li", { children: go(page - 1, {
|
|
159
|
+
label: previousLabel,
|
|
160
|
+
className: arrow,
|
|
161
|
+
children: /* @__PURE__ */ jsx(ChevronLeftGlyph, { className: cn(lean, "motion-safe:group-hover/arrow:-translate-x-px") })
|
|
162
|
+
}) }),
|
|
163
|
+
pageRange(page, pages, siblings).map((entry, index) => entry === GAP ? /* @__PURE__ */ jsx("li", {
|
|
164
|
+
"aria-hidden": true,
|
|
165
|
+
className: cn(place, "text-fg-muted"),
|
|
166
|
+
children: /* @__PURE__ */ jsx(GapGlyph, {})
|
|
167
|
+
}, `gap-${index}`) : /* @__PURE__ */ jsx("li", { children: go(entry, {
|
|
168
|
+
label: nameOf(entry),
|
|
169
|
+
className: cn(place, reach, "text-fg-body hover:text-fg not-aria-[current=page]:hover:bg-hover", "aria-[current=page]:bg-(--pagination-current) aria-[current=page]:font-medium aria-[current=page]:text-fg", "forced-colors:aria-[current=page]:outline forced-colors:aria-[current=page]:-outline-offset-1", focusRing),
|
|
170
|
+
children: entry
|
|
171
|
+
}) }, entry)),
|
|
172
|
+
/* @__PURE__ */ jsx("li", { children: go(page + 1, {
|
|
173
|
+
label: nextLabel,
|
|
174
|
+
className: arrow,
|
|
175
|
+
children: /* @__PURE__ */ jsx(ChevronRightGlyph, { className: cn(lean, "motion-safe:group-hover/arrow:translate-x-px") })
|
|
176
|
+
}) }),
|
|
177
|
+
/* @__PURE__ */ jsx("li", {
|
|
178
|
+
ref: mark,
|
|
179
|
+
"aria-hidden": true,
|
|
180
|
+
role: "presentation",
|
|
181
|
+
"data-slot": "pagination-mark",
|
|
182
|
+
className: "travels -z-10 rounded-md bg-tint"
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
export { Pagination, pageRange };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/components/prompt-input/keys.ts
|
|
2
|
+
/**
|
|
3
|
+
* A screen that is only touched: there Enter breaks the line and the key sends. An iPad with a
|
|
4
|
+
* keyboard and a trackpad also has a fine pointer, so Enter sends there as on a computer.
|
|
5
|
+
*/
|
|
6
|
+
const TOUCH_ONLY = "(pointer: coarse) and (not (any-pointer: fine))";
|
|
7
|
+
function promptKey(event, { touchOnly, running }) {
|
|
8
|
+
if (event.key !== "Enter") return "type";
|
|
9
|
+
if (event.isComposing || event.keyCode === 229) return "type";
|
|
10
|
+
if (event.shiftKey || event.altKey) return "type";
|
|
11
|
+
const modified = event.metaKey || event.ctrlKey;
|
|
12
|
+
if (touchOnly && !modified) return "type";
|
|
13
|
+
return running ? "hold" : "send";
|
|
14
|
+
}
|
|
15
|
+
export { TOUCH_ONLY, promptKey };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { FileRejection } from "../file-upload/files.js";
|
|
2
|
+
import { ComponentProps, ReactElement } from "react";
|
|
3
|
+
export type PromptInputProps = Omit<ComponentProps<"form">, "onSubmit" | "defaultValue" | "onChange"> & {
|
|
4
|
+
/** The text (controlled). */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** The text at first. */
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
onValueChange?: (value: string) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Sends the prompt: called with the text, trimmed. The field is emptied at once; when the
|
|
11
|
+
* promise rejects, the text comes back if nothing new was typed.
|
|
12
|
+
*/
|
|
13
|
+
onSubmit?: (text: string) => void | Promise<void>;
|
|
14
|
+
/** An answer is being written: the send key is the stop key. The field stays open. */
|
|
15
|
+
running?: boolean;
|
|
16
|
+
/** Halts the answer being written. */
|
|
17
|
+
onStop?: () => void;
|
|
18
|
+
/** Files that were chosen, dropped or pasted and are of a kind and size it takes. */
|
|
19
|
+
onFilesAdded?: (files: File[]) => void;
|
|
20
|
+
/** Files it did not take, each with its reason. */
|
|
21
|
+
onReject?: (rejections: FileRejection[]) => void;
|
|
22
|
+
/** As on a file input: `.pdf,image/*`. */
|
|
23
|
+
accept?: string;
|
|
24
|
+
/** The largest size a file may have, in bytes. */
|
|
25
|
+
maxSize?: number;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The field a prompt to an assistant is written in: one socket that holds the text, the files
|
|
30
|
+
* attached to it, the attach key and the send key, so the halo goes around all of it. Put a
|
|
31
|
+
* `PromptInputAttachments`, a `PromptInputTextarea` and `PromptInputActions` (with a
|
|
32
|
+
* `PromptInputAttach` and a `PromptInputSubmit`) inside.
|
|
33
|
+
*
|
|
34
|
+
* The text stands on top and the keys in a row of their own under it, the paper clip at the
|
|
35
|
+
* left and send at the right, where there is room for more keys (Justin, 2026-11-19).
|
|
36
|
+
*
|
|
37
|
+
* Enter sends and Shift+Enter breaks the line; on a screen that is only touched, Enter breaks
|
|
38
|
+
* the line and the key sends. A word being composed (Japanese, Chinese) is never sent. While
|
|
39
|
+
* an answer is written (`running`) the send key is the stop key, in the same place, and the
|
|
40
|
+
* field stays open, so the next prompt can be written; Enter waits.
|
|
41
|
+
*
|
|
42
|
+
* The field grows with its text up to about ten lines and then scrolls; its height follows on
|
|
43
|
+
* `settle`, and the line being typed is readable from its first frame. Files come by the attach
|
|
44
|
+
* key, by a drop on the field (it wears the halo while one hangs over it) and by paste. It
|
|
45
|
+
* sorts them by kind and size and hands them on; it does not upload.
|
|
46
|
+
*/
|
|
47
|
+
export declare function PromptInput({ value: valueProp, defaultValue, onValueChange, onSubmit, running, onStop, onFilesAdded, onReject, accept, maxSize, disabled, className, children, ...props }: PromptInputProps): import("react").JSX.Element;
|
|
48
|
+
export type PromptInputTextareaProps = Omit<ComponentProps<"textarea">, "value" | "defaultValue" | "id"> & {
|
|
49
|
+
/** The name of the field for assistive tech, where no label stands beside it. */
|
|
50
|
+
label?: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The text of the prompt. It grows with what is written, measured from a copy of the text laid
|
|
54
|
+
* out beside it, so it grows the same in every browser, up to about ten lines; then it scrolls
|
|
55
|
+
* and fades at its top where more stands above.
|
|
56
|
+
*/
|
|
57
|
+
export declare function PromptInputTextarea({ label, className, onKeyDown, onPaste, placeholder, ...props }: PromptInputTextareaProps): import("react").JSX.Element;
|
|
58
|
+
/** The keys of the prompt: attach, send, and whatever else belongs there. */
|
|
59
|
+
export declare function PromptInputActions({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
60
|
+
export type PromptInputAttachProps = Omit<ComponentProps<"button">, "children" | "onClick" | "type"> & {
|
|
61
|
+
label?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The paper clip: opens the file picker. What is chosen is sorted like a drop and handed to
|
|
65
|
+
* `onFilesAdded`; the same file can be chosen again.
|
|
66
|
+
*/
|
|
67
|
+
export declare function PromptInputAttach({ label, className }: PromptInputAttachProps): import("react").JSX.Element;
|
|
68
|
+
export type PromptInputSubmitProps = {
|
|
69
|
+
sendLabel?: string;
|
|
70
|
+
stopLabel?: string;
|
|
71
|
+
className?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The send key, the committed key of the prompt. With nothing to send it lies flat and stands
|
|
75
|
+
* up with the first word. While an answer is written it is the stop key, in the same place and
|
|
76
|
+
* size: the arrow shrinks away and the square seats. Pressing it keeps the keyboard in the text.
|
|
77
|
+
*/
|
|
78
|
+
export declare function PromptInputSubmit({ sendLabel, stopLabel, className }: PromptInputSubmitProps): import("react").JSX.Element;
|
|
79
|
+
export type PromptInputAttachmentsProps = Omit<ComponentProps<"div">, "children"> & {
|
|
80
|
+
/** `Attachment`s, each with a `key`: they are chips here. */
|
|
81
|
+
children?: ReactElement | ReactElement[] | false | null;
|
|
82
|
+
label?: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* The files attached to the prompt, as chips above the text. One that joins opens its place
|
|
86
|
+
* and seats; one taken away fades while its place closes. Backspace in the empty text takes the
|
|
87
|
+
* last one away. Empty, the row takes no room.
|
|
88
|
+
*/
|
|
89
|
+
export declare function PromptInputAttachments({ label, className, children, ...props }: PromptInputAttachmentsProps): import("react").JSX.Element;
|