@canvas-harness/react 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -116,6 +116,21 @@ type CanvasProps = {
|
|
|
116
116
|
* <Canvas background={{ color: '#fffaf3', pattern: 'dots', gap: 24 }} />
|
|
117
117
|
*/
|
|
118
118
|
background?: CanvasBackground;
|
|
119
|
+
/**
|
|
120
|
+
* Color for all selection chrome: outline, resize + rotate handles,
|
|
121
|
+
* edge endpoint + midpoint handles, marquee, drag-create preview,
|
|
122
|
+
* and the draft edge during creation. Defaults to `#3b82f6`. Update
|
|
123
|
+
* by changing the prop — `<Canvas>` calls
|
|
124
|
+
* `renderer.setSelectionColor` without recreating the renderer.
|
|
125
|
+
*
|
|
126
|
+
* Accepts any CSS color literal (hex, rgb(), named). Typically you
|
|
127
|
+
* also want to pass the same value to `<Minimap viewportColor={...} />`
|
|
128
|
+
* so the two stay visually in sync.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* <Canvas selectionColor="#10b981" />
|
|
132
|
+
*/
|
|
133
|
+
selectionColor?: string;
|
|
119
134
|
/**
|
|
120
135
|
* Render a custom node's React subtree. Called once per
|
|
121
136
|
* library-mounted custom-node id; positioning is handled by the
|
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,21 @@ type CanvasProps = {
|
|
|
116
116
|
* <Canvas background={{ color: '#fffaf3', pattern: 'dots', gap: 24 }} />
|
|
117
117
|
*/
|
|
118
118
|
background?: CanvasBackground;
|
|
119
|
+
/**
|
|
120
|
+
* Color for all selection chrome: outline, resize + rotate handles,
|
|
121
|
+
* edge endpoint + midpoint handles, marquee, drag-create preview,
|
|
122
|
+
* and the draft edge during creation. Defaults to `#3b82f6`. Update
|
|
123
|
+
* by changing the prop — `<Canvas>` calls
|
|
124
|
+
* `renderer.setSelectionColor` without recreating the renderer.
|
|
125
|
+
*
|
|
126
|
+
* Accepts any CSS color literal (hex, rgb(), named). Typically you
|
|
127
|
+
* also want to pass the same value to `<Minimap viewportColor={...} />`
|
|
128
|
+
* so the two stay visually in sync.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* <Canvas selectionColor="#10b981" />
|
|
132
|
+
*/
|
|
133
|
+
selectionColor?: string;
|
|
119
134
|
/**
|
|
120
135
|
* Render a custom node's React subtree. Called once per
|
|
121
136
|
* library-mounted custom-node id; positioning is handled by the
|
package/dist/index.js
CHANGED
|
@@ -979,6 +979,7 @@ function CanvasSurface({
|
|
|
979
979
|
onCreateDrag,
|
|
980
980
|
arrowDefaults,
|
|
981
981
|
background,
|
|
982
|
+
selectionColor,
|
|
982
983
|
renderCustomNodeView,
|
|
983
984
|
children
|
|
984
985
|
}) {
|
|
@@ -1011,6 +1012,7 @@ function CanvasSurface({
|
|
|
1011
1012
|
width: w,
|
|
1012
1013
|
height: h,
|
|
1013
1014
|
background,
|
|
1015
|
+
selectionColor,
|
|
1014
1016
|
onOverlayChange: (ids) => setMountedIds(ids)
|
|
1015
1017
|
});
|
|
1016
1018
|
r.start();
|
|
@@ -1024,6 +1026,9 @@ function CanvasSurface({
|
|
|
1024
1026
|
useEffect(() => {
|
|
1025
1027
|
rendererRef.current?.setBackground(background);
|
|
1026
1028
|
}, [background]);
|
|
1029
|
+
useEffect(() => {
|
|
1030
|
+
if (selectionColor !== void 0) rendererRef.current?.setSelectionColor(selectionColor);
|
|
1031
|
+
}, [selectionColor]);
|
|
1027
1032
|
useEffect(() => {
|
|
1028
1033
|
const el = wrapRef.current;
|
|
1029
1034
|
if (!el) return;
|
|
@@ -1061,6 +1066,7 @@ function CanvasSurface({
|
|
|
1061
1066
|
el.removeEventListener("dblclick", onDoubleClickHandler);
|
|
1062
1067
|
};
|
|
1063
1068
|
}, [store, onClick, onDoubleClick]);
|
|
1069
|
+
const justCommittedRef = useRef(false);
|
|
1064
1070
|
useEffect(() => {
|
|
1065
1071
|
const el = wrapRef.current;
|
|
1066
1072
|
if (!el || !onCreateDrag) return;
|
|
@@ -1068,7 +1074,6 @@ function CanvasSurface({
|
|
|
1068
1074
|
let startScreen = null;
|
|
1069
1075
|
let activePointerId = null;
|
|
1070
1076
|
let committed = false;
|
|
1071
|
-
const justCommittedRef = { current: false };
|
|
1072
1077
|
const screenFromEvent = (e) => {
|
|
1073
1078
|
const rect = el.getBoundingClientRect();
|
|
1074
1079
|
return { x: e.clientX - rect.left, y: e.clientY - rect.top };
|