@salesforce/metadata-core-sdk 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/sdk/contracts/core/IMetadataParser.d.ts +39 -0
- package/dist/sdk/contracts/core/IMetadataParser.d.ts.map +1 -1
- package/dist/sdk/contracts/types/MetadataPluginInfo.d.ts +39 -9
- package/dist/sdk/contracts/types/MetadataPluginInfo.d.ts.map +1 -1
- package/dist/sdk/contracts/types/SelectableNode.d.ts +62 -0
- package/dist/sdk/contracts/types/SelectableNode.d.ts.map +1 -0
- package/dist/sdk/contracts/types/SelectableNode.js +8 -0
- package/dist/sdk/contracts/types/SelectableNode.js.map +1 -0
- package/dist/sdk/contracts/types/index.d.ts +1 -0
- package/dist/sdk/contracts/types/index.d.ts.map +1 -1
- package/dist/sdk/contracts/types/index.js +1 -0
- package/dist/sdk/contracts/types/index.js.map +1 -1
- package/dist/sdk/hooks/vibe-edit/index.d.ts +39 -0
- package/dist/sdk/hooks/vibe-edit/index.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/index.js +42 -0
- package/dist/sdk/hooks/vibe-edit/index.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGeometry.d.ts +56 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGeometry.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGeometry.js +138 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGeometry.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraph.d.ts +66 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraph.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraph.js +73 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraph.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraphEngine.d.ts +64 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraphEngine.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraphEngine.js +161 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraphEngine.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/types.d.ts +47 -0
- package/dist/sdk/hooks/vibe-edit/selection/types.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/types.js +40 -0
- package/dist/sdk/hooks/vibe-edit/selection/types.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/useMarqueeSelection.d.ts +30 -0
- package/dist/sdk/hooks/vibe-edit/selection/useMarqueeSelection.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/useMarqueeSelection.js +50 -0
- package/dist/sdk/hooks/vibe-edit/selection/useMarqueeSelection.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.css +26 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.d.ts +84 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.js +256 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.css +207 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.d.ts +43 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.js +80 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.css +79 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.d.ts +116 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.js +264 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.js.map +1 -0
- package/dist/sdk/utils/HostCommunicationUtils.d.ts +2 -0
- package/dist/sdk/utils/HostCommunicationUtils.d.ts.map +1 -1
- package/dist/sdk/utils/HostCommunicationUtils.js +11 -2
- package/dist/sdk/utils/HostCommunicationUtils.js.map +1 -1
- package/dist/sdk/webviewMessageTypes.d.ts +103 -5
- package/dist/sdk/webviewMessageTypes.d.ts.map +1 -1
- package/dist/sdk/webviewMessageTypes.js +9 -4
- package/dist/sdk/webviewMessageTypes.js.map +1 -1
- package/package.json +11 -3
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { itemKey } from '../selection/selectionGeometry.js';
|
|
9
|
+
import { type SelectedItem } from '../selection/types.js';
|
|
10
|
+
import './MarqueeSelection.css';
|
|
11
|
+
/**
|
|
12
|
+
* Pure hover-funnel step. Given the previously-hovered key (`type::id` or null),
|
|
13
|
+
* the item now under the pointer (or null), and whether a marquee drag is in
|
|
14
|
+
* progress, decides whether the hover target changed and what to emit:
|
|
15
|
+
*
|
|
16
|
+
* - during a drag → never emit (hover is suppressed while rubber-banding);
|
|
17
|
+
* - moving within the same element → no change (dedup by hover key);
|
|
18
|
+
* - moving onto a new element / off all elements → change, emit the item/null.
|
|
19
|
+
*
|
|
20
|
+
* Extracted so the transition/dedup/suppression contract is unit-testable
|
|
21
|
+
* without a DOM. The component owns the RAF throttle + the hoverKey ref.
|
|
22
|
+
*/
|
|
23
|
+
export declare function nextHover(prevKey: string | null, hit: SelectedItem | null, dragging: boolean): {
|
|
24
|
+
changed: boolean;
|
|
25
|
+
key: string | null;
|
|
26
|
+
item: SelectedItem | null;
|
|
27
|
+
};
|
|
28
|
+
interface MarqueeSelectionProps {
|
|
29
|
+
/** When false, the overlay is inert and pointer events pass through. */
|
|
30
|
+
active: boolean;
|
|
31
|
+
/** Currently selected items (keyed by `type::id`). */
|
|
32
|
+
selected: Map<string, SelectedItem>;
|
|
33
|
+
/** Replace the entire selection (drag with no modifier). */
|
|
34
|
+
onReplace: (items: SelectedItem[]) => void;
|
|
35
|
+
/** Add items to the selection (shift/cmd-drag). */
|
|
36
|
+
onAdd: (items: SelectedItem[]) => void;
|
|
37
|
+
/** Toggle a single item (click / shift-click / cmd-click). */
|
|
38
|
+
onToggle: (item: SelectedItem) => void;
|
|
39
|
+
/** Clear the selection (click on empty space, no modifier). */
|
|
40
|
+
onClear: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Activate (open/drill-into) the item under a double-click. Lets a host drill
|
|
43
|
+
* into a nested view (e.g. a subagent's detail) WITHOUT leaving select-mode —
|
|
44
|
+
* single-click still toggles selection, double-click opens. Optional: overlays
|
|
45
|
+
* that have nothing to drill into simply omit it.
|
|
46
|
+
*/
|
|
47
|
+
onActivate?: (item: SelectedItem) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Hover changed: the most-specific selectable element now under the pointer,
|
|
50
|
+
* or null when the pointer is over empty space / has left the overlay. Fires
|
|
51
|
+
* only on hover-target transitions (RAF-throttled, deduped by `type::id`),
|
|
52
|
+
* and is suppressed during a marquee drag. Optional; overlays with no hover
|
|
53
|
+
* affordance simply omit it. Intra-core-sdk child->parent callback — never
|
|
54
|
+
* crosses a wire boundary.
|
|
55
|
+
*/
|
|
56
|
+
onHover?: (item: SelectedItem | null) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Marquee preview changed: the full set of elements the drag box currently
|
|
59
|
+
* covers, INCLUDING finer nested elements (a tile's label / description rows
|
|
60
|
+
* as well as the tile), so the owner can show the dotted hover affordance on
|
|
61
|
+
* every selectable the box touches while the user is still dragging. This uses
|
|
62
|
+
* the raw covered set (coveredInMarquee) — NOT the ancestor-wins collapse — so
|
|
63
|
+
* the finer selectables are visible mid-drag even though release selects just
|
|
64
|
+
* the outermost element per {@link selectInMarquee}. RAF-throttled; fires with
|
|
65
|
+
* `[]` when the drag ends or is cancelled. Optional; overlays that don't want a
|
|
66
|
+
* bulk-selection preview simply omit it.
|
|
67
|
+
*/
|
|
68
|
+
onMarqueePreview?: (items: SelectedItem[]) => void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Renderer-agnostic marquee + click selection overlay.
|
|
72
|
+
*
|
|
73
|
+
* Covers its positioned parent. When `active`, a left-drag rubber-bands a
|
|
74
|
+
* selection box and selects every `[data-mv-selectable]` element it covers by
|
|
75
|
+
* >= the coverage threshold (ancestor-wins for nested elements). A click (drag
|
|
76
|
+
* under the click threshold) toggles the most-specific element at the point.
|
|
77
|
+
* Shift/Cmd makes both gestures additive, enabling discontiguous selection.
|
|
78
|
+
*
|
|
79
|
+
* Gestures all funnel into the four callbacks; the owner holds the selection
|
|
80
|
+
* state (see useMarqueeSelection).
|
|
81
|
+
*/
|
|
82
|
+
export declare const MarqueeSelection: React.FC<MarqueeSelectionProps>;
|
|
83
|
+
export { itemKey };
|
|
84
|
+
//# sourceMappingURL=MarqueeSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarqueeSelection.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/ui/MarqueeSelection.tsx"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,EAIL,OAAO,EAGR,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,wBAAwB,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,OAAO,EA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LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { selectInMarquee, coveredInMarquee, selectAtPoint, itemKey, rectFromPoints, } from '../selection/selectionGeometry.js';
|
|
9
|
+
import { CLICK_THRESHOLD_PX } from '../selection/types.js';
|
|
10
|
+
import './MarqueeSelection.css';
|
|
11
|
+
/**
|
|
12
|
+
* Pure hover-funnel step. Given the previously-hovered key (`type::id` or null),
|
|
13
|
+
* the item now under the pointer (or null), and whether a marquee drag is in
|
|
14
|
+
* progress, decides whether the hover target changed and what to emit:
|
|
15
|
+
*
|
|
16
|
+
* - during a drag → never emit (hover is suppressed while rubber-banding);
|
|
17
|
+
* - moving within the same element → no change (dedup by hover key);
|
|
18
|
+
* - moving onto a new element / off all elements → change, emit the item/null.
|
|
19
|
+
*
|
|
20
|
+
* Extracted so the transition/dedup/suppression contract is unit-testable
|
|
21
|
+
* without a DOM. The component owns the RAF throttle + the hoverKey ref.
|
|
22
|
+
*/
|
|
23
|
+
export function nextHover(prevKey, hit, dragging) {
|
|
24
|
+
if (dragging) {
|
|
25
|
+
return { changed: false, key: prevKey, item: null };
|
|
26
|
+
}
|
|
27
|
+
const key = hit ? itemKey(hit) : null;
|
|
28
|
+
if (key === prevKey) {
|
|
29
|
+
// No transition — nothing is emitted, so keep `item` null in every no-emit
|
|
30
|
+
// branch (matches the dragging case above). Callers only read `item` when
|
|
31
|
+
// `changed` is true; a consistent null here just makes the shape easier to
|
|
32
|
+
// reason about.
|
|
33
|
+
return { changed: false, key, item: null };
|
|
34
|
+
}
|
|
35
|
+
return { changed: true, key, item: hit };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Renderer-agnostic marquee + click selection overlay.
|
|
39
|
+
*
|
|
40
|
+
* Covers its positioned parent. When `active`, a left-drag rubber-bands a
|
|
41
|
+
* selection box and selects every `[data-mv-selectable]` element it covers by
|
|
42
|
+
* >= the coverage threshold (ancestor-wins for nested elements). A click (drag
|
|
43
|
+
* under the click threshold) toggles the most-specific element at the point.
|
|
44
|
+
* Shift/Cmd makes both gestures additive, enabling discontiguous selection.
|
|
45
|
+
*
|
|
46
|
+
* Gestures all funnel into the four callbacks; the owner holds the selection
|
|
47
|
+
* state (see useMarqueeSelection).
|
|
48
|
+
*/
|
|
49
|
+
export const MarqueeSelection = ({ active, selected, onReplace, onAdd, onToggle, onClear, onActivate, onHover, onMarqueePreview, }) => {
|
|
50
|
+
const overlayRef = useRef(null);
|
|
51
|
+
const startRef = useRef(null);
|
|
52
|
+
const [box, setBox] = useState(null);
|
|
53
|
+
// Hover funnel state. rafRef throttles hit-testing to one probe per frame;
|
|
54
|
+
// lastPointRef holds the most recent pointer coords the scheduled probe reads;
|
|
55
|
+
// hoverKeyRef dedups so onHover fires only when the target element changes.
|
|
56
|
+
const rafRef = useRef(null);
|
|
57
|
+
const lastPointRef = useRef(null);
|
|
58
|
+
const hoverKeyRef = useRef(null);
|
|
59
|
+
// Resolve the DOM root to hit-test against: the overlay's positioned parent,
|
|
60
|
+
// which contains the rendered visualization.
|
|
61
|
+
const getRoot = useCallback(() => {
|
|
62
|
+
return overlayRef.current?.parentElement ?? null;
|
|
63
|
+
}, []);
|
|
64
|
+
const handlePointerDown = useCallback((e) => {
|
|
65
|
+
if (!active || e.button !== 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
startRef.current = {
|
|
69
|
+
x: e.clientX,
|
|
70
|
+
y: e.clientY,
|
|
71
|
+
additive: e.shiftKey || e.metaKey || e.ctrlKey,
|
|
72
|
+
};
|
|
73
|
+
setBox(rectFromPoints(e.clientX, e.clientY, e.clientX, e.clientY));
|
|
74
|
+
overlayRef.current?.setPointerCapture(e.pointerId);
|
|
75
|
+
// A drag is starting: drop any hover so the outline doesn't linger under
|
|
76
|
+
// the marquee, and cancel a pending hover probe.
|
|
77
|
+
if (rafRef.current !== null) {
|
|
78
|
+
cancelAnimationFrame(rafRef.current);
|
|
79
|
+
rafRef.current = null;
|
|
80
|
+
}
|
|
81
|
+
if (hoverKeyRef.current !== null) {
|
|
82
|
+
hoverKeyRef.current = null;
|
|
83
|
+
onHover?.(null);
|
|
84
|
+
}
|
|
85
|
+
}, [active, onHover]);
|
|
86
|
+
const handlePointerMove = useCallback((e) => {
|
|
87
|
+
if (startRef.current) {
|
|
88
|
+
// Active drag: update the marquee box. Single-element hover is suppressed
|
|
89
|
+
// (see nextHover's `dragging` guard), but if the owner wants a bulk
|
|
90
|
+
// preview we recompute the covered set — throttled to one probe/frame —
|
|
91
|
+
// so every selectable the box touches (tile AND its finer label /
|
|
92
|
+
// description rows) gets the dotted hover mark live.
|
|
93
|
+
const s = startRef.current;
|
|
94
|
+
const marqueeRect = rectFromPoints(s.x, s.y, e.clientX, e.clientY);
|
|
95
|
+
setBox(marqueeRect);
|
|
96
|
+
if (onMarqueePreview) {
|
|
97
|
+
lastPointRef.current = { x: e.clientX, y: e.clientY };
|
|
98
|
+
if (rafRef.current === null) {
|
|
99
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
100
|
+
rafRef.current = null;
|
|
101
|
+
const start = startRef.current;
|
|
102
|
+
const pt = lastPointRef.current;
|
|
103
|
+
const root = getRoot();
|
|
104
|
+
// Guard: the drag may have ended before this frame ran.
|
|
105
|
+
if (!start || !pt || !root) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// Preview shows the FULL covered set (incl. finer nested
|
|
109
|
+
// elements); release still selects via the ancestor-wins rule.
|
|
110
|
+
onMarqueePreview(coveredInMarquee(root, rectFromPoints(start.x, start.y, pt.x, pt.y)));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
// No drag: hit-test for hover, throttled to one probe per animation frame.
|
|
117
|
+
if (!onHover) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
lastPointRef.current = { x: e.clientX, y: e.clientY };
|
|
121
|
+
if (rafRef.current !== null) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
125
|
+
rafRef.current = null;
|
|
126
|
+
const pt = lastPointRef.current;
|
|
127
|
+
const root = getRoot();
|
|
128
|
+
if (!pt || !root) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const hit = selectAtPoint(root, pt.x, pt.y);
|
|
132
|
+
const step = nextHover(hoverKeyRef.current, hit, startRef.current !== null);
|
|
133
|
+
if (step.changed) {
|
|
134
|
+
hoverKeyRef.current = step.key;
|
|
135
|
+
onHover(step.item);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}, [onHover, onMarqueePreview, getRoot]);
|
|
139
|
+
const handlePointerUp = useCallback((e) => {
|
|
140
|
+
const s = startRef.current;
|
|
141
|
+
startRef.current = null;
|
|
142
|
+
setBox(null);
|
|
143
|
+
// Drag is over: cancel a pending preview probe and clear the preview marks
|
|
144
|
+
// (the covered elements become the actual selection via onReplace/onAdd).
|
|
145
|
+
if (rafRef.current !== null) {
|
|
146
|
+
cancelAnimationFrame(rafRef.current);
|
|
147
|
+
rafRef.current = null;
|
|
148
|
+
}
|
|
149
|
+
onMarqueePreview?.([]);
|
|
150
|
+
if (!s) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
overlayRef.current?.releasePointerCapture(e.pointerId);
|
|
154
|
+
const root = getRoot();
|
|
155
|
+
if (!root) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const dist = Math.hypot(e.clientX - s.x, e.clientY - s.y);
|
|
159
|
+
if (dist < CLICK_THRESHOLD_PX) {
|
|
160
|
+
// Click gesture: toggle the most-specific element, or clear empty space.
|
|
161
|
+
const hit = selectAtPoint(root, e.clientX, e.clientY);
|
|
162
|
+
if (hit) {
|
|
163
|
+
onToggle(hit);
|
|
164
|
+
}
|
|
165
|
+
else if (!s.additive) {
|
|
166
|
+
onClear();
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
// Drag gesture: marquee hit-test with the >=50% coverage rule.
|
|
171
|
+
const marquee = rectFromPoints(s.x, s.y, e.clientX, e.clientY);
|
|
172
|
+
const items = selectInMarquee(root, marquee);
|
|
173
|
+
if (s.additive) {
|
|
174
|
+
onAdd(items);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
onReplace(items);
|
|
178
|
+
}
|
|
179
|
+
}, [getRoot, onAdd, onReplace, onToggle, onClear, onMarqueePreview]);
|
|
180
|
+
// Double-click drills into the item under the pointer without leaving
|
|
181
|
+
// select-mode. The single-click toggle still fires (React dispatches click
|
|
182
|
+
// before dblclick), so the net effect of a double-click is: toggle on, toggle
|
|
183
|
+
// off, then open — leaving the selection unchanged and the detail view open.
|
|
184
|
+
const handleDoubleClick = useCallback((e) => {
|
|
185
|
+
if (!active || !onActivate) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const root = getRoot();
|
|
189
|
+
if (!root) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const hit = selectAtPoint(root, e.clientX, e.clientY);
|
|
193
|
+
if (hit) {
|
|
194
|
+
onActivate(hit);
|
|
195
|
+
}
|
|
196
|
+
}, [active, onActivate, getRoot]);
|
|
197
|
+
// Pointer left the overlay: clear any pending probe and drop the hover. During
|
|
198
|
+
// an active drag the marquee keeps rubber-banding (pointer capture), so we do
|
|
199
|
+
// NOT clear the preview here — only the single-element hover, which is already
|
|
200
|
+
// suppressed mid-drag. pointerup owns the preview teardown.
|
|
201
|
+
const handlePointerLeave = useCallback(() => {
|
|
202
|
+
if (startRef.current) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (rafRef.current !== null) {
|
|
206
|
+
cancelAnimationFrame(rafRef.current);
|
|
207
|
+
rafRef.current = null;
|
|
208
|
+
}
|
|
209
|
+
if (hoverKeyRef.current !== null) {
|
|
210
|
+
hoverKeyRef.current = null;
|
|
211
|
+
onHover?.(null);
|
|
212
|
+
}
|
|
213
|
+
}, [onHover]);
|
|
214
|
+
// On unmount, cancel any in-flight hover probe so its callback can't run
|
|
215
|
+
// against a torn-down tree, and drop a still-active hover so the parent's
|
|
216
|
+
// hovered state isn't left stale (e.g. select-mode toggled off with the
|
|
217
|
+
// pointer still over an element). `onHover` is read via a ref so this effect
|
|
218
|
+
// stays mount/unmount-only and the callback identity can't stale it.
|
|
219
|
+
const onHoverRef = useRef(onHover);
|
|
220
|
+
onHoverRef.current = onHover;
|
|
221
|
+
const onMarqueePreviewRef = useRef(onMarqueePreview);
|
|
222
|
+
onMarqueePreviewRef.current = onMarqueePreview;
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
return () => {
|
|
225
|
+
if (rafRef.current !== null) {
|
|
226
|
+
cancelAnimationFrame(rafRef.current);
|
|
227
|
+
rafRef.current = null;
|
|
228
|
+
}
|
|
229
|
+
if (hoverKeyRef.current !== null) {
|
|
230
|
+
hoverKeyRef.current = null;
|
|
231
|
+
onHoverRef.current?.(null);
|
|
232
|
+
}
|
|
233
|
+
// Drop any live preview so the parent's covered set isn't left stale if
|
|
234
|
+
// the overlay unmounts mid-drag (e.g. select-mode toggled off).
|
|
235
|
+
onMarqueePreviewRef.current?.([]);
|
|
236
|
+
};
|
|
237
|
+
}, []);
|
|
238
|
+
if (!active) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
// Render the live marquee box relative to the overlay's own client rect.
|
|
242
|
+
const overlayRect = overlayRef.current?.getBoundingClientRect();
|
|
243
|
+
const boxStyle = box && overlayRect
|
|
244
|
+
? {
|
|
245
|
+
left: box.left - overlayRect.left,
|
|
246
|
+
top: box.top - overlayRect.top,
|
|
247
|
+
width: box.right - box.left,
|
|
248
|
+
height: box.bottom - box.top,
|
|
249
|
+
}
|
|
250
|
+
: undefined;
|
|
251
|
+
return (React.createElement("div", { ref: overlayRef, className: "mv-marquee-overlay", onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onDoubleClick: handleDoubleClick },
|
|
252
|
+
boxStyle && React.createElement("div", { className: "mv-marquee-box", style: boxStyle }),
|
|
253
|
+
React.createElement("span", { hidden: true }, selected.size)));
|
|
254
|
+
};
|
|
255
|
+
export { itemKey };
|
|
256
|
+
//# sourceMappingURL=MarqueeSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarqueeSelection.js","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/ui/MarqueeSelection.tsx"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,cAAc,GAEf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAqB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,wBAAwB,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CACvB,OAAsB,EACtB,GAAwB,EACxB,QAAiB;IAEjB,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACtD,CAAC;IACD,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtC,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;QACpB,2EAA2E;QAC3E,0EAA0E;QAC1E,2EAA2E;QAC3E,gBAAgB;QAChB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC7C,CAAC;IACD,OAAO,E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under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
|
|
8
|
+
.vibe-edit-panel {
|
|
9
|
+
position: absolute;
|
|
10
|
+
bottom: var(--mv-spacing-md);
|
|
11
|
+
left: 50%;
|
|
12
|
+
transform: translateX(-50%);
|
|
13
|
+
z-index: 20;
|
|
14
|
+
width: min(560px, calc(100% - 2 * var(--mv-spacing-md)));
|
|
15
|
+
/* Never grow past the canvas: cap to the space above the bottom dock so a
|
|
16
|
+
large selection / long content scrolls WITHIN the panel instead of pushing
|
|
17
|
+
the panel off the top of the viewport. The chips region is the flexible
|
|
18
|
+
scroll area (below); the header, textarea and footer stay pinned. */
|
|
19
|
+
max-height: calc(100% - 2 * var(--mv-spacing-md));
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
gap: var(--mv-spacing-sm);
|
|
23
|
+
padding: var(--mv-spacing-md);
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
background: var(--mv-panel-bg);
|
|
26
|
+
border: 1px solid var(--mv-panel-border);
|
|
27
|
+
border-radius: var(--mv-radius-lg);
|
|
28
|
+
box-shadow: var(--mv-shadow-xl);
|
|
29
|
+
font-family: var(--mv-font-family);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.vibe-edit-panel__header {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.vibe-edit-panel__title {
|
|
39
|
+
font-size: var(--mv-font-size-sm);
|
|
40
|
+
font-weight: var(--mv-font-weight-semibold);
|
|
41
|
+
color: var(--mv-text-primary);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.vibe-edit-panel__close {
|
|
45
|
+
border: none;
|
|
46
|
+
background: transparent;
|
|
47
|
+
color: var(--mv-text-secondary);
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
font-size: var(--mv-font-size-sm);
|
|
50
|
+
line-height: 1;
|
|
51
|
+
padding: var(--mv-spacing-xs);
|
|
52
|
+
border-radius: var(--mv-radius-sm);
|
|
53
|
+
transition: background var(--mv-transition-fast);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.vibe-edit-panel__close:hover {
|
|
57
|
+
background: var(--mv-bg-surface-hover);
|
|
58
|
+
color: var(--mv-text-primary);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.vibe-edit-panel__chips {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-wrap: wrap;
|
|
64
|
+
gap: var(--mv-spacing-xs);
|
|
65
|
+
/* The flexible region: chips take whatever height is left after the pinned
|
|
66
|
+
header/textarea/footer and scroll internally when the selection is large.
|
|
67
|
+
min-height:0 lets this flex child actually shrink so overflow-y engages. */
|
|
68
|
+
flex: 1 1 auto;
|
|
69
|
+
min-height: 0;
|
|
70
|
+
max-height: 96px;
|
|
71
|
+
overflow-y: auto;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.vibe-edit-panel__chip {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: var(--mv-spacing-xs);
|
|
78
|
+
max-width: 180px;
|
|
79
|
+
padding: 2px 2px 2px var(--mv-spacing-sm);
|
|
80
|
+
font-size: var(--mv-font-size-2xs);
|
|
81
|
+
font-family: var(--mv-font-family-mono);
|
|
82
|
+
color: var(--mv-text-primary);
|
|
83
|
+
/* Match the panel's own background so a chip reads as part of the box, not a
|
|
84
|
+
stark white pill on a gray surface (the border + label still delineate it).
|
|
85
|
+
Was --mv-bg-surface (#fff), which stood out against --mv-panel-bg (#f8f8f8). */
|
|
86
|
+
background: var(--mv-panel-bg);
|
|
87
|
+
border: 1px solid var(--mv-border-default);
|
|
88
|
+
border-radius: var(--mv-radius-full);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* The label truncates; the ✕ never does — it's a fixed-size sibling below. */
|
|
92
|
+
.vibe-edit-panel__chip-label {
|
|
93
|
+
min-width: 0;
|
|
94
|
+
overflow: hidden;
|
|
95
|
+
white-space: nowrap;
|
|
96
|
+
text-overflow: ellipsis;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* Per-chip remove (✕) — the reliable, gesture-free deselect path. Always fully
|
|
100
|
+
visible: it sits outside the label's truncation and can never shrink away. */
|
|
101
|
+
.vibe-edit-panel__chip-remove {
|
|
102
|
+
display: inline-flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
justify-content: center;
|
|
105
|
+
flex: 0 0 auto;
|
|
106
|
+
width: 16px;
|
|
107
|
+
height: 16px;
|
|
108
|
+
padding: 0;
|
|
109
|
+
border: none;
|
|
110
|
+
border-radius: var(--mv-radius-full);
|
|
111
|
+
background: var(--mv-bg-surface-hover);
|
|
112
|
+
color: var(--mv-text-secondary);
|
|
113
|
+
font-size: 10px;
|
|
114
|
+
line-height: 1;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
transition: background var(--mv-transition-fast), color var(--mv-transition-fast);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.vibe-edit-panel__chip-remove:hover {
|
|
120
|
+
background: var(--mv-interactive-primary);
|
|
121
|
+
color: var(--mv-button-primary-fg);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.vibe-edit-panel__chip-remove:focus-visible {
|
|
125
|
+
outline: 2px solid var(--mv-border-focus);
|
|
126
|
+
outline-offset: 1px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Field chips read as a sub-selection. Per the design spec the prominent blue
|
|
130
|
+
tint is dropped for a subtle, integrated look that matches the surrounding
|
|
131
|
+
surface — differentiated from default chips only by a slightly stronger
|
|
132
|
+
border + a mono-tinted label, not an accent fill. */
|
|
133
|
+
.vibe-edit-panel__chip--field {
|
|
134
|
+
color: var(--mv-text-secondary);
|
|
135
|
+
border-color: var(--mv-border-hover, var(--mv-border-default));
|
|
136
|
+
/* Same panel-matched fill as the default chip (see .vibe-edit-panel__chip). */
|
|
137
|
+
background: var(--mv-panel-bg);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* Wraps the textarea so the submit CTA can sit inside the input box, docked to
|
|
141
|
+
its bottom-right corner (matches the design). */
|
|
142
|
+
.vibe-edit-panel__input-wrap {
|
|
143
|
+
position: relative;
|
|
144
|
+
display: flex;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.vibe-edit-panel__input {
|
|
148
|
+
width: 100%;
|
|
149
|
+
resize: vertical;
|
|
150
|
+
min-height: 48px;
|
|
151
|
+
padding: var(--mv-spacing-sm);
|
|
152
|
+
/* Reserve room at the bottom for the docked Send CTA so typed text never runs
|
|
153
|
+
underneath it. */
|
|
154
|
+
padding-bottom: calc(var(--mv-spacing-md) + 24px);
|
|
155
|
+
font-family: var(--mv-font-family);
|
|
156
|
+
font-size: var(--mv-font-size-sm);
|
|
157
|
+
line-height: var(--mv-line-height-normal);
|
|
158
|
+
color: var(--mv-text-primary);
|
|
159
|
+
background: var(--mv-bg-input);
|
|
160
|
+
border: 1px solid var(--mv-border-input);
|
|
161
|
+
border-radius: var(--mv-radius-md);
|
|
162
|
+
box-sizing: border-box;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.vibe-edit-panel__input:focus {
|
|
166
|
+
outline: none;
|
|
167
|
+
border-color: var(--mv-border-focus);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.vibe-edit-panel__footer {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
justify-content: space-between;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.vibe-edit-panel__hint {
|
|
177
|
+
font-size: var(--mv-font-size-2xs);
|
|
178
|
+
color: var(--mv-text-muted);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* Docked inside the input box at the bottom-right corner. */
|
|
182
|
+
.vibe-edit-panel__submit {
|
|
183
|
+
position: absolute;
|
|
184
|
+
right: var(--mv-spacing-sm);
|
|
185
|
+
bottom: var(--mv-spacing-sm);
|
|
186
|
+
display: inline-flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
gap: var(--mv-spacing-xs);
|
|
189
|
+
padding: var(--mv-spacing-2xs, 4px) var(--mv-spacing-sm);
|
|
190
|
+
font-size: var(--mv-font-size-xs);
|
|
191
|
+
font-weight: var(--mv-font-weight-medium);
|
|
192
|
+
color: var(--mv-button-primary-fg);
|
|
193
|
+
background: var(--mv-interactive-primary);
|
|
194
|
+
border: none;
|
|
195
|
+
border-radius: var(--mv-radius-md);
|
|
196
|
+
cursor: pointer;
|
|
197
|
+
transition: opacity var(--mv-transition-fast);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.vibe-edit-panel__submit:disabled {
|
|
201
|
+
opacity: 0.5;
|
|
202
|
+
cursor: not-allowed;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.vibe-edit-panel__submit:not(:disabled):hover {
|
|
206
|
+
opacity: 0.9;
|
|
207
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import './VibeEditPanel.css';
|
|
9
|
+
/** A single selected element shown as a chip in the panel. */
|
|
10
|
+
export interface VibeEditChip {
|
|
11
|
+
/** Text shown on the chip. */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Tooltip / full identifier. */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** Visual variant — 'primary' tints the chip with the accent (e.g. fields). */
|
|
16
|
+
variant?: 'default' | 'primary';
|
|
17
|
+
}
|
|
18
|
+
interface VibeEditPanelProps {
|
|
19
|
+
/** Chips describing the current selection. Empty ⇒ the panel is hidden. */
|
|
20
|
+
chips: VibeEditChip[];
|
|
21
|
+
/** Submit the prompt for the current selection. Returns whether dispatch succeeded. */
|
|
22
|
+
onSubmit: (prompt: string) => boolean;
|
|
23
|
+
/** Clear the current selection (also dismisses the panel). */
|
|
24
|
+
onClear: () => void;
|
|
25
|
+
/**
|
|
26
|
+
* Remove a single selected element by its chip index — an explicit,
|
|
27
|
+
* gesture-free deselect path (the chip's ✕). Optional; when omitted the chips
|
|
28
|
+
* render without a remove button.
|
|
29
|
+
*/
|
|
30
|
+
onRemove?: (index: number) => void;
|
|
31
|
+
/** Optional placeholder for the prompt textarea. */
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Bottom-docked prompt UI for the vibe-edit flow, shared across plugins. Appears
|
|
36
|
+
* whenever one or more elements are selected. The user describes the change and
|
|
37
|
+
* submits; the plugin maps the selection to context and hands it to the host's
|
|
38
|
+
* coding agent. This component is plugin-agnostic — it only renders chips + a
|
|
39
|
+
* textarea and reports the typed prompt back via onSubmit.
|
|
40
|
+
*/
|
|
41
|
+
export declare const VibeEditPanel: React.FC<VibeEditPanelProps>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=VibeEditPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VibeEditPanel.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/ui/VibeEditPanel.tsx"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,qBAAqB,CAAC;AAiB7B,8DAA8D;AAC9D,MAAM,WAAW,YAAY;IAC3B,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAED,UAAU,kBAAkB;IAC1B,2EAA2E;IAC3E,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,uFAAuF;IACvF,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,8DAA8D;IAC9D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA4HtD,CAAC"}
|