@open-artifact/editor-kit 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +128 -2
- package/package.json +58 -4
- package/src/Announcer.d.ts +2 -0
- package/src/Announcer.js +8 -0
- package/src/FindBar.d.ts +31 -0
- package/src/FindBar.js +34 -0
- package/src/agent.d.ts +20 -0
- package/src/agent.js +40 -0
- package/src/announce.d.ts +18 -0
- package/src/announce.js +21 -0
- package/src/chrome.d.ts +180 -0
- package/src/chrome.js +108 -0
- package/src/collab/CommentList.d.ts +23 -0
- package/src/collab/CommentList.js +117 -0
- package/src/collab/CommentViews.d.ts +116 -0
- package/src/collab/CommentViews.js +531 -0
- package/src/collab/HistoryViews.d.ts +38 -0
- package/src/collab/HistoryViews.js +103 -0
- package/src/collab/PresenceViews.d.ts +52 -0
- package/src/collab/PresenceViews.js +46 -0
- package/src/collab/cds/cds.d.ts +148 -0
- package/src/collab/cds/cds.js +230 -0
- package/src/collab/cds/comment-card.d.ts +93 -0
- package/src/collab/cds/comment-card.js +211 -0
- package/src/collab/cds/comment-composer.d.ts +28 -0
- package/src/collab/cds/comment-composer.js +101 -0
- package/src/collab/cds/comments-css.d.ts +2 -0
- package/src/collab/cds/comments-css.js +3 -0
- package/src/collab/cds/comments.css +497 -0
- package/src/collab/cds/edge-piles.d.ts +69 -0
- package/src/collab/cds/edge-piles.js +178 -0
- package/src/collab/cds/layer.d.ts +41 -0
- package/src/collab/cds/layer.js +143 -0
- package/src/collab/cds/markdown.d.ts +17 -0
- package/src/collab/cds/markdown.js +507 -0
- package/src/collab/cds/shield.d.ts +28 -0
- package/src/collab/cds/shield.js +114 -0
- package/src/collab/cds/time.d.ts +2 -0
- package/src/collab/cds/time.js +41 -0
- package/src/collab/collab.d.ts +100 -0
- package/src/collab/collab.js +119 -0
- package/src/collab/comments.d.ts +147 -0
- package/src/collab/comments.js +287 -0
- package/src/collab/history-wiring.d.ts +32 -0
- package/src/collab/history-wiring.js +53 -0
- package/src/collab/history.d.ts +53 -0
- package/src/collab/history.js +94 -0
- package/src/collab/peer-colors.d.ts +123 -0
- package/src/collab/peer-colors.js +273 -0
- package/src/collab/pins.d.ts +70 -0
- package/src/collab/pins.js +44 -0
- package/src/collab/presence.d.ts +92 -0
- package/src/collab/presence.js +158 -0
- package/src/design-systems.d.ts +46 -0
- package/src/design-systems.js +61 -0
- package/src/downloads.d.ts +24 -0
- package/src/downloads.js +36 -0
- package/src/find.d.ts +64 -0
- package/src/find.js +147 -0
- package/src/index.d.ts +25 -0
- package/src/index.js +25 -0
- package/src/keys.d.ts +13 -0
- package/src/keys.js +20 -0
- package/src/merge.d.ts +23 -0
- package/src/merge.js +116 -0
- package/src/page-link.d.ts +33 -0
- package/src/page-link.js +75 -0
- package/src/project-sync.d.ts +118 -0
- package/src/project-sync.js +174 -0
- package/src/react.d.ts +16 -0
- package/src/react.js +16 -0
- package/src/roles.d.ts +33 -0
- package/src/roles.js +26 -0
- package/src/session.d.ts +42 -0
- package/src/session.js +37 -0
- package/src/shell.d.ts +56 -0
- package/src/shell.js +96 -0
- package/src/stash.d.ts +26 -0
- package/src/stash.js +66 -0
- package/src/styles.css +17 -0
package/src/chrome.d.ts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitives of the editor chrome (Design, Slides and Whiteboard): floating
|
|
3
|
+
* cards (12px radius, hairline ring, soft shadow), 28px / 32px / 36px ghost
|
|
4
|
+
* controls (pressed = blue-soft), icon-only tool buttons, dark tooltips with
|
|
5
|
+
* key chips, menus (14px radius, 28px rows, submenus included), popovers
|
|
6
|
+
* and color swatch rows.
|
|
7
|
+
*
|
|
8
|
+
* Menus and popovers take a `mark` (a `data-*` attribute their popup
|
|
9
|
+
* carries, e.g. so a board surface starts no gesture on it) and a
|
|
10
|
+
* `popupBase` (classes in place of {@link POPUP}) for editors whose popups
|
|
11
|
+
* look different.
|
|
12
|
+
*
|
|
13
|
+
* Styled with the editor's chrome tokens (`bg-chrome`, `text-chrome-fg`,
|
|
14
|
+
* `bg-chrome-hover`, `bg-chrome-pressed`, `text-chrome-accent`,
|
|
15
|
+
* `shadow-chrome`, `bg-tip`…); the focus ring is `outline-chrome-focus`, so
|
|
16
|
+
* each editor picks its own focus color.
|
|
17
|
+
*/
|
|
18
|
+
import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactElement, type ReactNode } from 'react';
|
|
19
|
+
import type { ChromeDraw, ShellConnection } from '@open-artifact/runtime';
|
|
20
|
+
/** A floating chrome card. */
|
|
21
|
+
export declare const Card: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
|
+
/** The 1 × 18px divider between groups of controls (`vertical: false`: a full-width 1px rule between rows). */
|
|
23
|
+
export declare function ChromeDivider({ className, vertical }: {
|
|
24
|
+
className?: string;
|
|
25
|
+
vertical?: boolean;
|
|
26
|
+
}): ReactNode;
|
|
27
|
+
/** Where a tooltip or popup opens. */
|
|
28
|
+
export type ChromeSide = 'top' | 'bottom' | 'left' | 'right';
|
|
29
|
+
/** A `data-*` attribute a popup carries (see the module comment). */
|
|
30
|
+
export type ChromeMark = `data-${string}`;
|
|
31
|
+
/** A dark tooltip; the shortcut shows as a key chip. */
|
|
32
|
+
export declare function Tip({ label, shortcut, side, children, disabled, }: {
|
|
33
|
+
label: ReactNode;
|
|
34
|
+
shortcut?: string;
|
|
35
|
+
side?: ChromeSide;
|
|
36
|
+
/** Never open (e.g. while a popup of the trigger is open). */
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
children: ReactElement<Record<string, unknown>>;
|
|
39
|
+
}): ReactNode;
|
|
40
|
+
/** Shares hover delays between neighbouring tooltips. */
|
|
41
|
+
export declare function TipGroup({ children }: {
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
}): ReactNode;
|
|
44
|
+
/** Props of {@link ChromeButton}. */
|
|
45
|
+
export interface ChromeButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
46
|
+
/** Pressed state (tools, toggles). */
|
|
47
|
+
pressed?: boolean;
|
|
48
|
+
/** Icon-only: a square control. */
|
|
49
|
+
square?: boolean;
|
|
50
|
+
/** Control height: 28px (cards), 32px (bottom toolbars) or 36px (a board's tool bar). */
|
|
51
|
+
size?: 'md' | 'lg' | 'xl';
|
|
52
|
+
}
|
|
53
|
+
/** A ghost control: 8px radius, 14px text, blue-soft when pressed. */
|
|
54
|
+
export declare const ChromeButton: import("react").ForwardRefExoticComponent<ChromeButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
55
|
+
/** A {@link ChromeButton} with a tooltip that still shows while it is disabled. */
|
|
56
|
+
export declare const TipButton: import("react").ForwardRefExoticComponent<ChromeButtonProps & {
|
|
57
|
+
tip: ReactNode;
|
|
58
|
+
shortcut?: string;
|
|
59
|
+
side?: ChromeSide;
|
|
60
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
61
|
+
/** Props of {@link ToolButton}. */
|
|
62
|
+
export interface ToolButtonProps extends Omit<ChromeButtonProps, 'children' | 'square'> {
|
|
63
|
+
/** Accessible name and tooltip text. */
|
|
64
|
+
label: string;
|
|
65
|
+
/** Longer tooltip text, when it differs from the name. */
|
|
66
|
+
tip?: ReactNode;
|
|
67
|
+
icon: ReactNode;
|
|
68
|
+
shortcut?: string;
|
|
69
|
+
tipSide?: ChromeSide;
|
|
70
|
+
}
|
|
71
|
+
/** A square, icon-only control with a tooltip (36px by default; its icon drawn at 18px). */
|
|
72
|
+
export declare const ToolButton: import("react").ForwardRefExoticComponent<ToolButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
73
|
+
/** Classes of a chrome menu's popup. */
|
|
74
|
+
export declare const POPUP = "min-w-[128px] max-w-[320px] rounded-[14px] bg-chrome p-1.5 text-[14px] leading-5 font-control text-chrome-fg shadow-chrome-popup outline-none origin-[var(--transform-origin)] transition-[opacity,transform] duration-100 data-[starting-style]:scale-95 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0";
|
|
75
|
+
/** A chrome menu. `trigger` is rendered as the menu's trigger. */
|
|
76
|
+
export declare function ChromeMenu({ trigger, children, side, align, className, tip, open, onOpenChange, sideOffset, mark, popupBase, }: {
|
|
77
|
+
trigger: ReactElement<Record<string, unknown>>;
|
|
78
|
+
children: ReactNode;
|
|
79
|
+
side?: ChromeSide;
|
|
80
|
+
align?: 'start' | 'center' | 'end';
|
|
81
|
+
className?: string;
|
|
82
|
+
/** Tooltip of the trigger. */
|
|
83
|
+
tip?: {
|
|
84
|
+
label: ReactNode;
|
|
85
|
+
shortcut?: string;
|
|
86
|
+
side?: ChromeSide;
|
|
87
|
+
};
|
|
88
|
+
open?: boolean;
|
|
89
|
+
onOpenChange?: (open: boolean) => void;
|
|
90
|
+
/** Gap between the trigger and the popup (default 6px). */
|
|
91
|
+
sideOffset?: number;
|
|
92
|
+
/** A `data-*` attribute the popup carries. */
|
|
93
|
+
mark?: ChromeMark;
|
|
94
|
+
/** Popup classes in place of {@link POPUP}. */
|
|
95
|
+
popupBase?: string;
|
|
96
|
+
}): ReactNode;
|
|
97
|
+
/** Props of {@link ChromeMenuItem}. */
|
|
98
|
+
export interface ChromeMenuItemProps {
|
|
99
|
+
children: ReactNode;
|
|
100
|
+
/** A second, muted line under the label. */
|
|
101
|
+
description?: ReactNode;
|
|
102
|
+
/** Keep the menu open after a click (default: close). */
|
|
103
|
+
closeOnClick?: boolean;
|
|
104
|
+
onSelect?: () => void;
|
|
105
|
+
shortcut?: string;
|
|
106
|
+
/** Shows a check column; `true` draws the mark. */
|
|
107
|
+
checked?: boolean;
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
danger?: boolean;
|
|
110
|
+
icon?: ReactNode;
|
|
111
|
+
title?: string;
|
|
112
|
+
}
|
|
113
|
+
/** One menu row. */
|
|
114
|
+
export declare function ChromeMenuItem({ children, onSelect, shortcut, checked, disabled, danger, icon, title, description, closeOnClick }: ChromeMenuItemProps): ReactNode;
|
|
115
|
+
/** A submenu row and its popup. */
|
|
116
|
+
export declare function ChromeSubmenu({ label, icon, children, disabled, className, mark, popupBase, }: {
|
|
117
|
+
label: ReactNode;
|
|
118
|
+
icon?: ReactNode;
|
|
119
|
+
children: ReactNode;
|
|
120
|
+
disabled?: boolean;
|
|
121
|
+
/** Extra classes of the popup. */
|
|
122
|
+
className?: string;
|
|
123
|
+
/** A `data-*` attribute the popup carries. */
|
|
124
|
+
mark?: ChromeMark;
|
|
125
|
+
/** Popup classes in place of {@link POPUP}. */
|
|
126
|
+
popupBase?: string;
|
|
127
|
+
}): ReactNode;
|
|
128
|
+
/** A menu separator. */
|
|
129
|
+
export declare function ChromeMenuSeparator(): ReactNode;
|
|
130
|
+
/** A muted group label inside a menu. */
|
|
131
|
+
export declare function ChromeMenuLabel({ children }: {
|
|
132
|
+
children: ReactNode;
|
|
133
|
+
}): ReactNode;
|
|
134
|
+
/** Props of {@link ChromePopover}. */
|
|
135
|
+
export interface ChromePopoverProps {
|
|
136
|
+
trigger: ReactElement<Record<string, unknown>>;
|
|
137
|
+
children: ReactNode;
|
|
138
|
+
side?: ChromeSide;
|
|
139
|
+
align?: 'start' | 'center' | 'end';
|
|
140
|
+
open?: boolean;
|
|
141
|
+
onOpenChange?: (open: boolean) => void;
|
|
142
|
+
className?: string;
|
|
143
|
+
/** Accessible name of the popup. */
|
|
144
|
+
label?: string;
|
|
145
|
+
/** Element the popup is positioned against instead of the trigger. */
|
|
146
|
+
anchor?: Element | null | (() => Element | null);
|
|
147
|
+
/** Gap between the anchor and the popup (default 8px). */
|
|
148
|
+
gap?: number;
|
|
149
|
+
/** Move focus into the popup when it opens (default: true). */
|
|
150
|
+
initialFocus?: boolean;
|
|
151
|
+
/** A `data-*` attribute the popup carries. */
|
|
152
|
+
mark?: ChromeMark;
|
|
153
|
+
/** Popup classes in place of {@link POPUP}. */
|
|
154
|
+
popupBase?: string;
|
|
155
|
+
}
|
|
156
|
+
/** A floating chrome panel anchored to a trigger (or to `anchor`). */
|
|
157
|
+
export declare function ChromePopover({ trigger, children, side, align, open, onOpenChange, className, label, anchor, gap, initialFocus, mark, popupBase, }: ChromePopoverProps): ReactNode;
|
|
158
|
+
/** One color choice of a {@link SwatchRow}. */
|
|
159
|
+
export interface Swatch {
|
|
160
|
+
/** The value stored (a palette name or `#rrggbb`). */
|
|
161
|
+
name: string;
|
|
162
|
+
/** CSS color drawn. */
|
|
163
|
+
value: string;
|
|
164
|
+
label: string;
|
|
165
|
+
}
|
|
166
|
+
/** A row of round color swatches (radio semantics); the current one is ringed in the chrome accent. */
|
|
167
|
+
export declare function SwatchRow({ label, swatches, current, onPick, size, className, }: {
|
|
168
|
+
label: string;
|
|
169
|
+
swatches: readonly Swatch[];
|
|
170
|
+
current: string | undefined;
|
|
171
|
+
onPick: (name: string) => void;
|
|
172
|
+
/** Diameter of a swatch, px (its hit area is 8px larger). */
|
|
173
|
+
size?: number;
|
|
174
|
+
className?: string;
|
|
175
|
+
}): ReactNode;
|
|
176
|
+
/**
|
|
177
|
+
* Whether the Shell framing the page draws `draw` (its save state, its export formats): the page then hides its own
|
|
178
|
+
* copy, so there is one of each. False outside a Shell and for Shells older than `draws`.
|
|
179
|
+
*/
|
|
180
|
+
export declare function useShellDraw(shell: ShellConnection | null | undefined, draw: ChromeDraw): boolean;
|
package/src/chrome.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Primitives of the editor chrome (Design, Slides and Whiteboard): floating
|
|
4
|
+
* cards (12px radius, hairline ring, soft shadow), 28px / 32px / 36px ghost
|
|
5
|
+
* controls (pressed = blue-soft), icon-only tool buttons, dark tooltips with
|
|
6
|
+
* key chips, menus (14px radius, 28px rows, submenus included), popovers
|
|
7
|
+
* and color swatch rows.
|
|
8
|
+
*
|
|
9
|
+
* Menus and popovers take a `mark` (a `data-*` attribute their popup
|
|
10
|
+
* carries, e.g. so a board surface starts no gesture on it) and a
|
|
11
|
+
* `popupBase` (classes in place of {@link POPUP}) for editors whose popups
|
|
12
|
+
* look different.
|
|
13
|
+
*
|
|
14
|
+
* Styled with the editor's chrome tokens (`bg-chrome`, `text-chrome-fg`,
|
|
15
|
+
* `bg-chrome-hover`, `bg-chrome-pressed`, `text-chrome-accent`,
|
|
16
|
+
* `shadow-chrome`, `bg-tip`…); the focus ring is `outline-chrome-focus`, so
|
|
17
|
+
* each editor picks its own focus color.
|
|
18
|
+
*/
|
|
19
|
+
import { Menu as BaseMenu } from '@base-ui/react/menu';
|
|
20
|
+
import { Popover as BasePopover } from '@base-ui/react/popover';
|
|
21
|
+
import { Tooltip as BaseTooltip } from '@base-ui/react/tooltip';
|
|
22
|
+
import { Check, ChevronRight } from 'lucide-react';
|
|
23
|
+
import { forwardRef, useEffect, useState } from 'react';
|
|
24
|
+
import { cn } from '@open-artifact/ui';
|
|
25
|
+
/** A floating chrome card. */
|
|
26
|
+
export const Card = forwardRef(function Card({ className, ...rest }, ref) {
|
|
27
|
+
return _jsx("div", { ref: ref, className: cn('pointer-events-auto flex items-center gap-1 rounded-[12px] bg-chrome text-chrome-fg shadow-chrome', className), ...rest });
|
|
28
|
+
});
|
|
29
|
+
/** The 1 × 18px divider between groups of controls (`vertical: false`: a full-width 1px rule between rows). */
|
|
30
|
+
export function ChromeDivider({ className, vertical = true }) {
|
|
31
|
+
return _jsx("div", { "aria-hidden": "true", className: cn(vertical ? 'mx-0.5 h-[18px] w-px' : 'my-1 h-px w-full', 'shrink-0 bg-chrome-line', className) });
|
|
32
|
+
}
|
|
33
|
+
/** The props that put `mark` on an element. */
|
|
34
|
+
const marked = (mark) => (mark ? { [mark]: '' } : {});
|
|
35
|
+
/** A dark tooltip; the shortcut shows as a key chip. */
|
|
36
|
+
export function Tip({ label, shortcut, side = 'bottom', children, disabled, }) {
|
|
37
|
+
return (_jsxs(BaseTooltip.Root, { disabled: disabled, children: [_jsx(BaseTooltip.Trigger, { render: children }), _jsx(BaseTooltip.Portal, { children: _jsx(BaseTooltip.Positioner, { side: side, sideOffset: 8, className: "z-[1000]", children: _jsxs(BaseTooltip.Popup, { className: "flex max-w-80 items-center gap-1.5 rounded-[6px] bg-tip px-2 py-[5px] text-[13px] leading-[18px] text-tip-fg shadow-[0_1px_2px_rgb(11_11_11/0.06),0_2px_8px_rgb(11_11_11/0.08)] transition-opacity data-[ending-style]:opacity-0 data-[starting-style]:opacity-0", children: [_jsx("span", { children: label }), shortcut ? _jsx("kbd", { className: "rounded-[4px] bg-white/15 px-1 font-sans text-[12px] leading-4 text-tip-fg/80", children: shortcut }) : null] }) }) })] }));
|
|
38
|
+
}
|
|
39
|
+
/** Shares hover delays between neighbouring tooltips. */
|
|
40
|
+
export function TipGroup({ children }) {
|
|
41
|
+
return (_jsx(BaseTooltip.Provider, { delay: 400, closeDelay: 0, children: children }));
|
|
42
|
+
}
|
|
43
|
+
const HEIGHTS = { md: 'h-7', lg: 'h-8', xl: 'h-9' };
|
|
44
|
+
const WIDTHS = { md: 'w-7', lg: 'w-8', xl: 'w-9' };
|
|
45
|
+
/** A ghost control: 8px radius, 14px text, blue-soft when pressed. */
|
|
46
|
+
export const ChromeButton = forwardRef(function ChromeButton({ pressed, square, size = 'md', className, type = 'button', ...rest }, ref) {
|
|
47
|
+
return (_jsx("button", { ref: ref, type: type, "aria-pressed": pressed, className: cn('inline-flex shrink-0 select-none items-center justify-center gap-1 whitespace-nowrap rounded-[8px] text-[14px] font-control leading-5 text-chrome-fg outline-none transition-colors duration-100 ease-out', 'hover:bg-chrome-hover focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-chrome-focus', 'disabled:pointer-events-none disabled:opacity-40', HEIGHTS[size], square ? WIDTHS[size] : 'px-[9px]', pressed && 'bg-chrome-pressed text-chrome-pressed-fg hover:bg-chrome-pressed', className), ...rest }));
|
|
48
|
+
});
|
|
49
|
+
/** A {@link ChromeButton} with a tooltip that still shows while it is disabled. */
|
|
50
|
+
export const TipButton = forwardRef(function TipButton({ tip, shortcut, side, disabled, ...rest }, ref) {
|
|
51
|
+
const button = _jsx(ChromeButton, { ref: ref, disabled: disabled, ...rest });
|
|
52
|
+
// A disabled button gets no pointer events, so the tooltip hangs on a wrapper.
|
|
53
|
+
return (_jsx(Tip, { label: tip, shortcut: shortcut, side: side, children: disabled ? _jsx("span", { className: "inline-flex", children: button }) : button }));
|
|
54
|
+
});
|
|
55
|
+
/** A square, icon-only control with a tooltip (36px by default; its icon drawn at 18px). */
|
|
56
|
+
export const ToolButton = forwardRef(function ToolButton({ label, tip, icon, shortcut, tipSide = 'top', size = 'xl', className, ...rest }, ref) {
|
|
57
|
+
return (_jsx(Tip, { label: tip ?? label, shortcut: shortcut, side: tipSide, children: _jsx(ChromeButton, { ref: ref, square: true, size: size, "aria-label": label, className: cn('[&_svg]:size-[18px] [&_svg]:shrink-0', className), ...rest, children: icon }) }));
|
|
58
|
+
});
|
|
59
|
+
/* ---------------------------------- menus --------------------------------- */
|
|
60
|
+
/** Classes of a chrome menu's popup. */
|
|
61
|
+
export const POPUP = 'min-w-[128px] max-w-[320px] rounded-[14px] bg-chrome p-1.5 text-[14px] leading-5 font-control text-chrome-fg shadow-chrome-popup outline-none origin-[var(--transform-origin)] transition-[opacity,transform] duration-100 data-[starting-style]:scale-95 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0';
|
|
62
|
+
const ITEM = 'flex h-7 cursor-default select-none items-center gap-2 rounded-[8px] px-2.5 outline-none data-[highlighted]:bg-chrome-hover data-[popup-open]:bg-chrome-hover data-[disabled]:opacity-40';
|
|
63
|
+
/** A chrome menu. `trigger` is rendered as the menu's trigger. */
|
|
64
|
+
export function ChromeMenu({ trigger, children, side = 'bottom', align = 'start', className, tip, open, onOpenChange, sideOffset = 6, mark, popupBase = POPUP, }) {
|
|
65
|
+
const triggerElement = _jsx(BaseMenu.Trigger, { render: trigger });
|
|
66
|
+
return (_jsxs(BaseMenu.Root, { open: open, onOpenChange: onOpenChange ? (next) => onOpenChange(next) : undefined, children: [tip ? (_jsx(Tip, { label: tip.label, shortcut: tip.shortcut, side: tip.side ?? (side === 'top' ? 'top' : 'bottom'), children: triggerElement })) : (triggerElement), _jsx(BaseMenu.Portal, { children: _jsx(BaseMenu.Positioner, { side: side, align: align, sideOffset: sideOffset, className: "z-[1000]", children: _jsx(BaseMenu.Popup, { ...marked(mark), className: cn(popupBase, className), children: children }) }) })] }));
|
|
67
|
+
}
|
|
68
|
+
/** One menu row. */
|
|
69
|
+
export function ChromeMenuItem({ children, onSelect, shortcut, checked, disabled, danger, icon, title, description, closeOnClick }) {
|
|
70
|
+
return (_jsxs(BaseMenu.Item, { className: cn(ITEM, description !== undefined && 'h-auto min-h-7 items-start py-1.5', danger && 'text-danger data-[highlighted]:bg-danger data-[highlighted]:text-white'), disabled: disabled, onClick: onSelect, closeOnClick: closeOnClick, title: title, children: [checked !== undefined ? (_jsx("span", { className: "flex size-4 shrink-0 items-center justify-center", children: checked ? _jsx(Check, { className: "size-4 text-chrome-accent", strokeWidth: 2.25 }) : null })) : null, icon ? _jsx("span", { "data-chrome-icon": "", className: "flex size-4 shrink-0 items-center justify-center text-chrome-muted", children: icon }) : null, description !== undefined ? (_jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "truncate", children: children }), _jsx("span", { className: "truncate text-[12px] leading-4 text-chrome-muted", children: description })] })) : (_jsx("span", { className: "min-w-0 flex-1 truncate", children: children })), shortcut ? _jsx("span", { className: "ml-6 max-w-40 shrink-0 truncate text-[13px] text-chrome-muted", children: shortcut }) : null] }));
|
|
71
|
+
}
|
|
72
|
+
/** A submenu row and its popup. */
|
|
73
|
+
export function ChromeSubmenu({ label, icon, children, disabled, className, mark, popupBase = POPUP, }) {
|
|
74
|
+
return (_jsxs(BaseMenu.SubmenuRoot, { children: [_jsxs(BaseMenu.SubmenuTrigger, { className: ITEM, disabled: disabled, children: [icon ? _jsx("span", { "data-chrome-icon": "", className: "flex size-4 shrink-0 items-center justify-center text-chrome-muted", children: icon }) : null, _jsx("span", { className: "min-w-0 flex-1 truncate", children: label }), _jsx(ChevronRight, { className: "size-4 shrink-0 text-chrome-muted", strokeWidth: 1.5 })] }), _jsx(BaseMenu.Portal, { children: _jsx(BaseMenu.Positioner, { sideOffset: 4, className: "z-[1000]", children: _jsx(BaseMenu.Popup, { ...marked(mark), className: cn(popupBase, className), children: children }) }) })] }));
|
|
75
|
+
}
|
|
76
|
+
/** A menu separator. */
|
|
77
|
+
export function ChromeMenuSeparator() {
|
|
78
|
+
return _jsx(BaseMenu.Separator, { className: "mx-2.5 my-1 h-px bg-chrome-line" });
|
|
79
|
+
}
|
|
80
|
+
/** A muted group label inside a menu. */
|
|
81
|
+
export function ChromeMenuLabel({ children }) {
|
|
82
|
+
return _jsx("div", { className: "px-2.5 py-1 text-[13px] font-medium text-chrome-muted", children: children });
|
|
83
|
+
}
|
|
84
|
+
/** A floating chrome panel anchored to a trigger (or to `anchor`). */
|
|
85
|
+
export function ChromePopover({ trigger, children, side = 'top', align = 'center', open, onOpenChange, className, label, anchor, gap = 8, initialFocus = true, mark, popupBase = POPUP, }) {
|
|
86
|
+
return (_jsxs(BasePopover.Root, { open: open, onOpenChange: onOpenChange ? (next) => onOpenChange(next) : undefined, children: [_jsx(BasePopover.Trigger, { render: trigger }), _jsx(BasePopover.Portal, { children: _jsx(BasePopover.Positioner, { side: side, align: align, sideOffset: gap, anchor: anchor ?? undefined, className: "z-[1000]", children: _jsx(BasePopover.Popup, { ...marked(mark), "aria-label": label, initialFocus: initialFocus ? undefined : false, className: cn(popupBase, className), children: children }) }) })] }));
|
|
87
|
+
}
|
|
88
|
+
/** A row of round color swatches (radio semantics); the current one is ringed in the chrome accent. */
|
|
89
|
+
export function SwatchRow({ label, swatches, current, onPick, size = 20, className, }) {
|
|
90
|
+
return (_jsx("div", { role: "radiogroup", "aria-label": label, className: cn('flex items-center gap-1', className), children: swatches.map((swatch) => {
|
|
91
|
+
const on = swatch.name === current;
|
|
92
|
+
return (_jsx(Tip, { label: swatch.label, side: "top", children: _jsx("button", { type: "button", role: "radio", "aria-checked": on, "aria-label": swatch.label, onClick: () => onPick(swatch.name), className: "grid shrink-0 place-items-center rounded-full outline-none transition-shadow focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-chrome-focus", style: { width: size + 8, height: size + 8 }, children: _jsx("span", { className: cn('block rounded-full ring-1 ring-inset ring-black/10 dark:ring-white/15', on && 'ring-2 ring-chrome-accent ring-offset-2 ring-offset-chrome'), style: { width: size, height: size, background: swatch.value } }) }) }, swatch.name));
|
|
93
|
+
}) }));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether the Shell framing the page draws `draw` (its save state, its export formats): the page then hides its own
|
|
97
|
+
* copy, so there is one of each. False outside a Shell and for Shells older than `draws`.
|
|
98
|
+
*/
|
|
99
|
+
export function useShellDraw(shell, draw) {
|
|
100
|
+
const [draws, setDraws] = useState(() => shell?.draws.has(draw) ?? false);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (!shell)
|
|
103
|
+
return undefined;
|
|
104
|
+
setDraws(shell.draws.has(draw));
|
|
105
|
+
return shell.onHello((next) => setDraws(next.has(draw)));
|
|
106
|
+
}, [shell, draw]);
|
|
107
|
+
return draws;
|
|
108
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fixed under the bar the comments button is in, at the right edge; every thread newest first, open ones unless
|
|
3
|
+
* "Show resolved" is ticked in its filter menu; "Send all to {agent}" for whoever may send; a click on a row shows the
|
|
4
|
+
* thread where it is (comment mode on, its anchor in view, its card open). Each row is a flat comment card whose
|
|
5
|
+
* Resolve and ⋯ menu (Reopen, Delete thread) show while it is hovered or current.
|
|
6
|
+
*
|
|
7
|
+
* What a type supplies is only its threads and anchors (the controller); the panel is the same everywhere.
|
|
8
|
+
*/
|
|
9
|
+
import { type ReactNode } from 'react';
|
|
10
|
+
import type { CommentsController } from './comments.ts';
|
|
11
|
+
import type { AgentBadge } from './CommentViews.tsx';
|
|
12
|
+
/** The room the open panel takes at the right edge (pins' edge tabs keep clear of it). */
|
|
13
|
+
export declare const ALL_COMMENTS_RIGHT: number;
|
|
14
|
+
export interface AllCommentsProps<A> {
|
|
15
|
+
comments: CommentsController<A>;
|
|
16
|
+
agent: AgentBadge;
|
|
17
|
+
/** Where the panel starts, px from the window's top (default 12: under a Shell's bar, the frame's top). */
|
|
18
|
+
top?: number;
|
|
19
|
+
/** What the empty panel says to someone who can comment. */
|
|
20
|
+
hint?: string;
|
|
21
|
+
}
|
|
22
|
+
/** The "All comments" panel, while the comments store says it is open. */
|
|
23
|
+
export declare function AllComments<A>({ comments, agent, top, hint }: AllCommentsProps<A>): ReactNode;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* fixed under the bar the comments button is in, at the right edge; every thread newest first, open ones unless
|
|
4
|
+
* "Show resolved" is ticked in its filter menu; "Send all to {agent}" for whoever may send; a click on a row shows the
|
|
5
|
+
* thread where it is (comment mode on, its anchor in view, its card open). Each row is a flat comment card whose
|
|
6
|
+
* Resolve and ⋯ menu (Reopen, Delete thread) show while it is hovered or current.
|
|
7
|
+
*
|
|
8
|
+
* What a type supplies is only its threads and anchors (the controller); the panel is the same everywhere.
|
|
9
|
+
*/
|
|
10
|
+
import { Menu as BaseMenu } from '@base-ui/react/menu';
|
|
11
|
+
import { useId, useState } from 'react';
|
|
12
|
+
import { Button, CheckboxMark, cn, Icon, MENU_ITEM, Menu, MenuPopup, panelClass, panelVars, RobotGlyph, Tooltip, useCdsRoot } from "./cds/cds.js";
|
|
13
|
+
import { Actions, Comment, CommentCard, DeleteConfirm, MoreMenu, ResolveAction, useLayerMenu } from "./cds/comment-card.js";
|
|
14
|
+
import { CommentsLayer } from "./cds/layer.js";
|
|
15
|
+
import { commentMarkdown } from "./cds/markdown.js";
|
|
16
|
+
import { commentAgo } from "./cds/time.js";
|
|
17
|
+
/** The panel: 300px, 12px from the right edge and from the bar above it. */
|
|
18
|
+
const PANEL_WIDTH = 300;
|
|
19
|
+
const PANEL_GAP = 12;
|
|
20
|
+
/** The room the open panel takes at the right edge (pins' edge tabs keep clear of it). */
|
|
21
|
+
export const ALL_COMMENTS_RIGHT = PANEL_WIDTH + PANEL_GAP * 2;
|
|
22
|
+
/** The "All comments" panel, while the comments store says it is open. */
|
|
23
|
+
export function AllComments({ comments, agent, top = PANEL_GAP, hint }) {
|
|
24
|
+
const open = comments.store((s) => s.listOpen && s.available);
|
|
25
|
+
if (!open)
|
|
26
|
+
return null;
|
|
27
|
+
return (_jsx(CommentsLayer, { mark: "data-comments-panel-layer", children: _jsx(Panel, { comments: comments, agent: agent, top: top, hint: hint }) }));
|
|
28
|
+
}
|
|
29
|
+
const firstAt = (thread) => thread.messages[0]?.at ?? '';
|
|
30
|
+
function Panel({ comments, agent, top, hint }) {
|
|
31
|
+
const { dark } = useCdsRoot();
|
|
32
|
+
const threads = comments.store((s) => s.threads);
|
|
33
|
+
const showResolved = comments.store((s) => s.showResolved);
|
|
34
|
+
const on = comments.store((s) => s.on);
|
|
35
|
+
const active = comments.store((s) => s.active);
|
|
36
|
+
const close = () => comments.store.getState().setListOpen(false);
|
|
37
|
+
const all = threads.filter((t) => t.messages.length > 0);
|
|
38
|
+
const shown = all.filter((t) => showResolved || t.status === 'open').sort((a, b) => firstAt(b).localeCompare(firstAt(a)));
|
|
39
|
+
const resolved = all.filter((t) => t.status === 'resolved').length;
|
|
40
|
+
return (_jsxs("section", { "aria-label": "All comments", "data-comments-panel": "", className: cn(panelClass(true), 'fixed flex flex-col text-body text-primary'), style: {
|
|
41
|
+
top,
|
|
42
|
+
right: PANEL_GAP,
|
|
43
|
+
width: PANEL_WIDTH,
|
|
44
|
+
maxWidth: `calc(100vw - ${PANEL_GAP * 2}px)`,
|
|
45
|
+
maxHeight: `calc(100dvh - ${top + PANEL_GAP}px)`,
|
|
46
|
+
zIndex: 40,
|
|
47
|
+
// Over a host that lets the pointer through (a frame's comments layer), the panel still takes it.
|
|
48
|
+
pointerEvents: 'auto',
|
|
49
|
+
...panelVars(dark),
|
|
50
|
+
}, onKeyDown: (event) => {
|
|
51
|
+
// A menu's Escape (its popup is a portal, so React bubbles its keys here) closes only the menu.
|
|
52
|
+
const inMenu = event.target instanceof Element && event.target.closest('[data-cds=Menu]');
|
|
53
|
+
if (event.key === 'Escape' && !event.defaultPrevented && !inMenu) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
close();
|
|
56
|
+
}
|
|
57
|
+
}, children: [_jsxs("div", { className: "flex shrink-0 items-center gap-xs", style: { padding: '10px 10px 6px 16px' }, children: [_jsx("span", { className: "min-w-0 flex-1 truncate font-medium", children: "All comments" }), _jsx(FilterMenu, { showResolved: showResolved, onShowResolved: (next) => comments.store.getState().setShowResolved(next) }), _jsx(Button, { variant: "ghost", iconOnly: true, "aria-label": "Close", icon: _jsx(Icon, { name: "X", size: "sm" }), onClick: close })] }), _jsx(SendAll, { comments: comments, agent: agent, threads: all }), _jsxs("div", { className: "flex min-h-0 flex-col gap-xs overflow-y-auto [--cds-comment-card-bg:var(--cds-surface-2)]", style: { padding: '0 12px 12px' }, children: [all.length === 0 ? (_jsxs("div", { "data-comments-empty": "", className: "flex flex-1 flex-col items-center justify-center gap-xs px-lg text-center", style: { paddingBlock: 'var(--cds-pad-xl)' }, children: [_jsx("span", { className: "text-body font-medium text-secondary", children: "No comments yet" }), _jsx("span", { className: "text-caption text-muted", children: comments.canComment() ? (hint ?? 'Press the comment button, then click anywhere on the artifact to add one.') : 'Only people with comment access can add one.' })] })) : shown.length === 0 ? (_jsxs("span", { "data-comments-filtered-empty": "", className: "px-lg text-center text-caption text-muted", style: { paddingBlock: 'var(--cds-pad-xl)' }, children: ["No open comments.", resolved > 0 ? (_jsxs(_Fragment, { children: [' ', _jsx("button", { type: "button", className: "cds-text-link cds-text-link-underline inline text-inherit", onClick: () => comments.store.getState().setShowResolved(true), children: `Show ${resolved} resolved` })] })) : null] })) : null, shown.map((thread) => (
|
|
58
|
+
// The current row is the thread whose card is showing (out of comment mode no card shows).
|
|
59
|
+
_jsx(PanelThread, { comments: comments, agent: agent, thread: thread, current: on && active === thread.id }, thread.id)))] })] }));
|
|
60
|
+
}
|
|
61
|
+
function FilterGlyph() {
|
|
62
|
+
return (_jsx("svg", { "data-cds": "Icon", "aria-hidden": true, width: "1em", height: "1em", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.2, strokeLinecap: "round", style: { fontSize: 'calc(1rem * var(--cds-rem-scale,1))' }, children: _jsx("path", { d: "M2.5 4.5h11M4.5 8h7M6.5 11.5h3" }) }));
|
|
63
|
+
}
|
|
64
|
+
function FilterMenu({ showResolved, onShowResolved }) {
|
|
65
|
+
const [open, setOpen] = useLayerMenu();
|
|
66
|
+
return (_jsxs(Menu.Root, { open: open, onOpenChange: setOpen, modal: false, children: [_jsx(Tooltip, { content: "Filter", disabled: open, children: _jsx(Menu.Trigger, { render: _jsx(Button, { variant: "ghost", iconOnly: true, tooltip: false, "aria-label": "Filter", icon: _jsx(FilterGlyph, {}) }) }) }), _jsx(MenuPopup, { align: "end", children: _jsxs(BaseMenu.CheckboxItem, { checked: showResolved, onCheckedChange: onShowResolved, closeOnClick: false, className: cn(MENU_ITEM, 'group/cb text-primary data-[highlighted]:bg-fill-ghost-hover'), children: [_jsx(CheckboxMark, {}), _jsx("span", { className: "min-w-0 flex-1 truncate", children: "Show resolved" })] }) })] }));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* "Send all to {agent}": every open thread with something from a person the agent hasn't been handed.
|
|
70
|
+
* Shown to whoever may send once an open thread has a person's comment; right after a send, with nothing new since, it
|
|
71
|
+
* says so instead of sending again.
|
|
72
|
+
*/
|
|
73
|
+
function SendAll({ comments, agent, threads }) {
|
|
74
|
+
const [sending, setSending] = useState(false);
|
|
75
|
+
const [justSent, setJustSent] = useState(false);
|
|
76
|
+
const open = threads.filter((t) => t.status === 'open' && t.messages.some((m) => m.author.kind === 'person'));
|
|
77
|
+
if (!comments.canSendToAgent() || !agent.available || open.length === 0)
|
|
78
|
+
return null;
|
|
79
|
+
const nothingNew = !open.some((t) => comments.canSendThread(t));
|
|
80
|
+
const reason = nothingNew ? (justSent ? `These comments were just sent to ${agent.name}.` : `${agent.name} has every comment.`) : undefined;
|
|
81
|
+
return (_jsx("div", { className: "flex shrink-0 flex-col items-end gap-sm", style: { padding: '0 12px 8px' }, children: _jsx(Tooltip, { content: reason, side: "bottom", children: _jsx(Button, { "data-comments-send-all": "", "data-size": "sm", variant: "secondary", busy: sending, "aria-disabled": reason !== undefined || sending || undefined, className: "aria-disabled:opacity-disabled", onClick: () => {
|
|
82
|
+
if (reason !== undefined || sending)
|
|
83
|
+
return;
|
|
84
|
+
setSending(true);
|
|
85
|
+
void comments
|
|
86
|
+
.sendAllToAgent()
|
|
87
|
+
.then(() => setJustSent(true))
|
|
88
|
+
.finally(() => setSending(false));
|
|
89
|
+
}, children: `Send all to ${agent.name}` }) }) }));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A thread in the panel: a flat comment card. Its resolve button and ⋯ menu (Reopen, Delete thread) show while the row
|
|
93
|
+
* is hovered or current; the delete confirmation opens in the row. A click elsewhere on it, the replies line included,
|
|
94
|
+
* shows the thread where it is.
|
|
95
|
+
*/
|
|
96
|
+
function PanelThread({ comments, agent, thread, current }) {
|
|
97
|
+
const [confirming, setConfirming] = useState(false);
|
|
98
|
+
const [resolving, setResolving] = useState(false);
|
|
99
|
+
const [deleting, setDeleting] = useState(false);
|
|
100
|
+
const nameId = useId();
|
|
101
|
+
const first = thread.messages[0];
|
|
102
|
+
const replies = thread.messages.length - 1;
|
|
103
|
+
const resolved = thread.status === 'resolved';
|
|
104
|
+
const commenting = comments.canComment();
|
|
105
|
+
const author = first.author.kind === 'agent' ? first.author.name || agent.name : first.author.name || 'Someone';
|
|
106
|
+
const items = [
|
|
107
|
+
...(resolved && commenting ? [{ label: 'Reopen', icon: 'Comment', onSelect: () => void comments.resolve(thread.id, false) }] : []),
|
|
108
|
+
...(comments.canRemove() ? [{ label: 'Delete thread', icon: 'Trash', variant: 'danger', onSelect: () => setConfirming(true) }] : []),
|
|
109
|
+
];
|
|
110
|
+
return (_jsxs(CommentCard, { variant: "flat", expanded: false, active: current, labelledBy: nameId, onExpand: () => comments.show(thread), className: "rounded", children: [_jsx(Comment, { nameId: nameId, authorName: author, agent: first.author.kind === 'agent', timestamp: _jsxs(_Fragment, { children: [commentAgo(first.at), resolved && ' · Resolved', thread.agent ? (_jsx("span", { role: "img", "aria-label": `Sent to ${agent.name}`, className: "inline-flex", style: { width: 18, height: 18, marginInlineStart: 4, verticalAlign: 'middle', color: 'var(--cds-fill-brand)' }, children: _jsx(RobotGlyph, {}) })) : null] }), confirm: confirming ? (_jsx(DeleteConfirm, { busy: deleting, onCancel: () => setConfirming(false), onDelete: () => {
|
|
111
|
+
setDeleting(true);
|
|
112
|
+
void comments.remove(thread.id).finally(() => setDeleting(false));
|
|
113
|
+
} })) : undefined, actions: _jsxs(Actions, { placement: current ? 'pinned' : undefined, children: [commenting ? (_jsx(ResolveAction, { resolved: resolved, busy: resolving, onResolve: () => {
|
|
114
|
+
setResolving(true);
|
|
115
|
+
void comments.resolve(thread.id, true).finally(() => setResolving(false));
|
|
116
|
+
} })) : null, _jsx(MoreMenu, { items: items })] }), children: _jsx("span", { className: "line-clamp-3", children: commentMarkdown(first.text, { flat: true }) }) }), replies > 0 && !confirming ? (_jsx("button", { type: "button", "data-cds-part": "replies-toggle", className: "self-start text-body font-normal text-accent hover:underline", children: replies === 1 ? '1 reply' : `${replies} replies` })) : null] }));
|
|
117
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { CommentThread } from '@open-artifact/runtime';
|
|
3
|
+
import { type CommentsController } from './comments.ts';
|
|
4
|
+
import { type AnchorState, type Box, type Camera, type PinPlace, type Point } from './pins.ts';
|
|
5
|
+
export declare const COMMENT_TARGET = "#ae7303";
|
|
6
|
+
export declare const COMMENT_CURSOR: string;
|
|
7
|
+
/** The agent as comment UI shows it. */
|
|
8
|
+
export interface AgentBadge {
|
|
9
|
+
available: boolean;
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
/** A short "5m ago" style time. */
|
|
13
|
+
export declare function timeAgo(iso: string, now?: number): string;
|
|
14
|
+
export interface CommentCaptureProps<A> {
|
|
15
|
+
comments: CommentsController<A>;
|
|
16
|
+
/** Comment mode applies here now (the editor's surface is showing). */
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
/** Space is held: the surface underneath pans. */
|
|
19
|
+
panning?: boolean;
|
|
20
|
+
/** The surface's camera at this moment (read on release, so a live camera mid-glide is fine). */
|
|
21
|
+
camera(): Camera;
|
|
22
|
+
/** What lies under a world point. */
|
|
23
|
+
anchorAt(world: Point): A;
|
|
24
|
+
/** The anchor of a dragged area (world corners). */
|
|
25
|
+
areaAnchor(a: Point, b: Point): A;
|
|
26
|
+
/** The world box of an anchor: outlined under the pointer, so it shows what a click comments on. */
|
|
27
|
+
highlight?(anchor: A): Box | null;
|
|
28
|
+
/** What lies under the resting pointer (`null` once it leaves, drags or the camera moves). */
|
|
29
|
+
onHover?(anchor: A | null): void;
|
|
30
|
+
/** Changes when what lies under the pointer may have changed without it moving (e.g. an artboard finished loading). */
|
|
31
|
+
revision?: unknown;
|
|
32
|
+
}
|
|
33
|
+
/** In comment mode: clicks place threads, drags draw areas. */
|
|
34
|
+
export declare function CommentCapture<A>({ comments, enabled, panning, camera, anchorAt, areaAnchor, highlight, onHover, revision }: CommentCaptureProps<A>): ReactNode;
|
|
35
|
+
type Size = {
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
/** Where a pin goes for a point (surface px): below it, or above it when the room is there. */
|
|
40
|
+
export interface PinBox {
|
|
41
|
+
left: number;
|
|
42
|
+
top: number;
|
|
43
|
+
/** Above the point. */
|
|
44
|
+
flip: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare function pinBox(point: Point, viewport: Size): PinBox;
|
|
47
|
+
export interface CommentPopoverProps {
|
|
48
|
+
/** Beside this pin… */
|
|
49
|
+
pin?: PinBox;
|
|
50
|
+
/** …or with its top-left corner here (a page that marks its threads itself). */
|
|
51
|
+
corner?: Point;
|
|
52
|
+
/** The surface it is kept inside (px, from the layer's top-left corner). */
|
|
53
|
+
viewport: Size;
|
|
54
|
+
onEscape(): void;
|
|
55
|
+
/** A function gets the height the card may take, and the popover keeps to it. */
|
|
56
|
+
children: ReactNode | ((maxHeight: number) => ReactNode);
|
|
57
|
+
}
|
|
58
|
+
export declare function CommentPopover({ pin, corner, viewport, onEscape, children }: CommentPopoverProps): ReactNode;
|
|
59
|
+
export interface CommentPinsProps<A> {
|
|
60
|
+
comments: CommentsController<A>;
|
|
61
|
+
/** The surface's camera (pins re-place when it changes). */
|
|
62
|
+
camera: Camera;
|
|
63
|
+
/** The surface's size: pins and cards are kept inside it; pins past its edges become "More comments" tabs. */
|
|
64
|
+
viewport: Size;
|
|
65
|
+
/** Where an anchor's pin sits on the surface shown now; `null`: not here (another page, no pin, orphaned). */
|
|
66
|
+
place(anchor: A): PinPlace | null;
|
|
67
|
+
/** The world box an open thread highlights. */
|
|
68
|
+
highlight?(anchor: A): Box | null;
|
|
69
|
+
/** What lies under a world point (where a dragged pin lands); without it (and {@link onMove}) pins are not dragged. */
|
|
70
|
+
anchorAt?(world: Point): A;
|
|
71
|
+
/** Pins can be dragged to move their thread (default: when {@link anchorAt} or {@link onMove} is given). */
|
|
72
|
+
movable?: boolean;
|
|
73
|
+
/** A pin dropped at a screen point: the host moves the thread itself (instead of `comments.move(anchorAt(…))`). */
|
|
74
|
+
onMove?(id: string, screen: Point): void;
|
|
75
|
+
agent: AgentBadge;
|
|
76
|
+
/** Changes whenever pins may have moved without threads or camera changing (document edits, layout). */
|
|
77
|
+
revision?: unknown;
|
|
78
|
+
/** Pins past the surface's edges become "More comments" tabs at that edge (default: on). */
|
|
79
|
+
piles?: boolean;
|
|
80
|
+
/** Bars over the surface's edges (px): a toolbar at its top or its bottom, which the tabs keep clear of. */
|
|
81
|
+
insets?: {
|
|
82
|
+
top?: number;
|
|
83
|
+
bottom?: number;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export declare function CommentPins<A>({ comments, camera, viewport, place, highlight, anchorAt, movable, onMove, agent, revision, piles, insets }: CommentPinsProps<A>): ReactNode;
|
|
87
|
+
export interface ThreadCardProps<A> {
|
|
88
|
+
comments: CommentsController<A>;
|
|
89
|
+
agent: AgentBadge;
|
|
90
|
+
thread: CommentThread;
|
|
91
|
+
/** How its anchor resolves (default: asked of the controller); a note under the first comment says what changed. */
|
|
92
|
+
state?: AnchorState;
|
|
93
|
+
/** The comments scroll past this height; the reply box stays under them. */
|
|
94
|
+
maxHeight?: number;
|
|
95
|
+
/** The close button (default: closes the card). */
|
|
96
|
+
onClose?(): void;
|
|
97
|
+
}
|
|
98
|
+
export declare function ThreadCard<A>(props: ThreadCardProps<A>): ReactNode;
|
|
99
|
+
export interface CommentComposerProps<A> {
|
|
100
|
+
comments: CommentsController<A>;
|
|
101
|
+
agent: AgentBadge;
|
|
102
|
+
/** What the new thread is on. */
|
|
103
|
+
anchor: A;
|
|
104
|
+
/** Escape and Cancel (default: drops the draft). */
|
|
105
|
+
onCancel?(): void;
|
|
106
|
+
}
|
|
107
|
+
export declare function CommentComposer<A>(props: CommentComposerProps<A>): ReactNode;
|
|
108
|
+
export interface CommentsButtonProps<A> {
|
|
109
|
+
comments: CommentsController<A>;
|
|
110
|
+
/** The comment-mode key its tooltip names (default C). */
|
|
111
|
+
shortcut?: string;
|
|
112
|
+
/** The tooltips' side (default: below, for a bar at the top). */
|
|
113
|
+
side?: 'top' | 'bottom';
|
|
114
|
+
}
|
|
115
|
+
export declare function CommentsButton<A>({ comments, shortcut, side }: CommentsButtonProps<A>): ReactNode;
|
|
116
|
+
export {};
|