Skip to main content

<ShapePaletteComponent/>

This is a palette that sources its draggable items from the SVG shapes that the surface it is attached to has available.

To locate the surface it should attach to, this component should be contained within a SurfaceProvider.

Usage​

import {FLOWCHART_SHAPES, BASIC_SHAPES} from "@visuallyjs/browser-ui";
import {SurfaceProvider, SurfaceComponent, ShapePaletteComponent} from "@visuallyjs/browser-ui-react";

<SurfaceProvider>
<SurfaceComponent renderOptions={{
shapes:{
sets:[FLOWCHART_SHAPES, BASIC_SHAPES]
}
}}/>

<ShapePaletteComponent/>
</SurfaceProvider>

Props​

ShapePaletteComponentProps
Props for the ShapePaletteComponent
NameTypeDescription
allowClickToAdd?booleanWhen in tap mode, allow addition of new vertices simply by clicking, instead of requiring a shape be drawn. (When this is true, the drawing method also still works)
allowDropOnEdge?boolean | CanDropOnEdgeFilterWhether or not to allow drop on edge. Defaults to false.
allowRotation?booleanWhether or not to allow rotation of elements being dragged. Defaults to true.
autoEdgeConnect?boolean | AutoEdgeConnectOptionsControls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.
className?stringOptional class name to append to the root element's class list.
dataGenerator?DataGeneratorFunctionOptional data generator to allow you to specify initial data for some element to be dragged. Note that you cannot override the object's type with this function. The palette will set the new object's type to match the type of the element that the user is dragging from the palette.
dragSize?SizeOptional size to use for dragged elements.
fill?stringOptional fill color to use for dragged elements. This should be in RGB or hex format, not a color like 'white' or 'cyan' etc.
iconSize?SizeOptional size to use for icons.
initialSet?stringID of the initial set to show, if any. When you have multiple shapes in a set you may want the palette to open up showing just one set.
inspector?booleanWhen true, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
mode?PaletteModeMode to use for the palette.
onVertexAdded?OnVertexAddedCallbackOptional callback to invoke when a vertex as been dragged onto the canvas
outline?stringOptional color to use for outline of dragged elements. Should be in RGB or hex format.
paletteStrokeWidth?numberStroke width to use for shapes in palette. Defaults to 1.
preparedShapes?Array<PreparedShape>Optional set of prepared shapes to show in the palette. When this is provided, the palette will only render these shapes, and not the contents of the shape library.
rotationSpeed?numberThe number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
selectAfterDrop?booleanWhen true (which is the default), a newly dropped vertex will be set as the underlying model's selection.
showAllMessage?stringMessage to use for the 'show all' option in the shape set drop down when there is more than one set of shapes. Defaults to Show all.
showGroups?booleanWhether or not to show groups in the palette. Defaults to true.
showLabels?booleanOptionally show each shape icon's label underneath it
surface?SurfaceSurface to attach the drag/drop to. Optional; this component can extract the Surface from a SurfaceProvider, or from being a child of a SurfaceComponent. You'd only need to set this in certain advanced scenarios.
updateTypeOnPaletteTap?booleanWhen true, clicking on an entry in the palette will change the type of any selected vertices to that type. Defaults to false. This is a potentially destructive operation if the properties of the new shape type are not compatible with the old one.