@crewlethq/ui 0.129.0 → 0.130.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.
@@ -63,6 +63,8 @@
63
63
  * or zoomed, a resize keeps their view and only keeps the content
64
64
  * reachable. It is opt in because a screen that chooses its own views
65
65
  * after a fit (a chart held at a legible zoom) decides its own refits.
66
+ * The same "untouched" is what `restoreView` asks: a fit it gives back is
67
+ * the fit of the content as it stands then, never the old fit's transform.
66
68
  * - MOTION ONLY ON REQUEST. A fit, a zoom button or a reveal eases; a drag, a
67
69
  * pinch, a wheel and a relayout anchor never do, and under reduced motion
68
70
  * nothing does. An easing lasts as long as its transition: a clamp that
@@ -102,8 +104,18 @@ export interface CanvasHandle {
102
104
  zoomBy(factor: number): void;
103
105
  /** Zoom about the viewport centre to one scale, 1 being actual size, within the limits. */
104
106
  zoomTo(scale: number): void;
105
- /** Pan the least distance that brings a world rectangle into view. */
106
- reveal(target: CanvasRect): void;
107
+ /**
108
+ * Pan the least distance that brings a world rectangle into view, clear of
109
+ * the end bar, as a fit is (see [CanvasProps.overlayEnd]).
110
+ *
111
+ * `outside` is where a rectangle lying WHOLLY outside the view is brought:
112
+ * `edge`, the default, just inside the nearest edge, for a reader stepping
113
+ * to the next item; `centre`, the middle of the view at the same zoom, for a
114
+ * reader SENT to an item somewhere else, and that move travels rather than
115
+ * corrects. A rectangle partly in view moves the least distance either way.
116
+ * See [revealView].
117
+ */
118
+ reveal(target: CanvasRect, outside?: 'edge' | 'centre'): void;
107
119
  /** Keep a node still on screen across a relayout: see `anchorView`. */
108
120
  anchor(before: CanvasPoint, after: CanvasPoint): void;
109
121
  /**
@@ -138,7 +150,18 @@ export interface CanvasHandle {
138
150
  * Calling it twice keeps the first view, as [focusRegion] does.
139
151
  */
140
152
  rememberView(): void;
141
- /** Ease back to the view [focusRegion] left, if it has not been given back already. */
153
+ /**
154
+ * Ease back to the view [focusRegion] or [rememberView] left, if it has not
155
+ * been given back already.
156
+ *
157
+ * A FIT IS GIVEN BACK AS A FIT. Where the view left was the untouched fit (a
158
+ * fit nobody has moved since, as `refitOnResize` counts one), what comes
159
+ * back is the fit of the content as it stands NOW rather than the old fit's
160
+ * zoom and pan: a fit says "all of the content", and a surface that changed
161
+ * the content while it was open (a node added in it, a branch opened for
162
+ * it) and gave back the old transform cut the new content off at the edges.
163
+ * A view the reader moved is theirs, and comes back exactly.
164
+ */
142
165
  restoreView(): void;
143
166
  /** A world rectangle in viewport coordinates, for positioning an overlay. */
144
167
  screenRect(target: CanvasRect): CanvasRect;
@@ -25,7 +25,9 @@
25
25
  * fit even at the smallest zoom it aligns to the TOP, where a tree's root
26
26
  * is, rather than centring the root off screen.
27
27
  * - A REVEAL MOVES AS LITTLE AS IT CAN: nothing when the target is already in
28
- * view, otherwise just enough to bring it inside the padding.
28
+ * view, otherwise just enough to bring it inside the padding. The one
29
+ * exception is asked for by name: a target a reader is SENT to that none of
30
+ * the view shows is drawn in its middle (see [revealView]).
29
31
  */
30
32
  export interface CanvasPoint {
31
33
  x: number;
@@ -189,8 +191,20 @@ export declare function clampPan(view: CanvasView, content: CanvasRect, viewport
189
191
  * screens wide, and a fit that stops at a quarter clips it on every side.
190
192
  */
191
193
  export declare function fitView(content: CanvasRect, viewport: CanvasSize, padding?: number, floor?: number): CanvasView;
192
- /** The smallest pan that brings world rectangle `target` inside the padded viewport. */
193
- export declare function revealView(view: CanvasView, target: CanvasRect, viewport: CanvasSize, padding?: number): CanvasView;
194
+ /**
195
+ * The smallest pan that brings world rectangle `target` inside the padded
196
+ * viewport, at the same zoom.
197
+ *
198
+ * `outside` is where a target lying WHOLLY outside the viewport is brought.
199
+ * `edge`, the default, is the least pan, which leaves it just inside the edge
200
+ * it came in by: right for a reader stepping to the next item, which is
201
+ * beside the one before. `centre` draws its middle on the viewport's middle:
202
+ * for a reader SENT to an item somewhere else (after an operation, an undo or
203
+ * a search), whom the least pan left against the edge with nothing of the
204
+ * content around it on that side. A target partly in view moves the least
205
+ * distance either way, and one in view does not move.
206
+ */
207
+ export declare function revealView(view: CanvasView, target: CanvasRect, viewport: CanvasSize, padding?: number, outside?: 'edge' | 'centre'): CanvasView;
194
208
  /**
195
209
  * The view that draws world point `after` where `before` was drawn.
196
210
  *
@@ -1,4 +1,4 @@
1
- export { CANVAS_COMPOSE_CONTEXT, CANVAS_FIT_MAX_ZOOM, CANVAS_FIT_PADDING, CANVAS_FOCUS_CONTEXT, CANVAS_MAX_ZOOM, CANVAS_MIN_ZOOM, CANVAS_PAN_MARGIN, CANVAS_PAN_STEP, CANVAS_REVEAL_PADDING, CANVAS_TAP_SLOP, CANVAS_WHEEL_LINE_PX, CANVAS_WHEEL_ZOOM_PER_PIXEL, CANVAS_ZOOM_CEILING, CANVAS_ZOOM_LIMITS, CANVAS_ZOOM_STEP, Canvas, IDENTITY_VIEW, ShortcutTip, anchorView, beyondSlop, clampPan, clampZoom, fitView, gridOf, panBy, pinchView, regionView, revealView, screenRect, toScreen, toWorld, wheelPixels, wheelZoomFactor, zoomAt, zoomLimits } from '../chunk-ELZSD6FJ.js';
1
+ export { CANVAS_COMPOSE_CONTEXT, CANVAS_FIT_MAX_ZOOM, CANVAS_FIT_PADDING, CANVAS_FOCUS_CONTEXT, CANVAS_MAX_ZOOM, CANVAS_MIN_ZOOM, CANVAS_PAN_MARGIN, CANVAS_PAN_STEP, CANVAS_REVEAL_PADDING, CANVAS_TAP_SLOP, CANVAS_WHEEL_LINE_PX, CANVAS_WHEEL_ZOOM_PER_PIXEL, CANVAS_ZOOM_CEILING, CANVAS_ZOOM_LIMITS, CANVAS_ZOOM_STEP, Canvas, IDENTITY_VIEW, ShortcutTip, anchorView, beyondSlop, clampPan, clampZoom, fitView, gridOf, panBy, pinchView, regionView, revealView, screenRect, toScreen, toWorld, wheelPixels, wheelZoomFactor, zoomAt, zoomLimits } from '../chunk-MNVIIZQP.js';
2
2
  import '../chunk-X4HBZSXA.js';
3
3
  import '../chunk-VBBLHS2Y.js';
4
4
  import '../chunk-M2M6ZD7P.js';
@@ -1,8 +1,8 @@
1
- export { BOARD_NAME_MIN_CHARS, CANVAS_BOARD_MAX_LIVE, CANVAS_BOARD_MIN_LIVE_WIDTH, CANVAS_BOARD_MIN_ZOOM, CANVAS_NOTE_COLORS, CanvasBoard, TITLE_GLYPH_EM, boardName, boardRoom, liveBoards, titleSize } from '../chunk-NNMI7FAI.js';
1
+ export { BOARD_NAME_MIN_CHARS, CANVAS_BOARD_MAX_LIVE, CANVAS_BOARD_MIN_LIVE_WIDTH, CANVAS_BOARD_MIN_ZOOM, CANVAS_NOTE_COLORS, CanvasBoard, TITLE_GLYPH_EM, boardName, boardRoom, liveBoards, titleSize } from '../chunk-QM2QFKIA.js';
2
2
  import '../chunk-YJPQJVRJ.js';
3
- import '../chunk-N47PA4V4.js';
3
+ import '../chunk-AKCIF6XN.js';
4
4
  import '../chunk-NPEI2QAN.js';
5
- import '../chunk-ELZSD6FJ.js';
5
+ import '../chunk-MNVIIZQP.js';
6
6
  import '../chunk-X4HBZSXA.js';
7
7
  import '../chunk-VBBLHS2Y.js';
8
8
  import '../chunk-M2M6ZD7P.js';
@@ -1,6 +1,6 @@
1
- export { CanvasToolbar, toolForKey } from '../chunk-N47PA4V4.js';
1
+ export { CanvasToolbar, toolForKey } from '../chunk-AKCIF6XN.js';
2
2
  import '../chunk-NPEI2QAN.js';
3
- import '../chunk-ELZSD6FJ.js';
3
+ import '../chunk-MNVIIZQP.js';
4
4
  import '../chunk-X4HBZSXA.js';
5
5
  import '../chunk-VBBLHS2Y.js';
6
6
  import '../chunk-M2M6ZD7P.js';
@@ -14,6 +14,17 @@ export interface CommentThreadComment {
14
14
  editedAt?: TimeValue | undefined;
15
15
  /** The id of the remark this one answers. */
16
16
  replyTo?: string | undefined;
17
+ /** The remark's own words as its author wrote them (its markdown), which an edit starts from. */
18
+ source?: string | undefined;
19
+ /** The reader may rewrite this remark, which is theirs. Offered only with `onEdit` and a `source`. */
20
+ editable?: boolean | undefined;
21
+ /** The reader may take this remark down. Offered only with `onRemove`. */
22
+ removable?: boolean | undefined;
23
+ /**
24
+ * Taken down: its words are gone. It keeps its place, author and time, so a
25
+ * reply to it still reads in order, and offers nothing.
26
+ */
27
+ removed?: boolean | undefined;
17
28
  }
18
29
  /**
19
30
  * What a submit answers. `false` keeps the draft and the reply target, for a
@@ -39,6 +50,23 @@ export interface CommentThreadLabels {
39
50
  submitReply: string;
40
51
  /** Why the submit control waits while the field is empty. */
41
52
  emptyDraft: string;
53
+ /** Edit on one of the reader's own remarks, and its accessible name. */
54
+ edit: string;
55
+ editOwn: string;
56
+ /** The field an edit is made in. */
57
+ editField: string;
58
+ save: string;
59
+ cancel: string;
60
+ /** Why Save waits while the edited words are empty: an empty remark is taken down instead. */
61
+ emptyEdit: string;
62
+ /** Delete on a remark, its accessible name, and the question it asks before it acts. */
63
+ remove: string;
64
+ removeOwn: (name: string) => string;
65
+ removeAsk: string;
66
+ removeConfirm: string;
67
+ keep: string;
68
+ /** What a remark that was taken down reads as. */
69
+ removed: string;
42
70
  }
43
71
  export declare const COMMENT_THREAD_LABELS: CommentThreadLabels;
44
72
  export interface CommentThreadProps {
@@ -55,6 +83,18 @@ export interface CommentThreadProps {
55
83
  disabledReason?: string | undefined;
56
84
  /** A post in flight that the host is tracking. The thread also tracks its own. */
57
85
  busy?: boolean | undefined;
86
+ /**
87
+ * Rewrites one of the reader's own remarks (`editable`, with its `source`).
88
+ * Without it no remark offers Edit. Resolve to `false` to keep the editor
89
+ * open with what was typed, such as when the server refused the write.
90
+ */
91
+ onEdit?: ((comment: CommentThreadComment, body: string) => CommentThreadSubmitResult | Promise<CommentThreadSubmitResult>) | undefined;
92
+ /**
93
+ * Takes a remark down (`removable`), once the reader has confirmed it in
94
+ * place. Without it no remark offers Delete. Resolve to `false` to keep the
95
+ * question open, such as when the server refused the write.
96
+ */
97
+ onRemove?: ((comment: CommentThreadComment) => CommentThreadSubmitResult | Promise<CommentThreadSubmitResult>) | undefined;
58
98
  /** A line beside the submit control: who is told, how the remark is shared. */
59
99
  hint?: ReactNode;
60
100
  /** Under the field: the server's refusal of the last post, as the host words it. */
@@ -81,5 +121,12 @@ export interface CommentThreadProps {
81
121
  * A SUBMIT IS ONE AT A TIME. The submit control is disabled while a post is in
82
122
  * flight, so a second press cannot send the same remark twice, and the draft
83
123
  * is cleared only once the host says the post landed.
124
+ *
125
+ * THE READER'S OWN REMARKS ARE EDITED AND TAKEN DOWN IN PLACE. Edit swaps the
126
+ * remark's words for a field holding what was written (`source`), saved or
127
+ * left with Cancel; Delete asks in place before it acts, since the words go
128
+ * for everybody. Which remarks offer either is the host's to say (`editable`,
129
+ * `removable`): who may is the server's rule. A remark taken down keeps its
130
+ * row, so a reply to it still reads in order.
84
131
  */
85
- export declare function CommentThread({ comments, subject, onSubmit, disabledReason, busy, hint, notice, heading, now, labels: overrides, className, }: CommentThreadProps): import("react").JSX.Element;
132
+ export declare function CommentThread({ comments, subject, onSubmit, onEdit, onRemove, disabledReason, busy, hint, notice, heading, now, labels: overrides, className, }: CommentThreadProps): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
- export { COMMENT_THREAD_LABELS, CommentThread } from '../chunk-BF3PFRBE.js';
1
+ export { COMMENT_THREAD_LABELS, CommentThread } from '../chunk-WLCPN22T.js';
2
2
  import '../chunk-HF5L56YQ.js';
3
3
  import '../chunk-GBKBME7Q.js';
4
4
  import '../chunk-WGLOH33S.js';
@@ -73,14 +73,38 @@
73
73
  font-size: var(--font-size-xs);
74
74
  }
75
75
 
76
- /* Reply sits at the row's far end, wherever the head wraps, its padding and
77
- edge pulled out as a card foot's ghost is (StatusCard.css), so the word ends
78
- on the line the hairline under the remark ends on rather than 9px inside. */
79
- .crewlet-comment-thread__reply {
76
+ /* The remark's controls (Edit, Delete, Reply) sit at the row's far end,
77
+ wherever the head wraps, the last one's padding and edge pulled out as a
78
+ card foot's ghost is (StatusCard.css), so the word ends on the line the
79
+ hairline under the remark ends on rather than 9px inside. */
80
+ .crewlet-comment-thread__actions {
81
+ display: inline-flex;
82
+ align-items: center;
83
+ gap: var(--spacing-1);
80
84
  margin-inline-start: auto;
81
85
  margin-inline-end: calc(-1 * (var(--spacing-2) + 1px));
82
86
  }
83
87
 
88
+ .crewlet-comment-thread__removed {
89
+ margin: 0;
90
+ color: var(--color-text-tertiary);
91
+ font-size: var(--font-size-compact);
92
+ font-style: italic;
93
+ }
94
+
95
+ .crewlet-comment-thread__confirm {
96
+ display: flex;
97
+ flex-wrap: wrap;
98
+ align-items: center;
99
+ gap: var(--spacing-2);
100
+ color: var(--color-text-secondary);
101
+ font-size: var(--font-size-compact);
102
+ }
103
+
104
+ .crewlet-comment-thread__confirm > span {
105
+ margin-inline-end: auto;
106
+ }
107
+
84
108
  .crewlet-comment-thread__compose {
85
109
  display: flex;
86
110
  flex-direction: column;
@@ -1,6 +1,6 @@
1
- export { ContrastBadge, ContrastLevelTag, contrastLevel, contrastRatio, formatContrastRatio } from '../chunk-3YOLD7WG.js';
2
- import '../chunk-7W3LYIOC.js';
1
+ export { ContrastBadge, ContrastLevelTag, contrastLevel, contrastRatio, formatContrastRatio } from '../chunk-F7NHMBGJ.js';
3
2
  import '../chunk-SJ3EUCFD.js';
3
+ import '../chunk-7W3LYIOC.js';
4
4
  import '../chunk-QRE6JCHS.js';
5
5
  import '../chunk-RRRK2KB6.js';
6
6
  import '../chunk-ODEQTPFM.js';
@@ -1,8 +1,8 @@
1
- export { ContrastHelp } from '../chunk-SIL5WE55.js';
2
- import '../chunk-3YOLD7WG.js';
3
- import '../chunk-7W3LYIOC.js';
1
+ export { ContrastHelp } from '../chunk-LPQF7Z44.js';
2
+ import '../chunk-F7NHMBGJ.js';
4
3
  import '../chunk-SJ3EUCFD.js';
5
4
  import '../chunk-KDRJZWE3.js';
5
+ import '../chunk-7W3LYIOC.js';
6
6
  import '../chunk-QRE6JCHS.js';
7
7
  import '../chunk-X5YI6E5X.js';
8
8
  import '../chunk-TDFLCUBE.js';
@@ -7,8 +7,8 @@ import '../chunk-VSD3536L.js';
7
7
  import '../chunk-KW7T23RT.js';
8
8
  import '../chunk-STJ7QBC3.js';
9
9
  import '../chunk-DTIW4CHZ.js';
10
- import '../chunk-NPEI2QAN.js';
11
10
  import '../chunk-EE3DJMSQ.js';
11
+ import '../chunk-NPEI2QAN.js';
12
12
  import '../chunk-KDRJZWE3.js';
13
13
  import '../chunk-GBKBME7Q.js';
14
14
  import '../chunk-WGLOH33S.js';
@@ -1,8 +1,8 @@
1
- export { GRAPH_CANVAS_DETAIL_ZOOM, GRAPH_CANVAS_FIT_FLOOR, GRAPH_CANVAS_FLOW_LIMIT, GRAPH_CANVAS_FOCUS_ZOOM, GRAPH_CANVAS_LABELS, GRAPH_CANVAS_NARROW_WIDTH, GRAPH_CANVAS_TILE_ZOOM, GRAPH_EDGE_FAMILIES, GRAPH_ORDER_SWEEPS, GraphCanvas, graphDetail, graphFocusView, graphItemKey, graphNeighbourhood, graphReach, graphStep, graphTrunks, graphWindow, layoutGraph, placeTrunkLabels, routeGraphEdges } from '../chunk-UGEFJGJ7.js';
1
+ export { GRAPH_CANVAS_DETAIL_ZOOM, GRAPH_CANVAS_FIT_FLOOR, GRAPH_CANVAS_FLOW_LIMIT, GRAPH_CANVAS_FOCUS_ZOOM, GRAPH_CANVAS_LABELS, GRAPH_CANVAS_NARROW_WIDTH, GRAPH_CANVAS_TILE_ZOOM, GRAPH_EDGE_FAMILIES, GRAPH_ORDER_SWEEPS, GraphCanvas, graphDetail, graphFocusView, graphItemKey, graphNeighbourhood, graphReach, graphStep, graphTrunks, graphWindow, layoutGraph, placeTrunkLabels, routeGraphEdges } from '../chunk-2AKVGQ73.js';
2
2
  import '../chunk-MY374UUD.js';
3
3
  import '../chunk-3JLG6KRU.js';
4
4
  import '../chunk-L6HUVA33.js';
5
- import '../chunk-ELZSD6FJ.js';
5
+ import '../chunk-MNVIIZQP.js';
6
6
  import '../chunk-X4HBZSXA.js';
7
7
  import '../chunk-475DOAWF.js';
8
8
  import '../chunk-WSIJDWUG.js';
@@ -1,8 +1,8 @@
1
- export { LogoSlot, LogoSlotGroup } from '../chunk-4Q7AWZ6O.js';
1
+ export { LogoSlot, LogoSlotGroup } from '../chunk-OIC6S5ES.js';
2
2
  import '../chunk-XF5PDUDH.js';
3
- import '../chunk-3YOLD7WG.js';
4
- import '../chunk-7W3LYIOC.js';
3
+ import '../chunk-F7NHMBGJ.js';
5
4
  import '../chunk-SJ3EUCFD.js';
5
+ import '../chunk-7W3LYIOC.js';
6
6
  import '../chunk-QRE6JCHS.js';
7
7
  import '../chunk-M2M6ZD7P.js';
8
8
  import '../chunk-XSPCITPN.js';
@@ -167,6 +167,19 @@ export interface TreeCardContext {
167
167
  * that promised these there would be a promise kept by doing nothing.
168
168
  */
169
169
  export interface TreeCanvasHandle extends TreeViewHandle {
170
+ /**
171
+ * Open every collapsed ancestor of a node, focus it, and bring it into view.
172
+ *
173
+ * A CALLER SENDING FOCUS IS SENDING THE READER SOMEWHERE: to the node an
174
+ * operation made or moved, to the one an undo or a search names. So a node
175
+ * that the view does not show at all is brought to the MIDDLE of the view,
176
+ * at the reader's zoom, with the chart around it on every side; the least
177
+ * pan left it against the edge it came in by, which after an add was the
178
+ * edge of the pane with nothing of the chart beyond it. A node partly in
179
+ * view moves the least distance, and one in view does not move. The tree's
180
+ * own arrow keys keep the least pan: a step lands beside the node before.
181
+ */
182
+ focusNode(id: string): void;
170
183
  /**
171
184
  * Ease onto one node's own card, remembering the view it left.
172
185
  *
@@ -202,9 +215,19 @@ export interface TreeCanvasHandle extends TreeViewHandle {
202
215
  * WHAT THE CHART DOES ABOUT IT. It opens `parent` if it is closed, eases onto
203
216
  * the ghost with the room a form needs rather than the room a label needs
204
217
  * ([CANVAS_COMPOSE_CONTEXT]), moves focus to the first control inside it, and
205
- * on Escape calls `onCancel`. When it goes, the view the reader left is given
206
- * back and focus returns to `parent`. Under `prefers-reduced-motion` every
218
+ * on Escape calls `onCancel`. When it goes, focus returns to `parent` and the
219
+ * view the reader left is given back. Under `prefers-reduced-motion` every
207
220
  * part of that still happens; only the animations do not.
221
+ *
222
+ * THE VIEW COMES BACK ON THE CHART THE COMPOSITION LEFT. An add ends with the
223
+ * node it made in `nodes` and the ghost gone, in one commit, and the new card
224
+ * is measured a frame later; the view is given back on the first layout that
225
+ * places it, not on the ghost's. A reader who had not moved the fit gets the
226
+ * fit of the chart as it now stands, with the new node and anything the
227
+ * composition opened for it inside; a reader who had moved the view gets it
228
+ * back exactly. A caller that then sends focus to the node it made
229
+ * (`focusNode`, as it does after any operation) has it brought to the middle
230
+ * of that view when the view does not show it.
208
231
  */
209
232
  export interface TreeComposing {
210
233
  /**
@@ -1,6 +1,6 @@
1
- export { TREE_ADD_MARK_MIN_ZOOM, TreeCanvas } from '../chunk-R7PMTSQD.js';
1
+ export { TREE_ADD_MARK_MIN_ZOOM, TreeCanvas } from '../chunk-Q4JX6UO7.js';
2
2
  import '../chunk-MY374UUD.js';
3
- import '../chunk-ELZSD6FJ.js';
3
+ import '../chunk-MNVIIZQP.js';
4
4
  import '../chunk-X4HBZSXA.js';
5
5
  import '../chunk-SK4BIFTG.js';
6
6
  import '../chunk-COS6LJ4K.js';
@@ -1,7 +1,7 @@
1
1
  import { useMeasuredSizes, isTypeAheadKey, typeAheadBuffer } from './chunk-MY374UUD.js';
2
2
  import { FullscreenToggle } from './chunk-3JLG6KRU.js';
3
3
  import { FilterChip } from './chunk-L6HUVA33.js';
4
- import { CANVAS_FIT_PADDING, Canvas } from './chunk-ELZSD6FJ.js';
4
+ import { CANVAS_FIT_PADDING, Canvas } from './chunk-MNVIIZQP.js';
5
5
  import { Text } from './chunk-475DOAWF.js';
6
6
  import { LayerHost } from './chunk-FIX72ZEC.js';
7
7
  import { VisuallyHidden } from './chunk-RRRK2KB6.js';
@@ -1,5 +1,5 @@
1
1
  import { Toolbar } from './chunk-NPEI2QAN.js';
2
- import { ShortcutTip } from './chunk-ELZSD6FJ.js';
2
+ import { ShortcutTip } from './chunk-MNVIIZQP.js';
3
3
  import { IconButton } from './chunk-X5YI6E5X.js';
4
4
  import { cx } from './chunk-ODEQTPFM.js';
5
5
  import './CanvasToolbar-EM5EVZED.css';
@@ -1,4 +1,4 @@
1
- import { ContrastLevelTag } from './chunk-3YOLD7WG.js';
1
+ import { ContrastLevelTag } from './chunk-F7NHMBGJ.js';
2
2
  import { Popover } from './chunk-KDRJZWE3.js';
3
3
  import { IconButton } from './chunk-X5YI6E5X.js';
4
4
  import { cx } from './chunk-ODEQTPFM.js';
@@ -102,12 +102,15 @@ function fitView(content, viewport, padding = CANVAS_FIT_PADDING, floor = CANVAS
102
102
  const y = drawnHeight <= roomY ? (viewport.height - drawnHeight) / 2 - content.y * k : padding - content.y * k;
103
103
  return { x, y, k };
104
104
  }
105
- function revealView(view, target, viewport, padding = CANVAS_REVEAL_PADDING) {
105
+ function revealView(view, target, viewport, padding = CANVAS_REVEAL_PADDING, outside = "edge") {
106
106
  const drawn = screenRect(view, target);
107
+ const off = (start, length, room) => start + length <= 0 || start >= room;
108
+ const centre = outside === "centre" && (off(drawn.x, drawn.width, viewport.width) || off(drawn.y, drawn.height, viewport.height));
107
109
  const axis = (offset, start, length, room) => {
108
110
  const low = padding;
109
111
  const high = room - padding;
110
112
  if (length > high - low) return offset + (low - start);
113
+ if (centre) return offset + (room / 2 - (start + length / 2));
111
114
  if (start < low) return offset + (low - start);
112
115
  if (start + length > high) return offset - (start + length - high);
113
116
  return offset;
@@ -311,9 +314,8 @@ function Canvas({
311
314
  if (!ready) return;
312
315
  const resized = sizeSeen.current.width !== size.width || sizeSeen.current.height !== size.height;
313
316
  sizeSeen.current = size;
314
- const was = fitted.current;
315
317
  const now = viewNow.current;
316
- const untouched = was !== null && was.x === now.x && was.y === now.y && was.k === now.k;
318
+ const untouched = sameView(fitted.current, now);
317
319
  if (refitOnResize && resized && untouched && content) {
318
320
  apply(fitOf(content), false);
319
321
  fitted.current = viewNow.current;
@@ -355,28 +357,43 @@ function Canvas({
355
357
  const factor = scale / viewNow.current.k;
356
358
  apply(zoomAt(viewNow.current, factor, { x: width / 2, y: height / 2 }, limitsNow.current), "near");
357
359
  },
358
- reveal: (target) => {
359
- const next = revealView(viewNow.current, target, sizeNow.current);
360
- if (next.x !== viewNow.current.x || next.y !== viewNow.current.y) apply(next, "near");
360
+ reveal: (target, outside = "edge") => {
361
+ const { top, bottom } = bandNow.current;
362
+ const room2 = { width: sizeNow.current.width, height: Math.max(0, sizeNow.current.height - top - bottom) };
363
+ const now = viewNow.current;
364
+ const inRoom = (how) => {
365
+ const next2 = revealView({ ...now, y: now.y - top }, target, room2, CANVAS_REVEAL_PADDING, how);
366
+ return { ...next2, y: next2.y + top };
367
+ };
368
+ const least = inRoom("edge");
369
+ const next = outside === "edge" ? least : inRoom(outside);
370
+ if (next.x === now.x && next.y === now.y) return;
371
+ apply(next, next.x === least.x && next.y === least.y ? "near" : "travel");
361
372
  },
362
373
  anchor: (before, after) => apply(anchorView(viewNow.current, before, after), false),
363
374
  rememberView: () => {
364
- left.current ??= viewNow.current;
375
+ left.current ??= { view: viewNow.current, fit: sameView(fitted.current, viewNow.current) };
365
376
  },
366
377
  focusRegion: (target, context, ceiling) => {
367
- left.current ??= viewNow.current;
378
+ left.current ??= { view: viewNow.current, fit: sameView(fitted.current, viewNow.current) };
368
379
  apply(regionView(target, sizeNow.current, limitsNow.current, context, ceiling), "travel");
369
380
  },
370
381
  restoreView: () => {
371
382
  const was = left.current;
372
383
  if (!was) return;
373
384
  left.current = null;
374
- apply(was, "travel");
385
+ const bounds = contentNow.current;
386
+ if (was.fit && bounds) {
387
+ apply(fitOf(bounds), "travel");
388
+ fitted.current = viewNow.current;
389
+ return;
390
+ }
391
+ apply(was.view, "travel");
375
392
  },
376
393
  screenRect: (target) => screenRect(viewNow.current, target),
377
394
  worldAt: (client) => toWorld(viewNow.current, local({ clientX: client.x, clientY: client.y }))
378
395
  }),
379
- [apply, fitNow, local]
396
+ [apply, fitNow, fitOf, local]
380
397
  );
381
398
  useEffect(() => {
382
399
  const el = viewport.current;
@@ -679,6 +696,9 @@ function Canvas({
679
696
  }
680
697
  );
681
698
  }
699
+ function sameView(fit, view) {
700
+ return fit !== null && fit.x === view.x && fit.y === view.y && fit.k === view.k;
701
+ }
682
702
  function gridOf(view) {
683
703
  const k = view.k > 0 && Number.isFinite(view.k) ? view.k : 1;
684
704
  return { scale: k * 2 ** -Math.floor(Math.log2(k)), x: view.x, y: view.y };
@@ -1,5 +1,5 @@
1
1
  import { FileDrop, FilePickButton } from './chunk-XF5PDUDH.js';
2
- import { contrastRatio } from './chunk-3YOLD7WG.js';
2
+ import { contrastRatio } from './chunk-F7NHMBGJ.js';
3
3
  import { normalizeHex } from './chunk-7W3LYIOC.js';
4
4
  import { Button } from './chunk-M2M6ZD7P.js';
5
5
  import { VisuallyHidden } from './chunk-RRRK2KB6.js';
@@ -1,5 +1,5 @@
1
1
  import { useTreeState, useMeasuredSizes, layoutForest, treeAncestors, useLayoutAnchor, treeExpandable, layoutConnectors, treeItemAction, treeStep, treePosInSet, treeSetSize, treeLevel, placeGroups } from './chunk-MY374UUD.js';
2
- import { CANVAS_COMPOSE_CONTEXT, CANVAS_FIT_MAX_ZOOM, Canvas } from './chunk-ELZSD6FJ.js';
2
+ import { CANVAS_COMPOSE_CONTEXT, CANVAS_FIT_MAX_ZOOM, Canvas } from './chunk-MNVIIZQP.js';
3
3
  import { useMediaMatch, REDUCED_MOTION_QUERY } from './chunk-COS6LJ4K.js';
4
4
  import { focusables } from './chunk-EDPMHSLZ.js';
5
5
  import { cx } from './chunk-ODEQTPFM.js';
@@ -146,6 +146,8 @@ function TreeCanvas({
146
146
  const composeParent = composing?.parent ?? null;
147
147
  const eased = useRef(null);
148
148
  const returnTo = useRef(null);
149
+ const remembered = useRef(false);
150
+ const restoring = useRef(false);
149
151
  const takeFocus = useRef(false);
150
152
  const composeEl = useRef(null);
151
153
  const { measure, sizes, measured } = useMeasuredSizes();
@@ -239,6 +241,19 @@ function TreeCanvas({
239
241
  useLayoutEffect(() => {
240
242
  shownPositions.current = positions;
241
243
  }, [positions]);
244
+ useLayoutEffect(() => {
245
+ if (composeId !== null) {
246
+ restoring.current = false;
247
+ return;
248
+ }
249
+ if (remembered.current) {
250
+ remembered.current = false;
251
+ restoring.current = true;
252
+ }
253
+ if (!restoring.current || !placed || !layout) return;
254
+ restoring.current = false;
255
+ canvas.current?.restoreView();
256
+ }, [composeId, placed, layout]);
242
257
  const fittedFor = useRef(fitKey);
243
258
  const placedOnce = useRef(false);
244
259
  useLayoutEffect(() => {
@@ -267,10 +282,10 @@ function TreeCanvas({
267
282
  };
268
283
  const pendingFocus = useRef(null);
269
284
  const focusNow = useCallback(
270
- (id) => {
285
+ (id, outside) => {
271
286
  const el = items.current.get(id);
272
287
  const placed2 = layout?.byId.get(cardOf(id));
273
- if (!el || !el.isConnected || !placed2) return false;
288
+ if (!el || !el.isConnected || !placed2 || !drawn?.byId.has(cardOf(id))) return false;
274
289
  el.focus({ preventScroll: true });
275
290
  const card2 = el.closest(".crewlet-tree-canvas__card");
276
291
  const top = card2 ? offsetWithin(el, card2) : 0;
@@ -280,23 +295,23 @@ function TreeCanvas({
280
295
  width: placed2.width,
281
296
  height: el.offsetHeight > 0 && top > 0 ? el.offsetHeight : placed2.height
282
297
  };
283
- canvas.current?.reveal(rect);
298
+ canvas.current?.reveal(rect, outside);
284
299
  return true;
285
300
  },
286
- [layout, cardOf]
301
+ [layout, drawn, cardOf]
287
302
  );
288
303
  const focusNode = useCallback(
289
- (id) => {
304
+ (id, outside = "edge") => {
290
305
  if (!model.parent.has(id)) return;
291
306
  const opened = tree.open(id);
292
307
  setActive(id);
293
- if (opened || !focusNow(id)) pendingFocus.current = id;
308
+ if (opened || restoring.current || !focusNow(id, outside)) pendingFocus.current = { id, outside };
294
309
  },
295
310
  [model, tree, setActive, focusNow]
296
311
  );
297
312
  useLayoutEffect(() => {
298
- const id = pendingFocus.current;
299
- if (id !== null && focusNow(id)) pendingFocus.current = null;
313
+ const want = pendingFocus.current;
314
+ if (want !== null && !restoring.current && focusNow(want.id, want.outside)) pendingFocus.current = null;
300
315
  });
301
316
  const focusRef = useRef(focusNode);
302
317
  focusRef.current = focusNode;
@@ -308,7 +323,8 @@ function TreeCanvas({
308
323
  useImperativeHandle(
309
324
  ref,
310
325
  () => ({
311
- focusNode: (id) => focusRef.current(id),
326
+ // A CALLER SENDS THE READER SOMEWHERE: see [TreeCanvasHandle.focusNode].
327
+ focusNode: (id) => focusRef.current(id, "centre"),
312
328
  expandAll,
313
329
  collapseAll,
314
330
  focusRegion: (id) => {
@@ -339,6 +355,7 @@ function TreeCanvas({
339
355
  const was = eased.current;
340
356
  if (composeId !== null) {
341
357
  canvas.current?.rememberView();
358
+ remembered.current = true;
342
359
  takeFocus.current = takeFocus.current || eased.current !== composeId;
343
360
  const box = placedCards?.get(composeId);
344
361
  if (!box || was === composeId) return;
@@ -352,7 +369,6 @@ function TreeCanvas({
352
369
  const back = returnTo.current;
353
370
  eased.current = null;
354
371
  returnTo.current = null;
355
- canvas.current?.restoreView();
356
372
  if (back !== null) {
357
373
  setActive(back);
358
374
  items.current.get(back)?.focus({ preventScroll: true });
@@ -1,6 +1,6 @@
1
1
  import { Note } from './chunk-YJPQJVRJ.js';
2
- import { CanvasToolbar, toolForKey } from './chunk-N47PA4V4.js';
3
- import { IDENTITY_VIEW, Canvas } from './chunk-ELZSD6FJ.js';
2
+ import { CanvasToolbar, toolForKey } from './chunk-AKCIF6XN.js';
3
+ import { IDENTITY_VIEW, Canvas } from './chunk-MNVIIZQP.js';
4
4
  import { IconButton } from './chunk-X5YI6E5X.js';
5
5
  import { cx } from './chunk-ODEQTPFM.js';
6
6
  import './CanvasBoard-U6LR5F6H.css';