nudge-ui 0.2.2 → 0.2.3
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/README.md +164 -46
- package/dist/client.mjs +252 -61
- package/dist/css/value-semantics/colorSemantics.d.ts +4 -0
- package/dist/css/value-semantics/colorSemantics.js +17 -0
- package/dist/hosts/astro/astroRuntimeConfig.js +1 -0
- package/dist/hosts/astro/clientTransport.js +38 -32
- package/dist/hosts/astro/integration.js +5 -1
- package/dist/hosts/astro/markdownIdentity.d.ts +28 -0
- package/dist/hosts/astro/markdownIdentity.js +81 -0
- package/dist/hosts/next/manifest.js +1 -1
- package/dist/hosts/next/sidecar.js +5 -1
- package/dist/hosts/static/manifest.js +1 -1
- package/dist/hosts/static/server.js +3 -0
- package/dist/hosts/vite/vite.d.ts +3 -0
- package/dist/hosts/vite/vite.js +24 -4
- package/dist/inspector/agent/McpConnectionDialog.js +13 -19
- package/dist/inspector/agent/activity.d.ts +18 -0
- package/dist/inspector/agent/activity.js +70 -0
- package/dist/inspector/agent/client.d.ts +2 -0
- package/dist/inspector/agent/client.js +29 -1
- package/dist/inspector/agent/connectionStatus.js +1 -1
- package/dist/inspector/agent/httpTransport.js +9 -2
- package/dist/inspector/agent/protocol.d.ts +6 -3
- package/dist/inspector/agent/protocol.js +1 -1
- package/dist/inspector/agent/verification.d.ts +11 -1
- package/dist/inspector/agent/verification.js +53 -25
- package/dist/inspector/canvas/AgentActivityOverlay.d.ts +13 -0
- package/dist/inspector/canvas/AgentActivityOverlay.js +111 -0
- package/dist/inspector/canvas/CanvasCard.d.ts +9 -2
- package/dist/inspector/canvas/CanvasCard.js +133 -38
- package/dist/inspector/canvas/CanvasElementOverlay.js +152 -16
- package/dist/inspector/canvas/CanvasToolIcons.d.ts +10 -0
- package/dist/inspector/canvas/CanvasToolIcons.js +20 -0
- package/dist/inspector/canvas/CanvasToolbar.js +8 -4
- package/dist/inspector/canvas/CanvasWorkspace.js +225 -57
- package/dist/inspector/canvas/StaleChangeIndicator.js +3 -13
- package/dist/inspector/canvas/agentPresentation.d.ts +8 -8
- package/dist/inspector/canvas/agentPresentation.js +64 -52
- package/dist/inspector/canvas/canvasGestures.d.ts +1 -1
- package/dist/inspector/canvas/canvasGestures.js +1 -1
- package/dist/inspector/canvas/canvasStore.d.ts +46 -82
- package/dist/inspector/canvas/canvasStore.js +251 -284
- package/dist/inspector/canvas/frameContent.d.ts +21 -0
- package/dist/inspector/canvas/frameContent.js +44 -0
- package/dist/inspector/canvas/frameProtocol.d.ts +21 -4
- package/dist/inspector/canvas/frameProtocol.js +3 -3
- package/dist/inspector/canvas/keyboardShortcuts.d.ts +3 -1
- package/dist/inspector/canvas/keyboardShortcuts.js +4 -4
- package/dist/inspector/canvas/layout.d.ts +52 -0
- package/dist/inspector/canvas/layout.js +106 -0
- package/dist/inspector/canvas/projection.d.ts +15 -5
- package/dist/inspector/canvas/projection.js +69 -13
- package/dist/inspector/canvas/rendererBootstrap.js +32 -4
- package/dist/inspector/canvas/rendererElementSelector.js +47 -6
- package/dist/inspector/canvas/rendererStylesheet.js +2 -2
- package/dist/inspector/canvas/resizeHandleScale.js +1 -1
- package/dist/inspector/canvas/sessionStore.d.ts +11 -26
- package/dist/inspector/canvas/sessionStore.js +43 -183
- package/dist/inspector/canvas/staleChangeDetector.js +9 -3
- package/dist/inspector/canvas/useCanvasLayoutAnimation.d.ts +5 -0
- package/dist/inspector/canvas/useCanvasLayoutAnimation.js +107 -0
- package/dist/inspector/canvas/viewStore.d.ts +38 -0
- package/dist/inspector/canvas/viewStore.js +104 -0
- package/dist/inspector/canvas/wheelPan.d.ts +8 -0
- package/dist/inspector/canvas/wheelPan.js +8 -0
- package/dist/inspector/changes/changesLog.d.ts +6 -5
- package/dist/inspector/changes/changesLog.js +40 -32
- package/dist/inspector/changes/draftChanges.d.ts +56 -0
- package/dist/inspector/changes/draftChanges.js +300 -0
- package/dist/inspector/changes/previewDiagnostics.d.ts +4 -2
- package/dist/inspector/changes/previewDiagnostics.js +11 -25
- package/dist/inspector/clientManifest.d.ts +1 -1
- package/dist/inspector/comments/CommentsOverlay.d.ts +2 -0
- package/dist/inspector/comments/CommentsOverlay.js +250 -0
- package/dist/inspector/comments/element.d.ts +6 -0
- package/dist/inspector/comments/element.js +47 -0
- package/dist/inspector/comments/store.d.ts +29 -0
- package/dist/inspector/comments/store.js +121 -0
- package/dist/inspector/comments/verification.d.ts +5 -0
- package/dist/inspector/comments/verification.js +52 -0
- package/dist/inspector/drafts/model.d.ts +35 -0
- package/dist/inspector/drafts/model.js +45 -0
- package/dist/inspector/drafts/store.d.ts +28 -0
- package/dist/inspector/drafts/store.js +231 -0
- package/dist/inspector/index.js +20 -27
- package/dist/inspector/inline-text/inlineTextEditor.js +7 -0
- package/dist/inspector/inspection/useBrowserCssInspection.js +15 -1
- package/dist/inspector/iterations/capture.d.ts +2 -0
- package/dist/inspector/iterations/capture.js +173 -0
- package/dist/inspector/iterations/client.d.ts +7 -0
- package/dist/inspector/iterations/client.js +52 -0
- package/dist/inspector/iterations/coordinator.d.ts +15 -0
- package/dist/inspector/iterations/coordinator.js +130 -0
- package/dist/inspector/iterations/prompt.d.ts +3 -0
- package/dist/inspector/iterations/prompt.js +26 -0
- package/dist/inspector/overlay/DomNavigator.js +21 -15
- package/dist/inspector/overlay/interactionStyles.js +3 -1
- package/dist/inspector/overlay/spacingGestures.d.ts +13 -1
- package/dist/inspector/overlay/spacingGestures.js +82 -5
- package/dist/inspector/projection/{workspaceProjection.d.ts → draftProjection.d.ts} +6 -6
- package/dist/inspector/projection/{workspaceProjection.js → draftProjection.js} +4 -4
- package/dist/inspector/projection/renderedInstance.d.ts +2 -1
- package/dist/inspector/projection/renderedInstance.js +9 -5
- package/dist/inspector/projection/structuralProjection.d.ts +2 -1
- package/dist/inspector/projection/structuralProjection.js +19 -15
- package/dist/inspector/projection/textProjection.d.ts +2 -1
- package/dist/inspector/projection/textProjection.js +8 -4
- package/dist/inspector/prompt/PromptSettingsDialog.js +1 -5
- package/dist/inspector/prompt/clipboardHandoff.d.ts +10 -18
- package/dist/inspector/prompt/clipboardHandoff.js +92 -143
- package/dist/inspector/prompt/generatePrompt.d.ts +4 -1
- package/dist/inspector/prompt/generatePrompt.js +17 -16
- package/dist/inspector/runtime/runtimeConfig.d.ts +9 -0
- package/dist/inspector/runtime/runtimeConfig.js +24 -0
- package/dist/inspector/settings/SettingsDialog.js +21 -8
- package/dist/inspector/shell/AgentStatusButton.d.ts +11 -0
- package/dist/inspector/shell/AgentStatusButton.js +36 -0
- package/dist/inspector/shell/AppShell.js +4 -2
- package/dist/inspector/shell/ChangesLog.js +46 -26
- package/dist/inspector/shell/CopyPromptButton.js +138 -89
- package/dist/inspector/shell/EmptyState.js +9 -8
- package/dist/inspector/shell/InspectorShell.js +13 -21
- package/dist/inspector/shell/PeekOriginalButton.js +24 -23
- package/dist/inspector/shell/originalPreview.js +5 -5
- package/dist/inspector/shell/shortcuts.d.ts +3 -0
- package/dist/inspector/shell/shortcuts.js +11 -0
- package/dist/inspector/sketch/SketchEditor.js +14 -14
- package/dist/inspector/sketch/SketchEntryButton.js +1 -1
- package/dist/inspector/sketch/SketchFrameOverlay.d.ts +3 -1
- package/dist/inspector/sketch/SketchFrameOverlay.js +11 -8
- package/dist/inspector/sketch/SketchLayersPanel.js +13 -5
- package/dist/inspector/sketch/SketchOverlay.js +7 -7
- package/dist/inspector/sketch/SketchWorkspace.js +18 -12
- package/dist/inspector/sketch/interaction.d.ts +1 -0
- package/dist/inspector/sketch/interaction.js +8 -4
- package/dist/inspector/sketch/model.d.ts +5 -0
- package/dist/inspector/sketch/model.js +6 -2
- package/dist/inspector/sketch/raster.d.ts +1 -2
- package/dist/inspector/sketch/raster.js +68 -4
- package/dist/inspector/styleEditors/BackgroundEditor.d.ts +4 -0
- package/dist/inspector/styleEditors/BackgroundEditor.js +195 -0
- package/dist/inspector/styleEditors/BorderEditor.js +49 -78
- package/dist/inspector/styleEditors/BorderRadiusEditor.js +6 -1
- package/dist/inspector/styleEditors/BoxShadowEditor.d.ts +1 -2
- package/dist/inspector/styleEditors/BoxShadowEditor.js +132 -4
- package/dist/inspector/styleEditors/ColorPicker.d.ts +5 -1
- package/dist/inspector/styleEditors/ColorPicker.js +10 -4
- package/dist/inspector/styleEditors/GapField.js +3 -5
- package/dist/inspector/styleEditors/GridChildSection.d.ts +1 -1
- package/dist/inspector/styleEditors/GridChildSection.js +18 -9
- package/dist/inspector/styleEditors/GridPicker.d.ts +1 -1
- package/dist/inspector/styleEditors/GridPicker.js +8 -2
- package/dist/inspector/styleEditors/GridSection.js +1 -1
- package/dist/inspector/styleEditors/GridValueField.js +19 -14
- package/dist/inspector/styleEditors/ImageBackgroundEditor.d.ts +18 -0
- package/dist/inspector/styleEditors/ImageBackgroundEditor.js +118 -0
- package/dist/inspector/styleEditors/LayoutBlockedIndicator.d.ts +2 -2
- package/dist/inspector/styleEditors/LayoutBlockedIndicator.js +3 -3
- package/dist/inspector/styleEditors/LayoutComboField.js +6 -4
- package/dist/inspector/styleEditors/LayoutDropdown.js +6 -3
- package/dist/inspector/styleEditors/LayoutSection.js +32 -11
- package/dist/inspector/styleEditors/SpacingBox.js +7 -5
- package/dist/inspector/styleEditors/Typography.js +11 -3
- package/dist/inspector/styleEditors/backgroundLayers.d.ts +24 -0
- package/dist/inspector/styleEditors/backgroundLayers.js +51 -0
- package/dist/inspector/styleEditors/gradientValue.d.ts +17 -0
- package/dist/inspector/styleEditors/gradientValue.js +114 -0
- package/dist/inspector/styleEditors/inlineAuthored.d.ts +10 -0
- package/dist/inspector/styleEditors/inlineAuthored.js +114 -0
- package/dist/inspector/styleEditors/layoutValue.d.ts +0 -8
- package/dist/inspector/styleEditors/layoutValue.js +0 -42
- package/dist/inspector/styleEditors/nudgeValue.d.ts +2 -2
- package/dist/inspector/styleEditors/nudgeValue.js +36 -8
- package/dist/inspector/tokens/TokenField.d.ts +7 -0
- package/dist/inspector/tokens/TokenField.js +29 -21
- package/dist/inspector/tokens/TokenLabel.js +5 -14
- package/dist/inspector/tokens/editActions.d.ts +1 -1
- package/dist/inspector/tokens/editActions.js +1 -1
- package/dist/inspector/ui/AtRuleContext.js +4 -6
- package/dist/inspector/ui/Button.d.ts +6 -2
- package/dist/inspector/ui/Button.js +4 -3
- package/dist/inspector/ui/ControlSurface.d.ts +2 -2
- package/dist/inspector/ui/ControlSurface.js +4 -3
- package/dist/inspector/ui/InlineStyleWarning.d.ts +11 -0
- package/dist/inspector/ui/InlineStyleWarning.js +13 -0
- package/dist/inspector/ui/InspectorPopover.d.ts +2 -1
- package/dist/inspector/ui/InspectorPopover.js +4 -5
- package/dist/inspector/ui/PopoverListbox.d.ts +2 -1
- package/dist/inspector/ui/PopoverListbox.js +8 -7
- package/dist/inspector/ui/SegmentedControl.d.ts +2 -1
- package/dist/inspector/ui/SegmentedControl.js +2 -2
- package/dist/inspector/ui/Select.d.ts +6 -1
- package/dist/inspector/ui/Select.js +7 -11
- package/dist/inspector/ui/SideValuesField.js +1 -1
- package/dist/inspector/ui/Tooltip.d.ts +26 -0
- package/dist/inspector/ui/Tooltip.js +32 -0
- package/dist/inspector/ui/classNames.d.ts +2 -0
- package/dist/inspector/ui/classNames.js +4 -0
- package/dist/inspector/ui/customCursors.d.ts +23 -0
- package/dist/inspector/ui/customCursors.js +122 -0
- package/dist/inspector/ui/dragCursor.d.ts +0 -2
- package/dist/inspector/ui/dragCursor.js +2 -10
- package/dist/inspector/ui/portalContainer.d.ts +2 -0
- package/dist/inspector/ui/portalContainer.js +6 -0
- package/dist/inspector/ui/styles.js +29 -21
- package/dist/inspector/workspace/commands.d.ts +9 -0
- package/dist/inspector/workspace/commands.js +82 -0
- package/dist/inspector/workspace/controller.d.ts +4 -0
- package/dist/inspector/workspace/controller.js +66 -0
- package/dist/inspector/workspace/handoff.d.ts +42 -0
- package/dist/inspector/workspace/handoff.js +115 -0
- package/dist/inspector/workspace/timeline.d.ts +30 -0
- package/dist/inspector/workspace/timeline.js +108 -0
- package/dist/internal/agent-protocol.d.ts +19 -2
- package/dist/internal/agent-protocol.js +13 -0
- package/dist/nudge-ui.mjs +558 -311
- package/dist/project/artifacts.d.ts +13 -0
- package/dist/project/artifacts.js +253 -0
- package/dist/transport/artifacts.d.ts +8 -0
- package/dist/transport/artifacts.js +9 -0
- package/dist/transport/editor.js +3 -1
- package/dist/transport/routes.d.ts +2 -0
- package/dist/transport/routes.js +2 -0
- package/package.json +6 -2
- package/dist/inspector/changes/workspaceChanges.d.ts +0 -47
- package/dist/inspector/changes/workspaceChanges.js +0 -265
|
@@ -36,7 +36,7 @@ export function SideValuesField({ label, sides, pairedControls, defaultExpanded
|
|
|
36
36
|
}
|
|
37
37
|
return (_jsx("div", { className: "side-values", "data-test": dataTest, "data-property": dataProperty, "data-empty": empty ? "true" : undefined, ...(hasPairedControls
|
|
38
38
|
? { "data-expanded": isExpanded ? "true" : "false" }
|
|
39
|
-
: {}), children: empty ? (_jsxs("div", { className: "side-values__header", children: [_jsx("span", { className: "side-values__label", children: displayLabel }), emptyAction ?? (_jsx(IconButton, { variant: "quiet", size: "default", "data-test": "add-value", label: `Add ${labelText}`,
|
|
39
|
+
: {}), children: empty ? (_jsxs("div", { className: "side-values__header", children: [_jsx("span", { className: "side-values__label", children: displayLabel }), emptyAction ?? (_jsx(IconButton, { variant: "quiet", size: "default", "data-test": "add-value", label: `Add ${labelText}`, onClick: onAdd, children: _jsx(IconPlus, { size: 16, "aria-hidden": "true" }) }))] })) : hasPairedControls ? (_jsxs(_Fragment, { children: [showLabel ? (_jsx("div", { className: "side-values__header", children: _jsx("span", { className: "side-values__label", children: displayLabel }) })) : null, _jsxs("div", { className: "side-values__value-row", children: [isExpanded ? (_jsx(SideControls, { label: label, sides: sides })) : (_jsx("div", { className: "side-values__pairs", role: "group", "aria-label": `${labelText} Grouped Sides`, children: orderedPairedControls.map(({ axis, control, icon }) => (_jsxs(ControlSurface, { className: "side-values__side", "data-test": `pair-value-${axis}`, "data-axis": axis, "aria-label": `${labelText} ${axis === "horizontal" ? "Left And Right" : "Top And Bottom"}`, children: [icon !== undefined ? icon : _jsx(AxisIndicator, { axis: axis }), _jsx("div", { className: "side-values__control", children: control })] }, axis))) })), _jsx(ToggleButton, { variant: "quiet", size: "default", "data-test": "individual-sides", label: isExpanded ? `Collapse ${labelText} Sides` : `Expand ${labelText} Sides`, pressed: isExpanded, onPressedChange: toggleExpanded, children: _jsx(IconBorderSides, { size: 16, "aria-hidden": "true" }) })] })] })) : (_jsxs(_Fragment, { children: [showLabel ? (_jsx("div", { className: "side-values__header", children: _jsx("span", { className: "side-values__label", children: displayLabel }) })) : null, _jsx(SideControls, { label: label, sides: sides })] })) }));
|
|
40
40
|
}
|
|
41
41
|
export function SideControls({ label, sides, layout = "sides", }) {
|
|
42
42
|
const displayOrder = layout === "corners" ? SIDE_NAMES : SIDE_DISPLAY_ORDER;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface TooltipGroupProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
delay?: number;
|
|
5
|
+
closeDelay?: number;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function TooltipGroup({ children, delay, closeDelay, timeout, }: TooltipGroupProps): ReactElement;
|
|
9
|
+
export interface TooltipProps {
|
|
10
|
+
children: ReactElement;
|
|
11
|
+
content?: ReactNode;
|
|
12
|
+
shortcut?: ReactNode;
|
|
13
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
14
|
+
align?: "start" | "center" | "end";
|
|
15
|
+
sideOffset?: number;
|
|
16
|
+
delay?: number;
|
|
17
|
+
closeDelay?: number;
|
|
18
|
+
disableFocus?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
stableTrigger?: boolean;
|
|
21
|
+
triggerClassName?: string;
|
|
22
|
+
positionerClassName?: string;
|
|
23
|
+
popupClassName?: string;
|
|
24
|
+
"data-test"?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function Tooltip({ children, content, shortcut, side, align, sideOffset, delay, closeDelay, disableFocus, disabled, stableTrigger, triggerClassName, positionerClassName, popupClassName, "data-test": dataTest, }: TooltipProps): ReactElement;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
3
|
+
import { cx } from "./classNames.js";
|
|
4
|
+
import { portalContainer } from "./portalContainer.js";
|
|
5
|
+
export function TooltipGroup({ children, delay = 500, closeDelay = 0, timeout = 400, }) {
|
|
6
|
+
return (_jsx(BaseTooltip.Provider, { delay: delay, closeDelay: closeDelay, timeout: timeout, children: children }));
|
|
7
|
+
}
|
|
8
|
+
function isDisabledTrigger(element) {
|
|
9
|
+
// SAFETY: Inspector triggers are host elements with optional disabled props.
|
|
10
|
+
return Boolean(element.props.disabled);
|
|
11
|
+
}
|
|
12
|
+
function defaultTooltipContent(element) {
|
|
13
|
+
// SAFETY: Inspector triggers carry label or aria-label for tooltip text.
|
|
14
|
+
const props = element.props;
|
|
15
|
+
return props.label ?? props["aria-label"] ?? null;
|
|
16
|
+
}
|
|
17
|
+
function preventFocusOpening(event) {
|
|
18
|
+
if (!("preventBaseUIHandler" in event))
|
|
19
|
+
return;
|
|
20
|
+
// SAFETY: The `in` guard proves preventBaseUIHandler exists on this Base UI focus event.
|
|
21
|
+
const preventBaseUIHandler = event.preventBaseUIHandler;
|
|
22
|
+
if (typeof preventBaseUIHandler === "function")
|
|
23
|
+
preventBaseUIHandler();
|
|
24
|
+
}
|
|
25
|
+
export function Tooltip({ children, content, shortcut, side = "top", align = "center", sideOffset = 8, delay, closeDelay, disableFocus = false, disabled = false, stableTrigger = false, triggerClassName, positionerClassName, popupClassName, "data-test": dataTest, }) {
|
|
26
|
+
if (disabled)
|
|
27
|
+
return children;
|
|
28
|
+
const childDisabled = isDisabledTrigger(children);
|
|
29
|
+
const trigger = stableTrigger || childDisabled ? (_jsx("span", { className: cx("tooltip__trigger", triggerClassName), "data-tooltip-trigger-disabled": childDisabled ? "" : undefined, children: children })) : children;
|
|
30
|
+
const tooltipContent = content ?? defaultTooltipContent(children);
|
|
31
|
+
return (_jsxs(BaseTooltip.Root, { disableHoverablePopup: true, children: [_jsx(BaseTooltip.Trigger, { render: trigger, delay: delay, closeDelay: closeDelay, onFocus: disableFocus ? preventFocusOpening : undefined }), _jsx(BaseTooltip.Portal, { container: portalContainer(), children: _jsx(BaseTooltip.Positioner, { className: cx("tooltip__positioner", positionerClassName), side: side, align: align, sideOffset: sideOffset, children: _jsxs(BaseTooltip.Popup, { className: cx("tooltip__popup", popupClassName), "data-test": dataTest, children: [_jsx("div", { className: "tooltip__content", children: tooltipContent }), shortcut !== undefined ? _jsx("span", { className: "tooltip__shortcut", children: shortcut }) : null] }) }) })] }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type RendererCursor = "design" | "drag" | "comment";
|
|
2
|
+
/** Custom property the renderer sets on its root to drive the interaction cursor. */
|
|
3
|
+
export declare const INTERACTION_CURSOR_PROPERTY = "--nudge-ui-interaction-cursor";
|
|
4
|
+
/** Rendered size and hotspot of the drag cursor, shared with the pointer-lock stand-in. */
|
|
5
|
+
export declare const DRAG_CURSOR_SIZE: {
|
|
6
|
+
readonly width: 28.8;
|
|
7
|
+
readonly height: 24;
|
|
8
|
+
};
|
|
9
|
+
export declare const DRAG_CURSOR_HOTSPOT: {
|
|
10
|
+
readonly x: 14.4;
|
|
11
|
+
readonly y: 12;
|
|
12
|
+
};
|
|
13
|
+
export declare const DESIGN_SELECT_CURSOR_URL: string;
|
|
14
|
+
export declare const DRAG_CURSOR_URL: string;
|
|
15
|
+
export declare const SKETCH_CURSOR_URL: string;
|
|
16
|
+
export declare const DESIGN_SELECT_CURSOR: string;
|
|
17
|
+
/** Cursor SVGs are separate images, so resolve CSS tokens before encoding them. */
|
|
18
|
+
export declare function createCommentCursor(tokenSource?: Element | null): string;
|
|
19
|
+
export declare const COMMENT_CURSOR: string;
|
|
20
|
+
export declare const PAN_CURSOR = "grab";
|
|
21
|
+
export declare const DRAG_CURSOR: string;
|
|
22
|
+
export declare const SKETCH_CURSOR: string;
|
|
23
|
+
export declare function rendererCursorValue(cursor: RendererCursor, commentCursor?: string): string;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const foundationStyles = ":host {\n all: initial;\n --surface-panel: #F5F5F4;\n --surface-control: var(--surface-well);\n --surface-control-hover: var(--surface-well-2x);\n --surface-raised: #FAFAFA;\n --surface-raised-2x: #fff ;\n --surface-raised-hover: #F5F5F4;\n --surface-well: hsla(0, 0%, 0%, 0.05);\n --surface-well-2x: hsla(0, 0%, 0%, 0.10);\n\n --border-subtle: hsla(0, 0%, 0%, 0.1);\n --border-medium: hsla(0, 0%, 0%, 0.2);\n --border-strong: #d8d8d8;\n\n --text-primary: #242424;\n --text-secondary: #6f6f6f;\n --text-muted: #777777;\n --text-muted-subtle: #a1a1a1;\n\n --accent: #0096ff;\n --accent-surface: rgba(0, 176, 255, 0.15);\n --warning: #d97706;\n --warning-text: #9a5b00;\n --warning-surface: #fff6e5;\n --danger: #df4b4b;\n --danger-text: #bd3636;\n --danger-surface: rgba(223, 75, 75, 0.2);\n --success: #2e7d52;\n\n --space-0: 0;\n --space-4: 4px;\n --space-8: 8px;\n --space-12: 12px;\n --space-16: 16px;\n --space-20: 20px;\n --space-24: 24px;\n --space-32: 32px;\n --space-40: 40px;\n --space-48: 48px;\n\n /* Radius */\n --radius-0: 0;\n --radius-4: 4px;\n --radius-8: 8px;\n --radius-12: 12px;\n --radius-16: 16px;\n --radius-20: 20px;\n --radius-24: 24px;\n --radius-pill: 999px;\n\n --radius-control: var(--radius-8);\n --shadow-outline: 0 0 0 1px rgba(0, 0, 0, 0.05);\n --shadow-popup: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.10);\n --shadow-control: inset 0 -2px 0 rgba(0, 0, 0, 0.03), 0 0 0 0.5px rgba(0, 0, 0, 0.25);\n --z-index: 2147483647;\n\n --font-family: \"Inter Variable\", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;\n --font-size-base: 12px;\n --font-size-small: 10px;\n --font-weight-base: 400;\n --font-weight-label: 600;\n\n /* Control semantic sizes */\n --control-height-small: 24px;\n --control-height-large: 32px;\n --control-height-xlarge: 40px;\n --label-column: 104px;\n\n --icon-size-small: 16px;\n --icon-size-large: 20px;\n --icon-stroke-width: 1.5px;\n\n position: fixed;\n inset: 0;\n z-index: var(--z-index);\n pointer-events: none;\n font-family: var(--font-family);\n background: transparent;\n box-sizing: border-box;\n}\n\n*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\nbutton,\ninput,\nselect {\n font-family: inherit;\n}\n";
|
|
2
|
+
/** Custom property the renderer sets on its root to drive the interaction cursor. */
|
|
3
|
+
export const INTERACTION_CURSOR_PROPERTY = "--nudge-ui-interaction-cursor";
|
|
4
|
+
const DESIGN_SELECT_CURSOR_SVG = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
5
|
+
<g clip-path="url(#clip0_1681_15)">
|
|
6
|
+
<g filter="url(#filter0_d_1681_15)">
|
|
7
|
+
<path d="M17.3586 9.11501L12.9167 10.8333L12.6544 10.95C12.457 11.0271 12.2776 11.1443 12.1278 11.2942C11.9779 11.444 11.8607 11.6234 11.7836 11.8208L9.94861 16.5242C9.42111 17.8783 7.47944 17.8058 7.05444 16.4158L3.40277 4.48418C3.04277 3.30918 4.14277 2.21001 5.31777 2.56918L17.2503 6.22085C18.6403 6.64668 18.7128 8.58668 17.3586 9.11501Z" fill="black"/>
|
|
8
|
+
<path d="M17.3586 9.11501L12.9167 10.8333L12.6544 10.95C12.457 11.0271 12.2776 11.1443 12.1278 11.2942C11.9779 11.444 11.8607 11.6234 11.7836 11.8208L9.94861 16.5242C9.42111 17.8783 7.47944 17.8058 7.05444 16.4158L3.40277 4.48418C3.04277 3.30918 4.14277 2.21001 5.31777 2.56918L17.2503 6.22085C18.6403 6.64668 18.7128 8.58668 17.3586 9.11501Z" stroke="white" stroke-linecap="round" stroke-linejoin="round"/>
|
|
9
|
+
</g>
|
|
10
|
+
</g>
|
|
11
|
+
<defs>
|
|
12
|
+
<filter id="filter0_d_1681_15" x="0.332611" y="0.332662" width="21.002" height="21.0009" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
13
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
14
|
+
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
|
15
|
+
<feOffset dy="0.833333"/>
|
|
16
|
+
<feGaussianBlur stdDeviation="1.25"/>
|
|
17
|
+
<feComposite in2="hardAlpha" operator="out"/>
|
|
18
|
+
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
|
19
|
+
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1681_15"/>
|
|
20
|
+
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1681_15" result="shape"/>
|
|
21
|
+
</filter>
|
|
22
|
+
<clipPath id="clip0_1681_15">
|
|
23
|
+
<rect width="20" height="20" fill="white"/>
|
|
24
|
+
</clipPath>
|
|
25
|
+
</defs>
|
|
26
|
+
</svg>`;
|
|
27
|
+
/** Rendered size and hotspot of the drag cursor, shared with the pointer-lock stand-in. */
|
|
28
|
+
export const DRAG_CURSOR_SIZE = { width: 28.8, height: 24 };
|
|
29
|
+
export const DRAG_CURSOR_HOTSPOT = { x: 14.4, y: 12 };
|
|
30
|
+
const DRAG_CURSOR_SVG = `<svg width="${DRAG_CURSOR_SIZE.width}" height="${DRAG_CURSOR_SIZE.height}" viewBox="0 0 24 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
31
|
+
<g filter="url(#filter0_d_1681_26)">
|
|
32
|
+
<path d="M13.2767 13.6586V7.616C13.2767 7.17654 13.736 6.88812 14.1318 7.07897L20.3982 10.1003C20.8478 10.3171 20.8478 10.9575 20.3982 11.1743L14.1318 14.1956C13.736 14.3864 13.2767 14.098 13.2767 13.6586Z" fill="black"/>
|
|
33
|
+
<path d="M13.2767 13.6586V7.616C13.2767 7.17654 13.736 6.88812 14.1318 7.07897L20.3982 10.1003C20.8478 10.3171 20.8478 10.9575 20.3982 11.1743L14.1318 14.1956C13.736 14.3864 13.2767 14.098 13.2767 13.6586Z" stroke="white"/>
|
|
34
|
+
</g>
|
|
35
|
+
<g filter="url(#filter1_d_1681_26)">
|
|
36
|
+
<path d="M9.74729 13.6586V7.616C9.74729 7.17654 9.28803 6.88812 8.89218 7.07897L2.62582 10.1003C2.17614 10.3171 2.17614 10.9575 2.62582 11.1743L8.89218 14.1956C9.28803 14.3864 9.74729 14.098 9.74729 13.6586Z" fill="black"/>
|
|
37
|
+
<path d="M9.74729 13.6586V7.616C9.74729 7.17654 9.28803 6.88812 8.89218 7.07897L2.62582 10.1003C2.17614 10.3171 2.17614 10.9575 2.62582 11.1743L8.89218 14.1956C9.28803 14.3864 9.74729 14.098 9.74729 13.6586Z" stroke="white"/>
|
|
38
|
+
</g>
|
|
39
|
+
<defs>
|
|
40
|
+
<filter id="filter0_d_1681_26" x="10.9881" y="5.32606" width="12.0358" height="11.8148" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
41
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
42
|
+
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
|
43
|
+
<feOffset dy="0.596185"/>
|
|
44
|
+
<feGaussianBlur stdDeviation="0.894277"/>
|
|
45
|
+
<feComposite in2="hardAlpha" operator="out"/>
|
|
46
|
+
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
|
47
|
+
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1681_26"/>
|
|
48
|
+
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1681_26" result="shape"/>
|
|
49
|
+
</filter>
|
|
50
|
+
<filter id="filter1_d_1681_26" x="4.76837e-06" y="5.32606" width="12.0358" height="11.8148" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
51
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
52
|
+
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
|
53
|
+
<feOffset dy="0.596185"/>
|
|
54
|
+
<feGaussianBlur stdDeviation="0.894277"/>
|
|
55
|
+
<feComposite in2="hardAlpha" operator="out"/>
|
|
56
|
+
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
|
57
|
+
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1681_26"/>
|
|
58
|
+
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1681_26" result="shape"/>
|
|
59
|
+
</filter>
|
|
60
|
+
</defs>
|
|
61
|
+
</svg>`;
|
|
62
|
+
const SKETCH_CURSOR_SVG = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
63
|
+
<g clip-path="url(#clip0_1681_8)">
|
|
64
|
+
<g filter="url(#filter0_d_1681_8)">
|
|
65
|
+
<path d="M11.6667 5L17.5 10.8333L14.1667 14.1667" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
|
|
66
|
+
<path d="M5.62132 15.6544C5.33535 15.5359 5.07552 15.3622 4.85667 15.1433C4.63776 14.9245 4.46411 14.6647 4.34563 14.3787C4.22715 14.0927 4.16617 13.7862 4.16617 13.4767C4.16617 13.1671 4.22715 12.8606 4.34563 12.5746C4.46411 12.2887 4.63776 12.0288 4.85667 11.81L13.6783 2.98833C13.8331 2.8335 14.0169 2.71067 14.2191 2.62687C14.4214 2.54307 14.6382 2.49994 14.8571 2.49994C15.076 2.49994 15.2928 2.54307 15.495 2.62687C15.6973 2.71067 15.8811 2.8335 16.0358 2.98833L17.0117 3.96417C17.1665 4.11894 17.2893 4.3027 17.3731 4.50495C17.4569 4.70721 17.5001 4.92399 17.5001 5.14292C17.5001 5.36184 17.4569 5.57862 17.3731 5.78088C17.2893 5.98313 17.1665 6.16689 17.0117 6.32167L8.19 15.1433C7.97116 15.3622 7.71133 15.5359 7.42536 15.6544C7.13939 15.7729 6.83288 15.8338 6.52334 15.8338C6.2138 15.8338 5.90729 15.7729 5.62132 15.6544Z" fill="white" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
|
|
67
|
+
<path d="M3.33334 16.6667L4.80668 15.1934" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
|
|
68
|
+
</g>
|
|
69
|
+
</g>
|
|
70
|
+
<defs>
|
|
71
|
+
<filter id="filter0_d_1681_8" x="0.333344" y="0.333272" width="20.1667" height="20.1667" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
72
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
73
|
+
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
|
74
|
+
<feOffset dy="0.833333"/>
|
|
75
|
+
<feGaussianBlur stdDeviation="1.25"/>
|
|
76
|
+
<feComposite in2="hardAlpha" operator="out"/>
|
|
77
|
+
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
|
78
|
+
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1681_8"/>
|
|
79
|
+
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1681_8" result="shape"/>
|
|
80
|
+
</filter>
|
|
81
|
+
<clipPath id="clip0_1681_8">
|
|
82
|
+
<rect width="20" height="20" fill="white"/>
|
|
83
|
+
</clipPath>
|
|
84
|
+
</defs>
|
|
85
|
+
</svg>`;
|
|
86
|
+
function cursorDataUrl(svg) {
|
|
87
|
+
return `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
|
88
|
+
}
|
|
89
|
+
export const DESIGN_SELECT_CURSOR_URL = cursorDataUrl(DESIGN_SELECT_CURSOR_SVG);
|
|
90
|
+
export const DRAG_CURSOR_URL = cursorDataUrl(DRAG_CURSOR_SVG);
|
|
91
|
+
export const SKETCH_CURSOR_URL = cursorDataUrl(SKETCH_CURSOR_SVG);
|
|
92
|
+
export const DESIGN_SELECT_CURSOR = `url("${DESIGN_SELECT_CURSOR_URL}") 3 4, default`;
|
|
93
|
+
/** Cursor SVGs are separate images, so resolve CSS tokens before encoding them. */
|
|
94
|
+
export function createCommentCursor(tokenSource) {
|
|
95
|
+
const styles = tokenSource?.ownerDocument.defaultView?.getComputedStyle(tokenSource);
|
|
96
|
+
const token = (name) => styles?.getPropertyValue(name).trim()
|
|
97
|
+
|| foundationStyles.match(new RegExp(`${name}:\\s*([^;]+);`))[1].trim();
|
|
98
|
+
const svg = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
99
|
+
<g clip-path="url(#comment-clip)"><g filter="url(#comment-shadow)">
|
|
100
|
+
<path d="M4.3 16.1L3 20L7.7 19C11.659 20.922 16.608 19.942 19.274 16.707C21.94 13.472 21.5 8.983 18.245 6.206C14.99 3.43 9.926 3.225 6.4 5.726C2.874 8.228 1.976 12.663 4.3 16.1Z" fill="${token("--text-primary")}" stroke="${token("--surface-raised-2x")}" stroke-width="${token("--icon-stroke-width")}" stroke-linecap="round" stroke-linejoin="round"/>
|
|
101
|
+
</g></g>
|
|
102
|
+
<defs>
|
|
103
|
+
<filter id="comment-shadow" x="-0.0000152588" y="1.81214" width="24.0141" height="22.0212" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
104
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
105
|
+
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
|
106
|
+
<feOffset dy="0.833333"/><feGaussianBlur stdDeviation="1.25"/>
|
|
107
|
+
<feComposite in2="hardAlpha" operator="out"/>
|
|
108
|
+
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
|
109
|
+
<feBlend mode="normal" in2="BackgroundImageFix" result="dropShadow"/>
|
|
110
|
+
<feBlend mode="normal" in="SourceGraphic" in2="dropShadow" result="shape"/>
|
|
111
|
+
</filter>
|
|
112
|
+
<clipPath id="comment-clip"><rect width="24" height="24" fill="white"/></clipPath>
|
|
113
|
+
</defs></svg>`;
|
|
114
|
+
return `url("${cursorDataUrl(svg)}") 3 20, crosshair`;
|
|
115
|
+
}
|
|
116
|
+
export const COMMENT_CURSOR = createCommentCursor();
|
|
117
|
+
export const PAN_CURSOR = "grab";
|
|
118
|
+
export const DRAG_CURSOR = `url("${DRAG_CURSOR_URL}") ${DRAG_CURSOR_HOTSPOT.x} ${DRAG_CURSOR_HOTSPOT.y}, grab`;
|
|
119
|
+
export const SKETCH_CURSOR = `url("${SKETCH_CURSOR_URL}") 3 17, crosshair`;
|
|
120
|
+
export function rendererCursorValue(cursor, commentCursor = COMMENT_CURSOR) {
|
|
121
|
+
return cursor === "comment" ? commentCursor : cursor === "drag" ? PAN_CURSOR : DESIGN_SELECT_CURSOR;
|
|
122
|
+
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const DRAG_CURSOR_URL: string;
|
|
2
|
-
export declare const DRAG_CURSOR: string;
|
|
3
1
|
export declare const DRAG_CURSOR_STYLES: string;
|
|
4
2
|
/** Shows the same cursor at a fixed viewport point while the native cursor is locked. */
|
|
5
3
|
export declare function showLockedDragCursor(doc: Document, point: {
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
<g filter="url(#right)"><path d="M19.1253 13.3682V3.50181C19.1253 2.77104 19.8836 2.28706 20.5464 2.5948L31.1718 7.52799C31.9436 7.88635 31.9436 8.98365 31.1718 9.34201L20.5464 14.2752C19.8836 14.5829 19.1253 14.099 19.1253 13.3682Z" fill="black" stroke="white"/></g>
|
|
3
|
-
<g filter="url(#left)"><path d="M16.1253 13.3682V3.50181C16.1253 2.77104 15.367 2.28706 14.7042 2.5948L4.07889 7.52799C3.30704 7.88635 3.30704 8.98365 4.07889 9.34201L14.7042 14.2752C15.367 14.5829 16.1253 14.099 16.1253 13.3682Z" fill="black" stroke="white"/></g>
|
|
4
|
-
<defs>
|
|
5
|
-
<filter id="right" x="15.6253" y="0" width="19.6253" height="18.87" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="1"/><feGaussianBlur stdDeviation="1.5"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="shadow"/><feBlend mode="normal" in="SourceGraphic" in2="shadow" result="shape"/></filter>
|
|
6
|
-
<filter id="left" x="0" y="0" width="19.6253" height="18.87" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="1"/><feGaussianBlur stdDeviation="1.5"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="shadow"/><feBlend mode="normal" in="SourceGraphic" in2="shadow" result="shape"/></filter>
|
|
7
|
-
</defs></svg>`;
|
|
8
|
-
export const DRAG_CURSOR_URL = `data:image/svg+xml,${encodeURIComponent(DRAG_CURSOR_SVG)}`;
|
|
9
|
-
export const DRAG_CURSOR = `url("${DRAG_CURSOR_URL}") 9 4, ew-resize`;
|
|
1
|
+
import { DRAG_CURSOR, DRAG_CURSOR_HOTSPOT, DRAG_CURSOR_SIZE, DRAG_CURSOR_URL } from "./customCursors.js";
|
|
10
2
|
export const DRAG_CURSOR_STYLES = `:host { --nudge-drag-cursor: ${DRAG_CURSOR}; }`;
|
|
11
3
|
/** Shows the same cursor at a fixed viewport point while the native cursor is locked. */
|
|
12
4
|
export function showLockedDragCursor(doc, point) {
|
|
@@ -15,7 +7,7 @@ export function showLockedDragCursor(doc, point) {
|
|
|
15
7
|
cursor.alt = "";
|
|
16
8
|
cursor.setAttribute("aria-hidden", "true");
|
|
17
9
|
cursor.dataset.test = "locked-drag-cursor";
|
|
18
|
-
cursor.style.cssText = `all: initial; position: fixed; left: ${point.x -
|
|
10
|
+
cursor.style.cssText = `all: initial; position: fixed; left: ${point.x - DRAG_CURSOR_HOTSPOT.x}px; top: ${point.y - DRAG_CURSOR_HOTSPOT.y}px; width: ${DRAG_CURSOR_SIZE.width}px; height: ${DRAG_CURSOR_SIZE.height}px; pointer-events: none; z-index: 2147483647; user-select: none;`;
|
|
19
11
|
doc.documentElement.append(cursor);
|
|
20
12
|
return () => cursor.remove();
|
|
21
13
|
}
|