@visuallyjs/browser-ui-react 1.0.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/background-component.d.ts +29 -0
- package/browser-ui-react.d.ts +14 -0
- package/chart-component.d.ts +197 -0
- package/color-picker-component.d.ts +19 -0
- package/controls-component.d.ts +59 -0
- package/decorator-component.d.ts +26 -0
- package/definitions.d.ts +345 -0
- package/diagram-component.d.ts +84 -0
- package/diagram-palette-component.d.ts +94 -0
- package/edge-type-picker.d.ts +15 -0
- package/export-controls-component.d.ts +50 -0
- package/global-context.d.ts +18 -0
- package/index.d.ts +29 -0
- package/inspector-component.d.ts +72 -0
- package/inspector-context.d.ts +25 -0
- package/jsx-wrapper.d.ts +52 -0
- package/miniview-component.d.ts +51 -0
- package/package.json +1 -0
- package/palette-component.d.ts +11 -0
- package/shape-component.d.ts +51 -0
- package/shape-palette-component.d.ts +9 -0
- package/surface-component.d.ts +7 -0
- package/surface-context.d.ts +44 -0
- package/visuallyjs-context.d.ts +22 -0
- package/visuallyjs.browser-ui-react.cjs.js +1 -0
- package/visuallyjs.browser-ui-react.es.js +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type BackgroundOptions, type GeneratedGridBackgroundOptions, type SimpleBackgroundOptions, type TiledBackgroundOptions } from "@visuallyjs/browser-ui";
|
|
2
|
+
/**
|
|
3
|
+
* Props for the background component. `type` defines the type of background to render, and each background type has its own set of options.
|
|
4
|
+
* @group Props
|
|
5
|
+
*/
|
|
6
|
+
export interface BackgroundComponentProps extends BackgroundOptions {
|
|
7
|
+
}
|
|
8
|
+
export declare function BackgroundComponent(props: BackgroundComponentProps): JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* Props for the grid background component.
|
|
11
|
+
* @group Props
|
|
12
|
+
*/
|
|
13
|
+
export interface GridBackgroundComponentProps extends Omit<GeneratedGridBackgroundOptions, "type"> {
|
|
14
|
+
}
|
|
15
|
+
export declare function GridBackgroundComponent(props: GridBackgroundComponentProps): JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* Props for the image background component.
|
|
18
|
+
* @group Props
|
|
19
|
+
*/
|
|
20
|
+
export interface ImageBackgroundComponentProps extends Omit<SimpleBackgroundOptions, "type"> {
|
|
21
|
+
}
|
|
22
|
+
export declare function ImageBackgroundComponent(props: ImageBackgroundComponentProps): JSX.Element;
|
|
23
|
+
/**
|
|
24
|
+
* Props for the tiled image background component
|
|
25
|
+
* @group Props
|
|
26
|
+
*/
|
|
27
|
+
export interface TiledImageBackgroundComponentProps extends Omit<TiledBackgroundOptions, "type"> {
|
|
28
|
+
}
|
|
29
|
+
export declare function TiledImageBackgroundComponent(props: TiledImageBackgroundComponentProps): JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Surface, BrowserUIModel, SurfaceOptions, ModelOptions } from "@visuallyjs/browser-ui";
|
|
2
|
+
/**
|
|
3
|
+
* Extension of the VisuallyJsModel for use in React. This is the class you use to manipulate and query the contents of the data model. You will rarely need to create one of these manually, since the UI components will do that for you (unless you have an app in which you wish to share one model among several renderers), but if you wish to perform programmatic operations on the data model this is the class you will interact with.
|
|
4
|
+
* @group Model
|
|
5
|
+
*/
|
|
6
|
+
export declare class BrowserUIReactModel extends BrowserUIModel {
|
|
7
|
+
render(container: Element, options?: SurfaceOptions): Surface;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new instance of the VisuallyJsModel for use in React. This method is public for the sake of completeness of the api docs, but it is not expected that library users will need to call this method manually, unless you have an app in which you wish to render one model across several different UIs.
|
|
11
|
+
* @param options
|
|
12
|
+
* @group Model
|
|
13
|
+
*/
|
|
14
|
+
export declare function newInstance(options?: ModelOptions): BrowserUIReactModel;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { ColumnChartOptions, BarChartOptions, CategoryValueChartOptions, LineChartOptions, AreaChartOptions, ObjectData, PieChartOptions, ScatterChartOptions, BubbleChartOptions, GaugeChartOptions, SankeyOptions, VisuallyJsDefaultJSON, ChartModelFilter } from "@visuallyjs/browser-ui";
|
|
2
|
+
/**
|
|
3
|
+
* Base interface for chart props
|
|
4
|
+
* @group Props
|
|
5
|
+
*/
|
|
6
|
+
export interface BaseChartProps {
|
|
7
|
+
/**
|
|
8
|
+
* Optional class name to set on the chart's root element.
|
|
9
|
+
*/
|
|
10
|
+
className?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Data to load
|
|
13
|
+
*/
|
|
14
|
+
data?: Array<ObjectData>;
|
|
15
|
+
/**
|
|
16
|
+
* URL to load data from
|
|
17
|
+
*/
|
|
18
|
+
url?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the chart is interactive.
|
|
21
|
+
*/
|
|
22
|
+
interactive?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Optional style object
|
|
25
|
+
*/
|
|
26
|
+
style?: Record<string, any>;
|
|
27
|
+
/**
|
|
28
|
+
* Whether or not to respond to changes in the `url` or `data` prop. Defaults to true.
|
|
29
|
+
*/
|
|
30
|
+
reactive?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Optional filter to apply to the chart's data source.
|
|
33
|
+
*/
|
|
34
|
+
dataSourceFilter?: ChartModelFilter;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* {@link ColumnChartComponent} props
|
|
38
|
+
* @group Props
|
|
39
|
+
*/
|
|
40
|
+
export interface ColumnChartComponentProps extends BaseChartProps {
|
|
41
|
+
/**
|
|
42
|
+
* Options for the column chart.
|
|
43
|
+
*/
|
|
44
|
+
options: Omit<ColumnChartOptions, "data" | "url" | "model">;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Provides a component that displays a column chart
|
|
48
|
+
* @group Components
|
|
49
|
+
*/
|
|
50
|
+
export declare function ColumnChartComponent(props: ColumnChartComponentProps): JSX.Element;
|
|
51
|
+
/**
|
|
52
|
+
* {@link BarChartComponent} props
|
|
53
|
+
* @group Props
|
|
54
|
+
*/
|
|
55
|
+
export interface BarChartComponentProps extends BaseChartProps {
|
|
56
|
+
/**
|
|
57
|
+
* Options for the bar chart
|
|
58
|
+
*/
|
|
59
|
+
options: Omit<BarChartOptions, "data" | "url" | "model">;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Provides a component that displays a bar chart
|
|
63
|
+
* @group Components
|
|
64
|
+
*/
|
|
65
|
+
export declare function BarChartComponent(props: BarChartComponentProps): JSX.Element;
|
|
66
|
+
/**
|
|
67
|
+
* {@link XYChartComponent} props
|
|
68
|
+
* @group Props
|
|
69
|
+
*/
|
|
70
|
+
export interface XYChartComponentProps extends BaseChartProps {
|
|
71
|
+
/**
|
|
72
|
+
* Options for the XY chart
|
|
73
|
+
*/
|
|
74
|
+
options: Omit<CategoryValueChartOptions, "data" | "url" | "model">;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Provides a component that displays an XY chart - a chart containing an X and a Y axis, one of which displays chart categories and the other values. If you want a dual value axis chart (and you dont want to use Scatter or Bubble) you can use the DualValueChartComponent
|
|
78
|
+
* @group Components
|
|
79
|
+
*/
|
|
80
|
+
export declare function XYChartComponent(props: XYChartComponentProps): JSX.Element;
|
|
81
|
+
/**
|
|
82
|
+
* {@link LineChartComponent} props
|
|
83
|
+
* @group Props
|
|
84
|
+
*/
|
|
85
|
+
export interface LineChartComponentProps extends BaseChartProps {
|
|
86
|
+
/**
|
|
87
|
+
* Options for the line chart.
|
|
88
|
+
*/
|
|
89
|
+
options: Omit<LineChartOptions, "data" | "url" | "model">;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Provides a component that displays a line chart
|
|
93
|
+
* @group Components
|
|
94
|
+
*/
|
|
95
|
+
export declare function LineChartComponent(props: LineChartComponentProps): JSX.Element;
|
|
96
|
+
/**
|
|
97
|
+
* {@link AreaChartComponent} props
|
|
98
|
+
* @group Props
|
|
99
|
+
*/
|
|
100
|
+
export interface AreaChartComponentProps extends BaseChartProps {
|
|
101
|
+
/**
|
|
102
|
+
* Options for the area chart.
|
|
103
|
+
*/
|
|
104
|
+
options: Omit<AreaChartOptions, "data" | "url" | "model">;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Provides a component that displays an area chart
|
|
108
|
+
* @group Components
|
|
109
|
+
*/
|
|
110
|
+
export declare function AreaChartComponent(props: AreaChartComponentProps): JSX.Element;
|
|
111
|
+
/**
|
|
112
|
+
* {@link PieChartComponent} props
|
|
113
|
+
* @group Props
|
|
114
|
+
*/
|
|
115
|
+
export interface PieChartComponentProps extends BaseChartProps {
|
|
116
|
+
/**
|
|
117
|
+
* Options for the pie chart.
|
|
118
|
+
*/
|
|
119
|
+
options: Omit<PieChartOptions, "data" | "url" | "model">;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Provides a component that displays a pie chart
|
|
123
|
+
* @group Components
|
|
124
|
+
*/
|
|
125
|
+
export declare function PieChartComponent(props: PieChartComponentProps): JSX.Element;
|
|
126
|
+
/**
|
|
127
|
+
* {@link ScatterChartComponent} props
|
|
128
|
+
* @group Props
|
|
129
|
+
*/
|
|
130
|
+
export interface ScatterChartComponentProps extends BaseChartProps {
|
|
131
|
+
/**
|
|
132
|
+
* Options for the scatter chart.
|
|
133
|
+
*/
|
|
134
|
+
options: Omit<ScatterChartOptions, "data" | "url" | "model">;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Provides a component that displays a scatter chart
|
|
138
|
+
* @group Components
|
|
139
|
+
*/
|
|
140
|
+
export declare function ScatterChartComponent(props: ScatterChartComponentProps): JSX.Element;
|
|
141
|
+
/**
|
|
142
|
+
* {@link BubbleChartComponent} props
|
|
143
|
+
* @group Props
|
|
144
|
+
*/
|
|
145
|
+
export interface BubbleChartComponentProps extends BaseChartProps {
|
|
146
|
+
/**
|
|
147
|
+
* Options for the bubble chart.
|
|
148
|
+
*/
|
|
149
|
+
options: Omit<BubbleChartOptions, "data" | "url" | "model">;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Provides a component that displays a bubble chart
|
|
153
|
+
* @group Components
|
|
154
|
+
*/
|
|
155
|
+
export declare function BubbleChartComponent(props: BubbleChartComponentProps): JSX.Element;
|
|
156
|
+
/**
|
|
157
|
+
* {@link GaugeChartComponent} props
|
|
158
|
+
* @group Props
|
|
159
|
+
*/
|
|
160
|
+
export interface GaugeChartComponentProps extends BaseChartProps {
|
|
161
|
+
/**
|
|
162
|
+
* Options for the gauge chart
|
|
163
|
+
*/
|
|
164
|
+
options: Omit<GaugeChartOptions, "data" | "url" | "model">;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Provides a component that displays a gauge chart
|
|
168
|
+
* @group Components
|
|
169
|
+
*/
|
|
170
|
+
export declare function GaugeChartComponent(props: GaugeChartComponentProps): JSX.Element;
|
|
171
|
+
/**
|
|
172
|
+
* {@link SankeyChartComponent} props
|
|
173
|
+
* @group Props
|
|
174
|
+
*/
|
|
175
|
+
export interface SankeyChartComponentProps extends Omit<BaseChartProps, "data"> {
|
|
176
|
+
/**
|
|
177
|
+
* Options for the sankey chart
|
|
178
|
+
*/
|
|
179
|
+
options: Omit<SankeyOptions, "data" | "url" | "model">;
|
|
180
|
+
/**
|
|
181
|
+
* Optional property to pivot the sankey chart on.
|
|
182
|
+
*/
|
|
183
|
+
pivot?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Optional data to load into the chart (in CSV format)
|
|
186
|
+
*/
|
|
187
|
+
csvData?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Optional data to load into the chart (in VisuallyJs default json format)
|
|
190
|
+
*/
|
|
191
|
+
jsonData?: VisuallyJsDefaultJSON;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Provides a component that displays a sankey chart
|
|
195
|
+
* @group Components
|
|
196
|
+
*/
|
|
197
|
+
export declare function SankeyChartComponent(props: SankeyChartComponentProps): JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for the ColorPicker inspector component.
|
|
3
|
+
* @group Props
|
|
4
|
+
*/
|
|
5
|
+
export interface ColorPickerComponentProps {
|
|
6
|
+
/**
|
|
7
|
+
* Maximum color swatches to show. Defaults to 10.
|
|
8
|
+
*/
|
|
9
|
+
maxColors?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Property name in the data that this picker represents. Required.
|
|
12
|
+
*/
|
|
13
|
+
propertyName: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Provides a color picker plus history, for use in an inspector.
|
|
17
|
+
* @group Components
|
|
18
|
+
*/
|
|
19
|
+
export declare function ColorPickerComponent(props: ColorPickerComponentProps): JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ControlsComponentButtons } from "@visuallyjs/browser-ui";
|
|
2
|
+
export declare const ATTRIBUTE_CAN_UNDO = "can-undo";
|
|
3
|
+
export declare const ATTRIBUTE_CAN_REDO = "can-redo";
|
|
4
|
+
export declare const CLASS_SELECTED_MODE = "vjs-selected-mode";
|
|
5
|
+
/**
|
|
6
|
+
* Props for the controls component.
|
|
7
|
+
* @group Props
|
|
8
|
+
*/
|
|
9
|
+
export interface ControlsComponentProps {
|
|
10
|
+
/**
|
|
11
|
+
* The ID of surface to attach to. Optional. Will be inferred from context if not provided.
|
|
12
|
+
*/
|
|
13
|
+
surfaceId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional message for the alert that the clear button shows by default. Defaults to `Clear dataset?`.
|
|
16
|
+
*/
|
|
17
|
+
clearMessage?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional callback to invoke when the user presses the clear button. If you provide this, the component will not show an alert, and instead call this method, passing in a function you can invoke if you wish to continue with the clear operation.
|
|
20
|
+
*/
|
|
21
|
+
onMaybeClear?: (doClear: () => void) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Optional extra buttons to add to the controls component.
|
|
24
|
+
*/
|
|
25
|
+
buttons?: ControlsComponentButtons;
|
|
26
|
+
/**
|
|
27
|
+
* Whether or not to show undo/redo buttons, defaults to true
|
|
28
|
+
*/
|
|
29
|
+
undoRedo?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether or not to show the zoom to extents button, defaults to true
|
|
32
|
+
*/
|
|
33
|
+
zoomToExtents?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not to show the zoom in/zoom out buttons, defaults to false
|
|
36
|
+
*/
|
|
37
|
+
zoomButtons?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether or not to show the clear button, defaults to true.
|
|
40
|
+
*/
|
|
41
|
+
clear?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Optional orientation for the controls. Defaults to 'row'.
|
|
44
|
+
*/
|
|
45
|
+
orientation?: 'row' | 'column';
|
|
46
|
+
/**
|
|
47
|
+
* Optional class name to append to the root element's class list.
|
|
48
|
+
*/
|
|
49
|
+
className?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Optional style object to apply to the container element.
|
|
52
|
+
*/
|
|
53
|
+
style?: Record<string, string>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Provides a component offering controls for a Surface or Paper component - zoom, lasso, undo/redo, etc.
|
|
57
|
+
* @group Components
|
|
58
|
+
*/
|
|
59
|
+
export declare function ControlsComponent(props: ControlsComponentProps): JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FixedElementConstraints, PointXY } from "@visuallyjs/browser-ui";
|
|
2
|
+
import { ReactElement, ReactNode } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Props for the {@link DecoratorComponent}
|
|
5
|
+
*/
|
|
6
|
+
export interface DecoratorComponentProps {
|
|
7
|
+
/**
|
|
8
|
+
* Whether to float the element over the UI, so that it does not move with the content (floating), or to place the element onto the canvas, so that it moves/zooms with the content (fixed). Floating is the default.
|
|
9
|
+
*/
|
|
10
|
+
placement?: 'fixed' | 'floating';
|
|
11
|
+
/**
|
|
12
|
+
* For floating placement, this is a point relative to the viewport origin. for fixed placement, this is a point relative to the canvas origin. Defaults to 0,0.
|
|
13
|
+
*/
|
|
14
|
+
position?: PointXY;
|
|
15
|
+
/**
|
|
16
|
+
* Optional constraints when using fixed placement: you can instruct the UI to restrict movement in one or both axes.
|
|
17
|
+
*/
|
|
18
|
+
constraints?: FixedElementConstraints;
|
|
19
|
+
/**
|
|
20
|
+
* You do not pass this prop yourself; React constructs this prop from any elements that are children of the surface component element in the JSX.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
children?: Array<ReactNode | ReactElement<any, any>> | ReactNode | ReactElement<any, any>;
|
|
24
|
+
}
|
|
25
|
+
export default function DecoratorComponent(props: DecoratorComponentProps): JSX.Element;
|
|
26
|
+
export { DecoratorComponent };
|
package/definitions.d.ts
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { Group, ObjectData, Port, Surface, SurfaceOptions, NodeMapping, EdgeMapping, DataGeneratorFunction, Size, BrowserElement, GroupIdentifierFunction, TypeGeneratorFunction, ModelOptions, CanvasDropFilter, OnVertexAddedCallback, OverlaySpec, Edge, Node, GroupMapping, PortMapping, PaletteMode, PreparedShape } from "@visuallyjs/browser-ui";
|
|
2
|
+
import { BrowserUIReactModel } from "./browser-ui-react";
|
|
3
|
+
import { MutableRefObject, ReactElement, ReactNode } from "react";
|
|
4
|
+
import { JsxWrapperProps } from "./jsx-wrapper";
|
|
5
|
+
/**
|
|
6
|
+
* Render options for a SurfaceComponent. This interface is the same as SurfaceOptions but with several vanilla-only
|
|
7
|
+
* options removed.
|
|
8
|
+
*/
|
|
9
|
+
export interface ReactSurfaceRenderOptions extends Omit<SurfaceOptions, "directRender" | "enhancedView" | "view" | "templates"> {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Definition of a node - its jsx, and behaviour.
|
|
13
|
+
*/
|
|
14
|
+
export interface ReactNodeMapping extends Omit<NodeMapping<any>, "template" | "templateId" | "parameters"> {
|
|
15
|
+
/**
|
|
16
|
+
* JSX used to render this node type. Optional; if you do not supply it a default template will be used.
|
|
17
|
+
*/
|
|
18
|
+
jsx?: (ctx: JsxWrapperProps<Node>) => any;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Definition of a group - its jsx, and behaviour.
|
|
22
|
+
*/
|
|
23
|
+
export interface ReactGroupMapping extends Omit<GroupMapping<any>, "template" | "templateId" | "parameters"> {
|
|
24
|
+
/**
|
|
25
|
+
* JSX used to render this group type. Optional; if you do not supply it a default template will be used.
|
|
26
|
+
*/
|
|
27
|
+
jsx?: (ctx: JsxWrapperProps<Group>) => any;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Definition of a port - its jsx, and behaviour. This is for advanced use cases.
|
|
31
|
+
*/
|
|
32
|
+
export interface ReactPortMapping extends Omit<PortMapping<any>, "template" | "templateId" | "parameters"> {
|
|
33
|
+
/**
|
|
34
|
+
* JSX used to render this port type. Optional; if you do not supply it a default template will be used.
|
|
35
|
+
*/
|
|
36
|
+
jsx?: (ctx: JsxWrapperProps<Port>) => any;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Spec for a react component overlay. A ctx object is passed in to your component and you are expected to return JSX.
|
|
40
|
+
*/
|
|
41
|
+
export interface ReactOverlaySpec {
|
|
42
|
+
/**
|
|
43
|
+
* Function to invoke to get JSX for the overlay
|
|
44
|
+
* @param ctx
|
|
45
|
+
*/
|
|
46
|
+
jsx: (ctx: JsxWrapperProps<Edge>) => any;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Edge mappings for a view.
|
|
50
|
+
*/
|
|
51
|
+
export interface ReactEdgeMapping extends Omit<EdgeMapping, "overlays"> {
|
|
52
|
+
overlays: Array<OverlaySpec | ReactOverlaySpec>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Options for the view in the react surface component. Maps node/group/port/edge types to JSX and behaviour.
|
|
56
|
+
*/
|
|
57
|
+
export interface ReactSurfaceViewOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Optional node mappings
|
|
60
|
+
*/
|
|
61
|
+
nodes?: Record<string, ReactNodeMapping>;
|
|
62
|
+
/**
|
|
63
|
+
* Optional group mappings
|
|
64
|
+
*/
|
|
65
|
+
groups?: Record<string, ReactGroupMapping>;
|
|
66
|
+
/**
|
|
67
|
+
* Optional port mappings. Because of the nature of JSX, separate port mappings are a little rare in VisuallyJs React, but they are supported if you need them.
|
|
68
|
+
*/
|
|
69
|
+
ports?: Record<string, ReactPortMapping>;
|
|
70
|
+
/**
|
|
71
|
+
* Optional edge mappings.
|
|
72
|
+
*/
|
|
73
|
+
edges?: Record<string, ReactEdgeMapping>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Props for the {@link SurfaceComponent}.
|
|
77
|
+
* @group Props
|
|
78
|
+
*/
|
|
79
|
+
export interface SurfaceComponentProps {
|
|
80
|
+
/**
|
|
81
|
+
* Render options such as layout, drag options etc
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
renderOptions?: ReactSurfaceRenderOptions;
|
|
85
|
+
/**
|
|
86
|
+
* Mappings of vertex types to components/jsx and edge types.
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
viewOptions?: ReactSurfaceViewOptions;
|
|
90
|
+
/**
|
|
91
|
+
* Any props to pass to children.
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
childProps?: any;
|
|
95
|
+
/**
|
|
96
|
+
* You do not pass this prop yourself; React constructs this prop from any elements that are children of the surface
|
|
97
|
+
* component element in the JSX.
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
children?: Array<ReactNode | ReactElement<any, any>> | ReactNode | ReactElement<any, any>;
|
|
101
|
+
/**
|
|
102
|
+
* Options for the underlying instance.
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
105
|
+
modelOptions?: ModelOptions;
|
|
106
|
+
/**
|
|
107
|
+
* Optional ID to assign to the surface that is created.
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
surfaceId?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Optional initial data
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
data?: any;
|
|
116
|
+
/**
|
|
117
|
+
* Optional URL to load initial data from.
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
url?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Optional instance to render. You mostly wont need to do this; the SurfaceComponent or PaperComponent will create
|
|
123
|
+
* an instance.
|
|
124
|
+
*/
|
|
125
|
+
model?: BrowserUIReactModel;
|
|
126
|
+
/**
|
|
127
|
+
* Optional class name to append to the root element's class list.
|
|
128
|
+
*/
|
|
129
|
+
className?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Optional style object to apply to the container element.
|
|
132
|
+
*/
|
|
133
|
+
style?: Record<string, string>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Reference to a SurfaceComponent. Offers methods to get the underlying surface and VisuallyJs instance.
|
|
137
|
+
* @group Handles
|
|
138
|
+
*/
|
|
139
|
+
export interface SurfaceComponentRef {
|
|
140
|
+
/**
|
|
141
|
+
* Gets the Surface canvas component.
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
getSurface: () => Surface;
|
|
145
|
+
/**
|
|
146
|
+
* Gets the underlying model instance, on which you can manage the model.
|
|
147
|
+
*
|
|
148
|
+
*/
|
|
149
|
+
getModel: () => BrowserUIReactModel;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Props for the {@link ShapePaletteComponent}
|
|
153
|
+
* @group Props
|
|
154
|
+
*/
|
|
155
|
+
export interface ShapePaletteComponentProps {
|
|
156
|
+
/**
|
|
157
|
+
* Optional 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.
|
|
158
|
+
*/
|
|
159
|
+
dataGenerator?: DataGeneratorFunction<ObjectData>;
|
|
160
|
+
/**
|
|
161
|
+
* Optional size to use for dragged elements.
|
|
162
|
+
*/
|
|
163
|
+
dragSize?: Size;
|
|
164
|
+
/**
|
|
165
|
+
* Optional size to use for icons.
|
|
166
|
+
*/
|
|
167
|
+
iconSize?: Size;
|
|
168
|
+
/**
|
|
169
|
+
* Optional fill color to use for dragged elements. This should be in RGB or hex format, _not_ a color like 'white' or 'cyan' etc.
|
|
170
|
+
*/
|
|
171
|
+
fill?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Optional color to use for outline of dragged elements. Should be in RGB or hex format.
|
|
174
|
+
*/
|
|
175
|
+
outline?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Message 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`.
|
|
178
|
+
*/
|
|
179
|
+
showAllMessage?: string;
|
|
180
|
+
/**
|
|
181
|
+
* When true (which is the default), a newly dropped vertex will be set as the underlying model's selection.
|
|
182
|
+
*/
|
|
183
|
+
selectAfterDrop?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Stroke width to use for shapes in palette. Defaults to 1.
|
|
186
|
+
*/
|
|
187
|
+
paletteStrokeWidth?: number;
|
|
188
|
+
/**
|
|
189
|
+
* ID 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.
|
|
190
|
+
*/
|
|
191
|
+
initialSet?: string;
|
|
192
|
+
/**
|
|
193
|
+
* Optional class name to append to the root element's class list.
|
|
194
|
+
*/
|
|
195
|
+
className?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Mode to use for the palette.
|
|
198
|
+
*/
|
|
199
|
+
mode?: PaletteMode;
|
|
200
|
+
/**
|
|
201
|
+
* When 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)
|
|
202
|
+
*/
|
|
203
|
+
allowClickToAdd?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Optional callback to invoke when a vertex as been dragged onto the canvas
|
|
206
|
+
*/
|
|
207
|
+
onVertexAdded?: OnVertexAddedCallback;
|
|
208
|
+
/**
|
|
209
|
+
* Surface 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.
|
|
210
|
+
*/
|
|
211
|
+
surface?: Surface;
|
|
212
|
+
/**
|
|
213
|
+
* Optionally show each shape icon's label underneath it
|
|
214
|
+
*/
|
|
215
|
+
showLabels?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Indicates two things: first, when one or more vertices are selected, clicking on an entry in the palette will change the type of the selected vertices to that type. Secondly, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
|
|
218
|
+
*/
|
|
219
|
+
inspector?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* 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.
|
|
222
|
+
*/
|
|
223
|
+
preparedShapes?: Array<PreparedShape>;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Ref handle for a {@link ShapePaletteComponent}
|
|
227
|
+
* @group Handles
|
|
228
|
+
*/
|
|
229
|
+
export interface ShapePaletteComponentRef {
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Props for the `PaletteComponent`
|
|
233
|
+
* @group Props
|
|
234
|
+
*/
|
|
235
|
+
export interface PaletteComponentProps {
|
|
236
|
+
/**
|
|
237
|
+
* Child elements. This is internal - its the child elements.
|
|
238
|
+
* @internal
|
|
239
|
+
*/
|
|
240
|
+
children?: Array<ReactNode> | ReactNode;
|
|
241
|
+
/**
|
|
242
|
+
* CSS 3 selector identifying what child elements of `container` are draggable/tappable. Optional. If omitted, a default of `[data-vjs-type]` will be used.
|
|
243
|
+
*/
|
|
244
|
+
selector?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Whether or not to allow drop on edge. Defaults to false.
|
|
247
|
+
*/
|
|
248
|
+
allowDropOnEdge?: boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Whether or not to allow drop on whitespace in the canvas. Defaults to true.
|
|
251
|
+
*/
|
|
252
|
+
allowDropOnCanvas?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Whether or not to allow drop on existing vertices. Defaults to true.
|
|
255
|
+
*/
|
|
256
|
+
allowDropOnGroup?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Defaults to false. Allows items to be dropped onto nodes in the canvas. If this is true and an element is dropped onto a node, the result is the same as if the element has been dropped onto whitespace. Note that when this is false and the user has dragged something over a node, the drag item is still not considered to be over the canvas, and releasing the mouse button at that time will not cause a new node to be added. Use `ignoreDropOnNode` if that's the behaviour you want.
|
|
259
|
+
*/
|
|
260
|
+
allowDropOnNode?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Defaults to false. When true, the palette treats nodes as if they are part of the canvas - a user can drag new items on top of existing nodes and the new item will be added to the canvas. If you want to force your users to drop on canvas whitespace, don't set this. Note that this flag will force `allowDropOnNode` to `false`.
|
|
263
|
+
*/
|
|
264
|
+
ignoreDropOnNode?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Function to use to get a dataset for an item that is being dragged or has been tapped. If omitted, Visually JS will use a default data generator that extracts data values from any `data-vjs-***` attribute on the element being dragged.
|
|
267
|
+
*/
|
|
268
|
+
dataGenerator?: DataGeneratorFunction<BrowserElement>;
|
|
269
|
+
/**
|
|
270
|
+
* Function to use to get the type of an item that is being dragged or has been tapped.
|
|
271
|
+
*/
|
|
272
|
+
typeGenerator?: TypeGeneratorFunction<BrowserElement>;
|
|
273
|
+
/**
|
|
274
|
+
* Function to use to determine whether an item that is being dragged or has been tapped represents a group.
|
|
275
|
+
*/
|
|
276
|
+
groupIdentifier?: GroupIdentifierFunction<BrowserElement>;
|
|
277
|
+
/**
|
|
278
|
+
* Optional extra css classes to set on the element
|
|
279
|
+
*/
|
|
280
|
+
className?: string;
|
|
281
|
+
/**
|
|
282
|
+
* Optional callback that will be invoked after a new vertex has been dropped and added to the dataset.
|
|
283
|
+
* @param v
|
|
284
|
+
*/
|
|
285
|
+
onVertexAdded?: OnVertexAddedCallback;
|
|
286
|
+
/**
|
|
287
|
+
* Defaults to false. When true, a newly added vertex is set as the model's current selection.
|
|
288
|
+
*/
|
|
289
|
+
selectAfterAdd?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Optional size to use for elements dragged from the palette, when in "drag" mode
|
|
292
|
+
*/
|
|
293
|
+
dragSize?: Size;
|
|
294
|
+
/**
|
|
295
|
+
* Optional filter to test if objects may be dropped on the canvas.
|
|
296
|
+
*/
|
|
297
|
+
canvasDropFilter?: CanvasDropFilter<BrowserElement>;
|
|
298
|
+
/**
|
|
299
|
+
* The surface to attach to. Optional: this component can derive a surface from a SurfaceProvider or SurfaceComponent. You'll only need this in certain advanced scenarios.
|
|
300
|
+
*/
|
|
301
|
+
surface?: Surface;
|
|
302
|
+
/**
|
|
303
|
+
* Mode to operate in - 'drag', 'tap' or 'draw'. Defaults to 'drag'.
|
|
304
|
+
*/
|
|
305
|
+
mode?: PaletteMode;
|
|
306
|
+
/**
|
|
307
|
+
* When in draw mode, allow addition of new vertices simply by clicking, instead of requiring a shape be drawn. (When this is true, the drag to draw functionality also still works)
|
|
308
|
+
*/
|
|
309
|
+
allowClickToAdd?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* This flag relates to "draw" mode, and defaults to false. When true, the palette only supports click to draw new vertices, not drag. This flag is forced to true if the associated UI does not have `useModelForSizes` set, since there is no point in allowing a user to drag a vertex to some size if its not going to be honoured. When you set this flag and associated UI does have `useModelForSizes` set, the palette will use default sizes for new nodes/groups.
|
|
312
|
+
*/
|
|
313
|
+
clickToAddOnly?: boolean;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Ref handle for a palette component.
|
|
317
|
+
* @group Handles
|
|
318
|
+
*/
|
|
319
|
+
export interface PaletteComponentRef {
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Handle for a reference to a mutable ref object which holds some object. Subinterfaces currently are SurfaceRef and ShapeLibraryRef
|
|
323
|
+
* @internal
|
|
324
|
+
*/
|
|
325
|
+
export interface RefHandle<T> {
|
|
326
|
+
set: (v: T) => any;
|
|
327
|
+
listen: (l: (v: T) => any) => void;
|
|
328
|
+
_ref: () => MutableRefObject<T>;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* CSS class set on the root element created by the JSX mapped to some node type when it is rendered, by a {@link SurfaceComponent} or {@link PaperComponent}.
|
|
332
|
+
* @group CSS Classes
|
|
333
|
+
*/
|
|
334
|
+
export declare const CLASS_REACT_NODE = "vjs-react-node";
|
|
335
|
+
/**
|
|
336
|
+
* CSS class set on the root element created by the JSX mapped to some group type when it is rendered, by a
|
|
337
|
+
* {@link SurfaceComponent} or {@link PaperComponent}.
|
|
338
|
+
* @group CSS Classes
|
|
339
|
+
*/
|
|
340
|
+
export declare const CLASS_REACT_GROUP = "vjs-react-group";
|
|
341
|
+
/**
|
|
342
|
+
* CSS class set on JSX overlay elements, by a {@link SurfaceComponent} or {@link PaperComponent}.
|
|
343
|
+
* @group CSS Classes
|
|
344
|
+
*/
|
|
345
|
+
export declare const CLASS_REACT_OVERLAY = "vjs-react-overlay";
|