macbetter 0.0.0-stage → 0.1.0-beta.2
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/LICENSE +201 -0
- package/README.md +92 -2
- package/dist/components/accessory-tile.d.ts +50 -0
- package/dist/components/accessory-tile.js +46 -0
- package/dist/components/activity-indicator.d.ts +15 -0
- package/dist/components/activity-indicator.js +15 -0
- package/dist/components/alert.d.ts +29 -0
- package/dist/components/alert.js +30 -0
- package/dist/components/artifact-card.d.ts +41 -0
- package/dist/components/artifact-card.js +57 -0
- package/dist/components/artwork.d.ts +44 -0
- package/dist/components/artwork.js +935 -0
- package/dist/components/attachment.d.ts +48 -0
- package/dist/components/attachment.js +65 -0
- package/dist/components/automation-row.d.ts +24 -0
- package/dist/components/automation-row.js +12 -0
- package/dist/components/avatar.d.ts +33 -0
- package/dist/components/avatar.js +45 -0
- package/dist/components/badge.d.ts +24 -0
- package/dist/components/badge.js +19 -0
- package/dist/components/button.d.ts +20 -0
- package/dist/components/button.js +10 -0
- package/dist/components/calendar.d.ts +30 -0
- package/dist/components/calendar.js +47 -0
- package/dist/components/camera-view.d.ts +40 -0
- package/dist/components/camera-view.js +44 -0
- package/dist/components/card.d.ts +14 -0
- package/dist/components/card.js +21 -0
- package/dist/components/carousel.d.ts +18 -0
- package/dist/components/carousel.js +33 -0
- package/dist/components/chat.d.ts +29 -0
- package/dist/components/chat.js +29 -0
- package/dist/components/checkbox.d.ts +13 -0
- package/dist/components/checkbox.js +16 -0
- package/dist/components/code-block.d.ts +39 -0
- package/dist/components/code-block.js +65 -0
- package/dist/components/code-field.d.ts +16 -0
- package/dist/components/code-field.js +29 -0
- package/dist/components/color-well.d.ts +23 -0
- package/dist/components/color-well.js +27 -0
- package/dist/components/combo-box.d.ts +42 -0
- package/dist/components/combo-box.js +102 -0
- package/dist/components/command-palette.d.ts +33 -0
- package/dist/components/command-palette.js +55 -0
- package/dist/components/confirmation.d.ts +24 -0
- package/dist/components/confirmation.js +50 -0
- package/dist/components/content-unavailable.d.ts +19 -0
- package/dist/components/content-unavailable.js +21 -0
- package/dist/components/context-menu.d.ts +9 -0
- package/dist/components/context-menu.js +15 -0
- package/dist/components/date-picker.d.ts +53 -0
- package/dist/components/date-picker.js +86 -0
- package/dist/components/description-list.d.ts +18 -0
- package/dist/components/description-list.js +17 -0
- package/dist/components/device-frame.d.ts +18 -0
- package/dist/components/device-frame.js +16 -0
- package/dist/components/dialog.d.ts +27 -0
- package/dist/components/dialog.js +35 -0
- package/dist/components/disclosure.d.ts +32 -0
- package/dist/components/disclosure.js +35 -0
- package/dist/components/dock.d.ts +28 -0
- package/dist/components/dock.js +80 -0
- package/dist/components/door-control.d.ts +20 -0
- package/dist/components/door-control.js +43 -0
- package/dist/components/energy-readout.d.ts +32 -0
- package/dist/components/energy-readout.js +27 -0
- package/dist/components/field.d.ts +28 -0
- package/dist/components/field.js +32 -0
- package/dist/components/gauge.d.ts +25 -0
- package/dist/components/gauge.js +42 -0
- package/dist/components/generated-image.d.ts +39 -0
- package/dist/components/generated-image.js +47 -0
- package/dist/components/glass.d.ts +34 -0
- package/dist/components/glass.js +31 -0
- package/dist/components/home-backdrop.d.ts +23 -0
- package/dist/components/home-backdrop.js +12 -0
- package/dist/components/home-section.d.ts +19 -0
- package/dist/components/home-section.js +21 -0
- package/dist/components/home-status.d.ts +24 -0
- package/dist/components/home-status.js +14 -0
- package/dist/components/hover-card.d.ts +14 -0
- package/dist/components/hover-card.js +16 -0
- package/dist/components/inspector.d.ts +29 -0
- package/dist/components/inspector.js +40 -0
- package/dist/components/level-control.d.ts +19 -0
- package/dist/components/level-control.js +13 -0
- package/dist/components/light-color-picker.d.ts +33 -0
- package/dist/components/light-color-picker.js +56 -0
- package/dist/components/list.d.ts +42 -0
- package/dist/components/list.js +42 -0
- package/dist/components/listbox.d.ts +16 -0
- package/dist/components/listbox.js +28 -0
- package/dist/components/lock-control.d.ts +20 -0
- package/dist/components/lock-control.js +35 -0
- package/dist/components/menu-bar.d.ts +14 -0
- package/dist/components/menu-bar.js +16 -0
- package/dist/components/menu.d.ts +40 -0
- package/dist/components/menu.js +54 -0
- package/dist/components/message.d.ts +65 -0
- package/dist/components/message.js +69 -0
- package/dist/components/model-picker.d.ts +61 -0
- package/dist/components/model-picker.js +59 -0
- package/dist/components/navigation-bar.d.ts +24 -0
- package/dist/components/navigation-bar.js +54 -0
- package/dist/components/outline.d.ts +21 -0
- package/dist/components/outline.js +40 -0
- package/dist/components/page-control.d.ts +10 -0
- package/dist/components/page-control.js +8 -0
- package/dist/components/plan.d.ts +25 -0
- package/dist/components/plan.js +43 -0
- package/dist/components/popover.d.ts +16 -0
- package/dist/components/popover.js +24 -0
- package/dist/components/progress.d.ts +27 -0
- package/dist/components/progress.js +27 -0
- package/dist/components/prompt-input.d.ts +93 -0
- package/dist/components/prompt-input.js +172 -0
- package/dist/components/radio.d.ts +16 -0
- package/dist/components/radio.js +13 -0
- package/dist/components/rating.d.ts +10 -0
- package/dist/components/rating.js +12 -0
- package/dist/components/reasoning.d.ts +28 -0
- package/dist/components/reasoning.js +52 -0
- package/dist/components/response.d.ts +14 -0
- package/dist/components/response.js +14 -0
- package/dist/components/scene-tile.d.ts +22 -0
- package/dist/components/scene-tile.js +13 -0
- package/dist/components/scroll-view.d.ts +21 -0
- package/dist/components/scroll-view.js +13 -0
- package/dist/components/search-field.d.ts +16 -0
- package/dist/components/search-field.js +12 -0
- package/dist/components/secure-field.d.ts +23 -0
- package/dist/components/secure-field.js +21 -0
- package/dist/components/segmented-control.d.ts +12 -0
- package/dist/components/segmented-control.js +10 -0
- package/dist/components/select.d.ts +45 -0
- package/dist/components/select.js +79 -0
- package/dist/components/sensor-readout.d.ts +29 -0
- package/dist/components/sensor-readout.js +12 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +11 -0
- package/dist/components/setup-code.d.ts +29 -0
- package/dist/components/setup-code.js +47 -0
- package/dist/components/sheet.d.ts +31 -0
- package/dist/components/sheet.js +51 -0
- package/dist/components/shimmer.d.ts +18 -0
- package/dist/components/shimmer.js +17 -0
- package/dist/components/sidebar.d.ts +30 -0
- package/dist/components/sidebar.js +26 -0
- package/dist/components/slider.d.ts +27 -0
- package/dist/components/slider.js +43 -0
- package/dist/components/sources.d.ts +51 -0
- package/dist/components/sources.js +46 -0
- package/dist/components/split-view.d.ts +11 -0
- package/dist/components/split-view.js +13 -0
- package/dist/components/squircle.d.ts +41 -0
- package/dist/components/squircle.js +63 -0
- package/dist/components/stepper.d.ts +30 -0
- package/dist/components/stepper.js +28 -0
- package/dist/components/suggestion.d.ts +23 -0
- package/dist/components/suggestion.js +29 -0
- package/dist/components/switch.d.ts +10 -0
- package/dist/components/switch.js +10 -0
- package/dist/components/tab-bar.d.ts +20 -0
- package/dist/components/tab-bar.js +17 -0
- package/dist/components/table.d.ts +49 -0
- package/dist/components/table.js +179 -0
- package/dist/components/tabs.d.ts +16 -0
- package/dist/components/tabs.js +19 -0
- package/dist/components/text-area.d.ts +14 -0
- package/dist/components/text-area.js +9 -0
- package/dist/components/text-field.d.ts +26 -0
- package/dist/components/text-field.js +23 -0
- package/dist/components/thermostat-control.d.ts +30 -0
- package/dist/components/thermostat-control.js +139 -0
- package/dist/components/toast.d.ts +30 -0
- package/dist/components/toast.js +114 -0
- package/dist/components/toggle.d.ts +21 -0
- package/dist/components/toggle.js +19 -0
- package/dist/components/token-field.d.ts +31 -0
- package/dist/components/token-field.js +78 -0
- package/dist/components/tool-call.d.ts +48 -0
- package/dist/components/tool-call.js +77 -0
- package/dist/components/toolbar.d.ts +27 -0
- package/dist/components/toolbar.js +39 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +18 -0
- package/dist/components/window.d.ts +56 -0
- package/dist/components/window.js +61 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +98 -0
- package/dist/lib/agent-glyphs.d.ts +10 -0
- package/dist/lib/agent-glyphs.js +19 -0
- package/dist/lib/cx.d.ts +9 -0
- package/dist/lib/cx.js +14 -0
- package/dist/lib/derive.d.ts +53 -0
- package/dist/lib/derive.js +255 -0
- package/dist/lib/field-glyphs.d.ts +13 -0
- package/dist/lib/field-glyphs.js +28 -0
- package/dist/lib/menu-glyphs.d.ts +6 -0
- package/dist/lib/menu-glyphs.js +15 -0
- package/dist/lib/platform.d.ts +18 -0
- package/dist/lib/platform.js +17 -0
- package/dist/lib/squircle.d.ts +23 -0
- package/dist/lib/squircle.js +69 -0
- package/dist/lib/theme.d.ts +42 -0
- package/dist/lib/theme.js +62 -0
- package/dist/styles/base.css +115 -0
- package/dist/styles/components/accessory-tile.css +461 -0
- package/dist/styles/components/activity-indicator.css +63 -0
- package/dist/styles/components/alert.css +433 -0
- package/dist/styles/components/artifact-card.css +238 -0
- package/dist/styles/components/artwork.css +380 -0
- package/dist/styles/components/attachment.css +540 -0
- package/dist/styles/components/automation-row.css +52 -0
- package/dist/styles/components/avatar.css +230 -0
- package/dist/styles/components/badge.css +204 -0
- package/dist/styles/components/button.css +298 -0
- package/dist/styles/components/calendar.css +287 -0
- package/dist/styles/components/camera-view.css +239 -0
- package/dist/styles/components/card.css +100 -0
- package/dist/styles/components/carousel.css +210 -0
- package/dist/styles/components/chat.css +209 -0
- package/dist/styles/components/checkbox.css +212 -0
- package/dist/styles/components/code-block.css +162 -0
- package/dist/styles/components/code-field.css +163 -0
- package/dist/styles/components/color-well.css +452 -0
- package/dist/styles/components/combo-box.css +222 -0
- package/dist/styles/components/command-palette.css +379 -0
- package/dist/styles/components/confirmation.css +189 -0
- package/dist/styles/components/content-unavailable.css +105 -0
- package/dist/styles/components/context-menu.css +43 -0
- package/dist/styles/components/date-picker.css +356 -0
- package/dist/styles/components/description-list.css +92 -0
- package/dist/styles/components/device-frame.css +202 -0
- package/dist/styles/components/dialog.css +366 -0
- package/dist/styles/components/disclosure.css +197 -0
- package/dist/styles/components/dock.css +404 -0
- package/dist/styles/components/door-control.css +187 -0
- package/dist/styles/components/energy-readout.css +161 -0
- package/dist/styles/components/field.css +175 -0
- package/dist/styles/components/gauge.css +239 -0
- package/dist/styles/components/generated-image.css +248 -0
- package/dist/styles/components/glass.css +113 -0
- package/dist/styles/components/home-backdrop.css +81 -0
- package/dist/styles/components/home-section.css +100 -0
- package/dist/styles/components/home-status.css +215 -0
- package/dist/styles/components/hover-card.css +145 -0
- package/dist/styles/components/index.css +94 -0
- package/dist/styles/components/inspector.css +236 -0
- package/dist/styles/components/level-control.css +247 -0
- package/dist/styles/components/light-color-picker.css +94 -0
- package/dist/styles/components/list.css +411 -0
- package/dist/styles/components/listbox.css +168 -0
- package/dist/styles/components/lock-control.css +164 -0
- package/dist/styles/components/menu-bar.css +94 -0
- package/dist/styles/components/menu.css +454 -0
- package/dist/styles/components/message.css +236 -0
- package/dist/styles/components/model-picker.css +64 -0
- package/dist/styles/components/navigation-bar.css +249 -0
- package/dist/styles/components/outline.css +248 -0
- package/dist/styles/components/page-control.css +127 -0
- package/dist/styles/components/plan.css +212 -0
- package/dist/styles/components/popover.css +186 -0
- package/dist/styles/components/progress.css +228 -0
- package/dist/styles/components/prompt-input.css +503 -0
- package/dist/styles/components/radio.css +281 -0
- package/dist/styles/components/rating.css +122 -0
- package/dist/styles/components/reasoning.css +214 -0
- package/dist/styles/components/response.css +303 -0
- package/dist/styles/components/scene-tile.css +295 -0
- package/dist/styles/components/scroll-view.css +195 -0
- package/dist/styles/components/search-field.css +128 -0
- package/dist/styles/components/secure-field.css +189 -0
- package/dist/styles/components/segmented-control.css +183 -0
- package/dist/styles/components/select.css +290 -0
- package/dist/styles/components/sensor-readout.css +231 -0
- package/dist/styles/components/separator.css +62 -0
- package/dist/styles/components/setup-code.css +138 -0
- package/dist/styles/components/sheet.css +345 -0
- package/dist/styles/components/shimmer.css +60 -0
- package/dist/styles/components/sidebar.css +261 -0
- package/dist/styles/components/slider.css +208 -0
- package/dist/styles/components/sources.css +349 -0
- package/dist/styles/components/split-view.css +75 -0
- package/dist/styles/components/squircle.css +44 -0
- package/dist/styles/components/stepper.css +278 -0
- package/dist/styles/components/suggestion.css +203 -0
- package/dist/styles/components/switch.css +115 -0
- package/dist/styles/components/tab-bar.css +223 -0
- package/dist/styles/components/table.css +313 -0
- package/dist/styles/components/tabs.css +262 -0
- package/dist/styles/components/text-area.css +94 -0
- package/dist/styles/components/text-field.css +294 -0
- package/dist/styles/components/thermostat-control.css +214 -0
- package/dist/styles/components/toast.css +418 -0
- package/dist/styles/components/toggle.css +312 -0
- package/dist/styles/components/token-field.css +193 -0
- package/dist/styles/components/tool-call.css +391 -0
- package/dist/styles/components/toolbar.css +370 -0
- package/dist/styles/components/tooltip.css +69 -0
- package/dist/styles/components/window.css +428 -0
- package/dist/styles/index.css +17 -0
- package/dist/styles/materials.css +263 -0
- package/dist/styles/platforms.css +214 -0
- package/dist/styles/themes/ember.css +24 -0
- package/dist/styles/themes/graphite.css +16 -0
- package/dist/styles/themes/nebula.css +16 -0
- package/dist/styles/themes/system.css +28 -0
- package/dist/styles/tokens.css +299 -0
- package/package.json +82 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ScrollArea, ScrollAreaContent, ScrollAreaScrollbar, ScrollAreaScrollToEnd, ScrollAreaThumb, ScrollAreaViewport, } from "@ui-sdk/react/scroll-area";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cx, join } from "../lib/cx.js";
|
|
6
|
+
const ChatBusyContext = React.createContext(false);
|
|
7
|
+
/** The thread. It follows the reply while you're at the end and lets go when you scroll up. */
|
|
8
|
+
function Chat({ stickToEnd = true, type = "hover", busy, className, children, ...props }) {
|
|
9
|
+
return (_jsx(ScrollArea, { stickToEnd: stickToEnd, type: type, "data-busy": busy ? "" : undefined, className: cx("mb-chat", className), ...props, children: (state) => (_jsxs(ChatBusyContext.Provider, { value: Boolean(busy), children: [typeof children === "function" ? children(state) : children, _jsx(ScrollAreaScrollbar, { orientation: "vertical", className: "mb-scroll-view-scrollbar mb-chat-scrollbar", children: _jsx(ScrollAreaThumb, { className: "mb-scroll-view-thumb" }) })] })) }));
|
|
10
|
+
}
|
|
11
|
+
/** The scrolling log of turns. Name it with `aria-label`. */
|
|
12
|
+
function ChatViewport({ "aria-label": ariaLabel = "Conversation", className, ...props }) {
|
|
13
|
+
const busy = React.useContext(ChatBusyContext);
|
|
14
|
+
return (_jsx(ScrollAreaViewport, { role: "log", "aria-live": "polite", "aria-label": ariaLabel, "aria-busy": busy || undefined, className: cx("mb-chat-viewport", className), ...props }));
|
|
15
|
+
}
|
|
16
|
+
/** The centered column the turns sit in, with even gaps between them. */
|
|
17
|
+
function ChatContent({ className, ...props }) {
|
|
18
|
+
return _jsx(ScrollAreaContent, { className: cx("mb-chat-content", className), ...props });
|
|
19
|
+
}
|
|
20
|
+
/** A floating glass button that jumps back to the latest turn. It shows only once you've scrolled away. */
|
|
21
|
+
function ChatScrollButton({ "aria-label": ariaLabel = "Scroll to latest", className, children, ...props }) {
|
|
22
|
+
return (_jsx(ScrollAreaScrollToEnd, { type: "button", "aria-label": ariaLabel, className: cx("mb-glass mb-chat-scroll-button", className), "data-shape": "circle", ...props, children: children ?? (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M8 2.75v10.5M3.5 8.75 8 13.25l4.5-4.5", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round" }) })) }));
|
|
23
|
+
}
|
|
24
|
+
/** The empty state of a new chat: a large greeting, with the composer and suggestions as children. */
|
|
25
|
+
function ChatGreeting({ icon, title, description, level = 1, className, children, ...props }) {
|
|
26
|
+
const Heading = `h${level}`;
|
|
27
|
+
return (_jsxs("div", { className: join("mb-chat-greeting", className), ...props, children: [icon ? (_jsx("div", { "aria-hidden": "true", className: "mb-chat-greeting-icon", children: icon })) : null, _jsx(Heading, { className: "mb-chat-greeting-title", children: title }), description ? _jsx("p", { className: "mb-chat-greeting-description", children: description }) : null, children ? _jsx("div", { className: "mb-chat-greeting-body", children: children }) : null] }));
|
|
28
|
+
}
|
|
29
|
+
export { Chat, ChatContent, ChatGreeting, ChatScrollButton, ChatViewport };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Checkbox as CheckboxPrimitive, CheckboxGroup as CheckboxGroupPrimitive, CheckboxIndicator as CheckboxIndicatorPrimitive } from "@ui-sdk/react/checkbox";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type CheckboxProps = Omit<React.ComponentProps<typeof CheckboxPrimitive>, "children"> & {
|
|
4
|
+
/** The checkbox's title. With it, the box and its text are one label, as `NSButton(checkboxWithTitle:)` is. */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** A line of secondary text under the title. */
|
|
7
|
+
description?: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
declare function CheckboxIndicator({ className, ...props }: React.ComponentProps<typeof CheckboxIndicatorPrimitive>): React.JSX.Element;
|
|
10
|
+
declare function Checkbox({ className, children, description, ...props }: CheckboxProps): React.JSX.Element;
|
|
11
|
+
declare function CheckboxGroup({ className, ...props }: React.ComponentProps<typeof CheckboxGroupPrimitive>): React.JSX.Element;
|
|
12
|
+
export { Checkbox, CheckboxGroup, CheckboxIndicator };
|
|
13
|
+
export type { CheckboxProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox as CheckboxPrimitive, CheckboxGroup as CheckboxGroupPrimitive, CheckboxIndicator as CheckboxIndicatorPrimitive, } from "@ui-sdk/react/checkbox";
|
|
3
|
+
import { cx } from "../lib/cx.js";
|
|
4
|
+
function CheckboxIndicator({ className, ...props }) {
|
|
5
|
+
return (_jsx(CheckboxIndicatorPrimitive, { className: cx("mb-checkbox-indicator", className), ...props, children: _jsxs("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className: "mb-checkbox-glyph", children: [_jsx("path", { className: "mb-checkbox-check", pathLength: 1, d: "M4.25 8.4 6.9 11 11.75 5" }), _jsx("path", { className: "mb-checkbox-dash", pathLength: 1, d: "M4.5 8h7" })] }) }));
|
|
6
|
+
}
|
|
7
|
+
function Checkbox({ className, children, description, ...props }) {
|
|
8
|
+
const box = (_jsx(CheckboxPrimitive, { className: cx("mb-checkbox", className), ...props, children: _jsx(CheckboxIndicator, {}) }));
|
|
9
|
+
if (children == null && description == null)
|
|
10
|
+
return box;
|
|
11
|
+
return (_jsxs("label", { className: "mb-checkbox-label", children: [box, _jsxs("span", { className: "mb-checkbox-text", children: [_jsx("span", { className: "mb-checkbox-title", children: children }), description == null ? null : _jsx("span", { className: "mb-checkbox-description", children: description })] })] }));
|
|
12
|
+
}
|
|
13
|
+
function CheckboxGroup({ className, ...props }) {
|
|
14
|
+
return _jsx(CheckboxGroupPrimitive, { className: cx("mb-checkbox-group", className), ...props });
|
|
15
|
+
}
|
|
16
|
+
export { Checkbox, CheckboxGroup, CheckboxIndicator };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type ButtonProps } from "./button.js";
|
|
3
|
+
type CodeBlockProps = React.ComponentProps<"div"> & {
|
|
4
|
+
/** Wraps long lines instead of scrolling sideways. */
|
|
5
|
+
wrap?: boolean;
|
|
6
|
+
/** Numbers each line in the gutter. Highlighted markup needs one element per line with the class `line`. */
|
|
7
|
+
lineNumbers?: boolean;
|
|
8
|
+
/** Scrolls the code past this height, in pixels or any CSS length. */
|
|
9
|
+
maxHeight?: number | string;
|
|
10
|
+
};
|
|
11
|
+
declare function CodeBlock({ wrap, lineNumbers, maxHeight, className, style, ...props }: CodeBlockProps): React.JSX.Element;
|
|
12
|
+
/** The title bar: a CodeBlockTitle, then a CodeBlockCopy at the trailing edge. */
|
|
13
|
+
declare function CodeBlockHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
14
|
+
type CodeBlockTitleProps = React.ComponentProps<"div"> & {
|
|
15
|
+
/** A language label after the file name, like `TypeScript`. */
|
|
16
|
+
language?: React.ReactNode;
|
|
17
|
+
};
|
|
18
|
+
declare function CodeBlockTitle({ language, className, children, ...props }: CodeBlockTitleProps): React.JSX.Element;
|
|
19
|
+
type CodeBlockContentProps = Omit<React.ComponentProps<"pre">, "children" | "dangerouslySetInnerHTML"> & {
|
|
20
|
+
/** Plain text. Each line is wrapped in its own element, so line numbers work. */
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Markup from your highlighter, used in place of children. A whole `<pre><code>` block, as most
|
|
24
|
+
* highlighters return, has its wrapper dropped and its lines kept. Only pass markup you trust.
|
|
25
|
+
*/
|
|
26
|
+
html?: string;
|
|
27
|
+
};
|
|
28
|
+
/** The code: a `<pre><code>` that scrolls sideways (or wraps) and takes focus so the keyboard can scroll it. */
|
|
29
|
+
declare function CodeBlockContent({ html, className, children, tabIndex, ...props }: CodeBlockContentProps): React.JSX.Element;
|
|
30
|
+
type CodeBlockCopyProps = Omit<ButtonProps, "value"> & {
|
|
31
|
+
/** The text to copy. Leave it out to copy what CodeBlockContent shows. */
|
|
32
|
+
value?: string;
|
|
33
|
+
/** How long the check mark stays, in milliseconds. */
|
|
34
|
+
resetAfter?: number;
|
|
35
|
+
};
|
|
36
|
+
/** Copies the code and shows a check mark for two seconds. If the clipboard is unavailable it does nothing. */
|
|
37
|
+
declare function CodeBlockCopy({ value, resetAfter, onClick, className, children, "aria-label": label, ...props }: CodeBlockCopyProps): React.JSX.Element;
|
|
38
|
+
export { CodeBlock, CodeBlockContent, CodeBlockCopy, CodeBlockHeader, CodeBlockTitle };
|
|
39
|
+
export type { CodeBlockContentProps, CodeBlockCopyProps, CodeBlockProps, CodeBlockTitleProps };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cx, join } from "../lib/cx.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
const CodeBlockContext = React.createContext(null);
|
|
7
|
+
function CodeBlock({ wrap, lineNumbers, maxHeight, className, style, ...props }) {
|
|
8
|
+
const code = React.useRef(null);
|
|
9
|
+
const height = typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight;
|
|
10
|
+
return (_jsx(CodeBlockContext.Provider, { value: code, children: _jsx("div", { "data-wrap": wrap ? "" : undefined, "data-line-numbers": lineNumbers ? "" : undefined, className: join("mb-code-block", className), style: height ? { "--mb-code-block-max-height": height, ...style } : style, ...props }) }));
|
|
11
|
+
}
|
|
12
|
+
/** The title bar: a CodeBlockTitle, then a CodeBlockCopy at the trailing edge. */
|
|
13
|
+
function CodeBlockHeader({ className, ...props }) {
|
|
14
|
+
return _jsx("div", { className: join("mb-code-block-header", className), ...props });
|
|
15
|
+
}
|
|
16
|
+
function CodeBlockTitle({ language, className, children, ...props }) {
|
|
17
|
+
return (_jsxs("div", { className: join("mb-code-block-title", className), ...props, children: [children != null ? _jsx("span", { className: "mb-code-block-title-text", children: children }) : null, language != null ? _jsx("span", { className: "mb-code-block-language", children: language }) : null] }));
|
|
18
|
+
}
|
|
19
|
+
function unwrap(html) {
|
|
20
|
+
return html
|
|
21
|
+
.trim()
|
|
22
|
+
.replace(/^<pre\b[^>]*>\s*(?:<code\b[^>]*>)?/i, "")
|
|
23
|
+
.replace(/(?:<\/code>)?\s*<\/pre>$/i, "");
|
|
24
|
+
}
|
|
25
|
+
function lines(text) {
|
|
26
|
+
const all = text.replace(/\n$/, "").split("\n");
|
|
27
|
+
return all.map((line, index) => (
|
|
28
|
+
// A line has no identity beyond its position.
|
|
29
|
+
_jsxs(React.Fragment, { children: [_jsx("span", { className: "mb-code-block-line", children: line }), index < all.length - 1 ? "\n" : null] }, index)));
|
|
30
|
+
}
|
|
31
|
+
/** The code: a `<pre><code>` that scrolls sideways (or wraps) and takes focus so the keyboard can scroll it. */
|
|
32
|
+
function CodeBlockContent({ html, className, children, tabIndex = 0, ...props }) {
|
|
33
|
+
const code = React.useContext(CodeBlockContext);
|
|
34
|
+
return (_jsx("pre", { tabIndex: tabIndex, className: join("mb-code-block-content", className), ...props, children: html !== undefined ? (_jsx("code", { ref: code, className: "mb-code-block-code", dangerouslySetInnerHTML: { __html: unwrap(html) } })) : (_jsx("code", { ref: code, className: "mb-code-block-code", children: typeof children === "string" ? lines(children) : children })) }));
|
|
35
|
+
}
|
|
36
|
+
function CopyGlyph() {
|
|
37
|
+
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", focusable: "false", children: [_jsx("rect", { x: "5.25", y: "5.25", width: "8.5", height: "8.5", rx: "2", stroke: "currentColor", strokeWidth: "1.3" }), _jsx("path", { d: "M10.75 3.25A1.75 1.75 0 0 0 9 2.25H4.25a2 2 0 0 0-2 2V9a1.75 1.75 0 0 0 1 1.58", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })] }));
|
|
38
|
+
}
|
|
39
|
+
function CheckGlyph() {
|
|
40
|
+
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "m3.25 8.5 3 3 6.5-7", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
41
|
+
}
|
|
42
|
+
/** Copies the code and shows a check mark for two seconds. If the clipboard is unavailable it does nothing. */
|
|
43
|
+
function CodeBlockCopy({ value, resetAfter = 2000, onClick, className, children, "aria-label": label = "Copy code", ...props }) {
|
|
44
|
+
const code = React.useContext(CodeBlockContext);
|
|
45
|
+
const [copied, setCopied] = React.useState(false);
|
|
46
|
+
const timer = React.useRef(undefined);
|
|
47
|
+
React.useEffect(() => () => clearTimeout(timer.current), []);
|
|
48
|
+
const copy = async () => {
|
|
49
|
+
const text = value ?? code?.current?.textContent ?? "";
|
|
50
|
+
try {
|
|
51
|
+
await navigator.clipboard.writeText(text);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
setCopied(true);
|
|
57
|
+
clearTimeout(timer.current);
|
|
58
|
+
timer.current = setTimeout(() => setCopied(false), resetAfter);
|
|
59
|
+
};
|
|
60
|
+
return (_jsx(Button, { variant: "plain", tone: "neutral", size: "sm", shape: "circle", "aria-label": copied ? "Copied" : label, "data-copied": copied ? "" : undefined, className: cx("mb-code-block-copy", className), onClick: (event, details) => {
|
|
61
|
+
onClick?.(event, details);
|
|
62
|
+
void copy();
|
|
63
|
+
}, ...props, children: children ?? (copied ? _jsx(CheckGlyph, {}) : _jsx(CopyGlyph, {})) }));
|
|
64
|
+
}
|
|
65
|
+
export { CodeBlock, CodeBlockContent, CodeBlockCopy, CodeBlockHeader, CodeBlockTitle };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OTPInput, OTPInputGroup, OTPInputSeparator, OTPInputSlot } from "@ui-sdk/react/otp-input";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type CodeFieldProps = Omit<React.ComponentProps<typeof OTPInput>, "maxLength" | "size"> & {
|
|
4
|
+
/** How many characters the code has, one cell each. */
|
|
5
|
+
length?: number;
|
|
6
|
+
/** Splits the cells into runs of this many with a dash between, like 3 for "123–456". */
|
|
7
|
+
groupSize?: number;
|
|
8
|
+
size?: "md" | "lg";
|
|
9
|
+
};
|
|
10
|
+
/** A one-time code: a row of rounded cells, filled by typing, pasting or autofill. */
|
|
11
|
+
declare function CodeField({ length, groupSize, size, className, children, ...props }: CodeFieldProps): React.JSX.Element;
|
|
12
|
+
declare function CodeFieldGroup({ className, ...props }: React.ComponentProps<typeof OTPInputGroup>): React.JSX.Element;
|
|
13
|
+
declare function CodeFieldSlot({ className, ...props }: React.ComponentProps<typeof OTPInputSlot>): React.JSX.Element;
|
|
14
|
+
declare function CodeFieldSeparator({ className, children, ...props }: React.ComponentProps<typeof OTPInputSeparator>): React.JSX.Element;
|
|
15
|
+
export { CodeField, CodeFieldGroup, CodeFieldSeparator, CodeFieldSlot };
|
|
16
|
+
export type { CodeFieldProps };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { OTPInput, OTPInputGroup, OTPInputSeparator, OTPInputSlot, } from "@ui-sdk/react/otp-input";
|
|
3
|
+
import { cx } from "../lib/cx.js";
|
|
4
|
+
/** A one-time code: a row of rounded cells, filled by typing, pasting or autofill. */
|
|
5
|
+
function CodeField({ length = 6, groupSize, size = "md", className, children, ...props }) {
|
|
6
|
+
const runs = chunk(length, groupSize && groupSize > 0 ? groupSize : length);
|
|
7
|
+
return (_jsx(OTPInput, { maxLength: length, "data-size": size, className: cx("mb-code-field", className), ...props, children: children ??
|
|
8
|
+
runs.map((run, i) => (_jsx(CodeFieldRun, { run: run, separated: i > 0 }, run[0]))) }));
|
|
9
|
+
}
|
|
10
|
+
function CodeFieldRun({ run, separated }) {
|
|
11
|
+
return (_jsxs(_Fragment, { children: [separated ? _jsx(CodeFieldSeparator, {}) : null, _jsx(CodeFieldGroup, { children: run.map((index) => (_jsx(CodeFieldSlot, { index: index }, index))) })] }));
|
|
12
|
+
}
|
|
13
|
+
function chunk(length, size) {
|
|
14
|
+
const runs = [];
|
|
15
|
+
for (let start = 0; start < length; start += size) {
|
|
16
|
+
runs.push(Array.from({ length: Math.min(size, length - start) }, (_, i) => start + i));
|
|
17
|
+
}
|
|
18
|
+
return runs;
|
|
19
|
+
}
|
|
20
|
+
function CodeFieldGroup({ className, ...props }) {
|
|
21
|
+
return _jsx(OTPInputGroup, { className: cx("mb-code-field-group", className), ...props });
|
|
22
|
+
}
|
|
23
|
+
function CodeFieldSlot({ className, ...props }) {
|
|
24
|
+
return _jsx(OTPInputSlot, { className: cx("mb-code-field-slot", className), ...props });
|
|
25
|
+
}
|
|
26
|
+
function CodeFieldSeparator({ className, children, ...props }) {
|
|
27
|
+
return (_jsx(OTPInputSeparator, { className: cx("mb-code-field-separator", className), ...props, children: children ?? _jsx("span", { className: "mb-code-field-dash" }) }));
|
|
28
|
+
}
|
|
29
|
+
export { CodeField, CodeFieldGroup, CodeFieldSeparator, CodeFieldSlot };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ColorPicker } from "@ui-sdk/react/color-picker";
|
|
2
|
+
import { Popover, PopoverContent } from "@ui-sdk/react/popover";
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
type ColorWellProps = Omit<React.ComponentProps<typeof ColorPicker>, "children"> & {
|
|
5
|
+
/** Extra content at the end of the editor. */
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** Preset colors under the editor. Pass `[]` for none. */
|
|
8
|
+
presets?: readonly string[];
|
|
9
|
+
/** Shows the opacity slider. */
|
|
10
|
+
alpha?: boolean;
|
|
11
|
+
size?: "sm" | "md" | "lg";
|
|
12
|
+
/** `auto` opens a bottom sheet on small touch screens, as UIColorWell does. */
|
|
13
|
+
presentation?: React.ComponentProps<typeof Popover>["presentation"];
|
|
14
|
+
side?: React.ComponentProps<typeof PopoverContent>["side"];
|
|
15
|
+
align?: React.ComponentProps<typeof PopoverContent>["align"];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A swatch button that opens a color editor in a popover: an area for saturation and brightness,
|
|
19
|
+
* hue and opacity sliders, a hex field and presets. `aria-label` names both the picker and the button.
|
|
20
|
+
*/
|
|
21
|
+
declare function ColorWell({ presets, alpha, size, presentation, side, align, space, format, className, children, "aria-label": label, ...props }: ColorWellProps): React.JSX.Element;
|
|
22
|
+
export { ColorWell };
|
|
23
|
+
export type { ColorWellProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ColorPicker, ColorPickerArea, ColorPickerAreaThumb, ColorPickerEyeDropper, ColorPickerInput, ColorPickerSlider, ColorPickerSliderThumb, ColorPickerSwatch, ColorPickerSwatches, ColorPickerSwatchItem, } from "@ui-sdk/react/color-picker";
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from "@ui-sdk/react/popover";
|
|
4
|
+
import { cx } from "../lib/cx.js";
|
|
5
|
+
/** Apple's system colors, light appearance. */
|
|
6
|
+
const systemColors = [
|
|
7
|
+
"#ff3b30",
|
|
8
|
+
"#ff9500",
|
|
9
|
+
"#ffcc00",
|
|
10
|
+
"#34c759",
|
|
11
|
+
"#00c7be",
|
|
12
|
+
"#30b0c7",
|
|
13
|
+
"#007aff",
|
|
14
|
+
"#5856d6",
|
|
15
|
+
"#af52de",
|
|
16
|
+
"#ff2d55",
|
|
17
|
+
"#a2845e",
|
|
18
|
+
"#8e8e93",
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* A swatch button that opens a color editor in a popover: an area for saturation and brightness,
|
|
22
|
+
* hue and opacity sliders, a hex field and presets. `aria-label` names both the picker and the button.
|
|
23
|
+
*/
|
|
24
|
+
function ColorWell({ presets = systemColors, alpha = true, size = "md", presentation = "auto", side = "bottom", align = "start", space = "hsv", format = "hex", className, children, "aria-label": label, ...props }) {
|
|
25
|
+
return (_jsx(ColorPicker, { "aria-label": label, space: space, format: format, "data-size": size, className: cx("mb-color-well", className), ...props, children: _jsxs(Popover, { presentation: presentation, children: [_jsx(PopoverTrigger, { "aria-label": label, className: "mb-color-well-trigger", children: _jsx(ColorPickerSwatch, { "aria-hidden": "true", className: "mb-color-well-swatch" }) }), _jsxs(PopoverContent, { side: side, align: align, sideOffset: 6, className: "mb-color-well-panel", children: [_jsx(ColorPickerArea, { className: "mb-color-well-area", children: _jsx(ColorPickerAreaThumb, { className: "mb-color-well-thumb" }) }), _jsxs("div", { className: "mb-color-well-sliders", children: [_jsx(ColorPickerSlider, { channel: "hue", className: "mb-color-well-slider", children: _jsx(ColorPickerSliderThumb, { className: "mb-color-well-thumb" }) }), alpha ? (_jsx(ColorPickerSlider, { channel: "alpha", className: "mb-color-well-slider", children: _jsx(ColorPickerSliderThumb, { className: "mb-color-well-thumb" }) })) : null] }), _jsxs("div", { className: "mb-color-well-fields", children: [_jsx(ColorPickerSwatch, { className: "mb-color-well-preview" }), _jsx(ColorPickerInput, { "aria-label": "Hex", className: "mb-color-well-input" }), _jsx(ColorPickerEyeDropper, { "aria-label": "Pick a color from the screen", className: "mb-color-well-eyedropper", children: _jsxs("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: [_jsx("path", { d: "m2 22 1-1h3l9-9" }), _jsx("path", { d: "M3 21v-3l9-9" }), _jsx("path", { d: "m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z" })] }) })] }), presets.length > 0 ? (_jsx(ColorPickerSwatches, { "aria-label": "Presets", className: "mb-color-well-presets", children: presets.map((preset) => (_jsx(ColorPickerSwatchItem, { value: preset, className: "mb-color-well-preset" }, preset))) })) : null, children] })] }) }));
|
|
26
|
+
}
|
|
27
|
+
export { ColorWell };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Autocomplete, AutocompleteClear as AutocompleteClearPrimitive, AutocompleteContent as AutocompleteContentPrimitive, AutocompleteEmpty as AutocompleteEmptyPrimitive, AutocompleteGroup as AutocompleteGroupPrimitive, AutocompleteGroupLabel as AutocompleteGroupLabelPrimitive, AutocompleteInput as AutocompleteInputPrimitive, AutocompleteItem as AutocompleteItemPrimitive, AutocompleteItemIcon as AutocompleteItemIconPrimitive, AutocompleteItems, AutocompleteItemText as AutocompleteItemTextPrimitive, AutocompleteLabel as AutocompleteLabelPrimitive, AutocompleteList as AutocompleteListPrimitive, AutocompleteSeparator as AutocompleteSeparatorPrimitive, AutocompleteStatus as AutocompleteStatusPrimitive, AutocompleteTrigger as AutocompleteTriggerPrimitive, createAutocompleteController } from "@ui-sdk/react/autocomplete";
|
|
2
|
+
import type { AutocompleteProps } from "@ui-sdk/react/autocomplete";
|
|
3
|
+
import { Combobox, ComboboxClear as ComboboxClearPrimitive, ComboboxContent as ComboboxContentPrimitive, ComboboxEmpty as ComboboxEmptyPrimitive, ComboboxGroup as ComboboxGroupPrimitive, ComboboxGroupLabel as ComboboxGroupLabelPrimitive, ComboboxInput as ComboboxInputPrimitive, ComboboxItem as ComboboxItemPrimitive, ComboboxItemIcon as ComboboxItemIconPrimitive, ComboboxItemIndicator as ComboboxItemIndicatorPrimitive, ComboboxItems, ComboboxItemText as ComboboxItemTextPrimitive, ComboboxLabel as ComboboxLabelPrimitive, ComboboxList as ComboboxListPrimitive, ComboboxSeparator as ComboboxSeparatorPrimitive, ComboboxStatus as ComboboxStatusPrimitive, ComboboxTrigger as ComboboxTriggerPrimitive, createComboboxController } from "@ui-sdk/react/combobox";
|
|
4
|
+
import type { ComboboxProps } from "@ui-sdk/react/combobox";
|
|
5
|
+
import type * as React from "react";
|
|
6
|
+
/** The field: holds the input, and the clear button and trigger at its trailing edge. */
|
|
7
|
+
declare function ComboboxControl({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
8
|
+
declare function ComboboxLabel({ className, ...props }: React.ComponentProps<typeof ComboboxLabelPrimitive>): React.JSX.Element;
|
|
9
|
+
declare function ComboboxInput({ className, ...props }: React.ComponentProps<typeof ComboboxInputPrimitive>): React.JSX.Element;
|
|
10
|
+
/** The button that shows every choice. Renders its own chevron; name it with `aria-label`. */
|
|
11
|
+
declare function ComboboxTrigger({ className, children, ...props }: React.ComponentProps<typeof ComboboxTriggerPrimitive>): React.JSX.Element;
|
|
12
|
+
declare function ComboboxClear({ className, children, ...props }: React.ComponentProps<typeof ComboboxClearPrimitive>): React.JSX.Element;
|
|
13
|
+
declare function ComboboxContent({ sideOffset, className, ...props }: React.ComponentProps<typeof ComboboxContentPrimitive>): React.JSX.Element;
|
|
14
|
+
declare function ComboboxList({ className, ...props }: React.ComponentProps<typeof ComboboxListPrimitive>): React.JSX.Element;
|
|
15
|
+
/** A choice. Renders its own checkmark beside the selected one. */
|
|
16
|
+
declare function ComboboxItem<T = string>({ className, children, ...props }: Omit<React.ComponentProps<typeof ComboboxItemPrimitive<T>>, "children"> & {
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
}): React.JSX.Element;
|
|
19
|
+
declare function ComboboxItemIndicator({ keepMounted, className, children, ...props }: React.ComponentProps<typeof ComboboxItemIndicatorPrimitive>): React.JSX.Element;
|
|
20
|
+
declare function ComboboxItemIcon({ className, ...props }: React.ComponentProps<typeof ComboboxItemIconPrimitive>): React.JSX.Element;
|
|
21
|
+
declare function ComboboxItemText({ className, ...props }: React.ComponentProps<typeof ComboboxItemTextPrimitive>): React.JSX.Element;
|
|
22
|
+
declare function ComboboxGroup({ className, ...props }: React.ComponentProps<typeof ComboboxGroupPrimitive>): React.JSX.Element;
|
|
23
|
+
declare function ComboboxGroupLabel({ className, ...props }: React.ComponentProps<typeof ComboboxGroupLabelPrimitive>): React.JSX.Element;
|
|
24
|
+
declare function ComboboxSeparator({ className, ...props }: React.ComponentProps<typeof ComboboxSeparatorPrimitive>): React.JSX.Element;
|
|
25
|
+
declare function ComboboxEmpty({ className, ...props }: React.ComponentProps<typeof ComboboxEmptyPrimitive>): React.JSX.Element;
|
|
26
|
+
declare function ComboboxStatus({ className, ...props }: React.ComponentProps<typeof ComboboxStatusPrimitive>): React.JSX.Element;
|
|
27
|
+
declare function AutocompleteLabel({ className, ...props }: React.ComponentProps<typeof AutocompleteLabelPrimitive>): React.JSX.Element;
|
|
28
|
+
declare function AutocompleteInput({ className, ...props }: React.ComponentProps<typeof AutocompleteInputPrimitive>): React.JSX.Element;
|
|
29
|
+
declare function AutocompleteTrigger({ className, children, ...props }: React.ComponentProps<typeof AutocompleteTriggerPrimitive>): React.JSX.Element;
|
|
30
|
+
declare function AutocompleteClear({ className, children, ...props }: React.ComponentProps<typeof AutocompleteClearPrimitive>): React.JSX.Element;
|
|
31
|
+
declare function AutocompleteContent({ sideOffset, className, ...props }: React.ComponentProps<typeof AutocompleteContentPrimitive>): React.JSX.Element;
|
|
32
|
+
declare function AutocompleteList({ className, ...props }: React.ComponentProps<typeof AutocompleteListPrimitive>): React.JSX.Element;
|
|
33
|
+
declare function AutocompleteItem({ className, ...props }: React.ComponentProps<typeof AutocompleteItemPrimitive>): React.JSX.Element;
|
|
34
|
+
declare function AutocompleteItemIcon({ className, ...props }: React.ComponentProps<typeof AutocompleteItemIconPrimitive>): React.JSX.Element;
|
|
35
|
+
declare function AutocompleteItemText({ className, ...props }: React.ComponentProps<typeof AutocompleteItemTextPrimitive>): React.JSX.Element;
|
|
36
|
+
declare function AutocompleteGroup({ className, ...props }: React.ComponentProps<typeof AutocompleteGroupPrimitive>): React.JSX.Element;
|
|
37
|
+
declare function AutocompleteGroupLabel({ className, ...props }: React.ComponentProps<typeof AutocompleteGroupLabelPrimitive>): React.JSX.Element;
|
|
38
|
+
declare function AutocompleteSeparator({ className, ...props }: React.ComponentProps<typeof AutocompleteSeparatorPrimitive>): React.JSX.Element;
|
|
39
|
+
declare function AutocompleteEmpty({ className, ...props }: React.ComponentProps<typeof AutocompleteEmptyPrimitive>): React.JSX.Element;
|
|
40
|
+
declare function AutocompleteStatus({ className, ...props }: React.ComponentProps<typeof AutocompleteStatusPrimitive>): React.JSX.Element;
|
|
41
|
+
export { Autocomplete, AutocompleteClear, AutocompleteContent, AutocompleteEmpty, AutocompleteGroup, AutocompleteGroupLabel, AutocompleteInput, AutocompleteItem, AutocompleteItemIcon, AutocompleteItems, AutocompleteItemText, AutocompleteLabel, AutocompleteList, AutocompleteSeparator, AutocompleteStatus, AutocompleteTrigger, Combobox, ComboboxClear, ComboboxContent, ComboboxControl, ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxItemIcon, ComboboxItemIndicator, ComboboxItems, ComboboxItemText, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxStatus, ComboboxTrigger, createAutocompleteController, createComboboxController, };
|
|
42
|
+
export type { AutocompleteProps, ComboboxProps };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Autocomplete, AutocompleteClear as AutocompleteClearPrimitive, AutocompleteContent as AutocompleteContentPrimitive, AutocompleteEmpty as AutocompleteEmptyPrimitive, AutocompleteGroup as AutocompleteGroupPrimitive, AutocompleteGroupLabel as AutocompleteGroupLabelPrimitive, AutocompleteInput as AutocompleteInputPrimitive, AutocompleteItem as AutocompleteItemPrimitive, AutocompleteItemIcon as AutocompleteItemIconPrimitive, AutocompleteItems, AutocompleteItemText as AutocompleteItemTextPrimitive, AutocompleteLabel as AutocompleteLabelPrimitive, AutocompleteList as AutocompleteListPrimitive, AutocompleteSeparator as AutocompleteSeparatorPrimitive, AutocompleteStatus as AutocompleteStatusPrimitive, AutocompleteTrigger as AutocompleteTriggerPrimitive, createAutocompleteController, } from "@ui-sdk/react/autocomplete";
|
|
3
|
+
import { Combobox, ComboboxClear as ComboboxClearPrimitive, ComboboxContent as ComboboxContentPrimitive, ComboboxEmpty as ComboboxEmptyPrimitive, ComboboxGroup as ComboboxGroupPrimitive, ComboboxGroupLabel as ComboboxGroupLabelPrimitive, ComboboxInput as ComboboxInputPrimitive, ComboboxItem as ComboboxItemPrimitive, ComboboxItemIcon as ComboboxItemIconPrimitive, ComboboxItemIndicator as ComboboxItemIndicatorPrimitive, ComboboxItems, ComboboxItemText as ComboboxItemTextPrimitive, ComboboxLabel as ComboboxLabelPrimitive, ComboboxList as ComboboxListPrimitive, ComboboxSeparator as ComboboxSeparatorPrimitive, ComboboxStatus as ComboboxStatusPrimitive, ComboboxTrigger as ComboboxTriggerPrimitive, createComboboxController, } from "@ui-sdk/react/combobox";
|
|
4
|
+
import { cx, join } from "../lib/cx.js";
|
|
5
|
+
import { CheckGlyph, ChevronGlyph } from "../lib/menu-glyphs.js";
|
|
6
|
+
function ClearGlyph() {
|
|
7
|
+
return (_jsxs("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: [_jsx("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor" }), _jsx("path", { d: "m5.6 5.6 4.8 4.8m0-4.8-4.8 4.8", stroke: "var(--mb-bg-field)", strokeWidth: "1.5", strokeLinecap: "round" })] }));
|
|
8
|
+
}
|
|
9
|
+
/** The field: holds the input, and the clear button and trigger at its trailing edge. */
|
|
10
|
+
function ComboboxControl({ className, ...props }) {
|
|
11
|
+
return _jsx("div", { className: join("mb-combo-box-control", className), ...props });
|
|
12
|
+
}
|
|
13
|
+
function ComboboxLabel({ className, ...props }) {
|
|
14
|
+
return _jsx(ComboboxLabelPrimitive, { className: cx("mb-combo-box-label", className), ...props });
|
|
15
|
+
}
|
|
16
|
+
function ComboboxInput({ className, ...props }) {
|
|
17
|
+
return _jsx(ComboboxInputPrimitive, { className: cx("mb-combo-box-input", className), ...props });
|
|
18
|
+
}
|
|
19
|
+
/** The button that shows every choice. Renders its own chevron; name it with `aria-label`. */
|
|
20
|
+
function ComboboxTrigger({ className, children, ...props }) {
|
|
21
|
+
return (_jsx(ComboboxTriggerPrimitive, { className: cx("mb-combo-box-trigger", className), ...props, children: children ?? _jsx(ChevronGlyph, { direction: "down" }) }));
|
|
22
|
+
}
|
|
23
|
+
function ComboboxClear({ className, children, ...props }) {
|
|
24
|
+
return (_jsx(ComboboxClearPrimitive, { className: cx("mb-combo-box-clear", className), ...props, children: children ?? _jsx(ClearGlyph, {}) }));
|
|
25
|
+
}
|
|
26
|
+
function ComboboxContent({ sideOffset = 4, className, ...props }) {
|
|
27
|
+
return (_jsx(ComboboxContentPrimitive, { sideOffset: sideOffset, className: cx("mb-menu-content mb-combo-box-content", className), ...props }));
|
|
28
|
+
}
|
|
29
|
+
function ComboboxList({ className, ...props }) {
|
|
30
|
+
return _jsx(ComboboxListPrimitive, { className: cx("mb-combo-box-list", className), ...props });
|
|
31
|
+
}
|
|
32
|
+
/** A choice. Renders its own checkmark beside the selected one. */
|
|
33
|
+
function ComboboxItem({ className, children, ...props }) {
|
|
34
|
+
return (_jsxs(ComboboxItemPrimitive, { className: cx("mb-menu-item mb-menu-checkable mb-combo-box-item", className), ...props, children: [_jsx(ComboboxItemIndicator, {}), children] }));
|
|
35
|
+
}
|
|
36
|
+
function ComboboxItemIndicator({ keepMounted = true, className, children, ...props }) {
|
|
37
|
+
return (_jsx(ComboboxItemIndicatorPrimitive, { keepMounted: keepMounted, className: cx("mb-menu-item-indicator mb-combo-box-item-indicator", className), ...props, children: children ?? _jsx(CheckGlyph, {}) }));
|
|
38
|
+
}
|
|
39
|
+
function ComboboxItemIcon({ className, ...props }) {
|
|
40
|
+
return _jsx(ComboboxItemIconPrimitive, { className: cx("mb-menu-item-icon", className), ...props });
|
|
41
|
+
}
|
|
42
|
+
function ComboboxItemText({ className, ...props }) {
|
|
43
|
+
return _jsx(ComboboxItemTextPrimitive, { className: cx("mb-combo-box-item-text", className), ...props });
|
|
44
|
+
}
|
|
45
|
+
function ComboboxGroup({ className, ...props }) {
|
|
46
|
+
return _jsx(ComboboxGroupPrimitive, { className: cx("mb-menu-group", className), ...props });
|
|
47
|
+
}
|
|
48
|
+
function ComboboxGroupLabel({ className, ...props }) {
|
|
49
|
+
return _jsx(ComboboxGroupLabelPrimitive, { className: cx("mb-menu-group-label", className), ...props });
|
|
50
|
+
}
|
|
51
|
+
function ComboboxSeparator({ className, ...props }) {
|
|
52
|
+
return _jsx(ComboboxSeparatorPrimitive, { className: cx("mb-menu-separator", className), ...props });
|
|
53
|
+
}
|
|
54
|
+
function ComboboxEmpty({ className, ...props }) {
|
|
55
|
+
return _jsx(ComboboxEmptyPrimitive, { className: cx("mb-combo-box-empty", className), ...props });
|
|
56
|
+
}
|
|
57
|
+
function ComboboxStatus({ className, ...props }) {
|
|
58
|
+
return _jsx(ComboboxStatusPrimitive, { className: cx("mb-combo-box-status", className), ...props });
|
|
59
|
+
}
|
|
60
|
+
function AutocompleteLabel({ className, ...props }) {
|
|
61
|
+
return _jsx(AutocompleteLabelPrimitive, { className: cx("mb-combo-box-label", className), ...props });
|
|
62
|
+
}
|
|
63
|
+
function AutocompleteInput({ className, ...props }) {
|
|
64
|
+
return _jsx(AutocompleteInputPrimitive, { className: cx("mb-combo-box-input", className), ...props });
|
|
65
|
+
}
|
|
66
|
+
function AutocompleteTrigger({ className, children, ...props }) {
|
|
67
|
+
return (_jsx(AutocompleteTriggerPrimitive, { className: cx("mb-combo-box-trigger", className), ...props, children: children ?? _jsx(ChevronGlyph, { direction: "down" }) }));
|
|
68
|
+
}
|
|
69
|
+
function AutocompleteClear({ className, children, ...props }) {
|
|
70
|
+
return (_jsx(AutocompleteClearPrimitive, { className: cx("mb-combo-box-clear", className), ...props, children: children ?? _jsx(ClearGlyph, {}) }));
|
|
71
|
+
}
|
|
72
|
+
function AutocompleteContent({ sideOffset = 4, className, ...props }) {
|
|
73
|
+
return (_jsx(AutocompleteContentPrimitive, { sideOffset: sideOffset, className: cx("mb-menu-content mb-combo-box-content", className), ...props }));
|
|
74
|
+
}
|
|
75
|
+
function AutocompleteList({ className, ...props }) {
|
|
76
|
+
return _jsx(AutocompleteListPrimitive, { className: cx("mb-combo-box-list", className), ...props });
|
|
77
|
+
}
|
|
78
|
+
function AutocompleteItem({ className, ...props }) {
|
|
79
|
+
return _jsx(AutocompleteItemPrimitive, { className: cx("mb-menu-item mb-combo-box-item", className), ...props });
|
|
80
|
+
}
|
|
81
|
+
function AutocompleteItemIcon({ className, ...props }) {
|
|
82
|
+
return _jsx(AutocompleteItemIconPrimitive, { className: cx("mb-menu-item-icon", className), ...props });
|
|
83
|
+
}
|
|
84
|
+
function AutocompleteItemText({ className, ...props }) {
|
|
85
|
+
return _jsx(AutocompleteItemTextPrimitive, { className: cx("mb-combo-box-item-text", className), ...props });
|
|
86
|
+
}
|
|
87
|
+
function AutocompleteGroup({ className, ...props }) {
|
|
88
|
+
return _jsx(AutocompleteGroupPrimitive, { className: cx("mb-menu-group", className), ...props });
|
|
89
|
+
}
|
|
90
|
+
function AutocompleteGroupLabel({ className, ...props }) {
|
|
91
|
+
return _jsx(AutocompleteGroupLabelPrimitive, { className: cx("mb-menu-group-label", className), ...props });
|
|
92
|
+
}
|
|
93
|
+
function AutocompleteSeparator({ className, ...props }) {
|
|
94
|
+
return _jsx(AutocompleteSeparatorPrimitive, { className: cx("mb-menu-separator", className), ...props });
|
|
95
|
+
}
|
|
96
|
+
function AutocompleteEmpty({ className, ...props }) {
|
|
97
|
+
return _jsx(AutocompleteEmptyPrimitive, { className: cx("mb-combo-box-empty", className), ...props });
|
|
98
|
+
}
|
|
99
|
+
function AutocompleteStatus({ className, ...props }) {
|
|
100
|
+
return _jsx(AutocompleteStatusPrimitive, { className: cx("mb-combo-box-status", className), ...props });
|
|
101
|
+
}
|
|
102
|
+
export { Autocomplete, AutocompleteClear, AutocompleteContent, AutocompleteEmpty, AutocompleteGroup, AutocompleteGroupLabel, AutocompleteInput, AutocompleteItem, AutocompleteItemIcon, AutocompleteItems, AutocompleteItemText, AutocompleteLabel, AutocompleteList, AutocompleteSeparator, AutocompleteStatus, AutocompleteTrigger, Combobox, ComboboxClear, ComboboxContent, ComboboxControl, ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxItemIcon, ComboboxItemIndicator, ComboboxItems, ComboboxItemText, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxStatus, ComboboxTrigger, createAutocompleteController, createComboboxController, };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CommandEmpty as CommandEmptyPrimitive, CommandGroup as CommandGroupPrimitive, CommandGroupLabel as CommandGroupLabelPrimitive, CommandInput as CommandInputPrimitive, CommandItem as CommandItemPrimitive, CommandItemIcon as CommandItemIconPrimitive, CommandItems, CommandItemText as CommandItemTextPrimitive, CommandList as CommandListPrimitive, CommandPage, CommandSeparator as CommandSeparatorPrimitive, CommandShortcut as CommandShortcutPrimitive, CommandStatus as CommandStatusPrimitive, createCommandController } from "@ui-sdk/react/command";
|
|
2
|
+
import type { CommandProps } from "@ui-sdk/react/command";
|
|
3
|
+
import { Dialog, DialogContent, DialogTrigger } from "@ui-sdk/react/dialog";
|
|
4
|
+
import type * as React from "react";
|
|
5
|
+
/** The palette's root: a dialog that holds a `Command`. Control it with `open` and `onOpenChange`. */
|
|
6
|
+
declare function CommandPalette(props: React.ComponentProps<typeof Dialog>): React.JSX.Element;
|
|
7
|
+
type CommandPaletteTriggerProps = Omit<React.ComponentProps<typeof DialogTrigger>, "children"> & {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
/** A search-field-shaped button that opens the palette, with ⌘K by default. */
|
|
11
|
+
declare function CommandPaletteTrigger({ shortcut, className, children, ...props }: CommandPaletteTriggerProps): React.JSX.Element;
|
|
12
|
+
type CommandPaletteContentProps = Omit<React.ComponentProps<typeof DialogContent>, "children"> & {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
/** Names the palette for screen readers. It isn't shown. */
|
|
15
|
+
title?: string;
|
|
16
|
+
};
|
|
17
|
+
/** The floating panel, Spotlight-style: a large translucent sheet of glass near the top of the screen. */
|
|
18
|
+
declare function CommandPaletteContent({ title, className, children, ...props }: CommandPaletteContentProps): React.JSX.Element;
|
|
19
|
+
declare function Command({ className, ...props }: CommandProps): React.JSX.Element;
|
|
20
|
+
/** The search field. Renders its own magnifier. */
|
|
21
|
+
declare function CommandInput({ className, ...props }: React.ComponentProps<typeof CommandInputPrimitive>): React.JSX.Element;
|
|
22
|
+
declare function CommandList({ className, ...props }: React.ComponentProps<typeof CommandListPrimitive>): React.JSX.Element;
|
|
23
|
+
declare function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandItemPrimitive>): React.JSX.Element;
|
|
24
|
+
declare function CommandItemIcon({ className, ...props }: React.ComponentProps<typeof CommandItemIconPrimitive>): React.JSX.Element;
|
|
25
|
+
declare function CommandItemText({ className, ...props }: React.ComponentProps<typeof CommandItemTextPrimitive>): React.JSX.Element;
|
|
26
|
+
declare function CommandShortcut({ className, ...props }: React.ComponentProps<typeof CommandShortcutPrimitive>): React.JSX.Element;
|
|
27
|
+
declare function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandGroupPrimitive>): React.JSX.Element;
|
|
28
|
+
declare function CommandGroupLabel({ className, ...props }: React.ComponentProps<typeof CommandGroupLabelPrimitive>): React.JSX.Element;
|
|
29
|
+
declare function CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandSeparatorPrimitive>): React.JSX.Element;
|
|
30
|
+
declare function CommandEmpty({ className, ...props }: React.ComponentProps<typeof CommandEmptyPrimitive>): React.JSX.Element;
|
|
31
|
+
declare function CommandStatus({ className, ...props }: React.ComponentProps<typeof CommandStatusPrimitive>): React.JSX.Element;
|
|
32
|
+
export { Command, CommandEmpty, CommandGroup, CommandGroupLabel, CommandInput, CommandItem, CommandItemIcon, CommandItems, CommandItemText, CommandList, CommandPage, CommandPalette, CommandPaletteContent, CommandPaletteTrigger, CommandSeparator, CommandShortcut, CommandStatus, createCommandController, };
|
|
33
|
+
export type { CommandPaletteContentProps, CommandPaletteTriggerProps, CommandProps };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Command as CommandPrimitive, CommandEmpty as CommandEmptyPrimitive, CommandGroup as CommandGroupPrimitive, CommandGroupLabel as CommandGroupLabelPrimitive, CommandInput as CommandInputPrimitive, CommandItem as CommandItemPrimitive, CommandItemIcon as CommandItemIconPrimitive, CommandItems, CommandItemText as CommandItemTextPrimitive, CommandList as CommandListPrimitive, CommandPage, CommandSeparator as CommandSeparatorPrimitive, CommandShortcut as CommandShortcutPrimitive, CommandStatus as CommandStatusPrimitive, createCommandController, } from "@ui-sdk/react/command";
|
|
3
|
+
import { Dialog, DialogBackdrop, DialogContent, DialogShortcut, DialogTitle, DialogTrigger, } from "@ui-sdk/react/dialog";
|
|
4
|
+
import { cx } from "../lib/cx.js";
|
|
5
|
+
import { SearchGlyph } from "../lib/menu-glyphs.js";
|
|
6
|
+
/** The palette's root: a dialog that holds a `Command`. Control it with `open` and `onOpenChange`. */
|
|
7
|
+
function CommandPalette(props) {
|
|
8
|
+
return _jsx(Dialog, { ...props });
|
|
9
|
+
}
|
|
10
|
+
/** A search-field-shaped button that opens the palette, with ⌘K by default. */
|
|
11
|
+
function CommandPaletteTrigger({ shortcut = "mod+k", className, children, ...props }) {
|
|
12
|
+
return (_jsxs(DialogTrigger, { shortcut: shortcut, className: cx("mb-command-palette-trigger", className), ...props, children: [_jsx(SearchGlyph, {}), _jsx("span", { className: "mb-command-palette-trigger-label", children: children ?? "Search" }), _jsx(DialogShortcut, { className: "mb-command-palette-trigger-shortcut" })] }));
|
|
13
|
+
}
|
|
14
|
+
/** The floating panel, Spotlight-style: a large translucent sheet of glass near the top of the screen. */
|
|
15
|
+
function CommandPaletteContent({ title = "Search", className, children, ...props }) {
|
|
16
|
+
return (_jsxs(_Fragment, { children: [_jsx(DialogBackdrop, { className: "mb-command-palette-backdrop" }), _jsxs(DialogContent, { className: cx("mb-command-palette", className), ...props, children: [_jsx(DialogTitle, { className: "mb-visually-hidden", children: title }), children] })] }));
|
|
17
|
+
}
|
|
18
|
+
function Command({ className, ...props }) {
|
|
19
|
+
return _jsx(CommandPrimitive, { className: cx("mb-command", className), ...props });
|
|
20
|
+
}
|
|
21
|
+
/** The search field. Renders its own magnifier. */
|
|
22
|
+
function CommandInput({ className, ...props }) {
|
|
23
|
+
return (_jsxs("div", { className: "mb-command-search", children: [_jsx(SearchGlyph, {}), _jsx(CommandInputPrimitive, { className: cx("mb-command-input", className), ...props })] }));
|
|
24
|
+
}
|
|
25
|
+
function CommandList({ className, ...props }) {
|
|
26
|
+
return _jsx(CommandListPrimitive, { className: cx("mb-command-list", className), ...props });
|
|
27
|
+
}
|
|
28
|
+
function CommandItem({ className, ...props }) {
|
|
29
|
+
return _jsx(CommandItemPrimitive, { className: cx("mb-command-item", className), ...props });
|
|
30
|
+
}
|
|
31
|
+
function CommandItemIcon({ className, ...props }) {
|
|
32
|
+
return _jsx(CommandItemIconPrimitive, { className: cx("mb-command-item-icon", className), ...props });
|
|
33
|
+
}
|
|
34
|
+
function CommandItemText({ className, ...props }) {
|
|
35
|
+
return _jsx(CommandItemTextPrimitive, { className: cx("mb-command-item-text", className), ...props });
|
|
36
|
+
}
|
|
37
|
+
function CommandShortcut({ className, ...props }) {
|
|
38
|
+
return _jsx(CommandShortcutPrimitive, { className: cx("mb-command-shortcut", className), ...props });
|
|
39
|
+
}
|
|
40
|
+
function CommandGroup({ className, ...props }) {
|
|
41
|
+
return _jsx(CommandGroupPrimitive, { className: cx("mb-command-group", className), ...props });
|
|
42
|
+
}
|
|
43
|
+
function CommandGroupLabel({ className, ...props }) {
|
|
44
|
+
return _jsx(CommandGroupLabelPrimitive, { className: cx("mb-command-group-label", className), ...props });
|
|
45
|
+
}
|
|
46
|
+
function CommandSeparator({ className, ...props }) {
|
|
47
|
+
return _jsx(CommandSeparatorPrimitive, { className: cx("mb-command-separator", className), ...props });
|
|
48
|
+
}
|
|
49
|
+
function CommandEmpty({ className, ...props }) {
|
|
50
|
+
return _jsx(CommandEmptyPrimitive, { className: cx("mb-command-empty", className), ...props });
|
|
51
|
+
}
|
|
52
|
+
function CommandStatus({ className, ...props }) {
|
|
53
|
+
return _jsx(CommandStatusPrimitive, { className: cx("mb-command-status", className), ...props });
|
|
54
|
+
}
|
|
55
|
+
export { Command, CommandEmpty, CommandGroup, CommandGroupLabel, CommandInput, CommandItem, CommandItemIcon, CommandItems, CommandItemText, CommandList, CommandPage, CommandPalette, CommandPaletteContent, CommandPaletteTrigger, CommandSeparator, CommandShortcut, CommandStatus, createCommandController, };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type ConfirmationState = "pending" | "allowed" | "denied";
|
|
3
|
+
type ConfirmationProps = React.ComponentProps<"div"> & {
|
|
4
|
+
/** `pending` asks; `allowed` and `denied` collapse it to one quiet line. */
|
|
5
|
+
state?: ConfirmationState;
|
|
6
|
+
/** The line shown once answered. Defaults to "Allowed" or "Denied"; say "Allowed once" or "Always allowed" when it matters. */
|
|
7
|
+
outcome?: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* An inline card that asks before a tool runs. It sits in the thread, not over it: nothing
|
|
11
|
+
* else on the page is blocked while it waits. It's a group named by its ConfirmationTitle.
|
|
12
|
+
*/
|
|
13
|
+
declare function Confirmation({ state, outcome, className, children, ...props }: ConfirmationProps): React.JSX.Element;
|
|
14
|
+
/** The tool's icon, in a tile at the start of the card. */
|
|
15
|
+
declare function ConfirmationIcon({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
16
|
+
/** The question, like "Allow Calendar to create an event?". It names the card. */
|
|
17
|
+
declare function ConfirmationTitle({ className, id, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
18
|
+
declare function ConfirmationDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
19
|
+
/** The request's details, such as a DescriptionList of what the tool will send. */
|
|
20
|
+
declare function ConfirmationDetails({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
21
|
+
/** The buttons: in a trailing row on macOS, stacked full width on iOS with the last one on top. */
|
|
22
|
+
declare function ConfirmationActions({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
23
|
+
export { Confirmation, ConfirmationActions, ConfirmationDescription, ConfirmationDetails, ConfirmationIcon, ConfirmationTitle, };
|
|
24
|
+
export type { ConfirmationProps, ConfirmationState };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { CheckGlyph, CrossGlyph } from "../lib/agent-glyphs.js";
|
|
5
|
+
import { join } from "../lib/cx.js";
|
|
6
|
+
const TitleIdContext = React.createContext(undefined);
|
|
7
|
+
/**
|
|
8
|
+
* An inline card that asks before a tool runs. It sits in the thread, not over it: nothing
|
|
9
|
+
* else on the page is blocked while it waits. It's a group named by its ConfirmationTitle.
|
|
10
|
+
*/
|
|
11
|
+
function Confirmation({ state = "pending", outcome, className, children, ...props }) {
|
|
12
|
+
const titleId = React.useId();
|
|
13
|
+
const outcomeId = React.useId();
|
|
14
|
+
const root = React.useRef(null);
|
|
15
|
+
const previous = React.useRef(state);
|
|
16
|
+
// Answering removes the buttons; keep focus in the card rather than losing it to the page.
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
const was = previous.current;
|
|
19
|
+
previous.current = state;
|
|
20
|
+
if (was !== "pending" || state === "pending")
|
|
21
|
+
return;
|
|
22
|
+
const element = root.current;
|
|
23
|
+
if (element && (element.contains(document.activeElement) || document.activeElement === document.body)) {
|
|
24
|
+
element.focus({ preventScroll: true });
|
|
25
|
+
}
|
|
26
|
+
}, [state]);
|
|
27
|
+
const resolved = state !== "pending";
|
|
28
|
+
return (_jsx("div", { ref: root, role: "group", "aria-labelledby": resolved ? outcomeId : titleId, tabIndex: resolved ? -1 : undefined, "data-state": state, className: join("mb-confirmation", className), ...props, children: resolved ? (_jsxs("p", { id: outcomeId, className: "mb-confirmation-outcome", children: [state === "allowed" ? (_jsx(CheckGlyph, { className: "mb-confirmation-outcome-glyph" })) : (_jsx(CrossGlyph, { className: "mb-confirmation-outcome-glyph" })), _jsx("span", { children: outcome ?? (state === "allowed" ? "Allowed" : "Denied") })] })) : (_jsx(TitleIdContext.Provider, { value: titleId, children: children })) }));
|
|
29
|
+
}
|
|
30
|
+
/** The tool's icon, in a tile at the start of the card. */
|
|
31
|
+
function ConfirmationIcon({ className, ...props }) {
|
|
32
|
+
return _jsx("span", { "aria-hidden": "true", className: join("mb-confirmation-icon", className), ...props });
|
|
33
|
+
}
|
|
34
|
+
/** The question, like "Allow Calendar to create an event?". It names the card. */
|
|
35
|
+
function ConfirmationTitle({ className, id, ...props }) {
|
|
36
|
+
const titleId = React.useContext(TitleIdContext);
|
|
37
|
+
return _jsx("p", { id: id ?? titleId, className: join("mb-confirmation-title", className), ...props });
|
|
38
|
+
}
|
|
39
|
+
function ConfirmationDescription({ className, ...props }) {
|
|
40
|
+
return _jsx("p", { className: join("mb-confirmation-description", className), ...props });
|
|
41
|
+
}
|
|
42
|
+
/** The request's details, such as a DescriptionList of what the tool will send. */
|
|
43
|
+
function ConfirmationDetails({ className, ...props }) {
|
|
44
|
+
return _jsx("div", { className: join("mb-confirmation-details", className), ...props });
|
|
45
|
+
}
|
|
46
|
+
/** The buttons: in a trailing row on macOS, stacked full width on iOS with the last one on top. */
|
|
47
|
+
function ConfirmationActions({ className, ...props }) {
|
|
48
|
+
return _jsx("div", { className: join("mb-confirmation-actions", className), ...props });
|
|
49
|
+
}
|
|
50
|
+
export { Confirmation, ConfirmationActions, ConfirmationDescription, ConfirmationDetails, ConfirmationIcon, ConfirmationTitle, };
|