@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,335 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Chip } from "../chip/chip.js";
|
|
3
|
+
import { useGround } from "../ground/ground.js";
|
|
4
|
+
import { Grow } from "../grow/grow.js";
|
|
5
|
+
import { Icon } from "../icon/icon.js";
|
|
6
|
+
import { ScrollFade } from "../scroll-fade/scroll-fade.js";
|
|
7
|
+
import { Shortcut, useShortcut } from "../shortcut/shortcut.js";
|
|
8
|
+
import { ChevronRightGlyph } from "../../internal/glyphs.js";
|
|
9
|
+
import { overlayBackdrop } from "../../internal/overlay.js";
|
|
10
|
+
import { listGroupLabel, listItem } from "../../internal/popup.js";
|
|
11
|
+
import { cn, mergeClassName } from "../../lib/cn.js";
|
|
12
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
14
|
+
import { Search01Icon } from "@hugeicons/core-free-icons";
|
|
15
|
+
import { Autocomplete } from "@base-ui/react/autocomplete";
|
|
16
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
17
|
+
// src/components/command/command.tsx
|
|
18
|
+
const CommandContext = createContext(null);
|
|
19
|
+
function useCommand(part) {
|
|
20
|
+
const state = useContext(CommandContext);
|
|
21
|
+
if (!state) throw new Error(`<${part}> must be used inside a <Command>.`);
|
|
22
|
+
return state;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The command palette: every page and every action of an app, reached by typing a few letters.
|
|
26
|
+
* It opens on ⌘K over whatever one is doing, and leaves as soon as something is chosen. It is
|
|
27
|
+
* for people who know what they want; everything in it must also be reachable by pointing.
|
|
28
|
+
*
|
|
29
|
+
* Give it the entries as `items` and put a `CommandContent` inside, with a `CommandInput`, a
|
|
30
|
+
* `CommandList` and a `CommandFooter`. An entry does something (`onSelect`) or opens a list of
|
|
31
|
+
* its own (`page`). Typing filters by label and keywords, ignoring case and accents.
|
|
32
|
+
*
|
|
33
|
+
* Word an entry like a button, the thing first and the action last ("Angebot schreiben"), or
|
|
34
|
+
* as the place it leads to ("Einstellungen"). An entry that opens a second list ends in an
|
|
35
|
+
* ellipsis ("Kunde zuweisen …").
|
|
36
|
+
*/
|
|
37
|
+
function Command({ items, open: controlled, defaultOpen = false, onOpenChange, shortcut = "mod+k", defaultQuery = "", onQueryChange, label = "Befehle", locale, modal = true, children }) {
|
|
38
|
+
const [kept, setKept] = useState(defaultOpen);
|
|
39
|
+
const open = controlled ?? kept;
|
|
40
|
+
const [trail, setTrail] = useState([]);
|
|
41
|
+
const [direction, setDirection] = useState("forward");
|
|
42
|
+
const [query, setTyped] = useState(defaultQuery);
|
|
43
|
+
const setOpen = useCallback((next) => {
|
|
44
|
+
setKept(next);
|
|
45
|
+
onOpenChange?.(next);
|
|
46
|
+
}, [onOpenChange]);
|
|
47
|
+
const setQuery = useCallback((next) => {
|
|
48
|
+
setTyped(next);
|
|
49
|
+
onQueryChange?.(next);
|
|
50
|
+
}, [onQueryChange]);
|
|
51
|
+
useShortcut(shortcut || "mod+k", () => setOpen(!open), { enabled: shortcut !== false });
|
|
52
|
+
const state = useMemo(() => ({
|
|
53
|
+
label,
|
|
54
|
+
locale,
|
|
55
|
+
items: trail[trail.length - 1]?.page ?? items,
|
|
56
|
+
trail,
|
|
57
|
+
direction,
|
|
58
|
+
query,
|
|
59
|
+
setQuery,
|
|
60
|
+
choose: (entry) => {
|
|
61
|
+
if (entry.page) {
|
|
62
|
+
setTrail((pages) => [...pages, entry]);
|
|
63
|
+
setDirection("forward");
|
|
64
|
+
setQuery("");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
entry.onSelect?.();
|
|
68
|
+
setOpen(false);
|
|
69
|
+
},
|
|
70
|
+
back: () => {
|
|
71
|
+
setTrail((pages) => pages.slice(0, -1));
|
|
72
|
+
setDirection("back");
|
|
73
|
+
setQuery("");
|
|
74
|
+
},
|
|
75
|
+
close: () => setOpen(false),
|
|
76
|
+
reset: () => {
|
|
77
|
+
setTrail([]);
|
|
78
|
+
setDirection("forward");
|
|
79
|
+
setQuery("");
|
|
80
|
+
}
|
|
81
|
+
}), [
|
|
82
|
+
label,
|
|
83
|
+
locale,
|
|
84
|
+
items,
|
|
85
|
+
trail,
|
|
86
|
+
direction,
|
|
87
|
+
query,
|
|
88
|
+
setQuery,
|
|
89
|
+
setOpen
|
|
90
|
+
]);
|
|
91
|
+
return /* @__PURE__ */ jsx(CommandContext, {
|
|
92
|
+
value: state,
|
|
93
|
+
children: /* @__PURE__ */ jsx(Dialog.Root, {
|
|
94
|
+
open,
|
|
95
|
+
onOpenChange: setOpen,
|
|
96
|
+
modal,
|
|
97
|
+
onOpenChangeComplete: (shown) => {
|
|
98
|
+
if (!shown) state.reset();
|
|
99
|
+
},
|
|
100
|
+
children
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A button that opens the palette, for those who do not know the shortcut yet. Render a
|
|
106
|
+
* `Button` through it and show the shortcut inside:
|
|
107
|
+
* `<CommandTrigger render={<Button />}>Suchen <Shortcut keys="mod+k" /></CommandTrigger>`.
|
|
108
|
+
*/
|
|
109
|
+
function CommandTrigger(props) {
|
|
110
|
+
return /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
111
|
+
"data-slot": "command-trigger",
|
|
112
|
+
...props
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The sheet, with its scrim: the page behind is dimmed as it is behind a dialog. It stands in
|
|
117
|
+
* the upper third of the window, where the eyes are and where a phone's keyboard leaves it
|
|
118
|
+
* alone.
|
|
119
|
+
*
|
|
120
|
+
* It is opened many times a day, mostly from the keyboard, so it does not make an entrance: it
|
|
121
|
+
* is there on `snap`, grown by a fiftieth and without travel, and it leaves by fading.
|
|
122
|
+
*/
|
|
123
|
+
function CommandContent({ className, children, ...props }) {
|
|
124
|
+
const ground = useGround();
|
|
125
|
+
const { label, locale, items, query, setQuery, close } = useCommand("CommandContent");
|
|
126
|
+
const { contains } = Autocomplete.useFilter({
|
|
127
|
+
locale,
|
|
128
|
+
usage: "sort",
|
|
129
|
+
sensitivity: "base"
|
|
130
|
+
});
|
|
131
|
+
const matches = useCallback((entry, typed) => contains(entry.label, typed) || (entry.keywords?.some((keyword) => contains(keyword, typed)) ?? false), [contains]);
|
|
132
|
+
return /* @__PURE__ */ jsxs(Dialog.Portal, { children: [/* @__PURE__ */ jsx(Dialog.Backdrop, {
|
|
133
|
+
"data-slot": "command-backdrop",
|
|
134
|
+
className: overlayBackdrop
|
|
135
|
+
}), /* @__PURE__ */ jsx(Dialog.Viewport, {
|
|
136
|
+
"data-slot": "command-viewport",
|
|
137
|
+
className: "fixed inset-0 z-50 flex max-h-dvh items-start justify-center overflow-hidden px-3 pt-[min(18dvh,9rem)] pb-3",
|
|
138
|
+
children: /* @__PURE__ */ jsx(Dialog.Popup, {
|
|
139
|
+
"data-slot": "command-content",
|
|
140
|
+
"data-theme": ground,
|
|
141
|
+
"aria-label": label,
|
|
142
|
+
className: mergeClassName([
|
|
143
|
+
"relative flex max-h-full w-full max-w-xl flex-col overflow-hidden rounded-2xl bg-sheet text-control text-fg-body depth-overlay outline-hidden",
|
|
144
|
+
"origin-top transition-[opacity,scale] spring-snap",
|
|
145
|
+
"data-starting-style:scale-[calc(1-(1-var(--motion-enter-scale))/2)] data-starting-style:opacity-0",
|
|
146
|
+
"data-ending-style:opacity-0 data-ending-style:spring-leave"
|
|
147
|
+
], className),
|
|
148
|
+
...props,
|
|
149
|
+
children: /* @__PURE__ */ jsx(Autocomplete.Root, {
|
|
150
|
+
open: true,
|
|
151
|
+
inline: true,
|
|
152
|
+
items,
|
|
153
|
+
filter: matches,
|
|
154
|
+
locale,
|
|
155
|
+
autoHighlight: "always",
|
|
156
|
+
keepHighlight: true,
|
|
157
|
+
value: query,
|
|
158
|
+
onValueChange: (value, details) => {
|
|
159
|
+
if (details.reason !== "item-press") setQuery(value);
|
|
160
|
+
},
|
|
161
|
+
onOpenChange: (shown, details) => {
|
|
162
|
+
if (!shown && details.reason === "escape-key") close();
|
|
163
|
+
},
|
|
164
|
+
children
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
})] });
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The field one types into. It has no frame of its own: it is the head of the sheet. A page
|
|
171
|
+
* that was opened stands before the text as a small plug, and Backspace in the empty field
|
|
172
|
+
* goes back out of it.
|
|
173
|
+
*
|
|
174
|
+
* The placeholder is an example of what can be typed ("z. B. Angebot schreiben"), not an
|
|
175
|
+
* instruction.
|
|
176
|
+
*/
|
|
177
|
+
function CommandInput({ className, placeholder, onKeyDown, ...props }) {
|
|
178
|
+
const { label, trail, query, back } = useCommand("CommandInput");
|
|
179
|
+
const page = trail[trail.length - 1];
|
|
180
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
181
|
+
"data-slot": "command-input-row",
|
|
182
|
+
className: "flex h-12 shrink-0 items-center gap-2.5 border-b border-hairline px-4",
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
185
|
+
icon: Search01Icon,
|
|
186
|
+
size: 16,
|
|
187
|
+
className: "text-fg-muted"
|
|
188
|
+
}),
|
|
189
|
+
trail.map((opened) => /* @__PURE__ */ jsx(Chip, {
|
|
190
|
+
"data-slot": "command-page",
|
|
191
|
+
className: "max-w-40 shrink-0 delay-0 starting:scale-90 starting:opacity-0",
|
|
192
|
+
children: opened.label.replace(/\s*…$/, "")
|
|
193
|
+
}, opened.value)),
|
|
194
|
+
/* @__PURE__ */ jsx(Autocomplete.Input, {
|
|
195
|
+
"data-slot": "command-input",
|
|
196
|
+
"aria-label": label,
|
|
197
|
+
placeholder: page ? page.pagePlaceholder : placeholder,
|
|
198
|
+
className: cn("h-full min-w-0 flex-1 bg-transparent text-control text-fg outline-hidden placeholder:text-fg-muted placeholder:italic pointer-coarse:text-base", className),
|
|
199
|
+
onKeyDown: (event) => {
|
|
200
|
+
onKeyDown?.(event);
|
|
201
|
+
if (event.key === "Backspace" && query === "" && trail.length > 0) {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
back();
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
...props
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function CommandRow({ entry }) {
|
|
212
|
+
const { choose } = useCommand("CommandList");
|
|
213
|
+
return /* @__PURE__ */ jsxs(Autocomplete.Item, {
|
|
214
|
+
value: entry,
|
|
215
|
+
disabled: entry.disabled,
|
|
216
|
+
onClick: () => choose(entry),
|
|
217
|
+
"data-slot": "command-item",
|
|
218
|
+
"data-page": entry.page ? "" : void 0,
|
|
219
|
+
className: cn(listItem, "group min-h-(--control-md) scroll-my-1"),
|
|
220
|
+
children: [
|
|
221
|
+
entry.icon && /* @__PURE__ */ jsx(Icon, {
|
|
222
|
+
icon: entry.icon,
|
|
223
|
+
size: 16,
|
|
224
|
+
className: "text-fg-muted group-data-disabled:text-on-disabled group-data-highlighted:text-fg"
|
|
225
|
+
}),
|
|
226
|
+
/* @__PURE__ */ jsx("span", {
|
|
227
|
+
className: "min-w-0 flex-1 truncate",
|
|
228
|
+
children: entry.label
|
|
229
|
+
}),
|
|
230
|
+
entry.detail !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
231
|
+
className: "ml-auto shrink-0 pl-3 whitespace-nowrap text-fg-muted tabular-nums",
|
|
232
|
+
children: entry.detail
|
|
233
|
+
}),
|
|
234
|
+
entry.shortcut && /* @__PURE__ */ jsx(Shortcut, {
|
|
235
|
+
keys: entry.shortcut,
|
|
236
|
+
className: "ml-auto pl-3"
|
|
237
|
+
}),
|
|
238
|
+
entry.page && /* @__PURE__ */ jsx(ChevronRightGlyph, {
|
|
239
|
+
width: 10,
|
|
240
|
+
height: 10,
|
|
241
|
+
className: "ml-auto text-fg-muted group-data-highlighted:text-fg"
|
|
242
|
+
})
|
|
243
|
+
]
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function isSection(item) {
|
|
247
|
+
return "items" in item;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The entries that match what was typed, in their sections. The first one is highlighted, so
|
|
251
|
+
* Enter takes it; the arrows move the highlight, which is instant like a menu's. The list is
|
|
252
|
+
* as tall as what it holds, up to a limit, and the sheet follows it instead of jumping.
|
|
253
|
+
*/
|
|
254
|
+
function CommandList({ empty, className, ...props }) {
|
|
255
|
+
const { trail, direction } = useCommand("CommandList");
|
|
256
|
+
const list = /* @__PURE__ */ jsx(ScrollFade, {
|
|
257
|
+
axis: "y",
|
|
258
|
+
"data-slot": "command-scroll",
|
|
259
|
+
className: cn("max-h-[min(22.5rem,calc(100dvh-16rem))] scroll-py-1 overscroll-contain p-1", className),
|
|
260
|
+
...props,
|
|
261
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
262
|
+
"data-slot": "command-page-list",
|
|
263
|
+
"data-direction": trail.length > 0 || direction === "back" ? direction : void 0,
|
|
264
|
+
className: "transition-[opacity,translate] spring-settle data-direction:starting:opacity-0 data-[direction=back]:starting:-translate-x-(--motion-enter-offset) data-[direction=forward]:starting:translate-x-(--motion-enter-offset)",
|
|
265
|
+
children: [/* @__PURE__ */ jsx(Autocomplete.Empty, {
|
|
266
|
+
"data-slot": "command-empty",
|
|
267
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
268
|
+
className: "px-2.5 py-6 text-center text-fg-muted",
|
|
269
|
+
children: empty
|
|
270
|
+
})
|
|
271
|
+
}), /* @__PURE__ */ jsx(Autocomplete.List, {
|
|
272
|
+
"data-slot": "command-list",
|
|
273
|
+
className: "outline-hidden",
|
|
274
|
+
children: (item) => isSection(item) ? /* @__PURE__ */ jsxs(Autocomplete.Group, {
|
|
275
|
+
items: item.items,
|
|
276
|
+
"data-slot": "command-group",
|
|
277
|
+
className: "not-first:mt-1",
|
|
278
|
+
children: [/* @__PURE__ */ jsx(Autocomplete.GroupLabel, {
|
|
279
|
+
"data-slot": "command-group-label",
|
|
280
|
+
className: listGroupLabel,
|
|
281
|
+
children: item.value
|
|
282
|
+
}), /* @__PURE__ */ jsx(Autocomplete.Collection, { children: (entry) => /* @__PURE__ */ jsx(CommandRow, { entry }, entry.value) })]
|
|
283
|
+
}, item.value) : /* @__PURE__ */ jsx(CommandRow, { entry: item }, item.value)
|
|
284
|
+
})]
|
|
285
|
+
}, trail.length)
|
|
286
|
+
});
|
|
287
|
+
return /* @__PURE__ */ jsx(Grow, {
|
|
288
|
+
"data-slot": "command-grow",
|
|
289
|
+
children: list
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function Hint({ keys, children }) {
|
|
293
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
294
|
+
className: "flex items-center gap-1.5",
|
|
295
|
+
children: [/* @__PURE__ */ jsx(Shortcut, { keys }), children]
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* The foot of the sheet: the keys that work here, said once. It is for the eye only, and it is
|
|
300
|
+
* not there on a touch screen, which has no keys. Pass children to put something else there.
|
|
301
|
+
*/
|
|
302
|
+
function CommandFooter({ chooseLabel = "Auswählen", moveLabel = "Bewegen", backLabel = "Zurück", closeLabel = "Schließen", className, children, ...props }) {
|
|
303
|
+
const { trail } = useCommand("CommandFooter");
|
|
304
|
+
return /* @__PURE__ */ jsx("div", {
|
|
305
|
+
"data-slot": "command-footer",
|
|
306
|
+
"aria-hidden": children === void 0 ? true : void 0,
|
|
307
|
+
className: cn("flex h-10 shrink-0 items-center gap-4 border-t border-hairline bg-well px-4 text-sm text-fg-muted pointer-coarse:hidden", className),
|
|
308
|
+
...props,
|
|
309
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
310
|
+
/* @__PURE__ */ jsx(Hint, {
|
|
311
|
+
keys: "enter",
|
|
312
|
+
children: chooseLabel
|
|
313
|
+
}),
|
|
314
|
+
/* @__PURE__ */ jsxs("span", {
|
|
315
|
+
className: "flex items-center gap-1.5",
|
|
316
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
317
|
+
className: "flex gap-1",
|
|
318
|
+
children: [/* @__PURE__ */ jsx(Shortcut, { keys: "up" }), /* @__PURE__ */ jsx(Shortcut, { keys: "down" })]
|
|
319
|
+
}), moveLabel]
|
|
320
|
+
}),
|
|
321
|
+
trail.length > 0 && /* @__PURE__ */ jsx(Hint, {
|
|
322
|
+
keys: "backspace",
|
|
323
|
+
children: backLabel
|
|
324
|
+
}),
|
|
325
|
+
/* @__PURE__ */ jsx("span", {
|
|
326
|
+
className: "ml-auto",
|
|
327
|
+
children: /* @__PURE__ */ jsx(Hint, {
|
|
328
|
+
keys: "esc",
|
|
329
|
+
children: closeLabel
|
|
330
|
+
})
|
|
331
|
+
})
|
|
332
|
+
] })
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
export { Command, CommandContent, CommandFooter, CommandInput, CommandList, CommandTrigger };
|